diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-05-15 09:51:27 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-05-15 09:51:27 (GMT) |
commit | d2d2d59c209cc6a7c8009dc44bd9a4a07aa04887 (patch) | |
tree | c76bee1bb05fcfbc7f6c89d7a735dd1253fc8788 /tests | |
parent | 2817b85e0527030b511e160a195365123fed2d07 (diff) | |
parent | 0be716f0f282bf6e937b7ad2a8beb171b51d1659 (diff) | |
download | tk-d2d2d59c209cc6a7c8009dc44bd9a4a07aa04887.zip tk-d2d2d59c209cc6a7c8009dc44bd9a4a07aa04887.tar.gz tk-d2d2d59c209cc6a7c8009dc44bd9a4a07aa04887.tar.bz2 |
Merge 8.6. Some tweaks, e.g. "bool" -> "int", "true" -> 1, "false" -> 0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frame.test | 8 | ||||
-rw-r--r-- | tests/grid.test | 25 | ||||
-rw-r--r-- | tests/pack.test | 21 | ||||
-rw-r--r-- | tests/place.test | 21 | ||||
-rw-r--r-- | tests/textWind.test | 5 | ||||
-rw-r--r-- | tests/ttk/entry.test | 29 | ||||
-rw-r--r-- | tests/ttk/scrollbar.test | 30 | ||||
-rw-r--r-- | tests/ttk/treeview.test | 29 | ||||
-rw-r--r-- | tests/unixEmbed.test | 1 |
9 files changed, 160 insertions, 9 deletions
diff --git a/tests/frame.test b/tests/frame.test index c7b0ed8..e374326 100644 --- a/tests/frame.test +++ b/tests/frame.test @@ -668,6 +668,12 @@ test frame-3.9 {TkCreateFrame procedure, -use option} -constraints { [expr {[winfo rooty .x] - [winfo rooty .t]}] \ [winfo width .t] [winfo height .t] } -cleanup { +# This call to update idletasks was added to prevent a crash that was +# observed on OSX 10.12 (Sierra) only. Any change, such as using the +# Development version to make debugging symbols available, adding a print +# statement, or calling update idletasks here, would make the test pass +# with no segfault. + update idletasks deleteWindows } -result {0 0 140 300} test frame-3.10 {TkCreateFrame procedure, -use option} -constraints { @@ -678,8 +684,10 @@ test frame-3.10 {TkCreateFrame procedure, -use option} -constraints { toplevel .t -container 1 -width 300 -height 120 wm geometry .t +0+0 option add *x.use [winfo id .t] + update toplevel .x -width 140 -height 300 -bg green tkwait visibility .x + update list [expr {[winfo rootx .x] - [winfo rootx .t]}] \ [expr {[winfo rooty .x] - [winfo rooty .t]}] \ [winfo width .t] [winfo height .t] diff --git a/tests/grid.test b/tests/grid.test index cba69db..62474ff 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -80,6 +80,7 @@ test grid-1.9 {basic argument checking} -body { grid_reset 1.9 } -returnCodes ok -result {} + test grid-2.1 {bbox} -body { grid bbox . } -result {0 0 0 0} @@ -192,6 +193,30 @@ test grid-3.9 {configure: basic argument checking} -body { } -cleanup { grid_reset 3.9 } -returnCodes error -result {invalid window shortcut, "y" should be '-', 'x', or '^'} +test grid-3.10 {ConfigureSlave procedure, bad -in option} -body { + frame .f + grid .f -in .f +} -cleanup { + grid_reset 3.10 +} -returnCodes error -result {window can't be managed in itself} +test grid-3.11 {prevent management loops} -body { + frame .f1 + frame .f2 + grid .f1 -in .f2 + grid .f2 -in .f1 +} -cleanup { + grid_reset 3.11 +} -returnCodes error -result {can't put .f2 inside .f1, would cause management loop} +test grid-3.12 {prevent management loops} -body { + frame .f1 + frame .f2 + frame .f3 + grid .f1 -in .f2 + grid .f2 -in .f3 + grid .f3 -in .f1 +} -cleanup { + grid_reset 3.12 +} -returnCodes error -result {can't put .f3 inside .f1, would cause management loop} test grid-4.1 {forget: basic argument checking} -body { grid forget foo diff --git a/tests/pack.test b/tests/pack.test index efb262b..e2efb4d 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -976,6 +976,27 @@ test pack-10.4 {bad -in window does not change master} -setup { winfo manager .pack.a pack .pack.a -in .pack.a } -returnCodes error -result {can't pack .pack.a inside itself} +test pack-10.5 {prevent management loops} -body { + frame .f1 + frame .f2 + pack .f1 -in .f2 + pack .f2 -in .f1 +} -cleanup { + destroy .f1 + destroy .f2 +} -returnCodes error -result {can't put .f2 inside .f1, would cause management loop} +test pack-10.6 {prevent management loops} -body { + frame .f1 + frame .f2 + frame .f3 + pack .f1 -in .f2 + pack .f2 -in .f3 + pack .f3 -in .f1 +} -cleanup { + destroy .f1 + destroy .f2 + destroy .f3 +} -returnCodes error -result {can't put .f3 inside .f1, would cause management loop} test pack-11.1 {info option} -setup { diff --git a/tests/place.test b/tests/place.test index ddfa64c..62e0ed2 100644 --- a/tests/place.test +++ b/tests/place.test @@ -118,7 +118,26 @@ test place-4.4 {ConfigureSlave procedure, bad -in option} -setup { } -body { place .t.f2 -in . } -returnCodes error -result {can't place .t.f2 relative to .} - +test place-4.5 {ConfigureSlave procedure, bad -in option} -setup { +} -body { + frame .t.f1 + place .t.f1 -in .t.f1 +} -returnCodes error -result {can't place .t.f1 relative to itself} +test place-4.6 {prevent management loops} -setup { + place forget .t.f1 +} -body { + place .t.f1 -in .t.f2 + place .t.f2 -in .t.f1 +} -returnCodes error -result {can't put .t.f2 inside .t.f1, would cause management loop} +test place-4.7 {prevent management loops} -setup { + place forget .t.f1 + place forget .t.f2 +} -body { + frame .t.f3 + place .t.f1 -in .t.f2 + place .t.f2 -in .t.f3 + place .t.f3 -in .t.f1 +} -returnCodes error -result {can't put .t.f3 inside .t.f1, would cause management loop} test place-5.1 {ConfigureSlave procedure, -relwidth option} -body { place .t.f2 -relwidth abcd diff --git a/tests/textWind.test b/tests/textWind.test index e189663..788c245 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -39,6 +39,11 @@ wm minsize . 1 1 wm positionfrom . user wm deiconify . +# This update is needed on MacOS to make sure that the window is mapped +# when the tests begin. + +update + set bw [.t cget -borderwidth] set px [.t cget -padx] set py [.t cget -pady] diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test index d95ef31..a920042 100644 --- a/tests/ttk/entry.test +++ b/tests/ttk/entry.test @@ -103,10 +103,37 @@ test entry-3.1 "bbox widget command" -body { test entry-3.2 "xview" -body { .e delete 0 end; .e insert end [string repeat "0" 40] - update idletasks set result [.e xview] } -result {0.0 0.5} +test entry-3.3 "xview" -body { + .e delete 0 end; + .e insert end abcdefghijklmnopqrstuvwxyz + .e xview end + set result [.e index @0] +} -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} + +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} + +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} + test entry-3.last "Series 3 cleanup" -body { destroy .e } diff --git a/tests/ttk/scrollbar.test b/tests/ttk/scrollbar.test index 341b5c1..903328e 100644 --- a/tests/ttk/scrollbar.test +++ b/tests/ttk/scrollbar.test @@ -4,16 +4,26 @@ loadTestedCommands testConstraint coreScrollbar [expr {[tk windowingsystem] eq "aqua"}] -test scrollbar-swapout-1 "Use core scrollbars on OSX..." -constraints { - coreScrollbar +# Before 2019 the code in library/ttk/scrollbar.tcl would replace the +# constructor of ttk::scrollbar with the constructor of tk::scrollbar +# unless the -class or -style options were specified.. +# Now there is an implementation of ttk::scrollbar for macOS. The +# tests are left in place, though, except that scrollbar-swapout-1 +# test was changed to expect the class to be TScrollbar instead of +# Scrollbar. + +test scrollbar-swapout-1 "Don't use core scrollbars on OSX..." \ + -constraints { + coreScrollbar } -body { ttk::scrollbar .sb -command "yadda" list [winfo class .sb] [.sb cget -command] -} -result [list Scrollbar yadda] -cleanup { +} -result [list TScrollbar yadda] -cleanup { destroy .sb } -test scrollbar-swapout-2 "... unless -style is specified ..." -constraints { +test scrollbar-swapout-2 "... regardless of whether -style ..." \ +-constraints { coreScrollbar } -body { ttk::style layout Vertical.Custom.TScrollbar \ @@ -24,7 +34,7 @@ test scrollbar-swapout-2 "... unless -style is specified ..." -constraints { destroy .sb } -test scrollbar-swapout-3 "... or -class." -constraints { +test scrollbar-swapout-3 "... or -class is specified." -constraints { coreScrollbar } -body { ttk::scrollbar .sb -command "yadda" -class Custom.TScrollbar @@ -44,13 +54,19 @@ test scrollbar-1.1 "Set method" -body { test scrollbar-1.2 "Set orientation" -body { .tsb configure -orient vertical - set w [winfo reqwidth .tsb] ; set h [winfo reqheight .tsb] + pack .tsb -side right -anchor e -expand 1 -fill y + wm geometry . 200x200 + update + set w [winfo width .tsb] ; set h [winfo height .tsb] expr {$h > $w} } -result 1 test scrollbar-1.3 "Change orientation" -body { .tsb configure -orient horizontal - set w [winfo reqwidth .tsb] ; set h [winfo reqheight .tsb] + pack .tsb -side bottom -anchor s -expand 1 -fill x + wm geometry . 200x200 + update + set w [winfo width .tsb] ; set h [winfo height .tsb] expr {$h < $w} } -result 1 diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index aa7e64a..a36e3d1 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -471,6 +471,18 @@ test treeview-9.0 "scroll callback - empty tree" -body { set ::scrolldata } -result [list 0.0 1.0] +test treeview-9.1 "scrolling" -setup { + pack [ttk::treeview .tree -show tree] -fill y + for {set i 1} {$i < 100} {incr i} { + .tree insert {} end -text $i + } +} -body { + .tree yview scroll 5 units + .tree identify item 2 2 +} -cleanup { + destroy .tree +} -result {I006} + ### identify tests: # proc identify* {tv comps args} { @@ -636,4 +648,21 @@ test treeview-3085489-2 "tag remove, no -tags" -setup { destroy .tv } -result [list] +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" + 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> \ + -x [expr ($x + $h / 2)] \ + -y [expr ($y + $h / 2)] + lappend res [.tv item foo -open] + .tv insert foo end -text "sub" + lappend res [.tv item foo -open] +} -result {0 0 0} + tcltest::cleanupTests diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 99f7265..a29995f 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -1234,6 +1234,7 @@ test unixEmbed-10.1 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con deleteWindows } -body { frame .f1 -container 1 -width 200 -height 50 + update pack .f1 update toplevel .t1 -use [winfo id .f1] -width 150 -height 80 |