sl@0
|
1 |
# This file tests the tclWinNotify.c file.
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# This file contains a collection of tests for one or more of the Tcl
|
sl@0
|
4 |
# built-in commands. Sourcing this file into Tcl runs the tests and
|
sl@0
|
5 |
# generates output for errors. No output means no errors were found.
|
sl@0
|
6 |
#
|
sl@0
|
7 |
# Copyright (c) 1997 by Sun Microsystems, Inc.
|
sl@0
|
8 |
# Copyright (c) 1998-1999 by Scriptics Corporation.
|
sl@0
|
9 |
#
|
sl@0
|
10 |
# See the file "license.terms" for information on usage and redistribution
|
sl@0
|
11 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
sl@0
|
12 |
#
|
sl@0
|
13 |
# RCS: @(#) $Id: winNotify.test,v 1.7 2000/04/10 17:19:06 ericm Exp $
|
sl@0
|
14 |
|
sl@0
|
15 |
if {[lsearch [namespace children] ::tcltest] == -1} {
|
sl@0
|
16 |
package require tcltest
|
sl@0
|
17 |
namespace import -force ::tcltest::*
|
sl@0
|
18 |
}
|
sl@0
|
19 |
|
sl@0
|
20 |
set ::tcltest::testConstraints(testeventloop) \
|
sl@0
|
21 |
[expr {[info commands testeventloop] != {}}]
|
sl@0
|
22 |
|
sl@0
|
23 |
# There is no explicit test for InitNotifier or NotifierExitHandler
|
sl@0
|
24 |
|
sl@0
|
25 |
test winNotify-1.1 {Tcl_SetTimer: positive timeout} {pcOnly} {
|
sl@0
|
26 |
set done 0
|
sl@0
|
27 |
after 1000 { set done 1 }
|
sl@0
|
28 |
vwait done
|
sl@0
|
29 |
set done
|
sl@0
|
30 |
} 1
|
sl@0
|
31 |
test winNotify-1.2 {Tcl_SetTimer: positive timeout, message pending} {pcOnly} {
|
sl@0
|
32 |
set x 0
|
sl@0
|
33 |
set y 1
|
sl@0
|
34 |
set a1 [after 0 { incr y }]
|
sl@0
|
35 |
after cancel $a1
|
sl@0
|
36 |
after 500 { incr x }
|
sl@0
|
37 |
vwait x
|
sl@0
|
38 |
list $x $y
|
sl@0
|
39 |
} {1 1}
|
sl@0
|
40 |
test winNotify-1.3 {Tcl_SetTimer: cancelling positive timeout} {pcOnly} {
|
sl@0
|
41 |
set x 0
|
sl@0
|
42 |
set y 1
|
sl@0
|
43 |
set id [after 10000 { incr y }]
|
sl@0
|
44 |
after 0 { incr x }
|
sl@0
|
45 |
vwait x
|
sl@0
|
46 |
after cancel $id
|
sl@0
|
47 |
list $x $y
|
sl@0
|
48 |
} {1 1}
|
sl@0
|
49 |
test winNotify-1.4 {Tcl_SetTimer: null timeout, message pending} {pcOnly} {
|
sl@0
|
50 |
set x 0
|
sl@0
|
51 |
set y 1
|
sl@0
|
52 |
after 0 { incr x }
|
sl@0
|
53 |
after 0 { incr y }
|
sl@0
|
54 |
vwait x
|
sl@0
|
55 |
list $x $y
|
sl@0
|
56 |
} {1 2}
|
sl@0
|
57 |
|
sl@0
|
58 |
test winNotify-2.1 {Tcl_ResetIdleTimer} {pcOnly} {
|
sl@0
|
59 |
set x 0
|
sl@0
|
60 |
update
|
sl@0
|
61 |
after idle { incr x }
|
sl@0
|
62 |
vwait x
|
sl@0
|
63 |
set x
|
sl@0
|
64 |
} 1
|
sl@0
|
65 |
test winNotify-2.2 {Tcl_ResetIdleTimer: message pending} {pcOnly} {
|
sl@0
|
66 |
set x 0
|
sl@0
|
67 |
set y 1
|
sl@0
|
68 |
update
|
sl@0
|
69 |
after idle { incr x }
|
sl@0
|
70 |
after idle { incr y }
|
sl@0
|
71 |
update
|
sl@0
|
72 |
list $x $y
|
sl@0
|
73 |
} {1 2}
|
sl@0
|
74 |
|
sl@0
|
75 |
test winNotify-3.1 {NotifierProc: non-modal normal timer} {pcOnly testeventloop} {
|
sl@0
|
76 |
update
|
sl@0
|
77 |
set x 0
|
sl@0
|
78 |
foreach i [after info] {
|
sl@0
|
79 |
after cancel $i
|
sl@0
|
80 |
}
|
sl@0
|
81 |
after 500 { incr x; testeventloop done }
|
sl@0
|
82 |
testeventloop wait
|
sl@0
|
83 |
set x
|
sl@0
|
84 |
} 1
|
sl@0
|
85 |
test winNotify-3.2 {NotifierProc: non-modal normal timer, rescheduled} {pcOnly testeventloop} {
|
sl@0
|
86 |
update
|
sl@0
|
87 |
set x 0
|
sl@0
|
88 |
foreach i [after info] {
|
sl@0
|
89 |
after cancel $i
|
sl@0
|
90 |
}
|
sl@0
|
91 |
after 500 { incr x; after 100 {incr x; testeventloop done }}
|
sl@0
|
92 |
testeventloop wait
|
sl@0
|
93 |
set x
|
sl@0
|
94 |
} 2
|
sl@0
|
95 |
test winNotify-3.3 {NotifierProc: modal normal timer} {pcOnly} {
|
sl@0
|
96 |
update
|
sl@0
|
97 |
set x 0
|
sl@0
|
98 |
foreach i [after info] {
|
sl@0
|
99 |
after cancel $i
|
sl@0
|
100 |
}
|
sl@0
|
101 |
after 500 { incr x }
|
sl@0
|
102 |
vwait x
|
sl@0
|
103 |
set x
|
sl@0
|
104 |
} 1
|
sl@0
|
105 |
test winNotify-3.4 {NotifierProc: modal normal timer, rescheduled} {pcOnly} {
|
sl@0
|
106 |
update
|
sl@0
|
107 |
set x 0
|
sl@0
|
108 |
foreach i [after info] {
|
sl@0
|
109 |
after cancel $i
|
sl@0
|
110 |
}
|
sl@0
|
111 |
set y 0
|
sl@0
|
112 |
after 500 { incr y; after 100 {incr x}}
|
sl@0
|
113 |
vwait x
|
sl@0
|
114 |
list $x $y
|
sl@0
|
115 |
} {1 1}
|
sl@0
|
116 |
test winNotify-3.5 {NotifierProc: non-modal idle timer} {pcOnly testeventloop} {
|
sl@0
|
117 |
update
|
sl@0
|
118 |
set x 0
|
sl@0
|
119 |
foreach i [after info] {
|
sl@0
|
120 |
after cancel $i
|
sl@0
|
121 |
}
|
sl@0
|
122 |
after idle { incr x; testeventloop done }
|
sl@0
|
123 |
testeventloop wait
|
sl@0
|
124 |
set x
|
sl@0
|
125 |
} 1
|
sl@0
|
126 |
test winNotify-3.6 {NotifierProc: non-modal idle timer, rescheduled} {pcOnly testeventloop} {
|
sl@0
|
127 |
update
|
sl@0
|
128 |
set x 0
|
sl@0
|
129 |
foreach i [after info] {
|
sl@0
|
130 |
after cancel $i
|
sl@0
|
131 |
}
|
sl@0
|
132 |
after idle { incr x; after idle {incr x; testeventloop done }}
|
sl@0
|
133 |
testeventloop wait
|
sl@0
|
134 |
set x
|
sl@0
|
135 |
} 2
|
sl@0
|
136 |
test winNotify-3.7 {NotifierProc: modal idle timer} {pcOnly} {
|
sl@0
|
137 |
update
|
sl@0
|
138 |
set x 0
|
sl@0
|
139 |
foreach i [after info] {
|
sl@0
|
140 |
after cancel $i
|
sl@0
|
141 |
}
|
sl@0
|
142 |
after idle { incr x }
|
sl@0
|
143 |
vwait x
|
sl@0
|
144 |
set x
|
sl@0
|
145 |
} 1
|
sl@0
|
146 |
test winNotify-3.8 {NotifierProc: modal idle timer, rescheduled} {pcOnly} {
|
sl@0
|
147 |
update
|
sl@0
|
148 |
set x 0
|
sl@0
|
149 |
foreach i [after info] {
|
sl@0
|
150 |
after cancel $i
|
sl@0
|
151 |
}
|
sl@0
|
152 |
set y 0
|
sl@0
|
153 |
after idle { incr y; after idle {incr x}}
|
sl@0
|
154 |
vwait x
|
sl@0
|
155 |
list $x $y
|
sl@0
|
156 |
} {1 1}
|
sl@0
|
157 |
|
sl@0
|
158 |
# Tcl_DoOneEvent is tested by the timer.test, io.test, and event.test files
|
sl@0
|
159 |
|
sl@0
|
160 |
# cleanup
|
sl@0
|
161 |
::tcltest::cleanupTests
|
sl@0
|
162 |
return
|
sl@0
|
163 |
|
sl@0
|
164 |
|
sl@0
|
165 |
|
sl@0
|
166 |
|
sl@0
|
167 |
|
sl@0
|
168 |
|
sl@0
|
169 |
|
sl@0
|
170 |
|
sl@0
|
171 |
|
sl@0
|
172 |
|
sl@0
|
173 |
|
sl@0
|
174 |
|