summaryrefslogtreecommitdiffstats
path: root/tests/busy.test
blob: bc0ae5f8ee239d5c29b50d5785a6f9b4843ed716 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# Tests for the tk busy command.
#
# This file contains a collection of tests for one or more of the Tk built-in
# commands. Sourcing this file runs the tests and generates output for errors.
# No output means no errors were found.
#
# Copyright (c) 1998-2000 by Jos Decoster. All rights reserved.

package require tcltest 2.1
tcltest::configure {*}$argv
tcltest::loadTestedCommands
namespace import -force tcltest::test

# There's currently no way to test the actual grab effect, per se, in an
# automated test. Therefore, this test suite only covers the interface to the
# grab command (ie, error messages, etc.)

test busy-1.1 {Tk_BusyObjCmd} -returnCodes error -body {
    tk busy
} -result {wrong # args: should be "tk busy options ?arg ...?"}

test busy-2.1 {tk busy hold} -returnCodes error -body {
    tk busy hold
} -result {wrong # args: should be "tk busy hold window ?-option value ...?"}
test busy-2.2 {tk busy hold root window} -body {
    set res [tk busy hold .]
    update
    set res
} -cleanup {
    tk busy forget .
} -result {._Busy}
test busy-2.3 {tk busy hold root window with shortcut} -body {
    set res [tk busy .]
    update
    set res
} -cleanup {
    tk busy forget .
} -result {._Busy}
test busy-2.4 {tk busy hold nested window} -setup {
    pack [frame .f]
} -body {
    set res [tk busy hold .f]
    update
    set res
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {.f_Busy}
test busy-2.5 {tk busy hold nested window with shortcut} -setup {
    pack [frame .f]
} -body {
    set res [tk busy .f]
    update
    set res
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {.f_Busy}
test busy-2.6 {tk busy hold toplevel window} -setup {
    toplevel .f
} -body {
    set res [tk busy hold .f]
    update
    set res
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {.f._Busy}
test busy-2.7 {tk busy hold toplevel window with shortcut} -setup {
    toplevel .f
} -body {
    set res [tk busy .f]
    update
    set res
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {.f._Busy}
test busy-2.8 {tk busy hold non existing window} -body {
    tk busy hold .f
    update
} -returnCodes error -result {bad window path name ".f"}
test busy-2.9 {tk busy hold (shortcut) non existing window} -body {
    tk busy .f
    update
} -returnCodes {error} -result {bad window path name ".f"}
test busy-2.10 {tk busy hold root window with cursor} -body {
    set res [tk busy hold . -cursor arrow]
    update
    set res
} -cleanup {
    tk busy forget .
} -result {._Busy}
test busy-2.11 {tk busy hold (shortcut) root window, cursor} -body {
    set res [tk busy . -cursor arrow]
    update
    set res
} -cleanup {
    tk busy forget .
} -result {._Busy}
test busy-2.12 {tk busy hold root window, invalid cursor} -body {
    tk busy hold . -cursor nonExistingCursor
    update
} -returnCodes error -cleanup {
    tk busy forget .
} -result {bad cursor spec "nonExistingCursor"}
test busy-2.13 {tk busy hold (shortcut) root window, invalid cursor} -body {
    tk busy . -cursor nonExistingCursor
    update
} -returnCodes error -cleanup {
    tk busy forget .
} -result {bad cursor spec "nonExistingCursor"}
test busy-2.14 {tk busy hold root window, invalid option} -body {
    tk busy hold . -invalidOption 1
    update
} -returnCodes error -cleanup {
    tk busy forget .
} -result {unknown option "-invalidOption"}
test busy-2.15 {tk busy hold (shortcut) root window, invalid option} -body {
    tk busy . -invalidOption 1
    update
} -returnCodes error -cleanup {
    tk busy forget .
} -result {unknown option "-invalidOption"}

test busy-3.1 {tk busy cget no window} -returnCodes error -body {
    tk busy cget
} -result {wrong # args: should be "tk busy cget window option"}
test busy-3.2 {tk busy cget no option} -returnCodes error -body {
    tk busy cget
} -result {wrong # args: should be "tk busy cget window option"}
test busy-3.3 {tk busy cget invalid window} -returnCodes error -body {
    tk busy cget .f -cursor
} -result {bad window path name ".f"}
test busy-3.4 {tk busy cget non-busy window} -setup {
    pack [frame .f]
} -body {
    tk busy cget .f -cursor
} -cleanup {
    destroy .f
} -returnCodes error -result {can't find busy window ".f"}
test busy-3.5 {tk busy cget invalid option} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy cget .f -invalidOption
} -cleanup {
    tk busy forget .f
    destroy .f
} -returnCodes error -result {unknown option "-invalidOption"}
test busy-3.6unix {tk busy cget unix} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy cget .f -cursor
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {watch} -constraints unix
test busy-3.6win {tk busy cget win} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy cget .f -cursor
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {wait} -constraints win
test busy-3.7 {tk busy cget unix} -setup {
    pack [frame .f]
    tk busy hold .f -cursor hand1
    update
} -body {
    tk busy cget .f -cursor
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {hand1}

test busy-4.1 {tk busy configure no window} -returnCodes error -body {
    tk busy configure
} -result {wrong # args: should be "tk busy configure window ?-option value ...?"}

test busy-4.2 {tk busy configure invalid window} -body {
    tk busy configure .f
} -returnCodes error -result {bad window path name ".f"}

test busy-4.3 {tk busy configure non-busy window} -setup {
    pack [frame .f]
} -body {
    tk busy configure .f
} -cleanup {
    destroy .f
} -returnCodes error -result {can't find busy window ".f"}

test busy-4.4 {tk busy configure} -constraints {nonwin} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy configure .f
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {{-cursor cursor Cursor watch watch}}

test busy-4.4-win {tk busy configure} -constraints {win} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy configure .f
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {{-cursor cursor Cursor wait wait}}

test busy-4.5 {tk busy configure} -constraints {nonwin} -setup {
    pack [frame .f]
    tk busy hold .f -cursor hand2
    update
} -body {
    tk busy configure .f
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {{-cursor cursor Cursor watch hand2}}

test busy-4.5-win {tk busy configure} -constraints win -setup {
    pack [frame .f]
    tk busy hold .f -cursor hand2
    update
} -body {
    tk busy configure .f
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {{-cursor cursor Cursor wait hand2}}

test busy-4.6 {tk busy configure invalid option} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy configure .f -invalidOption
} -cleanup {
    tk busy forget .f
    destroy .f
} -returnCodes error -result {unknown option "-invalidOption"}

test busy-4.7 {tk busy configure valid option} -constraints {nonwin} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy configure .f -cursor
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {-cursor cursor Cursor watch watch}

test busy-4.7-win {tk busy configure valid option} -constraints {win} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy configure .f -cursor
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {-cursor cursor Cursor wait wait}

test busy-4.8 {tk busy configure valid option} -constraints {
    nonwin
} -setup {
    pack [frame .f]
    tk busy hold .f -cursor circle
    update
} -body {
    tk busy configure .f -cursor
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {-cursor cursor Cursor watch circle}

test busy-4.8-win {tk busy configure valid option} -constraints win -setup {
    pack [frame .f]
    tk busy hold .f -cursor circle
    update
} -body {
    tk busy configure .f -cursor
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {-cursor cursor Cursor wait circle}

test busy-4.9 {tk busy configure valid option with value} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy configure .f -cursor pencil
    tk busy cget .f -cursor
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {pencil}

test busy-4.10 {tk busy configure valid option with invalid value} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy configure .f -cursor nonExistingCursor
} -returnCodes error -cleanup {
    tk busy forget .f
    destroy .f
} -result {bad cursor spec "nonExistingCursor"}

test busy-5.1 {tk busy forget} -returnCodes error -body {
    tk busy forget
} -result {wrong # args: should be "tk busy forget window"}
test busy-5.2 {tk busy forget non existing window} -body {
    tk busy forget .f
} -returnCodes error -result {bad window path name ".f"}
test busy-5.3 {tk busy forget non busy window} -setup {
    pack [frame .f]
} -body {
    tk busy forget .f
} -cleanup {
    destroy .f
} -returnCodes error -result {can't find busy window ".f"}
test busy-5.4 {tk busy forget window} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    set r [tk busy status .f]
    tk busy forget .f
    lappend r [tk busy status .f]
} -cleanup {
    destroy .f
} -result {1 0}

test busy-6.1 {tk busy status} -returnCodes error -body {
    tk busy status
} -result {wrong # args: should be "tk busy status window"}
test busy-6.2 {tk busy status non existing window} -body {
    tk busy status .f
} -result 0
test busy-6.3 {tk busy status non busy window} -setup {
    pack [frame .f]
} -body {
    tk busy status .f
} -cleanup {
    destroy .f
} -result 0
test busy-6.4 {tk busy status busy window} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy status .f
} -cleanup {
    tk busy forget .f
    destroy .f
} -result 1
test busy-6.5 {tk busy status forgotten busy window} -setup {
    pack [frame .f]
    tk busy hold .f
    update
    tk busy forget .f
} -body {
    tk busy status .f
} -cleanup {
    destroy .f
} -result 0

test busy-7.1 {tk busy current no busy} -body {
    tk busy current
} -result {}
test busy-7.2 {tk busy current 1 busy} -setup {
    pack [frame .f]
    tk busy hold .f
    update
} -body {
    tk busy current
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {.f}
test busy-7.3 {tk busy current 2 busy} -setup {
    pack [frame .f1]
    pack [frame .f2]
    tk busy hold .f1
    tk busy hold .f2
    update
} -body {
    lsort [tk busy current]
} -cleanup {
    tk busy forget .f1
    tk busy forget .f2
    destroy .f1 .f2
} -result {.f1 .f2}
test busy-7.4 {tk busy current 2 busy with matching filter} -setup {
    pack [frame .f1]
    pack [frame .f2]
    tk busy hold .f1
    tk busy hold .f2
    update
} -body {
    lsort [tk busy current *2*]
} -cleanup {
    tk busy forget .f1
    tk busy forget .f2
    destroy .f1 .f2
} -result {.f2}
test busy-7.5 {tk busy current 2 busy with non matching filter} -setup {
    pack [frame .f1]
    pack [frame .f2]
    tk busy hold .f1
    tk busy hold .f2
    update
} -body {
    lsort [tk busy current *3*]
} -cleanup {
    tk busy forget .f1
    tk busy forget .f2
    destroy .f1 .f2
} -result {}
test busy-7.6 {tk busy current 1 busy after forget} -setup {
    pack [frame .f]
    tk busy hold .f
    update
    tk busy forget .f
} -body {
    tk busy current
} -cleanup {
    destroy .f
} -result {}
test busy-7.7 {tk busy current 2 busy after forget} -setup {
    pack [frame .f1]
    pack [frame .f2]
    tk busy hold .f1
    tk busy hold .f2
    update
    tk busy forget .f1
} -body {
    lsort [tk busy current]
} -cleanup {
    tk busy forget .f2
    destroy .f1 .f2
} -result {.f2}
test busy-7.8 {tk busy current 2 busy with matching filter after forget} -setup {
    pack [frame .f1]
    pack [frame .f2]
    tk busy hold .f1
    tk busy hold .f2
    update
    tk busy forget .f1
} -body {
    lsort [tk busy current *2*]
} -cleanup {
    tk busy forget .f2
    destroy .f1 .f2
} -result {.f2}
test busy-7.9 {tk busy current 2 busy with non matching filter after forget} -setup {
    pack [frame .f1]
    pack [frame .f2]
    tk busy hold .f1
    tk busy hold .f2
    update
    tk busy forget .f1
} -body {
    lsort [tk busy current *3*]
} -cleanup {
    tk busy forget .f2
    destroy .f1 .f2
} -result {}

test busy-8.1 {tk busy busywindow with a busy toplevel} -body {
    toplevel .top
    tk busy .top
    tk busy busywindow .top
} -cleanup {
    tk busy forget .top
    destroy .top
} -result {.top._Busy}
test busy-8.2 {tk busy busywindow with a busy widget} -body {
    pack [frame .f]
    tk busy .f
    tk busy busywindow .f
} -cleanup {
    tk busy forget .f
    destroy .f
} -result {.f_Busy}
test busy-8.3 {tk busy busywindow with a nonexisting widget} -body {
    tk busy .
    tk busy busywindow .nonExistingWidget
} -cleanup {
    tk busy forget .
} -result {}


::tcltest::cleanupTests
return