Ignore:
Timestamp:
Nov 25, 2010, 5:54:57 PM (14 years ago)
Author:
braffert
Message:

Developing regression tester

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tester/testtree.tcl

    r1963 r1964  
    33#
    44#  Used to display a collapsible view of all tests found in the test
    5 #  directory.  Essentially an Itk Widget wrapper for blt::treeview.
    6 Provides methods to get all tests or all currently selected tests.
    7 Also helps handle data stored in treeview columns.  In each test xml,
    8 a label must be located at the path test.label.  Test labels may be
    9 be organized hierarchically by using dots to separate components of
    10 the test label.  (example: roomtemp.1eV)
     5#  directory.  The -command configuration option will be called when
     6the run button is clicked. Provides methods to get all tests or all
     7currently selected tests. Also helps handle data stored in treeview
     8columns.  In each test xml, a label must be located at the path
     9test.label.  Test labels may be organized hierarchically by using
     10dots to separate components of the test label.
    1111# ======================================================================
    1212#  AUTHOR:  Ben Rafferty, Purdue University
     
    2323
    2424itcl::class Rappture::Regression::TestTree {
    25     inherit itk::Widget
    26 
    27     constructor {testdir} { #defined later }
    28     public method populate {testdir}
     25    inherit itk::Widget
     26
     27    public variable command
     28    public variable testdir
     29
     30    constructor {testdir args} { #defined later }
    2931    public method getTests {{id 0}}
    3032    public method getSelected {}
    3133    public method getData {id}
    3234    public method setData {id data}
     35    public method updateLabel {}
     36
     37    private method populate {}
    3338}
    3439
     
    4146}
    4247
    43 itcl::body Rappture::Regression::TestTree::constructor {testdir} {
     48itcl::body Rappture::Regression::TestTree::constructor {args} {
    4449    # TODO: Use separate tree data structure and insert into treeview
    45     puts "Constructing TestTree."
     50    puts "Constructinig TestTree."
     51
    4652    itk_component add treeview {
    4753        blt::treeview $itk_interior.treeview -separator . -autocreate true \
    48             -selectmode multiple
    49     }
    50     $itk_component(treeview) column insert end xmlfile ran result diffs
     54            -selectmode multiple
     55    }
     56    $itk_component(treeview) column insert 0 result
     57    $itk_component(treeview) column insert end xmlfile ran diffs
    5158    $itk_component(treeview) column configure xmlfile ran diffs -hide yes
    5259    pack $itk_component(treeview) -expand yes -fill both
    53     populate $testdir
    54     # TODO: Fix default column spacing. Column name for the main/first column?
     60
     61    itk_component add bottomBar {
     62        frame $itk_interior.bottomBar
     63    }
     64    pack $itk_component(bottomBar) -fill x
     65
     66    itk_component add bSelectAll {
     67        button $itk_component(bottomBar).bSelectAll -text "Select all" \
     68            -command "$itk_component(treeview) selection set 0 end"
     69    }
     70    pack $itk_component(bSelectAll) -side left
     71
     72    itk_component add bSelectNone {
     73        button $itk_component(bottomBar).bSelectNone -text "Select none" \
     74            -command "$itk_component(treeview) selection clearall"
     75    }
     76    pack $itk_component(bSelectNone) -side left
     77
     78    itk_component add lSelected {
     79        label $itk_component(bottomBar).lSelected -text "0 tests selected"
     80    }
     81    pack $itk_component(lSelected) -side left -expand yes -fill x
     82    $itk_component(treeview) configure -selectcommand "$this updateLabel"
     83
     84    itk_component add bRun {
     85        button $itk_component(bottomBar).bRun -text "Run" -command runHandler \
     86            -state disabled
     87    }
     88    pack $itk_component(bRun) -side left
     89
    5590    # TODO: Fix black empty space when columns are shrunk
    56 }
    57 
     91    # TODO: Scrollbar(s)
     92
     93    eval itk_initialize $args
     94}
     95
     96# Repopulate tree if test directory changed
     97itcl::configbody Rappture::Regression::TestTree::testdir {
     98    populate
     99}
     100
     101itcl::configbody Rappture::Regression::TestTree::command {
     102    $itk_component(bRun) configure -command $command
     103}
    58104
    59105# ----------------------------------------------------------------------
     
    66112# any nodes previously contained by the treeview.
    67113# ----------------------------------------------------------------------
    68 itcl::body Rappture::Regression::TestTree::populate {testdir} {
     114itcl::body Rappture::Regression::TestTree::populate {} {
    69115    puts "Populating TestTree."
    70116    $itk_component(treeview) delete 0
    71     # TODO: Make file icon background transparent.
    72     set icon [image create photo -file images/file.gif]
     117    # TODO: add an appropriate icon
     118    set icon [Rappture::icon download]
    73119    # TODO: Descend through subdirectories inside testdir?
    74120    foreach testxml [glob -nocomplain -directory $testdir *.xml] {
     
    150196}
    151197
    152 
     198# ----------------------------------------------------------------------
     199# USAGE: updateLabel
     200#
     201# Used internally to update the label which indicates how many tests
     202# are currently selected.  Also disables the run button if no tests are
     203# selected.
     204# ----------------------------------------------------------------------
     205itcl::body Rappture::Regression::TestTree::updateLabel {} {
     206    set n [llength [getSelected]]
     207    $itk_component(lSelected) configure -text "$n tests selcted"
     208    if {$n > 0} {
     209        $itk_component(bRun) configure -state normal
     210    } else {
     211        $itk_component(bRun) configure -state disabled
     212    }
     213}
     214
Note: See TracChangeset for help on using the changeset viewer.