winNotify.test
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
源码类别:

通讯编程

开发平台:

Visual C++

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