diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2019-05-16 22:22:14 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2019-05-16 22:22:14 (GMT) |
commit | 645101e0fcf0cf36ae5276df0c82d29e6b775a19 (patch) | |
tree | 7de976e2f0a01ed077b4cb9691c49cbb5e4129f5 /tests/frame.test | |
parent | dcfcc6e1dbf1f90747815817b6a6260155006348 (diff) | |
download | tk-645101e0fcf0cf36ae5276df0c82d29e6b775a19.zip tk-645101e0fcf0cf36ae5276df0c82d29e6b775a19.tar.gz tk-645101e0fcf0cf36ae5276df0c82d29e6b775a19.tar.bz2 |
Fix some tests. Add some test cases.
Diffstat (limited to 'tests/frame.test')
-rw-r--r-- | tests/frame.test | 145 |
1 files changed, 118 insertions, 27 deletions
diff --git a/tests/frame.test b/tests/frame.test index 5b8f1bb..b2884f9 100644 --- a/tests/frame.test +++ b/tests/frame.test @@ -12,6 +12,8 @@ namespace import ::tcltest::* eval tcltest::configure $argv tcltest::loadTestedCommands +testConstraint x11 [expr {[tk windowingsystem] eq "x11"}] + # eatColors -- # Creates a toplevel window and allocates enough colors in it to # use up all the slots in the colormap. @@ -51,6 +53,20 @@ proc colorsFree {w {red 31} {green 245} {blue 192}} { expr {([lindex $vals 0]/256 == $red) && ([lindex $vals 1]/256 == $green) && ([lindex $vals 2]/256 == $blue)} } + +# uniq -- +# +# Returns the unique items of a list in the order they first appear. +# +# Arguments: +# list - The list to uniq-ify. +proc uniq {list} { + set d {} + foreach item $list { + dict set d $item {} + } + return [dict keys $d] +} test frame-1.1 {frame configuration options} -setup { deleteWindows @@ -424,7 +440,7 @@ test frame-2.14 {toplevel configuration options} -setup { } -cleanup { deleteWindows } -returnCodes error -result {unknown or ambiguous visual name "who_knows?": class must be best, directcolor, grayscale, greyscale, pseudocolor, staticcolor, staticgray, staticgrey, truecolor, or default} -test frame-2.15 {toplevel configuration options} -constraints haveDISPLAY -setup { +test frame-2.15 {toplevel configuration options} -constraints {x11 haveDISPLAY} -setup { deleteWindows } -body { toplevel .t -width 200 -height 100 -screen $env(DISPLAY) @@ -433,7 +449,7 @@ test frame-2.15 {toplevel configuration options} -constraints haveDISPLAY -setup } -cleanup { deleteWindows } -result {0} -test frame-2.16 {toplevel configuration options} -constraints haveDISPLAY -setup { +test frame-2.16 {toplevel configuration options} -constraints {x11 haveDISPLAY} -setup { deleteWindows } -body { toplevel .t -width 200 -height 100 -screen $env(DISPLAY) @@ -1585,46 +1601,117 @@ test frame-15.5 {TIP 262: frame background images} -setup { test frame-15.6 {TIP 262: frame background images} -setup { deleteWindows set result {} + . configure -width 200 -height 200 } -constraints testImageType -body { image create test gorp -variable result pack [frame .f -width 100 -height 100 -bgimg gorp] - update idletasks; update; update idletasks; update - return $result + update idletasks; update + raise [winfo parent .f]; # Try to make sure the frame fully repaints + update idletasks; update + return [uniq $result] } -cleanup { deleteWindows catch {image delete gorp} } -result {{gorp get} {gorp display 0 0 30 15}} +test frame-15.6a {TIP 262: frame background images (offsets)} -setup { + deleteWindows + set result {} + . configure -width 200 -height 200 +} -constraints testImageType -body { + image create test gorp -variable result + pack [frame .f -width 10 -height 10 -bgimg gorp] + update idletasks; update + raise [winfo parent .f]; # Try to make sure the frame fully repaints + update idletasks; update + return [uniq $result] +} -cleanup { + deleteWindows + catch {image delete gorp} +} -result {{gorp get} {gorp display 10 2 10 10}} test frame-15.7 {TIP 262: frame background images} -setup { deleteWindows set result {} + . configure -width 200 -height 200 } -constraints testImageType -body { image create test gorp -variable result pack [frame .f -width 50 -height 25 -bgimg gorp -tile 1] - update idletasks; update; update idletasks; update - return $result + update idletasks; update + raise [winfo parent .f]; # Try to make sure the frame fully repaints + update idletasks; update + return [uniq $result] } -cleanup { deleteWindows catch {image delete gorp} } -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 10} {gorp display 0 0 20 15} {gorp display 0 0 20 10}} +test frame-15.7a {TIP 262: frame background images (offsets)} -setup { + deleteWindows + set result {} + . configure -width 200 -height 200 +} -constraints testImageType -body { + image create test gorp -variable result + pack [frame .f -width 50 -height 25 -bgimg gorp -tile 1 -highlightthick 1] + update idletasks; update + raise [winfo parent .f]; # Try to make sure the frame fully repaints + update idletasks; update + return [uniq $result] +} -cleanup { + deleteWindows + catch {image delete gorp} +} -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 8} {gorp display 0 0 18 15} {gorp display 0 0 18 8}} +test frame-15.7b {TIP 262: frame background images (offsets)} -setup { + deleteWindows + set result {} + . configure -width 200 -height 200 +} -constraints testImageType -body { + image create test gorp -variable result + pack [frame .f -width 50 -height 25 -bgimg gorp -tile 1 -bd 2] + update idletasks; update + raise [winfo parent .f]; # Try to make sure the frame fully repaints + update idletasks; update + return [uniq $result] +} -cleanup { + deleteWindows + catch {image delete gorp} +} -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 6} {gorp display 0 0 16 15} {gorp display 0 0 16 6}} +test frame-15.7c {TIP 262: frame background images (offsets)} -setup { + deleteWindows + set result {} + . configure -width 200 -height 200 +} -constraints testImageType -body { + image create test gorp -variable result + pack [frame .f -width 50 -height 25 -bgimg gorp -tile 1 -bd 2 -highlightthick 1] + update idletasks; update + raise [winfo parent .f]; # Try to make sure the frame fully repaints + update idletasks; update + return [uniq $result] +} -cleanup { + deleteWindows + catch {image delete gorp} +} -result {{gorp get} {gorp display 0 0 30 15} {gorp display 0 0 30 4} {gorp display 0 0 14 15} {gorp display 0 0 14 4}} test frame-15.8 {TIP 262: toplevel background images} -setup { deleteWindows image create photo gorp -width 10 -height 10 gorp put black -to 2 2 7 7 } -body { - toplevel .f -width 100 -height 100 - list [image inuse gorp] [.f configure -backgroundimage gorp;update] \ - [image inuse gorp] [winfo width .f] [winfo height .f] + toplevel .t -width 100 -height 100 + update + # Used to verify that setting a background image doesn't change the widget size + set w [winfo width .t] + set h [winfo height .t] + list [image inuse gorp] [.t configure -backgroundimage gorp;update] \ + [image inuse gorp] \ + [expr {$w-[winfo width .t]}] [expr {$h-[winfo height .t]}] } -cleanup { image delete gorp deleteWindows -} -result {0 {} 1 100 100} +} -result {0 {} 1 0 0} test frame-15.9 {TIP 262: toplevel background images} -setup { deleteWindows catch {rename gorp ""} } -body { - toplevel .f -width 100 -height 100 + toplevel .t -width 100 -height 100 update - .f configure -backgroundimage gorp + .t configure -backgroundimage gorp } -returnCodes error -cleanup { deleteWindows } -result {image "gorp" doesn't exist} @@ -1633,9 +1720,9 @@ test frame-15.10 {TIP 262: toplevel background images} -setup { image create photo gorp -width 10 -height 10 gorp put black -to 2 2 7 7 } -body { - toplevel .f -width 100 -height 100 -backgroundimage gorp -tile yes + toplevel .t -width 100 -height 100 -backgroundimage gorp -tile yes update - list [.f cget -bgimg] [.f cget -tile] + list [.t cget -bgimg] [.t cget -tile] } -cleanup { image delete gorp deleteWindows @@ -1645,11 +1732,11 @@ test frame-15.11 {TIP 262: toplevel background images} -setup { image create photo gorp -width 10 -height 10 gorp put black -to 2 2 7 7 } -body { - toplevel .f -width 100 -height 100 -backgroundimage gorp -tile yes + toplevel .t -width 100 -height 100 -backgroundimage gorp -tile yes update gorp put red -to 15 15 20 20 update - list [.f cget -bgimg] [.f cget -tile] + list [.t cget -bgimg] [.t cget -tile] } -cleanup { image delete gorp deleteWindows @@ -1660,14 +1747,14 @@ test frame-15.12 {TIP 262: toplevel background images} -setup { gorp put black -to 2 2 7 7 set result {} } -body { - toplevel .f -width 100 -height 100 -backgroundimage gorp -tile yes + toplevel .t -width 100 -height 100 -backgroundimage gorp -tile yes update image delete gorp update - set result [list [.f cget -bgimg] [.f cget -tile]] + set result [list [.t cget -bgimg] [.t cget -tile]] image create photo gorp -width 250 -height 250 update - lappend result [.f cget -backgroundimage] + lappend result [.t cget -backgroundimage] } -cleanup { catch {image delete gorp} deleteWindows @@ -1677,10 +1764,12 @@ test frame-15.13 {TIP 262: toplevel background images} -setup { set result {} } -constraints testImageType -body { image create test gorp -variable result - toplevel .f -width 100 -height 100 -bgimg gorp - wm overrideredirect .f 1; # Reduce trouble from window managers - update idletasks; update; update idletasks; update - return $result + toplevel .t -width 100 -height 100 -bgimg gorp + wm overrideredirect .t 1; # Reduce trouble from window managers + update idletasks; update + raise .t; # Try to make sure the toplevel fully repaints + update idletasks; update + return [uniq $result] } -cleanup { deleteWindows catch {image delete gorp} @@ -1690,10 +1779,12 @@ test frame-15.14 {TIP 262: toplevel background images} -setup { set result {} } -constraints testImageType -body { image create test gorp -variable result - toplevel .f -width 50 -height 25 -bgimg gorp -tile 1 - wm overrideredirect .f 1; # Reduce trouble from window managers - update idletasks; update; update idletasks; update - return $result + toplevel .t -width 50 -height 25 -bgimg gorp -tile 1 + wm overrideredirect .t 1; # Reduce trouble from window managers + update idletasks; update + raise .t; # Try to make sure the toplevel fully repaints + update idletasks; update + return [uniq $result] } -cleanup { deleteWindows catch {image delete gorp} |