diff options
Diffstat (limited to 'tests/ttk')
-rw-r--r-- | tests/ttk/checkbutton.test | 2 | ||||
-rw-r--r-- | tests/ttk/combobox.test | 8 | ||||
-rw-r--r-- | tests/ttk/entry.test | 30 | ||||
-rw-r--r-- | tests/ttk/image.test | 2 | ||||
-rw-r--r-- | tests/ttk/labelframe.test | 2 | ||||
-rw-r--r-- | tests/ttk/panedwindow.test | 6 | ||||
-rw-r--r-- | tests/ttk/progressbar.test | 39 | ||||
-rw-r--r-- | tests/ttk/scrollbar.test | 94 | ||||
-rw-r--r-- | tests/ttk/spinbox.test | 6 | ||||
-rw-r--r-- | tests/ttk/treetags.test | 31 | ||||
-rw-r--r-- | tests/ttk/treeview.test | 16 | ||||
-rw-r--r-- | tests/ttk/ttk.test | 10 | ||||
-rw-r--r-- | tests/ttk/validate.test | 2 |
13 files changed, 198 insertions, 50 deletions
diff --git a/tests/ttk/checkbutton.test b/tests/ttk/checkbutton.test index 15d365f..5e929de 100644 --- a/tests/ttk/checkbutton.test +++ b/tests/ttk/checkbutton.test @@ -56,7 +56,7 @@ test checkbutton-1.7 "Button destroyed by click" -body { pack .top.mb focus -force .top.mb update - event generate .top.mb <1> + event generate .top.mb <Button-1> event generate .top.mb <ButtonRelease-1> update ; # shall not trigger error invalid command name ".top.b" } -result {} diff --git a/tests/ttk/combobox.test b/tests/ttk/combobox.test index 45fe0fc..c14db9b 100644 --- a/tests/ttk/combobox.test +++ b/tests/ttk/combobox.test @@ -38,18 +38,18 @@ test combobox-2.3 "current -- change value" -body { .cb current } -result 1 -test combobox-2.4 "current -- value not in list" -body { +test combobox-2.4 "current -- value not in list" -body { .cb set "z" .cb current } -result -1 -test combobox-2.5 "current -- set to end index" -body { +test combobox-2.5 "current -- set to end index" -body { .cb configure -values [list a b c d e thelastone] .cb current end .cb get } -result thelastone -test combobox-2.6 "current -- set to unknown index" -body { +test combobox-2.6 "current -- set to unknown index" -body { .cb configure -values [list a b c d e] .cb current notanindex } -returnCodes error -result {Incorrect index notanindex} @@ -58,7 +58,7 @@ test combobox-2.end "Cleanup" -body { destroy .cb } test combobox-3 "Read postoffset value dynamically from current style" -body { ttk::combobox .cb -values [list a b c] -style "DerivedStyle.TCombobox" - pack .cb -expand true -fill both + pack .cb -expand true -fill both ttk::style configure DerivedStyle.TCombobox -postoffset [list 25 0 0 0] ttk::combobox::Post .cb expr {[winfo rootx .cb.popdown] - [winfo rootx .cb]} diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test index 2e5f43c..a2d6016 100644 --- a/tests/ttk/entry.test +++ b/tests/ttk/entry.test @@ -84,7 +84,7 @@ test entry-2.1.1 "Create entry before scrollbar - scrollbar catches up" -body { -expand false -fill x update ; # no error lappend res [expr [lindex [.tsb get] 1] < 1] ; # scrollbar did update -} -result {1} -cleanup {destroy .te .tsb} +} -result 1 -cleanup {destroy .te .tsb} test entry-2.2 "Initial scroll position" -body { ttk::entry .e -font fixed -width 5 -xscrollcommand scroll @@ -128,28 +128,28 @@ test entry-3.3 "xview" -body { .e insert end abcdefghijklmnopqrstuvwxyz .e xview end set result [.e index @0] -} -result {7} +} -result 7 test entry-3.4 "xview" -body { .e delete 0 end; .e insert end abcdefghijklmnopqrstuvwxyz .e xview moveto 1.0 set result [.e index @0] -} -result {7} +} -result 7 test entry-3.5 "xview" -body { .e delete 0 end; .e insert end abcdefghijklmnopqrstuvwxyz .e xview scroll 5 units set result [.e index @0] -} -result {5} +} -result 5 test entry-3.6 "xview" -body { .e delete 0 end; .e insert end [string repeat abcdefghijklmnopqrstuvwxyz 5] .e xview scroll 2 pages set result [.e index @0] -} -result {40} +} -result 40 test entry-3.last "Series 3 cleanup" -body { destroy .e @@ -324,7 +324,25 @@ test entry-9.1 "Index range invariants" -setup { destroy .e } -test entry-10.1 {Bug [2830360fff] - Don't loose invalid at focus events} -setup { +test entry-10.1 {configuration option: "-placeholder"} -setup { + pack [ttk::entry .e] +} -body { + .e configure -placeholder {Some text} + .e cget -placeholder +} -cleanup { + destroy .e +} -result {Some text} + +test entry-10.2 {configuration option: "-placeholderforeground"} -setup { + pack [ttk::entry .e] +} -body { + .e configure -placeholder {Some text} -placeholderforeground red + .e cget -placeholderforeground +} -cleanup { + destroy .e +} -result {red} + +test entry-11.1 {Bug [2830360fff] - Don't loose invalid at focus events} -setup { pack [ttk::entry .e] update } -body { diff --git a/tests/ttk/image.test b/tests/ttk/image.test index a55f7f8..5e48d5c 100644 --- a/tests/ttk/image.test +++ b/tests/ttk/image.test @@ -23,7 +23,7 @@ test image-2.0 "Deletion of displayed image (label)" -setup { } -cleanup { destroy .ttk_image20 } -result {} - + test image-2.1 "Deletion of displayed image (checkbutton)" -setup { image create photo test.image -width 10 -height 10 } -body { diff --git a/tests/ttk/labelframe.test b/tests/ttk/labelframe.test index 28b4d2e..649c35f 100644 --- a/tests/ttk/labelframe.test +++ b/tests/ttk/labelframe.test @@ -70,7 +70,7 @@ test labelframe-3.6 "Destroy child slave" -body { # @@@ but seems to succeed if it's some other widget class. # @@@ I suspect a race condition; unable to track it down ATM. # -# @@@ FOLLOWUP: This *may* have been caused by a bug in ManagerIdleProc +# @@@ FOLLOWUP: This *may* have been caused by a bug in ManagerIdleProc # @@@ (see manager.c r1.11). There's still probably a race condition in here. # test labelframe-4.1 "Add nonchild slave" -body { diff --git a/tests/ttk/panedwindow.test b/tests/ttk/panedwindow.test index 7fe5c87..c1fc6ac 100644 --- a/tests/ttk/panedwindow.test +++ b/tests/ttk/panedwindow.test @@ -110,8 +110,8 @@ test panedwindow-2.end "Cleanup" -body { destroy .pw } # test panedwindow-3.0 "configure pane" -body { ttk::panedwindow .pw - .pw add [listbox .pw.lb1] - .pw add [listbox .pw.lb2] + .pw add [listbox .pw.lb1] + .pw add [listbox .pw.lb2] .pw pane 1 -weight 2 .pw pane 1 -weight } -result 2 @@ -253,7 +253,7 @@ test paned-propagation-setup "Setup." -body { frame .pw.f2 -width 100 -height 50 list [winfo reqwidth .pw.f1] [winfo reqheight .pw.f1] -} -result [list 100 50] +} -result [list 100 50] test paned-propagation-1 "Initial request size" -body { .pw add .pw.f1 diff --git a/tests/ttk/progressbar.test b/tests/ttk/progressbar.test index b9add86..7c888c6 100644 --- a/tests/ttk/progressbar.test +++ b/tests/ttk/progressbar.test @@ -82,4 +82,43 @@ test progressbar-end "Cleanup" -body { destroy .pb } +# check existence and default value of each non-core option of the widget +test progressbar-3.1 "progressbar non-core options" -setup { + set res {} + ttk::progressbar .defaultpb +} -body { + foreach option {-anchor -foreground -justify -style -text -wraplength \ + -length -maximum -mode -orient -phase -value -variable} { + lappend res [.defaultpb cget $option] + } + set res +} -cleanup { + unset res + destroy .defaultpb +} -result {w black left {} {} 0 100 100 determinate horizontal 0 0.0 {}} + +test progressbar-3.2 "TIP #442 options are taken into account" -setup { + set res {} + pack [ttk::progressbar .p -value 0 -maximum 50 -orient horizontal -mode determinate -length 500] + set thefont [font actual {Arial 10}] +} -body { + .p configure -anchor c -foreground blue -justify right \ + -text "TIP #442\noptions are now tested" -wraplength 100 + update + .p step 10 + .p configure -anchor e -font $thefont -foreground green -justify center \ + -text "Changing the value of each option\nfrom TIP #442" -wraplength 250 + update + .p step 20 + .p configure -orient vertical -text "Cannot be seen" + update + foreach option {-anchor -foreground -justify -text -wraplength} { + lappend res [list $option [.p cget $option]] + } + set res +} -cleanup { + unset res thefont + destroy .p +} -result {{-anchor e} {-foreground green} {-justify center} {-text {Cannot be seen}} {-wraplength 250}} + tcltest::cleanupTests diff --git a/tests/ttk/scrollbar.test b/tests/ttk/scrollbar.test index 903328e..443687a 100644 --- a/tests/ttk/scrollbar.test +++ b/tests/ttk/scrollbar.test @@ -18,8 +18,8 @@ test scrollbar-swapout-1 "Don't use core scrollbars on OSX..." \ } -body { ttk::scrollbar .sb -command "yadda" list [winfo class .sb] [.sb cget -command] -} -result [list TScrollbar yadda] -cleanup { - destroy .sb +} -result [list TScrollbar yadda] -cleanup { + destroy .sb } test scrollbar-swapout-2 "... regardless of whether -style ..." \ @@ -28,7 +28,7 @@ test scrollbar-swapout-2 "... regardless of whether -style ..." \ } -body { ttk::style layout Vertical.Custom.TScrollbar \ [ttk::style layout Vertical.TScrollbar] ; # See #1833339 - ttk::scrollbar .sb -command "yadda" -style Custom.TScrollbar + ttk::scrollbar .sb -command "yadda" -style Custom.TScrollbar list [winfo class .sb] [.sb cget -command] [.sb cget -style] } -result [list TScrollbar yadda Custom.TScrollbar] -cleanup { destroy .sb @@ -37,7 +37,7 @@ test scrollbar-swapout-2 "... regardless of whether -style ..." \ test scrollbar-swapout-3 "... or -class is specified." -constraints { coreScrollbar } -body { - ttk::scrollbar .sb -command "yadda" -class Custom.TScrollbar + ttk::scrollbar .sb -command "yadda" -class Custom.TScrollbar list [winfo class .sb] [.sb cget -command] } -result [list Custom.TScrollbar yadda] -cleanup { destroy .sb @@ -70,6 +70,92 @@ test scrollbar-1.3 "Change orientation" -body { expr {$h < $w} } -result 1 +test scrollbar-10.1.1 {<MouseWheel> event on scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [ttk::scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s <MouseWheel> -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} +test scrollbar-10.1.2 {<MouseWheel> event on scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [ttk::scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s <MouseWheel> -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} + +test scrollbar-10.2.1 {<Shift-MouseWheel> event on horizontal scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s <Shift-MouseWheel> -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.2 {<Shift-MouseWheel> event on horizontal scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s <Shift-MouseWheel> -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.3 {<MouseWheel> event on horizontal scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s <MouseWheel> -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.4 {<MouseWheel> event on horizontal scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s <MouseWheel> -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} + # # Scale tests: # diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test index b86f053..4bdabee 100644 --- a/tests/ttk/spinbox.test +++ b/tests/ttk/spinbox.test @@ -148,7 +148,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 { @@ -316,7 +316,7 @@ test spinbox-nostomp-3 "don't stomp on -variable (configure; -from/to)" -body { test spinbox-nostomp-4 "don't stomp on -variable (configure; -values)" -body { set SBV Apr - ttk::spinbox .sb + ttk::spinbox .sb .sb configure -textvariable SBV -values {Jan Feb Mar Apr May Jun Jul Aug} list $SBV [.sb get] } -cleanup { @@ -341,7 +341,7 @@ test spinbox-dieoctaldie-1 "Cope with leading zeros" -body { event generate .sb <<Decrement>>; lappend result $secs set result -} -result [list 07 08 09 10 11 10 09 08 07] -cleanup { +} -result [list 07 08 09 10 11 10 09 08 07] -cleanup { destroy .sb unset secs } diff --git a/tests/ttk/treetags.test b/tests/ttk/treetags.test index 7f26e2f..fd3a0c5 100644 --- a/tests/ttk/treetags.test +++ b/tests/ttk/treetags.test @@ -11,12 +11,11 @@ proc assert {expr {message ""}} { error "PANIC: $message ($expr failed)" } } -proc in {e l} { expr {[lsearch -exact $l $e] >= 0} } proc itemConstraints {tv item} { # $tag in [$tv item $item -tags] <==> [$tv tag has $tag $item] foreach tag [$tv item $item -tags] { - assert {[in $item [$tv tag has $tag]]} + assert {$item in [$tv tag has $tag]} } foreach child [$tv children $item] { itemConstraints $tv $child @@ -28,7 +27,7 @@ proc treeConstraints {tv} { # foreach tag [$tv tag names] { foreach item [$tv tag has $tag] { - assert {[in $tag [$tv item $item -tags]]} + assert {$tag in [$tv item $item -tags]} } } @@ -105,7 +104,7 @@ test treetags-1.8 "tag names" -body { } -result [list tag1 tag2 tag3] test treetags-1.9 "tag names - tag added to item" -body { - $tv item item1 -tags tag4 + $tv item item1 -tags tag4 lsort [$tv tag names] } -result [list tag1 tag2 tag3 tag4] @@ -114,6 +113,12 @@ test treetags-1.10 "tag names - tag configured" -body { lsort [$tv tag names] } -result [list tag1 tag2 tag3 tag4 tag5] +test treetags-1.11 "tag delete" -body { + $tv tag delete tag5 + $tv tag delete tag4 + lsort [$tv tag names] +} -result [list tag1 tag2 tag3] + test treetags-1.end "cleanup" -body { $tv item item1 -tags tag1 $tv item item2 -tags tag2 @@ -123,28 +128,28 @@ test treetags-1.end "cleanup" -body { } -result [list [list item1] [list item2] [list]] test treetags-2.0 "tag bind" -body { - $tv tag bind tag1 <KeyPress> {set ::KEY %A} - $tv tag bind tag1 <KeyPress> + $tv tag bind tag1 <Key> {set ::KEY %A} + $tv tag bind tag1 <Key> } -cleanup { treeConstraints $tv } -result {set ::KEY %A} test treetags-2.1 "Events delivered to tags" -body { - focus -force $tv ; update ;# needed so [event generate] delivers KeyPress + focus -force $tv ; update ;# needed so [event generate] delivers Key $tv focus item1 - event generate $tv <KeyPress-a> + event generate $tv <a> set ::KEY } -cleanup { treeConstraints $tv } -result a test treetags-2.2 "Events delivered to correct tags" -body { - $tv tag bind tag2 <KeyPress> [list set ::KEY2 %A] + $tv tag bind tag2 <Key> [list set ::KEY2 %A] $tv focus item1 - event generate $tv <KeyPress-b> + event generate $tv <b> $tv focus item2 - event generate $tv <KeyPress-c> + event generate $tv <c> list $::KEY $::KEY2 } -cleanup { @@ -201,12 +206,12 @@ test treetags-3.4 "stomp tags in tag binding procedure" -body { set result [list] $tv tag bind rm1 <<Remove>> { lappend ::result rm1 [%W focus] <<Remove>> } $tv tag bind rm2 <<Remove>> { - lappend ::result rm2 [%W focus] <<Remove>> + lappend ::result rm2 [%W focus] <<Remove>> %W item [%W focus] -tags {tag1} } $tv tag bind rm3 <<Remove>> { lappend ::result rm3 [%W focus] <<Remove>> } - $tv item item1 -tags {rm1 rm2 rm3} + $tv item item1 -tags {rm1 rm2 rm3} $tv focus item1 event generate $tv <<Remove>> set result diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index 0ad0443..4236b01 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -466,7 +466,7 @@ test treeview-8.6 "Selection - <<TreeviewSelect>> on selection add" -body { .tv selection add newnode.n1 update set res -} -result {1} +} -result 1 test treeview-8.7 "<<TreeviewSelect>> on selected item deletion" -body { .tv selection set {} @@ -560,7 +560,7 @@ test treeview-9.3 {scrolling on see command, requested item is closed} -setup { expr $after < $before } -cleanup { destroy .top -} -result {1} +} -result 1 ### identify tests: # @@ -699,9 +699,9 @@ test treeview-10.1 "Root node properly initialized (#1541739)" -setup { test treeview-3006842 "Null bindings" -setup { ttk::treeview .tv -show tree } -body { - .tv tag bind empty <ButtonPress-1> {} + .tv tag bind empty <Button-1> {} .tv insert {} end -text "Click me" -tags empty - event generate .tv <ButtonPress-1> -x 10 -y 10 + event generate .tv <Button-1> -x 10 -y 10 .tv tag bind empty } -result {} -cleanup { destroy .tv @@ -729,14 +729,14 @@ test treeview-3085489-2 "tag remove, no -tags" -setup { test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup { pack [ttk::treeview .tv] - .tv insert {} end -id foo -text "<-- (1) Click the blank space to my left" + .tv insert {} end -id foo -text "<-- (1) Click the blank space to my left" update } -body { foreach {x y w h} [.tv bbox foo #0] {} set res [.tv item foo -open] # using $h even for x computation is intentional here in order to simulate # a mouse click on the (invisible since we're on a leaf) indicator - event generate .tv <ButtonPress-1> \ + event generate .tv <Button-1> \ -x [expr {$x + $h / 2}] \ -y [expr {$y + $h / 2}] lappend res [.tv item foo -open] @@ -748,7 +748,7 @@ test treeview-368fa4561e "indicators cannot be clicked on leafs" -setup { test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is allowed" -setup { pack [ttk::treeview .tv] - .tv heading #0 -text "Drag my right edge -->" + .tv heading #0 -text "Drag my right edge -->" update } -body { set res [.tv column #0 -width] @@ -818,7 +818,7 @@ test treeview-ce470f20fd-4 "changing -stretch resizes columns" -setup { update idletasks ; # redisplay treeview } -body { # only some columns are displayed (and in a different order than declared - # in -columns), a non-displayed column becomes stretchable --> nothing + # in -columns), a non-displayed column becomes stretchable --> nothing # happens set origTreeWidth [winfo width .tv] set res [list [.tv column bar -width] [.tv column colA -width]] diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index aba3eba..53da18a 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -134,8 +134,8 @@ test ttk-selfdestruct-ok-1 "Intentional self-destruction" -body { # # Basic tests. # -test ttk-1.1 "Create button" -body { - pack [ttk::button .t] -expand true -fill both +test ttk-1.1 "Create multiline button showing justified text" -body { + pack [ttk::button .t -text "Hello\nWorld!!" -justify center] -expand true -fill both update } @@ -207,9 +207,9 @@ test ttk-2.8 "bug 3223850: button state disabled during click" -setup { set ttk28 {} pack [ttk::button .b -command {set ::ttk28 failed}] update -} -body { - bind .b <ButtonPress-1> {after 0 {.b configure -state disabled}} - after 1 {event generate .b <ButtonPress-1>} +} -body { + bind .b <Button-1> {after 0 {.b configure -state disabled}} + after 1 {event generate .b <Button-1>} after 20 {event generate .b <ButtonRelease-1>} set aid [after 100 {set ::ttk28 [.b instate {disabled !pressed}]}] vwait ::ttk28 diff --git a/tests/ttk/validate.test b/tests/ttk/validate.test index 417deac..5755943 100644 --- a/tests/ttk/validate.test +++ b/tests/ttk/validate.test @@ -161,7 +161,7 @@ test validate-1.18 {entry widget validation} -constraints coreEntry -body { list [.e cget -validate] $::vVals } -result {none {.e -1 -1 nextdata newdata {} all forced}} # DIFFERENCE: ttk::entry doesn't validate when setting linked -variable -# DIFFERENCE: ttk::entry doesn't disable validation +# DIFFERENCE: ttk::entry doesn't disable validation proc doval {W d i P s S v V} { set ::vVals [list $W $d $i $P $s $S $v $V] |