Index: tests/scrollbar.test ================================================================== --- tests/scrollbar.test +++ tests/scrollbar.test @@ -16,28 +16,42 @@ set scrollInfo $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] + } + } } } # XXX Note: this test file is woefully incomplete. Right now there are # only bits and pieces of tests. Please make this file more complete @@ -254,17 +268,17 @@ } {1} 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} { expr \ [format {%.6g} [.s fraction 4 [expr 200 - [testmetrics cyvscroll .s] - 2]]] \ @@ -280,13 +294,19 @@ 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} { format {%.6g} [.t.s fraction 100 0] } {0} @@ -316,13 +336,17 @@ list [catch {.s identify bogus 2} msg] $msg } {1 {expected integer but got "bogus"}} 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.2 {ScrollbarWidgetCmd procedure, "identify" option} aqua { + # macOS scrollbars have no arrows nowadays .s identify 5 5 -} {arrow1} +} {trough1} test scrollbar-3.51 {ScrollbarWidgetCmd procedure, "identify" option} { .s identify 5 35 } {trough1} test scrollbar-3.52 {ScrollbarWidgetCmd procedure, "identify" option} { .s set .3 .6 @@ -329,13 +353,17 @@ .s identify 5 80 } {slider} 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 } {} test scrollbar-3.57 {ScrollbarWidgetCmd procedure, "set" option} { list [catch {.s set abc def} msg] $msg @@ -454,16 +482,24 @@ .s identify -1 [expr [winfo height .s] / 2] } {} 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.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 {ScrollbarPosition procedure} unix { +test scrollbar-6.12.2 {ScrollbarPosition procedure} aqua { + # macOS scrollbars have no arrows nowadays .s identify 8 19 -} {arrow1} +} {trough1} test scrollbar-6.14 {ScrollbarPosition procedure} win { .s identify [expr [winfo width .s] / 2] 0 } {arrow1} test scrollbar-6.15 {ScrollbarPosition procedure} {testmetrics win} { .s identify [expr [winfo width .s] / 2] [expr [testmetrics cyvscroll .s] - 1] @@ -515,16 +551,24 @@ } {trough2} 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]] } {arrow2} test scrollbar-6.33 {ScrollbarPosition procedure} win { @@ -549,19 +593,27 @@ scrollbar .t.s -orient horizontal -relief sunken -bd 2 -highlightthickness 2 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] } {slider} test scrollbar-6.44 {ScrollbarPosition procedure} unix { @@ -581,11 +633,13 @@ } {horizontal vertical} 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 frame .t.f scrollbar .t.f.s -command doit @@ -600,11 +654,13 @@ update lappend result [winfo exists .t.f.s] [winfo exists .t.f] 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 frame .t.f scrollbar .t.f.s -command doit