summaryrefslogtreecommitdiffstats
path: root/tests/id.test
diff options
context:
space:
mode:
authorrjohnson <rjohnson>1998-04-01 09:51:44 (GMT)
committerrjohnson <rjohnson>1998-04-01 09:51:44 (GMT)
commit066ea7fd88d49cb456f74da71dbe875e4fc0aabb (patch)
tree8fb30cb152c4dc191be47fa043d2e6f5ea38c7ba /tests/id.test
parent13242623d2ff3ea02ab6a62bfb48a7dbb5c27e22 (diff)
downloadtk-066ea7fd88d49cb456f74da71dbe875e4fc0aabb.zip
tk-066ea7fd88d49cb456f74da71dbe875e4fc0aabb.tar.gz
tk-066ea7fd88d49cb456f74da71dbe875e4fc0aabb.tar.bz2
Initial revision
Diffstat (limited to 'tests/id.test')
-rw-r--r--tests/id.test96
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/id.test b/tests/id.test
new file mode 100644
index 0000000..2589d48
--- /dev/null
+++ b/tests/id.test
@@ -0,0 +1,96 @@
+# This file is a Tcl script to test out the procedures in the file
+# tkId.c, which recycle X resource identifiers. It is organized in
+# the standard fashion for Tcl tests.
+#
+# Copyright (c) 1995 Sun Microsystems, Inc.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# SCCS: @(#) id.test 1.7 97/05/15 09:47:10
+
+if {[info procs test] != "test"} {
+ source defs
+}
+
+foreach i [winfo children .] {
+ destroy $i
+}
+wm geometry . {}
+raise .
+
+test id-1.1 {WindowIdCleanup, delaying window release} {unixOnly} {
+ bind all <Destroy> {lappend x %W}
+ catch {unset map}
+ frame .f
+ set j 0
+ foreach i {a b c d e f g h i j k l m n o p q} {
+ toplevel .f.$i -height 50 -width 100
+ wm geometry .f.$i +$j+$j
+ incr j 10
+ update
+ set map([winfo id .f.$i]) .f.$i
+ set map([testwrapper .f.$i]) wrapper.f.$i
+ }
+ set x {}
+ destroy .f
+
+ # Destroy events should have occurred for all windows.
+ set result [list [lsort $x]]
+
+ set x {}
+ update idletasks
+ set reused {}
+ foreach i {a b c d e} {
+ set w .${i}2
+ frame $w -height 20 -width 100 -bd 2 -relief raised
+ pack $w
+ if [info exists map([winfo id $w])] {
+ lappend reused $map([winfo id $w])
+ }
+ set map([winfo id $w]) $w
+ }
+
+ # No window ids should have been reused: stale Destroy events still
+ # pending in queue.
+ lappend result [lsort $reused]
+
+ # Wait a few seconds, then try again; ids should still not have
+ # been re-used.
+
+ set y 0
+ after 2000 {set y 1}
+ tkwait variable y
+ foreach i {a b c} {
+ set w .${i}3
+ frame $w -height 20 -width 100 -bd 2 -relief raised
+ pack $w
+ if [info exists map([winfo id $w])] {
+ lappend reused $map([winfo id $w])
+ }
+ set map([winfo id $w])] $w
+ }
+
+ # Ids should not yet have been reused.
+ lappend result [lsort $reused]
+
+
+ # Wait a few more seconds, to give ids enough time to be recycled.
+ set y 0
+ after 6000 {set y 1}
+ tkwait variable y
+ foreach i {a b c d e f} {
+ set w .${i}4
+ frame $w -height 20 -width 100 -bd 2 -relief raised
+ pack $w
+ if [info exists map([winfo id $w])] {
+ lappend reused $map([winfo id $w])
+ }
+ set map([winfo id $w])] $w
+ }
+
+ # Ids should be reused now, due to time delay. Destroy events should
+ # have been discarded.
+ lappend result [lsort $reused] [lsort $x]
+} {{.f .f.a .f.b .f.c .f.d .f.e .f.f .f.g .f.h .f.i .f.j .f.k .f.l .f.m .f.n .f.o .f.p .f.q} {} {} {.f.o .f.p .f.q wrapper.f.p wrapper.f.q} {}}
+bind all <Destroy> {}