diff options
author | fvogel <fvogelnew1@free.fr> | 2024-05-05 21:35:03 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2024-05-05 21:35:03 (GMT) |
commit | 4a1ea025842883245014d58ce4786564089dce3b (patch) | |
tree | 50c8e26b9c813f6f8818e017fcd44b1b5fbbec11 /tests | |
parent | 74b174eed61acafb5e8bc26bfe8d8d33fcadd7aa (diff) | |
download | tk-4a1ea025842883245014d58ce4786564089dce3b.zip tk-4a1ea025842883245014d58ce4786564089dce3b.tar.gz tk-4a1ea025842883245014d58ce4786564089dce3b.tar.bz2 |
Fix [bb52855781]: ttk treeview tests not robust against display scaling.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ttk/treeview.test | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test index b424dfb..2327b99 100644 --- a/tests/ttk/treeview.test +++ b/tests/ttk/treeview.test @@ -929,7 +929,8 @@ proc columnids {tv dcols} { test treeview-identify-setup "identify series - setup" -body { destroy .tv ttk::setTheme default - ttk::style configure Treeview -rowheight 20 + ttk::style configure Treeview -rowheight 10m + ttk::style configure Treeview.Heading -font {Arial 10} ttk::treeview .tv -columns [list A B C] .tv insert {} end -id branch -text branch -open true .tv insert branch end -id item1 -text item1 -height 2 @@ -937,58 +938,62 @@ test treeview-identify-setup "identify series - setup" -body { .tv insert branch end -id item3 -text item3 .tv insert {} end -id item4 -text item4 - .tv column #0 -width 50 ;# 0-50 - .tv column A -width 50 ;# 50-100 - .tv column B -width 50 ;# 100-150 - .tv column C -width 50 ;# 150-200 (plus slop for margins) + .tv column #0 -width 200 ;# 0-200 + .tv column A -width 200 ;# 200-400 + .tv column B -width 200 ;# 400-600 + .tv column C -width 200 ;# 600-800 (plus slop for margins) wm geometry . {} ; pack .tv ; update } +# treeview-identify-setup sets heading row font to Arial with size 10 points, +# so the heading line center y-coordinate is (in pixels): +set yHLC [expr {([font metrics {Arial 10} -linespace] + 2) / 2.0}] +# which makes the following in millimeters: +set yHLC [expr {$yHLC / [winfo screenwidth .] * [winfo screenmmwidth .]}] test treeview-identify-1 "identify heading" -body { .tv configure -show {headings tree} update idletasks - identify* .tv {region column} 10 10 + identify* .tv {region column} 10 ${yHLC}m } -result [list heading #0] test treeview-identify-2 "identify columns" -body { .tv configure -displaycolumns #all update idletasks - columnids .tv [identify* .tv column 25 10 75 10 125 10 175 10] + columnids .tv [identify* .tv column 100 ${yHLC}m 300 ${yHLC}m 500 ${yHLC}m 700 ${yHLC}m] } -result [list \#0 A B C] test treeview-identify-3 "reordered columns" -body { .tv configure -displaycolumns {B A C} update idletasks - columnids .tv [identify* .tv column 25 10 75 10 125 10 175 10] + columnids .tv [identify* .tv column 100 ${yHLC}m 300 ${yHLC}m 500 ${yHLC}m 700 ${yHLC}m] } -result [list \#0 B A C] test treeview-identify-4 "no tree column" -body { .tv configure -displaycolumns #all -show {headings} update idletasks - identify* .tv {region column} 25 10 75 10 125 10 175 10 + identify* .tv {region column} 100 ${yHLC}m 300 ${yHLC}m 500 ${yHLC}m 700 ${yHLC}m } -result [list heading #1 heading #2 heading #3 nothing {}] -# Item height in default theme is 20px +# Item height (-rowheight) is 10 millimeters (set in treeview-identify-setup) test treeview-identify-5 "vertical scan - no headings" -body { .tv configure -displaycolumns #all -show {tree} update idletasks - identify* .tv {region item} 25 10 25 30 25 70 25 90 25 110 25 130 + identify* .tv {region item} 100 5m 100 15m 100 35m 100 45m 100 55m 100 65m } -result [list tree branch tree item1 tree item2 tree item3 tree item4 nothing {}] test treeview-identify-6 "vertical scan - with headings" -body { .tv configure -displaycolumns #all -show {tree headings} update idletasks - identify* .tv {region item} 25 10 25 30 25 50 25 90 25 110 + identify* .tv {region item} 100 ${yHLC}m 100 [expr {$yHLC+5}]m 100 [expr {$yHLC+15}]m 100 [expr {$yHLC+35}]m 100 [expr {$yHLC+45}]m } -result [list heading {} tree branch tree item1 tree item2 tree item3] test treeview-identify-7 "vertical scan - headings, no tree" -body { .tv configure -displaycolumns #all -show {headings} update idletasks - identify* .tv {region item cell} 25 10 25 30 25 50 75 90 25 110 + identify* .tv {region item cell} 100 ${yHLC}m 100 [expr {$yHLC+5}]m 100 [expr {$yHLC+15}]m 300 [expr {$yHLC+35}]m 100 [expr {$yHLC+45}]m } -result [list heading {} {} cell branch {branch #1} cell item1 {item1 #1} cell item2 {item2 #2} cell item3 {item3 #1}] -# In default theme, -indent and -itemheight both 20px # Disclosure element name is "Treeitem.indicator" set disclosure "*.indicator" test treeview-identify-8 "identify element" -body { @@ -996,18 +1001,21 @@ test treeview-identify-8 "identify element" -body { .tv insert branch 0 -id branch2 -open true .tv insert branch2 0 -id branch3 -open true .tv insert branch3 0 -id leaf3 - update idletasks; - identify* .tv {item element} 10 10 30 30 50 50 + ttk::style configure Treeview -indent 8m + update idletasks + identify* .tv {item element} 4m 5m 12m 15m 20m 25m } -match glob -result [list \ branch $disclosure branch2 $disclosure branch3 $disclosure] test treeview-identify-8.1 "identify element" -body { .tv configure -show {tree headings} update - identify* .tv element 1 1 10 10 25 25 + identify* .tv element 1 1 40 ${yHLC}m 10m [expr {$yHLC+6}]m # Heading elements are currently not reported } -result [list {} {} text] +ttk::style configure Treeview -rowheight 20 + # See #2381555 test treeview-identify-9 "identify works when horizontally scrolled" -setup { .tv configure -show {tree headings} |