summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authormdejong <mdejong>2003-03-12 00:25:40 (GMT)
committermdejong <mdejong>2003-03-12 00:25:40 (GMT)
commit5fa0b916e1a1c47c2251286bd3aad486bb08238b (patch)
tree1c5f6fc421347a2e042b8056bdecab04a447614a /tests
parent6be1cd95fff709a3869038db3e989865154259fb (diff)
downloadtk-5fa0b916e1a1c47c2251286bd3aad486bb08238b.zip
tk-5fa0b916e1a1c47c2251286bd3aad486bb08238b.tar.gz
tk-5fa0b916e1a1c47c2251286bd3aad486bb08238b.tar.bz2
* doc/wm.n (minimize, maximize): Remove claim
that the resizable command keeps scripts from changing the size of windows since it is not true. The resizable command only applies to user sizing via user interaction. * tests/unixWm.test: Replace broken tests with the nonPortable constraint with new tests for maxsize and minsize options. These tests verify that setting the minsize and maxsize will resize the window if needed, and that the wm hints will be updated with the new sizes. * tests/wm.test: Add an exhaustive set of tests for the wm maxsize and wm minsize commands. These tests verify that setting the minsize and maxsize will resize the window if needed. These tests have only been run under Win98 and Window Maker under Linux, so further tweaking may be needed for other systems. * unix/tkUnixWm.c (UpdateGeometryInfo, UpdateSizeHints): Fixup comments and initialization for the minWidth, minHeight, maxWidth, maxHeight, width, and height members of the WmInfo struct. Check to ensure that a new toplevel window size is not larger than the maxsize or smaller than the minsize when updating the geometry at idle time. Pass new width and height values to the UpdateSizeHints method so that it can properly set the window min and max sizes for a window that cannot be resized by the user. This fixes a bug where the window resizes back to the original size when the user clicks on the window border. * win/tkWinWm.c (UpdateGeometryInfo): Fixup comments and initialization for the minWidth, minHeight, maxWidth, maxHeight, width, and height members of the WmInfo struct. Check to ensure that a new toplevel window size is not larger than the maxsize or smaller than the minsize when updating the geometry at idle time. [Patch 568861]
Diffstat (limited to 'tests')
-rw-r--r--tests/unixWm.test92
-rw-r--r--tests/wm.test143
2 files changed, 209 insertions, 26 deletions
diff --git a/tests/unixWm.test b/tests/unixWm.test
index 4bb5379..9c77197 100644
--- a/tests/unixWm.test
+++ b/tests/unixWm.test
@@ -7,7 +7,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: unixWm.test,v 1.29 2002/11/07 22:27:04 mdejong Exp $
+# RCS: @(#) $Id: unixWm.test,v 1.30 2003/03/12 00:25:41 mdejong Exp $
package require tcltest 2.2
namespace import -force tcltest::configure
@@ -988,35 +988,83 @@ test unixWm-27.7 {Tk_WmCmd procedure, "iconwindow" option, withdrawing icon} {
set result
} {normal 1 icon 0}
-test unixWm-28.1 {Tk_WmCmd procedure, "maxsize" option} {nonPortable} {
- wm maxsize .t
-} {1137 870}
-
-test unixWm-28.2 {Tk_WmCmd procedure, "maxsize" option} {nonPortable} {
- # Not portable, because some window managers let applications override
- # minsize and maxsize.
-
- wm maxsize .t 200 150
- wm geom .t 300x200
- update
- list [winfo width .t] [winfo height .t]
-} {200 150}
-
catch {destroy .t}
catch {destroy .icon}
toplevel .t -width 100 -height 50
wm geom .t +0+0
update
-test unixWm-29.1 {Tk_WmCmd procedure, "minsize" option} {nonPortable} {
- # Not portable, because some window managers let applications override
- # minsize and maxsize.
+test unixWm-28.1 {Tk_WmCmd procedure, "maxsize" option, setting the
+ maxsize should update WM_NORMAL_HINTS} {
+ destroy .t
+ toplevel .t
+ wm maxsize .t 300 300
+ update
+ set hints [testprop [testwrapper .t] WM_NORMAL_HINTS]
+ format {%d %d} [lindex $hints 7] [lindex $hints 8]
+} {300 300}
- wm minsize .t 150 100
- wm geom .t 50x50
+test unixWm-28.2 {Tk_WmCmd procedure, "maxsize" option, setting the
+ maxsize to a value smaller than the current size should
+ set the maxsize in WM_NORMAL_HINTS} {
+ destroy .t
+ toplevel .t
+ wm geom .t 400x400
+ wm maxsize .t 300 300
update
- list [winfo width .t] [winfo height .t]
-} {150 100}
+ set hints [testprop [testwrapper .t] WM_NORMAL_HINTS]
+ format {%d %d} [lindex $hints 7] [lindex $hints 8]
+} {300 300}
+
+test unixWm-28.3 {Tk_WmCmd procedure, "maxsize" option, setting the
+ maxsize to a value smaller than the current size should
+ set the maxsize in WM_NORMAL_HINTS even if the
+ interactive resizable flag is set to 0} {
+ destroy .t
+ toplevel .t
+ wm geom .t 400x400
+ wm resizable .t 0 0
+ wm maxsize .t 300 300
+ update
+ set hints [testprop [testwrapper .t] WM_NORMAL_HINTS]
+ format {%d %d} [lindex $hints 7] [lindex $hints 8]
+} {300 300}
+
+test unixWm-29.1 {Tk_WmCmd procedure, "minsize" option, setting the
+ minsize should update WM_NORMAL_HINTS} {
+ destroy .t
+ toplevel .t
+ wm minsize .t 300 300
+ update
+ set hints [testprop [testwrapper .t] WM_NORMAL_HINTS]
+ format {%d %d} [lindex $hints 5] [lindex $hints 6]
+} {300 300}
+
+test unixWm-29.2 {Tk_WmCmd procedure, "minsize" option, setting the
+ minsize to a value larger than the current size should
+ set the maxsize in WM_NORMAL_HINTS} {
+ destroy .t
+ toplevel .t
+ wm geom .t 200x200
+ wm minsize .t 300 300
+ update
+ set hints [testprop [testwrapper .t] WM_NORMAL_HINTS]
+ format {%d %d} [lindex $hints 5] [lindex $hints 6]
+} {300 300}
+
+test unixWm-29.3 {Tk_WmCmd procedure, "minsize" option, setting the
+ minsize to a value larger than the current size should
+ set the minsize in WM_NORMAL_HINTS even if the
+ interactive resizable flag is set to 0} {
+ destroy .t
+ toplevel .t
+ wm geom .t 200x200
+ wm resizable .t 0 0
+ wm minsize .t 300 300
+ update
+ set hints [testprop [testwrapper .t] WM_NORMAL_HINTS]
+ format {%d %d} [lindex $hints 5] [lindex $hints 6]
+} {300 300}
catch {destroy .t}
catch {destroy .icon}
diff --git a/tests/wm.test b/tests/wm.test
index e9d2de5..3cffdb2 100644
--- a/tests/wm.test
+++ b/tests/wm.test
@@ -7,7 +7,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: wm.test,v 1.21 2003/01/28 20:39:19 jenglish Exp $
+# RCS: @(#) $Id: wm.test,v 1.22 2003/03/12 00:25:41 mdejong Exp $
# This file tests window manager interactions that work across
# platforms. Window manager tests that only work on a specific
@@ -663,12 +663,84 @@ test wm-maxsize-1.5 {usage} {
test wm-maxsize-1.6 {usage} {
catch {destroy .t2}
toplevel .t2
- wm maxsize .t2 200 150
+ wm maxsize .t2 300 200
set result [wm maxsize .t2]
destroy .t2
set result
+} {300 200}
+
+test wm-maxsize-1.7 {maxsize must be <= screen size} {
+ destroy .t
+ toplevel .t
+ foreach {t_width t_height} [wm maxsize .t] break
+ set s_width [winfo screenwidth .t]
+ set s_height [winfo screenheight .t]
+ expr {($t_width <= $s_width) && ($t_height <= $s_height)}
+} 1
+
+test wm-maxsize-2.1 {setting the maxsize to a value smaller
+ than the current size will resize a toplevel} {
+ destroy .t
+ toplevel .t -width 300 -height 300
+ update
+ wm maxsize .t 200 150
+ # UpdateGeometryInfo invoked at idle
+ update
+ lrange [split [wm geom .t] x+] 0 1
} {200 150}
+test wm-maxsize-2.2 {setting the maxsize to a value smaller
+ than the current size will resize a gridded toplevel} {
+ destroy .t
+ toplevel .t
+ wm grid .t 0 0 50 50
+ wm geometry .t 6x6
+ update
+ wm maxsize .t 4 3
+ # UpdateGeometryInfo invoked at idle
+ update
+ lrange [split [wm geom .t] x+] 0 1
+} {4 3}
+
+test wm-maxsize-2.3 {attempting to resize to a value
+ bigger than the current maxsize will
+ set it to the max size} {
+ destroy .t
+ toplevel .t -width 200 -height 200
+ wm maxsize .t 300 250
+ update
+ wm geom .t 400x300
+ update
+ lrange [split [wm geom .t] x+] 0 1
+} {300 250}
+
+test wm-maxsize-2.4 {attempting to resize to a value
+ bigger than the current maxsize will
+ set it to the max size when gridded} {
+ destroy .t
+ toplevel .t
+ wm grid .t 1 1 50 50
+ wm geom .t 4x4
+ wm maxsize .t 6 5
+ update
+ wm geom .t 8x6
+ update
+ lrange [split [wm geom .t] x+] 0 1
+} {6 5}
+
+test wm-maxsize-2.5 {Use max size if window size is not
+ explicitly set and the reqWidth/reqHeight are
+ bigger than the max size} {
+ destroy .t
+ toplevel .t
+ pack [frame .t.f -width 400 -height 400]
+ update idletasks
+ set req [list [winfo reqwidth .t] \
+ [winfo reqheight .t]]
+ wm maxsize .t 300 300
+ update
+ list $req [lrange [split [wm geom .t] x+] 0 1]
+} {{400 400} {300 300}}
test wm-minsize-1.1 {usage} {
list [catch {wm minsize} msg] $msg
@@ -693,12 +765,75 @@ test wm-minsize-1.5 {usage} {
test wm-minsize-1.6 {usage} {
catch {destroy .t2}
toplevel .t2
- wm minsize .t2 200 150
+ wm minsize .t2 300 200
set result [wm minsize .t2]
destroy .t2
set result
-} {200 150}
+} {300 200}
+
+test wm-minsize-2.1 {setting the minsize to a value larger
+ than the current size will resize a toplevel} {
+ destroy .t
+ toplevel .t -width 200 -height 200
+ update
+ wm minsize .t 400 300
+ # UpdateGeometryInfo invoked at idle
+ update
+ lrange [split [wm geom .t] x+] 0 1
+} {400 300}
+test wm-minsize-2.2 {setting the minsize to a value larger
+ than the current size will resize a gridded toplevel} {
+ destroy .t
+ toplevel .t
+ wm grid .t 1 1 50 50
+ wm geom .t 4x4
+ update
+ wm minsize .t 8 8
+ # UpdateGeometryInfo invoked at idle
+ update
+ lrange [split [wm geom .t] x+] 0 1
+} {8 8}
+
+test wm-minsize-2.3 {attempting to resize to a value
+ smaller than the current minsize will set
+ it to the minsize} {
+ destroy .t
+ toplevel .t -width 400 -height 400
+ wm minsize .t 300 300
+ update
+ wm geom .t 200x200
+ update
+ lrange [split [wm geom .t] x+] 0 1
+} {300 300}
+
+test wm-minsize-2.4 {attempting to resize to a value
+ smaller than the current minsize will set
+ it to the minsize when gridded} {
+ destroy .t
+ toplevel .t
+ wm grid .t 1 1 50 50
+ wm geom .t 8x8
+ wm minsize .t 6 6
+ update
+ wm geom .t 4x4
+ update
+ lrange [split [wm geom .t] x+] 0 1
+} {6 6}
+
+test wm-minsize-2.5 {Use min size if window size is not
+ explicitly set and the reqWidth/reqHeight are
+ smaller than the min size} {
+ destroy .t
+ toplevel .t
+ pack [frame .t.f -width 250 -height 250]
+ update idletasks
+ set req [list [winfo reqwidth .t] \
+ [winfo reqheight .t]]
+ wm minsize .t 300 300
+ update
+ list $req [lrange [split [wm geom .t] x+] 0 1]
+} {{250 250} {300 300}}
test wm-overrideredirect-1.1 {usage} {
list [catch {wm overrideredirect} msg] $msg