OSDN Git Service

touched all tk files to ease next import
[pf3gnuchains/pf3gnuchains4x.git] / tk / tests / id.test
1 # This file is a Tcl script to test out the procedures in the file
2 # tkId.c, which recycle X resource identifiers.  It is organized in
3 # the standard fashion for Tcl tests.
4 #
5 # Copyright (c) 1995 Sun Microsystems, Inc.
6 # Copyright (c) 1998-1999 by Scriptics Corporation.
7 # All rights reserved.
8 #
9 # RCS: @(#) $Id$
10
11 if {[lsearch [namespace children] ::tcltest] == -1} {
12     source [file join [pwd] [file dirname [info script]] defs.tcl]
13 }
14
15 if {[string compare testwrapper [info commands testwrapper]] != 0} {
16     puts "This application hasn't been compiled with the testwrapper command,"
17     puts "therefore I am skipping all of these tests."
18     ::tcltest::cleanupTests
19     return
20 }
21
22 foreach i [winfo children .] {
23     destroy $i
24 }
25 wm geometry . {}
26 raise .
27
28 test id-1.1 {WindowIdCleanup, delaying window release} {unixOnly} {
29     bind all <Destroy> {lappend x %W}
30     catch {unset map}
31     frame .f
32     set j 0
33     foreach i {a b c d e f g h i j k l m n o p q} {
34         toplevel .f.$i -height 50 -width 100
35         wm geometry .f.$i +$j+$j
36         incr j 10
37         update
38         set map([winfo id .f.$i]) .f.$i
39         set map([testwrapper .f.$i]) wrapper.f.$i
40     }
41     set x {}
42     destroy .f
43
44     # Destroy events should have occurred for all windows.
45     set result [list [lsort $x]]
46
47     set x {}
48     update idletasks
49     set reused {}
50     foreach i {a b c d e} {
51         set w .${i}2
52         frame $w -height 20 -width 100 -bd 2 -relief raised
53         pack $w
54         if [info exists map([winfo id $w])] {
55             lappend reused $map([winfo id $w])
56         }
57         set map([winfo id $w]) $w
58     }
59
60     # No window ids should have been reused: stale Destroy events still
61     # pending in queue.
62     lappend result [lsort $reused]
63
64     # Wait a few seconds, then try again;  ids should still not have
65     # been re-used.
66
67     set y 0
68     after 2000 {set y 1}
69     tkwait variable y
70     foreach i {a b c} {
71         set w .${i}3
72         frame $w -height 20 -width 100 -bd 2 -relief raised
73         pack $w
74         if [info exists map([winfo id $w])] {
75             lappend reused $map([winfo id $w])
76         }
77         set map([winfo id $w])] $w
78     }
79
80     # Ids should not yet have been reused.
81     lappend result [lsort $reused]
82
83
84     # Wait a few more seconds, to give ids enough time to be recycled.
85     set y 0
86     after 6000 {set y 1}
87     tkwait variable y
88     foreach i {a b c d e f} {
89         set w .${i}4
90         frame $w -height 20 -width 100 -bd 2 -relief raised
91         pack $w
92         if [info exists map([winfo id $w])] {
93             lappend reused $map([winfo id $w])
94         }
95         set map([winfo id $w])] $w
96     }
97
98     # Ids should be reused now, due to time delay.  Destroy events should
99     # have been discarded.
100     lappend result [lsort $reused] [lsort $x]
101 } {{.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} {}}
102 bind all <Destroy> {}
103
104 # cleanup
105 ::tcltest::cleanupTests
106 return
107
108
109
110
111
112
113
114
115
116
117
118
119