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