diff options
Diffstat (limited to 'tests/ttk/spinbox.test')
-rw-r--r-- | tests/ttk/spinbox.test | 76 |
1 files changed, 70 insertions, 6 deletions
diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test index 38bae14..673f3bf 100644 --- a/tests/ttk/spinbox.test +++ b/tests/ttk/spinbox.test @@ -3,7 +3,8 @@ # package require Tk -package require tcltest ; namespace import -force tcltest::* +package require tcltest 2.2 +namespace import -force tcltest::* loadTestedCommands test spinbox-1.0 "Spinbox tests -- setup" -body { @@ -126,7 +127,7 @@ test spinbox-1.8.2 "option -validate" -setup { .sb cget -validate } -cleanup { destroy .sb -} -result {none} +} -result none test spinbox-1.8.3 "option -validate" -setup { ttk::spinbox .sb -from 0 -to 100 @@ -148,7 +149,7 @@ test spinbox-1.8.4 "-validate option: " -setup { set ::spinbox_test } -cleanup { destroy .sb -} -result {50} +} -result 50 test spinbox-2.0 "current command -- unset should be 0" -constraints nyi -setup { @@ -204,22 +205,85 @@ test spinbox-3.0 "textarea should expand to fill widget" -setup { set ::spinbox_test {} ttk::spinbox .sb -from 0 -to 10 -textvariable SBV } -body { - grid .sb -sticky ew grid columnconfigure . 0 -weight 1 + update idletasks + set timer [after 500 {set ::spinbox_test timedout}] bind . <Map> { after idle { wm geometry . "210x80" - after 100 {set ::spinbox_test [.sb identify element 5 5]} + update idletasks + set ::spinbox_test [.sb identify element 25 5] } bind . <Map> {} } - after 500 {set ::spinbox_wait 1} ; vwait ::spinbox_wait + grid .sb -sticky ew + vwait ::spinbox_test set ::spinbox_test } -cleanup { destroy .sb unset -nocomplain ::spinbox_test SBV } -result {textarea} +test spinbox-4.0 "Increment with duplicates in -values, wrap" -setup { + ttk::spinbox .sb -values {one two three 4 5 two six} -wrap true + set max [expr {[llength [.sb cget -values]] + 2}] +} -body { + set ::spinbox_test [.sb get] + for {set i 0} {$i < $max} {incr i} { + event generate .sb <<Increment>> + lappend ::spinbox_test [.sb get] + } + for {set i 0} {$i < $max} {incr i} { + event generate .sb <<Decrement>> + lappend ::spinbox_test [.sb get] + } + set ::spinbox_test +} -cleanup { + destroy .sb + unset -nocomplain ::spinbox_test max +} -result {one two three 4 5 two six one two one six two 5 4 three two one six} + +test spinbox-4.1 "Increment with duplicates in -values, wrap, initial value set" -setup { + ttk::spinbox .sb -values {one two three 4 5 two six} -wrap true + set max [expr {[llength [.sb cget -values]] + 2}] +} -body { + .sb set three + set ::spinbox_test [.sb get] + for {set i 0} {$i < $max} {incr i} { + event generate .sb <<Increment>> + lappend ::spinbox_test [.sb get] + } + .sb set two ; # the first "two" in the -values list becomes the current value + for {set i 0} {$i < $max} {incr i} { + event generate .sb <<Decrement>> + lappend ::spinbox_test [.sb get] + } + set ::spinbox_test +} -cleanup { + destroy .sb + unset -nocomplain ::spinbox_test max +} -result {three 4 5 two six one two three 4 5 one six two 5 4 three two one six} + +test spinbox-4.2 "Increment with duplicates in -values, no wrap" -setup { + ttk::spinbox .sb -values {one two three 4 5 two six} -wrap false + set max [expr {[llength [.sb cget -values]] + 2}] +} -body { + set ::spinbox_test [.sb get] + for {set i 0} {$i < $max} {incr i} { + event generate .sb <<Increment>> + lappend ::spinbox_test [.sb get] + } + for {set i 0} {$i < $max} {incr i} { + event generate .sb <<Decrement>> + lappend ::spinbox_test [.sb get] + } + set ::spinbox_test +} -cleanup { + destroy .sb + unset -nocomplain ::spinbox_test max +} -result {one two three 4 5 two six six six two 5 4 three two one one one one} + + # nostomp: NB intentional difference between ttk::spinbox and tk::spinbox; # see also #1439266 # |