OSDN Git Service

touched all Tcl files to ease next import.
[pf3gnuchains/pf3gnuchains3x.git] / tcl / tests / winNotify.test
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$
14
15 if {[lsearch [namespace children] ::tcltest] == -1} {
16     package require tcltest
17     namespace import -force ::tcltest::*
18 }
19
20 set ::tcltest::testConstraints(testeventloop) \
21         [expr {[info commands testeventloop] != {}}]
22
23 # There is no explicit test for InitNotifier or NotifierExitHandler
24
25 test winNotify-1.1 {Tcl_SetTimer: positive timeout} {pcOnly} {
26     set done 0
27     after 1000 { set done 1 }
28     vwait done
29     set done
30 } 1
31 test winNotify-1.2 {Tcl_SetTimer: positive timeout, message pending} {pcOnly} {
32     set x 0
33     set y 1
34     set a1 [after 0 { incr y }]
35     after cancel $a1
36     after 500 { incr x }
37     vwait x
38     list $x $y
39 } {1 1}
40 test winNotify-1.3 {Tcl_SetTimer: cancelling positive timeout} {pcOnly} {
41     set x 0
42     set y 1
43     set id [after 10000 { incr y }]
44     after 0 { incr x }
45     vwait x
46     after cancel $id
47     list $x $y
48 } {1 1}
49 test winNotify-1.4 {Tcl_SetTimer: null timeout, message pending} {pcOnly} {
50     set x 0
51     set y 1
52     after 0 { incr x }
53     after 0 { incr y }
54     vwait x
55     list $x $y
56 } {1 2}
57
58 test winNotify-2.1 {Tcl_ResetIdleTimer} {pcOnly} {
59     set x 0
60     update
61     after idle { incr x }
62     vwait x
63     set x
64 } 1
65 test winNotify-2.2 {Tcl_ResetIdleTimer: message pending} {pcOnly} {
66     set x 0
67     set y 1
68     update
69     after idle { incr x }
70     after idle { incr y }
71     update
72     list $x $y
73 } {1 2}
74
75 test winNotify-3.1 {NotifierProc: non-modal normal timer} {pcOnly testeventloop} {
76     update
77     set x 0
78     foreach i [after info] {
79         after cancel $i
80     }
81     after 500 { incr x; testeventloop done }
82     testeventloop wait
83     set x
84 } 1
85 test winNotify-3.2 {NotifierProc: non-modal normal timer, rescheduled} {pcOnly testeventloop} {
86     update
87     set x 0
88     foreach i [after info] {
89         after cancel $i
90     }
91     after 500 { incr x; after 100 {incr x; testeventloop done }}
92     testeventloop wait
93     set x
94 } 2
95 test winNotify-3.3 {NotifierProc: modal normal timer} {pcOnly} {
96     update
97     set x 0
98     foreach i [after info] {
99         after cancel $i
100     }
101     after 500 { incr x }
102     vwait x
103     set x
104 } 1
105 test winNotify-3.4 {NotifierProc: modal normal timer, rescheduled} {pcOnly} {
106     update
107     set x 0
108     foreach i [after info] {
109         after cancel $i
110     }
111     set y 0
112     after 500 { incr y; after 100 {incr x}}
113     vwait x
114     list $x $y
115 } {1 1}
116 test winNotify-3.5 {NotifierProc: non-modal idle timer} {pcOnly testeventloop} {
117     update
118     set x 0
119     foreach i [after info] {
120         after cancel $i
121     }
122     after idle { incr x; testeventloop done }
123     testeventloop wait
124     set x
125 } 1
126 test winNotify-3.6 {NotifierProc: non-modal idle timer, rescheduled} {pcOnly testeventloop} {
127     update
128     set x 0
129     foreach i [after info] {
130         after cancel $i
131     }
132     after idle { incr x; after idle {incr x; testeventloop done }}
133     testeventloop wait
134     set x
135 } 2
136 test winNotify-3.7 {NotifierProc: modal idle timer} {pcOnly} {
137     update
138     set x 0
139     foreach i [after info] {
140         after cancel $i
141     }
142     after idle { incr x }
143     vwait x
144     set x
145 } 1
146 test winNotify-3.8 {NotifierProc: modal idle timer, rescheduled} {pcOnly} {
147     update
148     set x 0
149     foreach i [after info] {
150         after cancel $i
151     }
152     set y 0
153     after idle { incr y; after idle {incr x}}
154     vwait x
155     list $x $y
156 } {1 1}
157
158 # Tcl_DoOneEvent is tested by the timer.test, io.test, and event.test files
159
160 # cleanup
161 ::tcltest::cleanupTests
162 return
163
164
165
166
167
168
169
170
171
172
173
174
175