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 © 1997 Sun Microsystems, Inc. 8# Copyright © 1998-1999 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 13if {"::tcltest" ni [namespace children]} { 14 package require tcltest 2.5 15 namespace import -force ::tcltest::* 16} 17 18::tcltest::loadTestedCommands 19catch [list package require -exact tcl::test [info patchlevel]] 20 21testConstraint testeventloop [expr {[info commands testeventloop] != {}}] 22 23# There is no explicit test for InitNotifier or NotifierExitHandler 24 25test winNotify-1.1 {Tcl_SetTimer: positive timeout} {win} { 26 set done 0 27 after 1000 { set done 1 } 28 vwait done 29 set done 30} 1 31test winNotify-1.2 {Tcl_SetTimer: positive timeout, message pending} {win} { 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} 40test winNotify-1.3 {Tcl_SetTimer: cancelling positive timeout} {win} { 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} 49test winNotify-1.4 {Tcl_SetTimer: null timeout, message pending} {win} { 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 58test winNotify-2.1 {Tcl_ResetIdleTimer} {win} { 59 set x 0 60 update 61 after idle { incr x } 62 vwait x 63 set x 64} 1 65test winNotify-2.2 {Tcl_ResetIdleTimer: message pending} {win} { 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 75test winNotify-3.1 {NotifierProc: non-modal normal timer} {win 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 85test winNotify-3.2 {NotifierProc: non-modal normal timer, rescheduled} {win 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 95test winNotify-3.3 {NotifierProc: modal normal timer} {win} { 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 105test winNotify-3.4 {NotifierProc: modal normal timer, rescheduled} {win} { 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} 116test winNotify-3.5 {NotifierProc: non-modal idle timer} {win 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 126test winNotify-3.6 {NotifierProc: non-modal idle timer, rescheduled} {win 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 136test winNotify-3.7 {NotifierProc: modal idle timer} {win} { 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 146test winNotify-3.8 {NotifierProc: modal idle timer, rescheduled} {win} { 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 162return 163