summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2018-10-18 20:16:30 (GMT)
committerfvogel <fvogelnew1@free.fr>2018-10-18 20:16:30 (GMT)
commitdd711f199cb486be0e91ea582d3b9645c90bb3b5 (patch)
treec6fccccc1661b517f6d3f338a983b2054d94d13b /tests
parent862b1ce457db872564c56b295c9487f3fe529253 (diff)
downloadtk-dd711f199cb486be0e91ea582d3b9645c90bb3b5.zip
tk-dd711f199cb486be0e91ea582d3b9645c90bb3b5.tar.gz
tk-dd711f199cb486be0e91ea582d3b9645c90bb3b5.tar.bz2
Fix scrollbar.test: all tests that run on macOS now pass (and that's true for each platform BTW: Windows, Linux and macOS).
Diffstat (limited to 'tests')
-rw-r--r--tests/scrollbar.test106
1 files changed, 81 insertions, 25 deletions
diff --git a/tests/scrollbar.test b/tests/scrollbar.test
index dcfc711..d740f7c 100644
--- a/tests/scrollbar.test
+++ b/tests/scrollbar.test
@@ -18,24 +18,38 @@ proc scroll args {
proc getTroughSize {w} {
if {[testConstraint testmetrics]} {
+ # Only Windows has [testmetrics]
if [string match v* [$w cget -orient]] {
return [expr [winfo height $w] - 2*[testmetrics cyvscroll $w]]
} else {
return [expr [winfo width $w] - 2*[testmetrics cxhscroll $w]]
}
} else {
- # Calculations here assume that the arrow area is a square.
- if [string match v* [$w cget -orient]] {
- return [expr [winfo height $w] \
- - ([winfo width $w] \
- - [$w cget -highlightthickness] \
- - [$w cget -bd] + 1)*2]
- } else {
- return [expr [winfo width $w] \
- - ([winfo height $w] \
- - [$w cget -highlightthickness] \
- - [$w cget -bd] + 1)*2]
- }
+ if {[tk windowingsystem] eq "x11"} {
+ # Calculations here assume that the arrow area is a square.
+ if [string match v* [$w cget -orient]] {
+ return [expr [winfo height $w] \
+ - ([winfo width $w] \
+ - [$w cget -highlightthickness] \
+ - [$w cget -bd] + 1)*2]
+ } else {
+ return [expr [winfo width $w] \
+ - ([winfo height $w] \
+ - [$w cget -highlightthickness] \
+ - [$w cget -bd] + 1)*2]
+ }
+ } else {
+ # macOS aqua
+ if [string match v* [$w cget -orient]] {
+ return [expr [winfo height $w] \
+ - ([$w cget -highlightthickness] \
+ +[$w cget -bd])*2]
+ } else {
+ return [expr [winfo width $w] \
+ - ([$w cget -highlightthickness] \
+ +[$w cget -bd])*2]
+ }
+ }
}
}
@@ -256,13 +270,13 @@ test scrollbar-3.35 {ScrollbarWidgetCmd procedure, "fraction" option} {
format {%.6g} [.s fraction 4 21]
} [format %.6g [expr (21.0 - ([winfo height .s] - [getTroughSize .s])/2.0) \
/([getTroughSize .s] - 1)]]
-test scrollbar-3.36 {ScrollbarWidgetCmd procedure, "fraction" option} unix {
+test scrollbar-3.36 {ScrollbarWidgetCmd procedure, "fraction" option} x11 {
format {%.6g} [.s fraction 4 179]
} {1}
test scrollbar-3.37 {ScrollbarWidgetCmd procedure, "fraction" option} {testmetrics} {
format {%.6g} [.s fraction 4 [expr 200 - [testmetrics cyvscroll .s]]]
} {1}
-test scrollbar-3.38 {ScrollbarWidgetCmd procedure, "fraction" option} unix {
+test scrollbar-3.38 {ScrollbarWidgetCmd procedure, "fraction" option} x11 {
format {%.6g} [.s fraction 4 178]
} {0.993711}
test scrollbar-3.39 {ScrollbarWidgetCmd procedure, "fraction" option} {testmetrics win} {
@@ -282,9 +296,15 @@ test scrollbar-3.41 {ScrollbarWidgetCmd procedure, "fraction" option} {
format {%.6g} [.t.s fraction 100 0]
} {0.5}
if {[testConstraint testmetrics]} {
+ # Only Windows has [testmetrics]
place configure .t.s -width [expr 2*[testmetrics cxhscroll .t.s]+1]
} else {
- place configure .t.s -width [expr [winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)]
+ if {[tk windowingsystem] eq "x11"} {
+ place configure .t.s -width [expr [winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)]
+ } else {
+ # macOS aqua
+ place configure .t.s -width [expr 2*([.t.s cget -highlightthickness] + [.t.s cget -bd])]
+ }
}
update
test scrollbar-3.42 {ScrollbarWidgetCmd procedure, "fraction" option} {
@@ -318,9 +338,13 @@ test scrollbar-3.48 {ScrollbarWidgetCmd procedure, "identify" option} {
test scrollbar-3.49 {ScrollbarWidgetCmd procedure, "identify" option} {
list [catch {.s identify -1 bogus} msg] $msg
} {1 {expected integer but got "bogus"}}
-test scrollbar-3.50 {ScrollbarWidgetCmd procedure, "identify" option} {
+test scrollbar-3.50.1 {ScrollbarWidgetCmd procedure, "identify" option} notAqua {
.s identify 5 5
} {arrow1}
+test scrollbar-3.50.1 {ScrollbarWidgetCmd procedure, "identify" option} aqua {
+ # macOS scrollbars have no arrows nowadays
+ .s identify 5 5
+} {trough1}
test scrollbar-3.51 {ScrollbarWidgetCmd procedure, "identify" option} {
.s identify 5 35
} {trough1}
@@ -331,9 +355,13 @@ test scrollbar-3.52 {ScrollbarWidgetCmd procedure, "identify" option} {
test scrollbar-3.53 {ScrollbarWidgetCmd procedure, "identify" option} {
.s identify 5 145
} {trough2}
-test scrollbar-3.54 {ScrollbarWidgetCmd procedure, "identify" option} {unixOrPc} {
+test scrollbar-3.54.1 {ScrollbarWidgetCmd procedure, "identify" option} notAqua {
.s identify 5 195
} {arrow2}
+test scrollbar-3.54.2 {ScrollbarWidgetCmd procedure, "identify" option} aqua {
+ # macOS scrollbars have no arrows nowadays
+ .s identify 5 195
+} {trough2}
test scrollbar-3.56 {ScrollbarWidgetCmd procedure, "identify" option} unix {
.s identify 0 0
} {}
@@ -456,12 +484,20 @@ test scrollbar-6.9 {ScrollbarPosition procedure} {
test scrollbar-6.10 {ScrollbarPosition procedure} {
.s identify [winfo width .s] [expr [winfo height .s] / 2]
} {}
-test scrollbar-6.11 {ScrollbarPosition procedure} unix {
+test scrollbar-6.11.1 {ScrollbarPosition procedure} x11 {
.s identify 8 4
} {arrow1}
-test scrollbar-6.12 {ScrollbarPosition procedure} unix {
+test scrollbar-6.11.2 {ScrollbarPosition procedure} aqua {
+ # macOS scrollbars have no arrows nowadays
+ .s identify 8 4
+} {trough1}
+test scrollbar-6.12.1 {ScrollbarPosition procedure} x11 {
.s identify 8 19
} {arrow1}
+test scrollbar-6.12.2 {ScrollbarPosition procedure} aqua {
+ # macOS scrollbars have no arrows nowadays
+ .s identify 8 19
+} {trough1}
test scrollbar-6.14 {ScrollbarPosition procedure} win {
.s identify [expr [winfo width .s] / 2] 0
} {arrow1}
@@ -517,12 +553,20 @@ test scrollbar-6.28 {ScrollbarPosition procedure} {testmetrics win} {
.s identify [expr [winfo width .s] / 2] [expr [winfo height .s] \
- [testmetrics cyvscroll .s] - 1]
} {trough2}
-test scrollbar-6.29 {ScrollbarPosition procedure} unix {
+test scrollbar-6.29.1 {ScrollbarPosition procedure} x11 {
.s identify 8 180
} {arrow2}
-test scrollbar-6.30 {ScrollbarPosition procedure} unix {
+test scrollbar-6.29.2 {ScrollbarPosition procedure} aqua {
+ # macOS scrollbars have no arrows nowadays
+ .s identify 8 180
+} {trough2}
+test scrollbar-6.30.1 {ScrollbarPosition procedure} x11 {
.s identify 8 195
} {arrow2}
+test scrollbar-6.30.2 {ScrollbarPosition procedure} aqua {
+ # macOS scrollbars have no arrows nowadays
+ .s identify 8 195
+} {trough2}
test scrollbar-6.32 {ScrollbarPosition procedure} {testmetrics win} {
.s identify [expr [winfo width .s] / 2] [expr [winfo height .s] \
- [testmetrics cyvscroll .s]]
@@ -551,15 +595,23 @@ place .t.s -width 200
.t.s set .2 .4
update
-test scrollbar-6.39 {ScrollbarPosition procedure} unix {
+test scrollbar-6.39.1 {ScrollbarPosition procedure} x11 {
.t.s identify 4 8
} {arrow1}
+test scrollbar-6.39.2 {ScrollbarPosition procedure} aqua {
+ # macOS scrollbars have no arrows nowadays
+ .t.s identify 4 8
+} {trough1}
test scrollbar-6.40 {ScrollbarPosition procedure} win {
.t.s identify 0 [expr [winfo height .t.s] / 2]
} {arrow1}
-test scrollbar-6.41 {ScrollbarPosition procedure} unix {
+test scrollbar-6.41.1 {ScrollbarPosition procedure} x11 {
.t.s identify 82 8
} {slider}
+test scrollbar-6.41.2 {ScrollbarPosition procedure} aqua {
+ # macOS scrollbars have no arrows nowadays
+ .t.s identify 82 8
+} {trough2}
test scrollbar-6.43 {ScrollbarPosition procedure} {testmetrics win} {
.t.s identify [expr int(.4 / [.t.s delta 1 0]) + [testmetrics cxhscroll .t.s] \
- 1] [expr [winfo height .t.s] / 2]
@@ -583,7 +635,9 @@ test scrollbar-7.1 {EventuallyRedraw} {
catch {destroy .t}
toplevel .t
wm geometry .t +0+0
-test scrollbar-8.1 {TkScrollbarEventProc: recursive deletion} {
+test scrollbar-8.1 {TkScrollbarEventProc: recursive deletion} notAqua {
+ # constrained by notAqua because this test clicks on an arrow of the
+ # scrollbar - but macOS has no such arrows in modern scrollbars
proc doit {args} { destroy .t.f }
proc bgerror {args} {}
destroy .t.f
@@ -602,7 +656,9 @@ test scrollbar-8.1 {TkScrollbarEventProc: recursive deletion} {
rename bgerror {}
set result
} {1 0 0}
-test scrollbar-8.2 {TkScrollbarEventProc: recursive deletion} {
+test scrollbar-8.2 {TkScrollbarEventProc: recursive deletion} notAqua {
+ # constrained by notAqua because this test clicks on an arrow of the
+ # scrollbar - but macOS has no such arrows in modern scrollbars
proc doit {args} { destroy .t.f.s }
proc bgerror {args} {}
destroy .t.f