diff options
Diffstat (limited to 'tests/treectrl.test')
-rw-r--r-- | tests/treectrl.test | 373 |
1 files changed, 18 insertions, 355 deletions
diff --git a/tests/treectrl.test b/tests/treectrl.test index b71b613..452b80c 100644 --- a/tests/treectrl.test +++ b/tests/treectrl.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: treectrl.test,v 1.30 2006/09/22 23:29:46 treectrl Exp $ +# RCS: @(#) $Id: treectrl.test,v 1.31 2006/10/29 02:39:45 treectrl Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -244,78 +244,6 @@ test treectrl-1.54 {configure: -wrap empty option} -body { .t configure -wrap } -result {-wrap wrap Wrap {} {}} -# For the tests of the item descriptions we use [.t see], -# if we want to generate an error on unknown items. -# For the positive cases we use [.t item id] since it returns the item id. - -test treectrl-2.1 {bogus itemdesc} -body { - .t item id foo -} -returnCodes error -result {bad item description "foo"} - -test treectrl-2.2 {is all allowed?} -body { - .t item create -count 10 - set res [lsort -integer [.t item id all]] - .t item delete all - set res -} -result {0 1 2 3 4 5 6 7 8 9 10} - -test treectrl-2.3 {itemdesc number unknown} -body { - .t see 999 -} -returnCodes error -result {item "999" doesn't exist} - -test treectrl-2.4 {itemdesc number of root} -body { - .t item id 0 -} -result {0} - -test treectrl-2.5 {itemdesc active} -body { - .t item id active -} -result {0} - -test treectrl-2.6 {itemdesc abbreviated anchor} -body { - .t item id an -} -result {0} - -test treectrl-2.7 {itemdesc first} -body { - .t item id first -} -result {0} - -test treectrl-2.8 {itemdesc first visible} -body { - .t configure -showroot 1 - .t item id "first visible" -} -result {0} - -test treectrl-2.9 {itemdesc first visible without any node} -body { - .t configure -showroot 0 - .t see "first visible" -} -returnCodes error -result {item "first visible" doesn't exist} - -test treectrl-2.10 {itemdesc last} -body { - .t item id last -} -result {0} - -test treectrl-2.11 {itemdesc last visible} -body { - .t configure -showroot 1 - .t item id "last visible" -} -result {0} - -test treectrl-2.12 {itemdesc last visible without any node} -body { - .t configure -showroot 0 - .t see "last visible" -} -returnCodes error -result {item "last visible" doesn't exist} - -test treectrl-2.13 {itemdesc nearest without x/y} -body { - .t item id nearest -} -returnCodes error -result {missing arguments to "nearest" keyword} - -test treectrl-2.14 {itemdesc nearest with invalid x/y} -body { - .t item id "nearest foo bar" -} -returnCodes error -result {bad item description "nearest foo bar"} - -test treectrl-2.15 {itemdesc nearest with valid x/y, but no item} -body { - .t configure -showroot 0 - .t item id "nearest 10 10" -} -result {} - # Before continuing to test the item descriptions and their modifiers, # lets create some items with this hierarchy: # 0 @@ -328,6 +256,7 @@ test treectrl-2.15 {itemdesc nearest with valid x/y, but no item} -body { # | + 7 # + 8 test treectrl-2.16 {create some items} -body { +.t configure -showroot 1 -orient vertical set n1 [.t item create]; .t item lastchild 0 $n1 set n2 [.t item create]; .t item lastchild $n1 $n2 set n3 [.t item create]; .t item lastchild $n1 $n3 @@ -338,272 +267,6 @@ test treectrl-2.16 {create some items} -body { set n8 [.t item create]; .t item lastchild 0 $n8 } -result {8} -test treectrl-2.17 {itemdesc nearest with valid x/y} -body { - # I think this should return an item, but it doesn't... - .t item id "nearest 10 10" -} -result {} - -test treectrl-2.18 {itemdesc rnc without r/c} -body { - .t item id rnc -} -returnCodes error -result {missing arguments to "rnc" keyword} - -test treectrl-2.19 {itemdesc rnc with invalid r/c} -body { - .t item id "rnc foo bar" -} -returnCodes error -result {bad item description "rnc foo bar"} - -test treectrl-2.20 {itemdesc rnc with valid r/c} -body { - .t item id "rnc 0 0" -} -result {1} - -test treectrl-2.21 {itemdesc root} -body { - .t configure -showroot 1 -orient vertical - .t item id root -} -result {0} - -test treectrl-2.22 {bogus modifier} -body { - .t item id "0 foo" -} -returnCodes error -result {bad modifier "foo": must be *} -match glob - -test treectrl-2.23 {valid modifier with too less arguments} -body { - .t item id "0 child" -} -returnCodes error -result {missing arguments to "child" modifier} - -test treectrl-2.24 {modifier visible alone generates an error} -body { - .t item id "0 visible" -} -returnCodes error -result {bad modifier "visible": must be *} -match glob - -test treectrl-2.25 {modifier above} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n above"] - } - set res -} -result {{} 0 1 2 3 4 5 6 7} - -test treectrl-2.26 {modifier below} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n below"] - } - set res -} -result {1 2 3 4 5 6 7 8 {}} - -test treectrl-2.27 {modifier bottom} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n bottom"] - } - set res -} -result {8 8 8 8 8 8 8 8 8} - -test treectrl-2.28 {modifier child} -body { - set res {} - for {set n 0} {$n < 6} {incr n} { - for {set c 0} {$c < 3} {incr c} { - lappend res [.t item id "$n child $c"] - } - } - set res -} -result {1 5 8 2 3 {} {} {} {} 4 {} {} {} {} {} 6 7 {}} - -test treectrl-2.29 {modifier firstchild} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n firstchild"] - } - set res -} -result {1 2 {} 4 {} 6 {} {} {}} - -test treectrl-2.30 {modifier lastchild} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n lastchild"] - } - set res -} -result {8 3 {} 4 {} 7 {} {} {}} - -test treectrl-2.30 {modifier left, leftmost, right, and rightmost} -body { - list [.t item id "1 left"] [.t item id "1 right"] \ - [.t item id "2 leftmost"] [.t item id "3 rightmost"] -} -result {{} {} 2 3} - -test treectrl-2.31 {modifier next} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n next"] - } - set res -} -result {1 2 3 4 5 6 7 8 {}} - -test treectrl-2.32 {modifier nextsibling} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n nextsibling"] - } - set res -} -result {{} 5 3 {} {} 8 7 {} {}} - -test treectrl-2.33 {modifier parent} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n parent"] - } - set res -} -result {{} 0 1 1 3 0 5 5 0} - -test treectrl-2.34 {modifier prev} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n prev"] - } - set res -} -result {{} 0 1 2 3 4 5 6 7} - -test treectrl-2.34 {modifier prevsibling} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n prevsibling"] - } - set res -} -result {{} {} {} 2 {} 1 {} 6 5} - -test treectrl-2.35 {modifier sibling} -body { - set res {} - for {set n 0} {$n < 7} {incr n} { - for {set c 0} {$c < 3} {incr c} { - lappend res [.t item id "$n sibling $c"] - } - } - set res -} -result {{} {} {} 1 5 8 2 3 {} 2 3 {} 4 {} {} 1 5 8 6 7 {}} - -test treectrl-2.36 {modifier top} -body { - set res {} - for {set n 0} {$n < 9} {incr n} { - lappend res [.t item id "$n top"] - } - set res -} -result {0 0 0 0 0 0 0 0 0} - -test treectrl-2.37 {modifier cocktail} -body { - set res {} - set itemDesc 7 - foreach mod { - bottom rightmost sibling 0 nextsibling prev parent - prevsibling prev nextsibling lastchild next - } { - lappend itemDesc $mod - catch {lappend res [.t item id $itemDesc]} - } - set res -} -result {8 8 1 5 4 3 2 1 5 7 8} - -test treectrl-2.38 {multiple items: list} -body { - .t item id "list {3 8 8}" -} -result {3 8 8} - -test treectrl-2.39 {multiple items: range} -body { - .t item id "range 1 6" -} -result {1 2 3 4 5 6} - -test treectrl-2.40 {multiple items: range reversed} -body { - .t item id "range 6 1" -} -result {1 2 3 4 5 6} - -test treectrl-2.41 {multiple items: ancestors} -body { - .t item id "4 ancestors" -} -result {3 1 0} - -test treectrl-2.42 {multiple items: children} -body { - .t item id "root children" -} -result {1 5 8} - -test treectrl-2.43 {multiple items: nested list} -body { - .t item id "list {3 {list {1 root}} 4}" -} -result {3 1 0 4} - -# qualifiers in item descriptions -test treectrl-3.1 {where visible is allowed} -body { - .t item collapse 3 - .t item collapse 5 - set res {} - foreach index { - first last - } { - lappend res [.t item id "$index visible"] - } - foreach modifier { - next prev firstchild lastchild {child 1} - nextsibling prevsibling {sibling 0} - } { - lappend res [.t item id "5 $modifier visible"] - } - set res -} -result {0 8 8 3 {} {} {} 8 1 1} - -test treectrl-3.2 {where state is allowed} -body { - set res {} - foreach index { - first last - } { - lappend res [.t item id "$index state enabled"] - } - foreach modifier { - next prev firstchild lastchild {child 0} - nextsibling prevsibling {sibling 0} - } { - lappend res [.t item id "5 $modifier state enabled"] - } - set res -} -result {0 8 6 4 6 7 6 8 1 1} - -test treectrl-3.3 {qualifier state: missing args} -body { - .t item id "first state" -} -returnCodes error -result {missing arguments to "state" qualifier} - -test treectrl-3.4 {qualifier state: unknown state} -body { - .t item id "first state foo" -} -returnCodes error -result {unknown state "foo"} - -test treectrl-3.5 {qualifier state: toggle not allowed} -body { - .t item id "first state ~open" -} -returnCodes error -result {can't specify '~' for this command} - -test treectrl-3.6 {qualifier state: open ok} -body { - .t item id "first state open" -} -result {0} - -test treectrl-3.7 {qualifier state: !open ok} -body { - set res {} - lappend res [.t item id "first state !open"] - lappend res [.t item id "last state !open"] -} -result {3 5} - -test treectrl-3.8 {qualifier state: multiple states} -body { - .t item id "last state {open enabled active}" -} -result {0} - -test treectrl-3.9 {qualifier after index and modifier} -body { - .t item id "first state !open next state !open" -} -result {5} - -test treectrl-3.10 {qualifier state: following each modifier} -body { - set res {} - foreach modifier { - firstchild lastchild {child 0} - } { - lappend res [.t item id "root $modifier state !open"] - } - foreach modifier { - next prev nextsibling prevsibling {sibling 0} - } { - lappend res [.t item id "1 $modifier state !open"] - } - .t item expand 3 - .t item expand 5 - set res -} -result {5 5 5 3 {} 5 {} 5} - test treectrl-5.1 {state: missing args} -body { .t state } -returnCodes error -result {wrong # args: should be ".t state command ?arg arg ...?"} @@ -820,7 +483,7 @@ test treectrl-8.13 {selection includes: missing args} -body { test treectrl-8.14 {selection includes: invalid item} -body { .t selection includes {foo bar} -} -returnCodes error -result {bad item description "foo bar"} +} -returnCodes error -result {item "foo bar" doesn't exist} test treectrl-8.15 {selection includes: item is selected} -body { .t selection includes {root child 2} @@ -840,26 +503,26 @@ test treectrl-9.2 {see: too many args} -body { test treectrl-9.3 {see: invalid item} -body { .t see foo -} -returnCodes error -result {bad item description "foo"} +} -returnCodes error -result {item "foo" doesn't exist} test treectrl-9.4 {see: bottom most item} -body { .t see "root bottom" } -result {} test treectrl-10.1 {range: missing args} -body { - .t range -} -returnCodes error -result {wrong # args: should be ".t range first last"} + .t item range +} -returnCodes error -result {wrong # args: should be ".t item range first last"} test treectrl-10.2 {range: too many args} -body { - .t range foo bar baz -} -returnCodes error -result {wrong # args: should be ".t range first last"} + .t item range foo bar baz +} -returnCodes error -result {wrong # args: should be ".t item range first last"} test treectrl-10.3 {range: select all from top to bottom} -body { - .t range "root top" "root bottom" + .t item range "root top" "root bottom" } -result {0 1 2 3 4 5 6 7 8} test treectrl-10.4 {range: select all from bottom to top} -body { - .t range "root bottom" "root top" + .t item range "root bottom" "root top" } -result {0 1 2 3 4 5 6 7 8} test treectrl-11.1 {orphans: too many args} -body { @@ -876,16 +539,16 @@ test treectrl-11.3 {orphans: no orphans} -body { .t orphans } -result {} -test treectrl-12.1 {numitems: too many args} -body { - .t numitems foo -} -returnCodes error -result {wrong # args: should be ".t numitems"} +test treectrl-12.1 {item count: too many args} -body { + .t item count foo bar +} -returnCodes error -result {wrong # args: should be ".t item count ?-visible?"} -test treectrl-12.2 {numitems} -body { - .t numitems +test treectrl-12.2 {item count} -body { + .t item count } -result {9} -test treectrl-12.3 {numitems: simple double check with range} -body { - expr {[.t numitems] == [llength [.t range first last]]} +test treectrl-12.3 {item count: simple double check with range} -body { + expr {[.t item count] == [llength [.t item range first last]]} } -result {1} test treectrl-12.4 {contentbox: too many args} -body { @@ -1035,7 +698,7 @@ test treectrl-16.6 {dragimage offset: without preceding add} -body { test treectrl-16.7 {dragimage add: invalid item} -body { .t dragimage add foo -} -returnCodes error -result {bad item description "foo"} +} -returnCodes error -result {item "foo" doesn't exist} test treectrl-16.8 {dragimage add: invalid column} -body { .t dragimage add 1 foo |