OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tk/] [tests/] [id.test] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# 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
#
7
# See the file "license.terms" for information on usage and redistribution
8
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9
#
10
# RCS: @(#) $Id: id.test,v 1.1.1.1 2002-01-16 10:25:58 markom Exp $
11
 
12
if {[info procs test] != "test"} {
13
    source defs
14
}
15
 
16
if {[string compare testwrapper [info commands testwrapper]] != 0} {
17
    puts "This application hasn't been compiled with the testwrapper command,"
18
    puts "therefore I am skipping all of these tests."
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  {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  {}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.