summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2019-05-08 12:21:55 (GMT)
committerfvogel <fvogelnew1@free.fr>2019-05-08 12:21:55 (GMT)
commitd3976c34aa0da0b7c7232f381311938111be0946 (patch)
tree5cd14e9b941b0edc7439b3dc7d2ea19d94909655 /tests
parent3f9a6cdf9f72f70de3975b8dadc0680feeb90d00 (diff)
downloadtk-d3976c34aa0da0b7c7232f381311938111be0946.zip
tk-d3976c34aa0da0b7c7232f381311938111be0946.tar.gz
tk-d3976c34aa0da0b7c7232f381311938111be0946.tar.bz2
Add treeview tests checking for non-regression (the last added test already passed in core-8-6-branch)
Diffstat (limited to 'tests')
-rw-r--r--tests/ttk/treeview.test80
1 files changed, 79 insertions, 1 deletions
diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test
index b9fcd1e..22d978c 100644
--- a/tests/ttk/treeview.test
+++ b/tests/ttk/treeview.test
@@ -636,7 +636,7 @@ test treeview-3085489-2 "tag remove, no -tags" -setup {
destroy .tv
} -result [list]
-test treeview-ce470f20fd "dragging further than the right edge of the treeview is forbidden" -setup {
+test treeview-ce470f20fd-1 "dragging further than the right edge of the treeview is forbidden" -setup {
pack [ttk::treeview .tv]
.tv heading #0 -text "Drag my right edge -->"
update
@@ -644,6 +644,84 @@ test treeview-ce470f20fd "dragging further than the right edge of the treeview i
set res [.tv column #0 -width]
.tv drag #0 400
lappend res [expr {[.tv column #0 -width] > $res}]
+} -cleanup {
+ destroy .tv
} -result {200 0}
+proc nostretch {tv} {
+ foreach col [$tv cget -columns] {
+ $tv column $col -stretch 0
+ }
+ $tv column #0 -stretch 0
+ update idletasks ; # redisplay $tv
+}
+
+test treeview-ce470f20fd-2 "changing -stretch resizes columns" -setup {
+ pack [ttk::treeview .tv -columns {bar colA colB colC foo}]
+ foreach col [.tv cget -columns] {
+ .tv heading $col -text $col
+ }
+ nostretch .tv
+ .tv column colA -width 50 ; .tv column colB -width 50 ; # slack created
+ update idletasks ; # redisplay treeview
+} -body {
+ # when no column is stretchable and one of them becomes stretchable
+ # the stretchable column takes the slack and the widget is redisplayed
+ # automatically at idle time
+ set res [.tv column colA -width]
+ .tv column colA -stretch 1
+ update idletasks ; # no slack anymore, widget redisplayed
+ lappend res [expr {[.tv column colA -width] > $res}]
+} -cleanup {
+ destroy .tv
+} -result {50 1}
+
+test treeview-ce470f20fd-3 "changing -stretch resizes columns" -setup {
+ pack [ttk::treeview .tv -columns {bar colA colB colC foo}]
+ foreach col [.tv cget -columns] {
+ .tv heading $col -text $col
+ }
+ .tv configure -displaycolumns {colB colA colC}
+ nostretch .tv
+ .tv column colA -width 50 ; .tv column colB -width 50 ; # slack created
+ update idletasks ; # redisplay treeview
+} -body {
+ # only some columns are displayed (and in a different order than declared
+ # in -columns), a displayed column becomes stretchable --> the stretchable
+ # column expands
+ set res [.tv column colA -width]
+ .tv column colA -stretch 1
+ update idletasks ; # no slack anymore, widget redisplayed
+ lappend res [expr {[.tv column colA -width] > $res}]
+} -cleanup {
+ destroy .tv
+} -result {50 1}
+
+test treeview-ce470f20fd-4 "changing -stretch resizes columns" -setup {
+ pack [ttk::treeview .tv -columns {bar colA colB colC foo}]
+ foreach col [.tv cget -columns] {
+ .tv heading $col -text $col
+ }
+ .tv configure -displaycolumns {colB colA colC}
+ nostretch .tv
+ .tv column colA -width 50 ; .tv column bar -width 60 ; # slack created
+ 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
+ # happens
+ set origTreeWidth [winfo width .tv]
+ set res [list [.tv column bar -width] [.tv column colA -width]]
+ .tv column bar -stretch 1
+ update idletasks ; # no change, widget redisplayed
+ lappend res [.tv column bar -width] [.tv column colA -width]
+ # this column becomes visible --> widget resizes
+ .tv configure -displaycolumns {bar colC colA colB}
+ update idletasks ; # no slack anymore because the widget resizes (shrinks)
+ lappend res [.tv column bar -width] [.tv column colA -width] \
+ [expr {[winfo width .tv] < $origTreeWidth}]
+} -cleanup {
+ destroy .tv
+} -result {60 50 60 50 60 50 1}
+
tcltest::cleanupTests