blob: 162048a7a240e8db048bd95a574efdfb139c6f33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# This file is a Tcl script to test out Tk's "tk_dialog" command.
# NOTE
#
# This test file is platform-indifferent. Tests regarding the dialogs that
# are specific to the windows platform go into the test file winDialog.test.
#
#
# TESTFILE INITIALIZATION
#
package require tcltest 2.2; # needed in mode -singleproc 0
# Load the main script main.tcl, which takes care of:
# - setup for the application and the root window
# - importing commands from the tcltest namespace
# - loading of the testutils mechanism along with its utility procs
# - loading of Tk specific test constraints (additionally to constraints
# provided by the package tcltest)
source [file join [tcltest::configure -testdir] main.tcl]
# Ensure a pristine initial window state
resetWindows
# Import utility procs for specific functional areas
testutils import dialog
#
# TESTS
#
test dialog-1.1 {tk_dialog command} -body {
tk_dialog
} -match glob -returnCodes error -result {wrong # args: should be "tk_dialog w title text bitmap default *"}
test dialog-1.2 {tk_dialog command} -body {
tk_dialog foo foo foo foo foo
} -returnCodes error -result {bad window path name "foo"}
test dialog-1.3 {tk_dialog command} -body {
tk_dialog .d foo foo fooBitmap foo
} -cleanup {
destroy .d
} -returnCodes error -result {bitmap "fooBitmap" not defined}
test dialog-2.1 {tk_dialog operation} -body {
set x [after 5000 [list set tk::Priv(button) "no response"]]
after 100 {
if {![winfo ismapped .d.button0]} {
update
}
PressButton .d.button0
}
set res [tk_dialog .d foo foo info 0 click]
after cancel $x
return $res
} -cleanup {
destroy .d
} -result 0
test dialog-2.2 {tk_dialog operation} -setup {
proc HitReturn {w} {
event generate $w <Enter>
focus -force $w
event generate $w <Key> -keysym Return
}
} -body {
set x [after 5000 [list set tk::Priv(button) "no response"]]
after 100 HitReturn .d
set res [tk_dialog .d foo foo info 1 click default]
after cancel $x
return $res
} -cleanup {
destroy .d
} -result 1
test dialog-2.3 {tk_dialog operation} -body {
set x [after 5000 [list set tk::Priv(button) "no response"]]
after 100 destroy .d
set res [tk_dialog .d foo foo info 0 click]
after cancel $x
return $res
} -cleanup {
destroy .b
} -result -1
#
# TESTFILE CLEANUP
#
testutils forget dialog
cleanupTests
|