OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tk/] [tests/] [macMenu.test] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# This file is a Tcl script to test menus in Tk.  It is
2
# organized in the standard fashion for Tcl tests. This
3
# file tests the Macintosh-specific features of the menu
4
# system.
5
#
6
# Copyright (c) 1995-1997 Sun Microsystems, Inc.
7
#
8
# See the file "license.terms" for information on usage and redistribution
9
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
#
11
# RCS: @(#) $Id: macMenu.test,v 1.1.1.1 2002-01-16 10:25:59 markom Exp $
12
 
13
if {$tcl_platform(platform) != "macintosh"} {
14
    return
15
}
16
 
17
if {[lsearch [image types] test] < 0} {
18
    puts "This application hasn't been compiled with the \"test\" image"
19
    puts "type, so I can't run this test.  Are you sure you're using"
20
    puts "tktest instead of wish?"
21
    return
22
}
23
 
24
if {[info procs test] != "test"} {
25
    source defs
26
}
27
 
28
proc deleteWindows {} {
29
    foreach i [winfo children .] {
30
        catch [destroy $i]
31
    }
32
}
33
 
34
deleteWindows
35
wm geometry . {}
36
raise .
37
 
38
test macMenu-1.0 {TkMacUseMenuID} {} {
39
    # Can't really test TkMacUseMenuID; it's only called on startup.
40
} {}
41
 
42
test macMenu-2.1 {GetNewID} {
43
    catch {destroy .m1}
44
    list [catch {menu .m1} msg] $msg [destroy .m1]
45
} {0 .m1 {}}
46
test macMenu-2.2 {GetNewID - cascade menu} {
47
    catch {destroy .m1}
48
    menu .m1
49
    .m1 add cascade -menu .m2
50
    list [catch {menu .m2} msg] $msg [destroy .m1] [destroy .m2]
51
} {0 .m2 {} {}}
52
test macMenu-2.3 {GetNewID - running out of ids} {
53
    deleteWindows
54
    menu .menu
55
    for {set i 0} {$i < 230} {incr i} {
56
        menu .m$i
57
        .menu add cascade -label ".m$i" -menu .m$i
58
    }
59
    menu .breaker
60
    list [catch {.menu add cascade -menu .breaker} msg] $msg [deleteWindows]
61
} {1 {No more menus can be allocated.} {}}
62
 
63
test macMenu-3.1 {FreeID} {
64
    catch {destroy .m1}
65
    menu .m1
66
    list [catch {destroy .m1} msg] $msg
67
} {0 {}}
68
 
69
# No way to test running out of ids in TkpNewPlatformMenu
70
test macMenu-4.1 {TkpNewMenu} {
71
    catch {destroy .m1}
72
    list [catch {menu .m1} msg] $msg [catch {destroy .m1} msg2] $msg2
73
} {0 .m1 0 {}}
74
test macMenu-4.2 {TkpNewMenu - checking for help menu when one is there} {
75
    catch {destroy .m1}
76
    catch {destroy .m2}
77
    menu .m1
78
    menu .m1.help -tearoff 0
79
    .m1.help add command -label Test
80
    . configure -menu .m1
81
    raise .
82
    update
83
    list [catch {menu .m2} msg] $msg [destroy .m1] [destroy .m2] [. configure -menu ""]
84
} {0 .m2 {} {} {}}
85
test macMenu-4.3 {TkpNewMenu - menubar set but different interp} {
86
    catch {interp delete testinterp}
87
    catch {destroy .m1}
88
    interp create testinterp
89
    load {} Tk testinterp
90
    interp eval testinterp {raise .}
91
    interp eval testinterp {menu .m1}
92
    interp eval testinterp {. configure -menu .m1}
93
    interp eval testinterp {update}
94
    list [catch {menu .m1} msg] $msg [destroy .m1] [interp delete testinterp]
95
} {0 .m1 {} {}}
96
test macMenu-4.4 {TkpNewMenu - menubar set but new menu has different parent} {
97
    catch {destroy .m1}
98
    catch {destroy .m2}
99
    menu .m1 -tearoff 0
100
    .m1 add cascade -menu .m1.help
101
    menu .m2
102
    .m2 add cascade -menu .m2.help
103
    . configure -menu .m1
104
    raise .
105
    update
106
    list [catch {menu .m2.help} msg] $msg [. configure -menu ""] [destroy .m1] [destroy .m2]
107
} {0 .m2.help {} {} {}}
108
test macMenu-4.5 {TkpNewMenu - menubar set, same parent, not .help} {
109
    catch {destroy .m1}
110
    menu .m1 -tearoff 0
111
    .m1 add cascade -menu .m1.help
112
    . configure -menu .m1
113
    raise .
114
    update
115
    list [catch {menu .m1.foo} msg] $msg [. configure -menu ""] [destroy .m1]
116
} {0 .m1.foo {} {}}
117
test macMenu-4.6 {TkpNewMenu - creating the help menu} {
118
    catch {destroy .m1}
119
    menu .m1 -tearoff 0
120
    .m1 add cascade -menu .m1.help
121
    . configure -menu .m1
122
    raise .
123
    update
124
    list [catch {menu .m1.help} msg] $msg [. configure -menu ""] [destroy .m1]
125
} {0 .m1.help {} {}}
126
 
127
test macMenu-5.1 {TkpDestroyMenu} {
128
    catch {destroy .m1}
129
    menu .m1
130
    list [catch {destroy .m1} msg] $msg
131
} {0 {}}
132
test macMenu-5.2 {TkpDestroyMenu - help menu} {
133
    catch {destroy .m1}
134
    menu .m1 -tearoff 0
135
    .m1 add cascade -menu .m1.help
136
    . configure -menu .m1
137
    menu .m1.help
138
    raise .
139
    update
140
    list [catch {destroy .m1.help} msg] $msg [. configure -menu ""] [destroy .m1]
141
} {0 {} {} {}}
142
test macMenu-5.3 {TkpDestroyMenu - idle handler pending} {
143
    catch {destroy .m1}
144
    menu .m1
145
    .m1 add command -label test
146
    list [catch {destroy .m1} msg] $msg
147
} {0 {}}
148
test macMenu-5.4 {TkpDestroyMenu - idle handler not pending} {
149
    catch {destroy .m1}
150
    menu .m1
151
    .m1 add command -label test
152
    update idletasks
153
    list [catch {destroy .m1} msg] $msg
154
} {0 {}}
155
 
156
test macMenu-6.1 {SetMenuCascade} {
157
    catch {destroy .m1}
158
    catch {destroy .m2}
159
    menu .m1
160
    menu .m2
161
    list [catch {.m2 add cascade -menu .m1} msg] $msg [destroy .m1 .m2]
162
} {0 {} {}}
163
test macMenu-6.2 {SetMenuCascade - running out of ids} {
164
    deleteWindows
165
    menu .menu
166
    for {set i 0} {$i < 230} {incr i} {
167
        menu .m$i
168
        .menu add cascade -label ".m$i" -menu .m$i
169
    }
170
    menu .breaker
171
    list [catch {.menu add cascade -menu .breaker} msg] $msg [deleteWindows]
172
} {1 {No more menus can be allocated.} {}}
173
 
174
test macMenu-7.1 {TkpDestroyMenuEntry} {
175
    catch {destroy .m1}
176
    menu .m1
177
    .m1 add command -label "test"
178
    list [catch {.m1 delete 1} msg] $msg [destroy .m1]
179
} {0 {} {}}
180
test macMenu-7.2 {TkpDestroyMenuEntry - help menu} {
181
    catch {destroy .m1}
182
    menu .m1
183
    .m1 add cascade -menu .m1.help
184
    menu .m1.help -tearoff 0
185
    .m1.help add command -label "test"
186
    . configure -menu .m1
187
    raise .
188
    update
189
    list [catch {.m1.help delete test} msg] $msg [. configure -menu ""] [destroy .m1]
190
} {0 {} {} {}}
191
 
192
test macMenu-8.1 {GetEntryText} {
193
    catch {destroy .m1}
194
    list [catch {menu .m1} msg] $msg [destroy .m1]
195
} {0 .m1 {}}
196
test macMenu-8.2 {GetEntryText} {
197
    catch {destroy .m1}
198
    catch {image delete image1}
199
    menu .m1
200
    image create test image1
201
    list [catch {.m1 add command -image image1} msg] $msg [destroy .m1] [image delete image1]
202
} {0 {} {} {}}
203
test macMenu-8.3 {GetEntryText} {
204
    catch {destroy .m1}
205
    menu .m1
206
    list [catch {.m1 add command -bitmap questhead} msg] $msg [destroy .m1]
207
} {0 {} {}}
208
test macMenu-8.4 {GetEntryText} {
209
    catch {destroy .m1}
210
    menu .m1
211
    list [catch {.m1 add command} msg] $msg [destroy .m1]
212
} {0 {} {}}
213
test macMenu-8.5 {GetEntryText} {
214
    catch {destroy .m1}
215
    menu .m1
216
    .m1 add command -label "foo"
217
    list [catch {.m1 add command -label "foo"} msg] $msg [destroy .m1]
218
} {0 {} {}}
219
test macMenu-8.6 {GetEntryText} {
220
    catch {destroy .m1}
221
    menu .m1
222
    list [catch {.m1 add command -label "This is a very long string. 9012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890012345678900123456789001234567890"} \
223
            msg] $msg [destroy .m1]
224
} {0 {} {}}
225
test macMenu-8.7 {GetEntryText - elipses character} {
226
    catch {destroy .m1}
227
    menu .m1
228
    list [catch {.m1 add command -label "foo..."} msg] $msg [destroy .m1]
229
} {0 {} {}}
230
test macMenu-8.8 {GetEntryText - false elipses character} {
231
    catch {destroy .m1}
232
    menu .m1
233
    list [catch {.m1 add command -label "foo."} msg] $msg [destroy .m1]
234
} {0 {} {}}
235
test macMenu-8.9 {GetEntryText - false elipses character} {
236
    catch {destroy .m1}
237
    menu .m1
238
    list [catch {.m1 add command -label "foo.."} msg] $msg [destroy .m1]
239
} {0 {} {}}
240
test macMenu-8.10 {GetEntryText - false elipses character} {
241
    catch {destroy .m1}
242
    menu .m1
243
    list [catch {.m1 add command -label "foo.b"} msg] $msg [destroy .m1]
244
} {0 {} {}}
245
test macMenu-8.11 {GetEntryText - false elipses character} {
246
    catch {destroy .m1}
247
    menu .m1
248
    list [catch {.m1 add command -label "foo..b"} msg] $msg [destroy .m1]
249
} {0 {} {}}
250
 
251
 
252
# test macMenu-9.1 - assumes some fonts
253
test macMenu-9.1 {FindMarkCharacter} {
254
    catch {destroy .m1}
255
    menu .m1 -font "Helvetica 12" -tearoff 0
256
    .m1 add checkbutton -label test
257
    .m1 invoke test
258
    list [catch {update idletasks} msg] $msg [destroy .m1]
259
} {0 {} {}}
260
# All standard fonts have "¥" defined. We can't test further.
261
 
262
test macMenu-10.1 {SetMenuIndicator - cascade entry} {
263
    catch {destroy .m1}
264
    menu .m1
265
    list [catch {.m1 add cascade -label foo} msg] $msg [destroy .m1]
266
} {0 {} {}}
267
test macMenu-10.2 {SetMenuIndicator - not radio or checkbutton} {
268
    catch {destroy .m1}
269
    menu .m1
270
    list [catch {.m1 add command -label foo} msg] $msg [destroy .m1]
271
} {0 {} {}}
272
test macMenu-10.3 {SetMenuIndicator - indiatorOn false} {
273
    catch {destroy .m1}
274
    menu .m1
275
    list [catch {.m1 add checkbutton -label foo -indicatoron 0} msg] $msg [destroy .m1]
276
} {0 {} {}}
277
test macMenu-10.4 {SetMenuIndicator - entry not selected} {
278
    catch {destroy .m1}
279
    menu .m1
280
    list [catch {.m1 add checkbutton -label foo} msg] $msg [destroy .m1]
281
} {0 {} {}}
282
test macMenu-10.5 {SetMenuIndicator - checkbutton} {
283
    catch {destroy .m1}
284
    menu .m1
285
    .m1 add checkbutton -label foo
286
    list [catch {.m1 invoke foo} msg] $msg [destroy .m1]
287
} {0 {} {}}
288
test macMenu-10.6 {SetMenuIndicator - radio button} {
289
    catch {destroy .m1}
290
    menu .m1
291
    .m1 add radiobutton -label foo
292
    list [catch {.m1 invoke foo} msg] $msg [destroy .m1]
293
} {0 {} {}}
294
 
295
test macMenu-11.1 {SetMenuTitle} {
296
    catch {destroy .m1}
297
    catch {destroy .container}
298
    menu .container
299
    menu .m1
300
#previous title is .m1
301
    .container add cascade -label "File" -menu .m1
302
    list [catch {. configure -menu .container} msg] $msg [. configure -menu ""] [destroy .container .m1]
303
} {0 {} {} {}}
304
test macMenu-11.2 {SetMenuTitle} {
305
    menu .container
306
    menu .m1
307
    . configure -menu ""
308
#previous title is .m1
309
    .container add cascade -label "F" -menu .m1
310
    list [catch {. configure -menu .container} msg] $msg [. configure -menu ""] [destroy .container .m1]
311
} {0 {} {} {}}
312
 
313
test macMenu-12.1 {TkpConfigureMenuEntry} {
314
    catch {destroy .m1}
315
    . configure -menu ""
316
    menu .m1
317
    .m1 add cascade -menu .m3
318
    list [catch {.m1 entryconfigure 1 -menu .m2} msg] $msg [destroy .m1]
319
} {0 {} {}}
320
test macMenu-12.2 {TkpConfigureMenuEntry} {
321
    catch {destroy .m1}
322
    catch {destroy .m2}
323
    . configure -menu ""
324
    menu .m1
325
    .m1 add cascade -menu .m3
326
    menu .m2
327
    list [catch {.m1 entryconfigure 1 -menu .m2} msg] $msg [destroy .m1 .m2]
328
} {0 {} {}}
329
test macMenu-12.3 {TkpConfigureMenuEntry - running out of ids} {
330
    deleteWindows
331
    menu .menu
332
    for {set i 0} {$i < 230} {incr i} {
333
        menu .m$i
334
        .menu add cascade -label ".m$i" -menu .m$i
335
    }
336
    menu .breaker
337
    list [catch {.menu add cascade -menu .breaker} msg] $msg [deleteWindows]
338
} {1 {No more menus can be allocated.} {}}
339
test macMenu-12.4 {TkpConfigureMenuEntry - Control} {
340
    catch {destroy .m1}
341
    menu .m1
342
    list [catch {.m1 add command -accel "Control+S"} msg] $msg [destroy .m1]
343
} {0 {} {}}
344
test macMenu-12.5 {TkpConfigureMenuEntry - Ctrl} {
345
    catch {destroy .m1}
346
    menu .m1
347
    list [catch {.m1 add command -accel "Ctrl+S"} msg] $msg [destroy .m1]
348
} {0 {} {}}
349
test macMenu-12.6 {TkpConfigureMenuEntry - Shift} {
350
    catch {destroy .m1}
351
    menu .m1
352
    list [catch {.m1 add command -accel "Shift+S"} msg] $msg [destroy .m1]
353
} {0 {} {}}
354
test macMenu-12.7 {TkpConfigureMenuEntry - Option} {
355
    catch {destroy .m1}
356
    menu .m1
357
    list [catch {.m1 add command -accel "Opt+S"} msg] $msg [destroy .m1]
358
} {0 {} {}}
359
test macMenu-12.8 {TkpConfigureMenuEntry - Command} {
360
    catch {destroy .m1}
361
    menu .m1
362
    list [catch {.m1 add command -accel "Command+S"} msg] $msg [destroy .m1]
363
} {0 {} {}}
364
test macMenu-12.9 {TkpConfigureMenuEntry - Cmd} {
365
    catch {destroy .m1}
366
    menu .m1
367
    list [catch {.m1 add command -accel "Cmd+S"} msg] $msg [destroy .m1]
368
} {0 {} {}}
369
test macMenu-12.10 {TkpConfigureMenuEntry - Alt} {
370
    catch {destroy .m1}
371
    menu .m1
372
    list [catch {.m1 add command -accel "Alt+S"} msg] $msg [destroy .m1]
373
} {0 {} {}}
374
test macMenu-12.11 {TkpConfigureMenuEntry - Meta} {
375
    catch {destroy .m1}
376
    menu .m1
377
    list [catch {.m1 add command -accel "Meta+S"} msg] $msg [destroy .m1]
378
} {0 {} {}}
379
test macMenu-12.12 {TkpConfigureMenuEntry - Two modifiers} {
380
    catch {destroy .m1}
381
    menu .m1
382
    list [catch {.m1 add command -accel "Cmd+Shift+S"} msg] $msg [destroy .m1]
383
} {0 {} {}}
384
test macMenu-12.13 {TkpConfigureMenuEntry - dash instead of plus} {
385
    catch {destroy .m1}
386
    menu .m1
387
    list [catch {.m1 add command -accel "Command-S"} msg] $msg [destroy .m1]
388
} {0 {} {}}
389
test macMenu-12.14 {TkpConfigureMenuEntry - idler pending} {
390
    catch {destroy .m1}
391
    menu .m1 -tearoff 0
392
    .m1 add command -label test
393
    list [catch {.m1 entryconfigure test -label test2} msg] $msg [destroy .m1]
394
} {0 {} {}}
395
test macMenu-12.15 {TkpConfigureMenuEntry - idler not pending} {
396
    catch {destroy .m1}
397
    menu .m1 -tearoff 0
398
    .m1 add command -label test
399
    update idletasks
400
    list [catch {.m1 entryconfigure test -label test2} msg] $msg [destroy .m1]
401
} {0 {} {}}
402
 
403
test macMenu-13.1 {ReconfigureIndividualMenu - getting rid of zero items} {
404
    catch {destroy .m1}
405
    menu .m1 -tearoff 0
406
    .m1 add command -label test
407
    list [catch {update idletasks} msg] $msg [destroy .m1]
408
} {0 {} {}}
409
test macMenu-13.2 {ReconfigureIndividualMenu - getting rid of one item} {
410
    catch {destroy .m1}
411
    menu .m1 -tearoff 0
412
    .m1 add command -label test
413
    update idletasks
414
    .m1 delete test
415
    list [catch {update idletasks} msg] $msg [destroy .m1]
416
} {0 {} {}}
417
test macMenu-13.3 {ReconfigureIndividualMenu - getting rid of more than one} {
418
    catch {destroy .m1}
419
    menu .m1 -tearoff 0
420
    .m1 add command -label test
421
    .m1 add command -label test2
422
    update idletasks
423
    .m1 entryconfigure test2 -label "test two"
424
    list [catch {update idletasks} msg] $msg [destroy .m1]
425
} {0 {} {}}
426
test macMenu-13.4 {ReconfigureIndividualMenu - separator} {
427
    catch {destroy .m1}
428
    menu .m1
429
    .m1 add separator
430
    list [catch {update idletasks} msg] $msg [destroy .m1]
431
} {0 {} {}}
432
test macMenu-13.5 {ReconfigureIndividualMenu - disabled} {
433
    catch {destroy .m1}
434
    menu .m1
435
    .m1 add command
436
    .m1 entryconfigure 1 -state disabled
437
    list [catch {update idletasks} msg] $msg [destroy .m1]
438
} {0 {} {}}
439
test macMenu-13.6 {ReconfigureIndividualMenu - active} {
440
    catch {destroy .m1}
441
    menu .m1
442
    .m1 add command
443
    .m1 entryconfigure 1 -state active
444
    list [catch {update idletasks} msg] $msg [destroy .m1]
445
} {0 {} {}}
446
test macMenu-13.7 {ReconfigureIndividualMenu - checkbutton not checked} {
447
    catch {destroy .m1}
448
    menu .m1
449
    .m1 add checkbutton -label test
450
    list [catch {update idletasks} msg] $msg [destroy .m1]
451
} {0 {} {}}
452
test macMenu-13.8 {ReconfigureIndividualMenu - checkbutton - indicator off} {
453
    catch {destroy .m1}
454
    menu .m1
455
    .m1 add checkbutton -label test -indicatoron 0
456
    .m1 invoke test
457
    list [catch {update idletasks} msg] $msg [destroy .m1]
458
} {0 {} {}}
459
test macMenu-13.9 {ReconfigureIndividualMenu - checkbutton on} {
460
    catch {destroy .m1}
461
    menu .m1
462
    .m1 add checkbutton -label test
463
    .m1 invoke test
464
    list [catch {update idletasks} msg] $msg [destroy .m1]
465
} {0 {} {}}
466
test macMenu-13.10 {ReconfigureIndividualMenu - radiobutton not checked} {
467
    catch {destroy .m1}
468
    menu .m1
469
    .m1 add radiobutton -label test
470
    list [catch {update idletasks} msg] $msg [destroy .m1]
471
} {0 {} {}}
472
test macMenu-13.11 {ReconfigureIndividualMenu - radiobutton - indicator off} {
473
    catch {destroy .m1}
474
    menu .m1
475
    .m1 add radiobutton -label test -indicatoron 0
476
    .m1 invoke test
477
    list [catch {update idletasks} msg] $msg [destroy .m1]
478
} {0 {} {}}
479
test macMenu-13.12 {ReconfigureIndividualMenu - radiobutton on} {
480
    catch {destroy .m1}
481
    menu .m1
482
    .m1 add radiobutton -label test
483
    .m1 invoke test
484
    list [catch {update idletasks} msg] $msg [destroy .m1]
485
} {0 {} {}}
486
test macMenu-13.13 {ReconfigureIndividualMenu} {
487
    catch {destroy .m1}
488
    . configure -menu ""
489
    menu .m1
490
    .m1 add cascade -menu .m3
491
    .m1 entryconfigure 1 -menu .m2
492
    list [catch {update idletasks} msg] $msg [destroy .m1]
493
} {0 {} {}}
494
test macMenu-13.14 {ReconfigureIndividualMenu} {
495
    catch {destroy .m1}
496
    catch {destroy .m2}
497
    . configure -menu ""
498
    menu .m1
499
    .m1 add cascade -menu .m3
500
    menu .m2
501
    .m1 entryconfigure 1 -menu .m2
502
    list [catch {update idletasks} msg] $msg [destroy .m1 .m2]
503
} {0 {} {}}
504
test macMenu-13.15 {ReconfigureIndividualMenu - accelerator} {
505
    catch {destroy .m1}
506
    menu .m1
507
    .m1 add command -accel "Command-S"
508
    list [catch {update idletasks} msg] $msg [destroy .m1]
509
} {0 {} {}}
510
test macMenu-13.16 {ReconfigureIndividualMenu - parent is disabled} {
511
    catch {destroy .m1}
512
    menu .m1
513
    .m1 add cascade -label .m1.edit -label "Edit" -state disabled
514
    menu .m1.edit
515
    .m1.edit add command -label foo
516
    list [catch {update idletasks} msg] $msg [destroy .m1]
517
} {0 {} {}}
518
test macMenu-13.17 {ReconfigureIndividualMenu - disabling parent} {
519
    catch {destroy .m1}
520
    menu .m1
521
    .m1 add cascade -label .m1.edit -label Edit
522
    menu .m1.edit
523
    .m1.edit add command -label foo
524
    .m1 entryconfigure Edit -state disabled
525
    list [catch {update idletasks} msg] $msg [destroy .m1]
526
} {0 {} {}}
527
 
528
test macMenu-14.1 {ReconfigureMacintoshMenu - normal menu} {
529
    catch {destroy .m1}
530
    menu .m1 -tearoff 0
531
    .m1 add command -label test
532
    list [catch {update idletasks} msg] $msg [destroy .m1]
533
} {0 {} {}}
534
test macMenu-14.2 {ReconfigureMacintoshMenu - apple menu} {
535
    catch {destroy .m1}
536
    menu .m1
537
    .m1 add cascade -menu .m1.apple
538
    menu .m1.apple -tearoff 0
539
    .m1.apple add command -label test
540
    . configure -menu .m1
541
    raise .
542
    list [catch {update idletasks} msg] $msg [. configure -menu ""] [destroy .m1]
543
} {0 {} {} {}}
544
test macMenu-14.3 {ReconfigureMacintoshMenu - help menu} {
545
    catch {destroy .m1}
546
    menu .m1
547
    .m1 add cascade -menu .m1.help
548
    menu .m1.help -tearoff 0
549
    .m1.help add command -label test
550
    . configure -menu .m1
551
    raise .
552
    list [catch {update idletasks} msg] $msg [. configure -menu ""] [destroy .m1]
553
} {0 {} {} {}}
554
test macMenu-14.4 {ReconfigureMacintoshMenu - menubar} {
555
    catch {destroy .m1}
556
    menu .m1
557
    .m1 add cascade -menu .m1.file -label "foo"
558
    menu .m1.file
559
    . configure -menu .m1
560
    raise .
561
    .m1 entryconfigure foo -label "File"
562
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
563
} {0 {} {} {}}
564
 
565
test macMenu-15.1 {CompleteIdlers - no idle pending} {
566
    catch {destroy .m1}
567
    menu .m1
568
    .m1 add command -label test
569
    update idletasks
570
    list [catch {.m1 post 40 40} msg] $msg [destroy .m1]
571
} {0 {} {}}
572
test macMenu-15.2 {CompleteIdlers - idle pending} {
573
    catch {destroy .m1}
574
    menu .m1
575
    .m1 add command -label test
576
    list [catch {.m1 post 40 40} msg] $msg [destroy .m1]
577
} {0 {} {}}
578
test macMenu-15.3 {CompleteIdlers - recursive} {
579
    catch {destroy .m1}
580
    menu .m1
581
    .m1 add cascade -menu .m1.m2 -label test
582
    menu .m1.m2
583
    .m1.m2 add command -label test
584
    list [catch {.m1 post 40 40} msg] $msg [destroy .m1]
585
} {0 {} {}}
586
 
587
#Don't know how to generate nested post menus
588
test macMenu-16.1 {TkpPostMenu} {
589
    catch {destroy .m1}
590
    menu .m1 -postcommand "destroy .m1"
591
    list [catch {.m1 post 40 40} msg] $msg
592
} {0 {}}
593
test macMenu-16.2 {TkpPostMenu} {
594
    catch {destroy .m1}
595
    menu .m1 -postcommand "blork"
596
    list [catch {.m1 post 40 40} msg] $msg [destroy .m1]
597
} {1 {invalid command name "blork"} {}}
598
# We need to write the interactive test for menu posting.
599
 
600
test macMenu-17.1 {TkpMenuNewEntry - no idle pending} {
601
    catch {destroy .m1}
602
    menu .m1
603
    list [catch {.m1 add command -label test} msg] $msg [destroy .m1]
604
} {0 {} {}}
605
test macMenu-17.2 {TkpMenuNewEntry - idle pending} {
606
    catch {destroy .m1}
607
    menu .m1
608
    .m1 add command -label test
609
    list [catch {.m1 add command -label test2} msg] $msg [destroy .m1]
610
} {0 {} {}}
611
 
612
test macMenu-18.1 {DrawMenuBarWhenIdle} {
613
    catch {destroy .m1}
614
    . configure -menu ""
615
    menu .m1
616
    . configure -menu .m1
617
    list [catch {update idletasks} msg] $msg [. configure -menu ""] [destroy .m1]
618
} {0 {} {} {}}
619
test macMenu-18.2 {DrawMenuBarWhenIdle - clearing old apple menu out} {
620
    catch {destroy .m1}
621
    menu .m1
622
    .m1 add cascade -menu .m1.apple
623
    menu .m1.apple
624
    .m1.apple add command -label test
625
    . configure -menu .m1
626
    raise .
627
    update
628
    . configure -menu ""
629
    raise .
630
    list [catch {update} msg] $msg [destroy .m1]
631
} {0 {} {}}
632
test macMenu-18.3 {DrawMenuBarWhenIdle - clearing out old help menu} {
633
    catch {destroy .m1}
634
    menu .m1
635
    .m1 add cascade -menu .m1.help
636
    menu .m1.help
637
    .m1.help add command -label test
638
    . configure -menu .m1
639
    raise .
640
    update
641
    . configure -menu ""
642
    raise .
643
    list [catch {update} msg] $msg [destroy .m1]
644
} {0 {} {}}
645
test macMenu-18.4 {DrawMenuBarWhenIdle - menu not there} {
646
    catch {destroy .m1}
647
    . configure -menu .m1
648
    raise .
649
    list [catch {update} msg] $msg [. configure -menu ""]
650
} {0 {} {}}
651
test macMenu-18.5 {DrawMenuBarWhenIdle - menu there} {
652
    catch {destroy .m1}
653
    menu .m1
654
    . configure -menu .m1
655
    raise .
656
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
657
} {0 {} {} {}}
658
test macMenu-18.6 {DrawMenuBarWhenIdle - no apple menu} {
659
    catch {destroy .m1}
660
    menu .m1
661
    . configure -menu .m1
662
    raise .
663
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
664
} {0 {} {} {}}
665
test macMenu-18.7 {DrawMenuBarWhenIdle - apple menu references but not there} {
666
    catch {destroy .m1}
667
    menu .m1
668
    .m1 add cascade -menu .m1.apple
669
    . configure -menu .m1
670
    raise .
671
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
672
} {0 {} {} {}}
673
test macMenu-18.8 {DrawMenuBarWhenIdle - apple menu there} {
674
    catch {destroy .m1}
675
    menu .m1
676
    .m1 add cascade -menu .m1.apple
677
    menu .m1.apple
678
    .m1.apple add command -label test
679
    . configure -menu .m1
680
    raise .
681
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
682
} {0 {} {} {}}
683
test macMenu-18.9 {DrawMenuBarWhenIdle - apple menu there; no idle handler} {
684
    catch {destroy .m1}
685
    menu .m1
686
    .m1 add cascade -menu .m1.apple
687
    menu .m1.apple
688
    .m1.apple add command -label test
689
    . configure -menu .m1
690
    raise .
691
    update idletasks
692
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
693
} {0 {} {} {}}
694
test macMenu-18.10 {DrawMenuBarWhenIdle - no help menu} {
695
    catch {destroy .m1}
696
    menu .m1
697
    . configure -menu .m1
698
    raise .
699
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
700
} {0 {} {} {}}
701
test macMenu-18.11 {DrawMenuBarWhenIdle - help menu referenced but not there} {
702
    catch {destroy .m1}
703
    menu .m1
704
    .m1 add cascade -menu .m1.help
705
    . configure -menu .m1
706
    raise .
707
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
708
} {0 {} {} {}}
709
test macMenu-18.12 {DrawMenuBarWhenIdle - help menu there} {
710
    catch {destroy .m1}
711
    menu .m1
712
    .m1 add cascade -menu .m1.help
713
    menu .m1.help
714
    .m1.help add command -label test
715
    . configure -menu .m1
716
    raise .
717
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
718
} {0 {} {} {}}
719
test macMenu-18.13 {DrawMenuBarWhenIdle - help menu there - no idlers} {
720
    catch {destroy .m1}
721
    menu .m1
722
    .m1 add cascade -menu .m1.help
723
    menu .m1.help
724
    .m1.help add command -label test
725
    . configure -menu .m1
726
    raise .
727
    update idletasks
728
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
729
} {0 {} {} {}}
730
# Can't generate no menubar clone
731
test macMenu-18.14 {DrawMenuBarWhenIdle - apple and help menus in tearoff menubar} {
732
    catch {destroy .m1}
733
    menu .m1
734
    .m1 add cascade -menu .m1.apple
735
    .m1 add cascade -menu .m1.help
736
    menu .m1.apple
737
    menu .m1.help
738
    . configure -menu .m1
739
    raise .
740
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
741
} {0 {} {} {}}
742
test macMenu-18.15 {DrawMenuBarWhenIdle - apple and help menus in non-tearoff menubar} {
743
    catch {destroy .m1}
744
    menu .m1 -tearoff 0
745
    .m1 add cascade -menu .m1.apple
746
    .m1 add cascade -menu .m1.help
747
    menu .m1.apple
748
    menu .m1.help
749
    . configure -menu .m1
750
    raise .
751
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
752
} {0 {} {} {}}
753
test macMenu-18.16 {DrawMenuBarWhenIdle - no apple menu} {
754
    catch {destroy .m1}
755
    menu .m1 -tearoff 0
756
    . configure -menu .m1
757
    raise .
758
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
759
} {0 {} {} {}}
760
test macMenu-18.17 {DrawMenuBarWhenIdle - apple menu} {
761
    catch {destroy .m1}
762
    menu .m1 -tearoff 0
763
    . configure -menu .m1
764
    .m1 add cascade -menu .m1.apple
765
    menu .m1.apple
766
    .m1.apple add cascade -label test -menu .m1.apple.test
767
    menu .m1.apple.test
768
    raise .
769
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
770
} {0 {} {} {}}
771
test macMenu-18.18 {DrawMenuBarWhenIdle - big for loop} {
772
    catch {destroy .m1}
773
    menu .m1 -tearoff 0
774
    menu .m1.apple -tearoff 0
775
    menu .m1.help -tearoff 0
776
    menu .m1.foo -tearoff 0
777
    .m1 add cascade -menu .m1.apple
778
    .m1 add cascade -menu .m1.help
779
    .m1 add cascade -label Foo -menu .m1.foo
780
    . configure -menu .m1
781
    raise .
782
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
783
} {0 {} {} {}}
784
test macMenu-18.19 {DrawMenuBarWhenIdle = disabled menu} {
785
    catch {destroy .m1}
786
    menu .m1 -tearoff 0
787
    menu .m1.edit -tearoff 0
788
    .m1 add cascade -menu .m1.edit -label Edit
789
    . configure -menu .m1
790
    raise .
791
    .m1 entryconfigure Edit -state disabled
792
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
793
} {0 {} {} {}}
794
 
795
test macMenu-19.1 {RecursivelyInsertMenu} {
796
    catch {destroy .m1}
797
    catch {destroy .m2}
798
    catch {destroy .main}
799
    catch {destroy .t2}
800
    toplevel .t2 -menu .main
801
    wm geometry .t2 +0+0
802
    menu .main
803
    .main add cascade -menu .m1 -label ".m1"
804
    menu .m1
805
    .m1 add command -label "Test 2"
806
    .m1 add cascade -label ".m2" -menu .m2
807
    menu .m2
808
    .m2 add command -label "Test 3"
809
    list [catch {raise .t2} msg] $msg [destroy .t2 .main .m1 .m2]
810
} {0 {} {}}
811
test macMenu-19.2 {RecursivelyInsertMenu} {
812
    catch {destroy .m1}
813
    catch {destroy .m2}
814
    catch {destroy .main}
815
    catch {destroy .t2}
816
    toplevel .t2 -menu .main
817
    wm geometry .t2 +0+0
818
    menu .main
819
    .main add cascade -menu .m1 -label ".m1"
820
    menu .m1
821
    .m1 add command -label "Test 2"
822
    .m1 add cascade -label ".m2" -menu .m2
823
    menu .m2
824
    .m2 add command -label "Test 3"
825
    list [catch {raise .t2} msg] $msg [destroy .t2 .main .m1 .m2]
826
} {0 {} {}}
827
 
828
test macMenu-20.1 {SetDefaultMenuBar} {
829
    . configure -menu ""
830
    raise .
831
    list [catch {update} msg] $msg
832
} {0 {}}
833
 
834
test macMenu-21.1 {TkpSetMainMenubar - not front window} {
835
    catch {destroy .m1}
836
    catch {destroy .t2}
837
    toplevel .t2
838
    wm geometry .t2 +50+50
839
    menu .m1
840
    raise .
841
    update
842
    list [catch {.t2 configure -menu .m1} msg] $msg [destroy .t2] [destroy .m1]
843
} {0 {} {} {}}
844
test macMenu-21.2 {TkpSetMainMenubar - menu null} {
845
    . configure -menu ""
846
    raise .
847
    list [catch {update} msg] $msg
848
} {0 {}}
849
test macMenu-21.3 {TkpSetMainMenubar - different interps} {
850
    catch {destroy .m1}
851
    catch {interp delete testinterp}
852
    interp create testinterp
853
    load {} tk testinterp
854
    menu .m1
855
    . configure -menu .m1
856
    raise .
857
    update
858
    interp eval testinterp {menu .m1}
859
    interp eval testinterp {. configure -menu .m1}
860
    interp eval testinterp {raise .}
861
    list [catch {interp eval testinterp {update}} msg] $msg [interp delete testinterp] [. configure -menu ""] [destroy .m1]
862
} {0 {} {} {} {}}
863
test macMenu-21.4 {TkpSetMainMenubar - different windows} {
864
    catch {destroy .m1}
865
    catch {destroy .t2}
866
    menu .m1
867
    . configure -menu .m1
868
    toplevel .t2
869
    wm geometry .t2 +50+50
870
    .t2 configure -menu .m1
871
    raise .
872
    update
873
    raise .t2
874
    list [catch {update} msg] $msg [destroy .t2] [. configure -menu ""] [destroy .m1]
875
} {0 {} {} {} {}}
876
test macMenu-21.5 {TkpSetMainMenubar - old menu was null} {
877
    catch {destroy .m1}
878
    . configure -menu ""
879
    update
880
    menu .m1
881
    . configure -menu .m1
882
    raise .
883
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
884
} {0 {} {} {}}
885
test macMenu-21.6 {TkpSetMainMenubar - old menu different} {
886
    catch {destroy .m1}
887
    catch {destroy .m2}
888
    menu .m1
889
    menu .m2
890
    . configure -menu .m1
891
    raise .
892
    update
893
    . configure -menu .m2
894
    raise .
895
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1] [destroy .m2]
896
} {0 {} {} {} {}}
897
test macMenu-21.7 {TkpSetMainMenubar - child window NULL - parent window now} {
898
    catch {destroy .m1}
899
    catch {destroy .t2}
900
    toplevel .t2
901
    menu .m1
902
    .m1 add cascade -label Foo -menu .m1.foo
903
    menu .m1.foo
904
    .m1.foo add command -label foo
905
    . configure -menu .m1
906
    raise .t2
907
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1] [destroy .t2]
908
} {0 {} {} {} {}}
909
test macMenu-21.8 {TkpSetMainMenubar - tearoff window} {
910
    catch {destroy .t2}
911
    toplevel .t2 -menu .t2.m1
912
    menu .t2.m1
913
    .t2.m1 add cascade -label File -menu .t2.m1.foo
914
    menu .t2.m1.foo
915
    .t2.m1.foo add command -label foo
916
    raise .t2
917
    tkTearOffMenu .t2.m1.foo 100 100
918
    list [catch {update} msg] $msg [destroy .t2]
919
} {0 {} {}}
920
 
921
test macMenu-22.1 {TkSetWindowMenuBar} {
922
} {}
923
 
924
test macMenu-23.1 {TkMacDispatchMenuEvent} {
925
    # needs to be interactive.
926
} {}
927
 
928
test macMenu-24.1 {GetMenuIndicatorGeometry} {
929
    catch {destroy .m1}
930
    menu .m1
931
    .m1 add checkbutton -label foo
932
    .m1 invoke foo
933
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
934
} {0 {}}
935
 
936
test macMenu-25.1 {GetMenuAccelGeometry - cascade entry} {
937
    catch {destroy .m1}
938
    menu .m1
939
    .m1 add cascade -label foo
940
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
941
} {0 {}}
942
test macMenu-25.2 {GetMenuAccelGeometry - no accel} {
943
    catch {destroy .m1}
944
    menu .m1
945
    .m1 add command
946
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
947
} {0 {}}
948
test macMenu-25.3 {GetMenuAccelGeometry - no special chars - arbitrary string} {
949
    catch {destroy .m1}
950
    menu .m1
951
    .m1 add command -accel "Test"
952
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
953
} {0 {}}
954
test macMenu-25.4 {GetMenuAccelGeometry - Command} {
955
    catch {destroy .m1}
956
    menu .m1
957
    .m1 add command -label foo -accel "Cmd+S"
958
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
959
} {0 {}}
960
test macMenu-25.5 {GetMenuAccelGeometry - Control} {
961
    catch {destroy .m1}
962
    menu .m1
963
    .m1 add command -label foo -accel "Ctrl+S"
964
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
965
} {0 {}}
966
test macMenu-25.6 {GetMenuAccelGeometry - Shift} {
967
    catch {destroy .m1}
968
    menu .m1
969
    .m1 add command -label foo -accel "Shift+S"
970
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
971
} {0 {}}
972
test macMenu-25.7 {GetMenuAccelGeometry - Option} {
973
    catch {destroy .m1}
974
    menu .m1
975
    .m1 add command -label foo -accel "Opt+S"
976
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
977
} {0 {}}
978
test macMenu-25.8 {GetMenuAccelGeometry - Combination} {
979
    catch {destroy .m1}
980
    menu .m1
981
    .m1 add command -label foo -accel "Cmd+Shift+S"
982
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
983
} {0 {}}
984
test macMenu-25.9 {GetMenuAccelGeometry - extra text} {
985
    catch {destroy .m1}
986
    menu .m1
987
    .m1 add command -label foo -accel "Command+Delete"
988
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
989
} {0 {}}
990
 
991
test macMenu-26.1 {GetTearoffEntryGeometry} {
992
    # can't call this on power mac.
993
} {}
994
 
995
test macMenu-27.1 {GetMenuSeparatorGeometry} {
996
    catch {destroy .m1}
997
    menu .m1
998
    .m1 add separator
999
    list [catch {tkTearOffMenu .m1 40 40}] [destroy .m1]
1000
} {0 {}}
1001
 
1002
test macMenu-28.1 {DrawMenuEntryIndicator - non-checkbutton} {
1003
    catch {destroy .m1}
1004
    menu .m1
1005
    .m1 add command -label foo
1006
    set tearoff [tkTearOffMenu .m1 40 40]
1007
    list [catch {update} msg] $msg [destroy .m1]
1008
} {0 {} {}}
1009
test macMenu-28.2 {DrawMenuEntryIndicator - indicator off} {
1010
    catch {destroy .m1}
1011
    menu .m1
1012
    .m1 add checkbutton -label foo -indicatoron 0
1013
    .m1 invoke foo
1014
    set tearoff [tkTearOffMenu .m1 40 40]
1015
    list [catch {update} msg] $msg [destroy .m1]
1016
} {0 {} {}}
1017
test macMenu-28.3 {DrawMenuEntryIndicator - not selected} {
1018
    catch {destroy .m1}
1019
    menu .m1
1020
    .m1 add checkbutton -label foo
1021
    set tearoff [tkTearOffMenu .m1 40 40]
1022
    list [catch {update} msg] $msg [destroy .m1]
1023
} {0 {} {}}
1024
test macMenu-28.4 {DrawMenuEntryIndicator - checkbutton} {
1025
    catch {destroy .m1}
1026
    menu .m1
1027
    .m1 add checkbutton -label foo
1028
    .m1 invoke foo
1029
    set tearoff [tkTearOffMenu .m1 40 40]
1030
    list [catch {update} msg] $msg [destroy .m1]
1031
} {0 {} {}}
1032
test macMenu-28.5 {DrawMenuEntryIndicator - radiobutton} {
1033
    catch {destroy .m1}
1034
    menu .m1
1035
    .m1 add radiobutton -label foo
1036
    .m1 invoke foo
1037
    set tearoff [tkTearOffMenu .m1 40 40]
1038
    list [catch {update} msg] $msg [destroy .m1]
1039
} {0 {} {}}
1040
 
1041
# Cannot reproduce resources missing or color allocation failing easily.
1042
test macMenu-29.1 {DrawSICN} {
1043
   catch {destroy .m1}
1044
   menu .m1
1045
   .m1 add command -label foo -accel "Cmd+S"
1046
   set tearoff [tkTearOffMenu .m1 40 40]
1047
   list [catch {update} msg] $msg [destroy .m1]
1048
} {0 {} {}}
1049
 
1050
# Cannot reproduce resources missing
1051
test macMenu-30.1 {DrawMenuEntryAccelerator - cascade entry} {
1052
    catch {destroy .m1}
1053
    menu .m1
1054
    .m1 add cascade -label foo
1055
    set tearoff [tkTearOffMenu .m1 40 40]
1056
    list [catch {update} msg] $msg [destroy .m1]
1057
} {0 {} {}}
1058
test macMenu-30.2 {DrawMenuEntryAccelerator - no accel string} {
1059
    catch {destroy .m1}
1060
    menu .m1
1061
    .m1 add command -label foo
1062
    set tearoff [tkTearOffMenu .m1 40 40]
1063
    list [catch {update} msg] $msg [destroy .m1]
1064
} {0 {} {}}
1065
test macMenu-30.3 {DrawMenuEntryAccelerator - random accel string} {
1066
    catch {destroy .m1}
1067
    menu .m1
1068
    .m1 add command -label foo -accel foo
1069
    set tearoff [tkTearOffMenu .m1 40 40]
1070
    list [catch {update} msg] $msg [destroy .m1]
1071
} {0 {} {}}
1072
test macMenu-30.4 {DrawMenuEntryAccelerator - Command} {
1073
    catch {destroy .m1}
1074
    menu .m1
1075
    .m1 add command -label foo -accel "Cmd+S"
1076
    set tearoff [tkTearOffMenu .m1 40 40]
1077
    list [catch {update} msg] $msg [destroy .m1]
1078
} {0 {} {}}
1079
test macMenu-30.5 {DrawMenuEntryAccelerator - Option} {
1080
    catch {destroy .m1}
1081
    menu .m1
1082
    .m1 add command -label foo -accel "Opt+S"
1083
    set tearoff [tkTearOffMenu .m1 40 40]
1084
    list [catch {update} msg] $msg [destroy .m1]
1085
} {0 {} {}}
1086
test macMenu-30.6 {DrawMenuEntryAccelerator - Shift} {
1087
    catch {destroy .m1}
1088
    menu .m1
1089
    .m1 add command -label foo -accel "Shift+S"
1090
    set tearoff [tkTearOffMenu .m1 40 40]
1091
    list [catch {update} msg] $msg [destroy .m1]
1092
} {0 {} {}}
1093
test macMenu-30.7 {DrawMenuEntryAccelerator - Control} {
1094
    catch {destroy .m1}
1095
    menu .m1
1096
    .m1 add command -label foo -accel "Ctrl+S"
1097
    set tearoff [tkTearOffMenu .m1 40 40]
1098
    list [catch {update} msg] $msg [destroy .m1]
1099
} {0 {} {}}
1100
test macMenu-30.8 {DrawMenuEntryAccelerator - combination} {
1101
    catch {destroy .m1}
1102
    menu .m1
1103
    .m1 add command -label foo -accel "Cmd+Shift+S"
1104
    set tearoff [tkTearOffMenu .m1 40 40]
1105
    list [catch {update} msg] $msg [destroy .m1]
1106
} {0 {} {}}
1107
 
1108
test macMenu-31.1 {DrawMenuSeparator} {
1109
    catch {destroy .m1}
1110
    menu .m1
1111
    .m1 add separator
1112
    set tearoff [tkTearOffMenu .m1 40 40]
1113
    list [catch {update} msg] $msg [destroy .m1]
1114
} {0 {} {}}
1115
 
1116
test macMenu-32.1 {TkpDrawMenuEntryLabel} {
1117
    catch {destroy .m1}
1118
    menu .m1
1119
    .m1 add command -label foo
1120
    set tearoff [tkTearOffMenu .m1 40 40]
1121
    list [catch {update} msg] $msg [destroy .m1]
1122
} {0 {} {}}
1123
 
1124
test macMenu-33.1 {MenuDefProc - No way to test automatically.} {} {}
1125
test macMenu-34.1 {TkMacHandleTearoffMenu - no way to test automatically} {} {}
1126
test macMenu-35.1 {TkpInitializeMenuBindings - nothing to do} {} {}
1127
 
1128
test macMenu-36.1 {TkpComputeMenubarGeometry} {
1129
    catch {destroy .m1}
1130
    menu .m1
1131
    .m1 add cascade -label foo
1132
    . configure -menu .m1
1133
    list [catch {update} msg] $msg [. configure -menu ""] [destroy .m1]
1134
} {0 {} {} {}}
1135
 
1136
test macMenu-37.1 {DrawTearoffEntry - can't do automatically} {} {}
1137
test macMenu-38.1 {TkMacSetHelpMenuItemCount - called at boot time} {} {}
1138
test macMenu-39.1 {TkMacMenuClick - can't do automatically} {} {}
1139
 
1140
test macMenu-40.1 {TkpDrawMenuEntry - gc for active and not strict motif} {
1141
    catch {destroy .m1}
1142
    menu .m1
1143
    .m1 add command -label foo
1144
    set tearoff [tkTearOffMenu .m1 40 40]
1145
    .m1 entryconfigure 1 -state active
1146
    list [update] [destroy .m1]
1147
} {{} {}}
1148
test macMenu-40.2 {TkpDrawMenuEntry - gc for active menu item with its own gc} {
1149
    catch {destroy .m1}
1150
    menu .m1
1151
    .m1 add command -label foo -activeforeground red
1152
    set tearoff [tkTearOffMenu .m1 40 40]
1153
    .m1 entryconfigure 1 -state active
1154
    list [update] [destroy .m1]
1155
} {{} {}}
1156
test macMenu-40.3 {TkpDrawMenuEntry - gc for active and strict motif} {
1157
    catch {destroy .m1}
1158
    menu .m1
1159
    set tk_strictMotif 1
1160
    .m1 add command -label foo
1161
    set tearoff [tkTearOffMenu .m1 40 40]
1162
    .m1 entryconfigure 1 -state active
1163
    list [update] [destroy .m1] [set tk_strictMotif 0]
1164
} {{} {} 0}
1165
test macMenu-40.4 {TkpDrawMenuEntry - gc for disabled with disabledfg and custom entry} {
1166
    catch {destroy .m1}
1167
    menu .m1 -disabledforeground blue
1168
    .m1 add command -label foo -state disabled -background red
1169
    set tearoff [tkTearOffMenu .m1 40 40]
1170
    list [update] [destroy .m1]
1171
} {{} {}}
1172
test macMenu-40.5 {TkpDrawMenuEntry - gc for disabled with disabledFg} {
1173
    catch {destroy .m1}
1174
    menu .m1 -disabledforeground blue
1175
    .m1 add command -label foo -state disabled
1176
    set tearoff [tkTearOffMenu .m1 40 40]
1177
    list [update] [destroy .m1]
1178
} {{} {}}
1179
test macMenu-40.6 {TkpDrawMenuEntry - gc for disabled - no disabledFg} {
1180
    catch {destroy .m1}
1181
    menu .m1 -disabledforeground ""
1182
    .m1 add command -label foo -state disabled
1183
    set tearoff [tkTearOffMenu .m1 40 40]
1184
    list [update] [destroy .m1]
1185
} {{} {}}
1186
test macMenu-40.7 {TkpDrawMenuEntry - gc for normal - custom entry} {
1187
    catch {destroy .m1}
1188
    menu .m1
1189
    .m1 add command -label foo -foreground red
1190
    set tearoff [tkTearOffMenu .m1 40 40]
1191
    list [update] [destroy .m1]
1192
} {{} {}}
1193
test macMenu-40.8 {TkpDrawMenuEntry - gc for normal} {
1194
    catch {destroy .m1}
1195
    menu .m1
1196
    .m1 add command -label foo
1197
    set tearoff [tkTearOffMenu .m1 40 40]
1198
    list [update] [destroy .m1]
1199
} {{} {}}
1200
test macMenu-40.9 {TkpDrawMenuEntry - gc for indicator - custom entry} {
1201
    catch {destroy .m1}
1202
    menu .m1
1203
    .m1 add checkbutton -label foo -selectcolor orange
1204
    .m1 invoke 1
1205
    set tearoff [tkTearOffMenu .m1 40 40]
1206
    list [update] [destroy .m1]
1207
} {{} {}}
1208
test macMenu-40.10 {TkpDrawMenuEntry - gc for indicator} {
1209
    catch {destroy .m1}
1210
    menu .m1
1211
    .m1 add checkbutton -label foo
1212
    .m1 invoke 1
1213
    set tearoff [tkTearOffMenu .m1 40 40]
1214
    list [update] [destroy .m1]
1215
} {{} {}}
1216
test macMenu-40.11 {TkpDrawMenuEntry - border - custom entry} {
1217
    catch {destroy .m1}
1218
    menu .m1
1219
    .m1 add command -label foo -activebackground green
1220
    set tearoff [tkTearOffMenu .m1 40 40]
1221
    .m1 entryconfigure 1 -state active
1222
    list [update] [destroy .m1]
1223
} {{} {}}
1224
test macMenu-40.12 {TkpDrawMenuEntry - border} {
1225
    catch {destroy .m1}
1226
    menu .m1
1227
    .m1 add command -label foo
1228
    set tearoff [tkTearOffMenu .m1 40 40]
1229
    .m1 entryconfigure 1 -state active
1230
    list [update] [destroy .m1]
1231
} {{} {}}
1232
test macMenu-40.13 {TkpDrawMenuEntry - active border - strict motif} {
1233
    catch {destroy .m1}
1234
    set tk_strictMotif 1
1235
    menu .m1
1236
    .m1 add command -label foo
1237
    set tearoff [tkTearOffMenu .m1 40 40]
1238
    .m1 entryconfigure 1 -state active
1239
    list [update] [destroy .m1] [set tk_strictMotif 0]
1240
} {{} {} 0}
1241
test macMenu-40.14 {TkpDrawMenuEntry - active border - custom entry} {
1242
    catch {destroy .m1}
1243
    menu .m1
1244
    .m1 add command -label foo -activeforeground yellow
1245
    set tearoff [tkTearOffMenu .m1 40 40]
1246
    .m1 entryconfigure 1 -state active
1247
    list [update] [destroy .m1]
1248
} {{} {}}
1249
test macMenu-40.15 {TkpDrawMenuEntry - active border} {
1250
    catch {destroy .m1}
1251
    menu .m1
1252
    .m1 add command -label foo
1253
    set tearoff [tkTearOffMenu .m1 40 40]
1254
    .m1 entryconfigure 1 -state active
1255
    list [update] [destroy .m1]
1256
} {{} {}}
1257
test macMenu-40.16 {TkpDrawMenuEntry - font - custom entry} {
1258
    catch {destroy .m1}
1259
    menu .m1
1260
    .m1 add command -label foo -font "Helvectica 72"
1261
    set tearoff [tkTearOffMenu .m1 40 40]
1262
    list [update] [destroy .m1]
1263
} {{} {}}
1264
test macMenu-40.17 {TkpDrawMenuEntry - font} {
1265
    catch {destroy .m1}
1266
    menu .m1 -font "Courier 72"
1267
    .m1 add command -label foo
1268
    set tearoff [tkTearOffMenu .m1 40 40]
1269
    list [update] [destroy .m1]
1270
} {{} {}}
1271
test macMenu-40.18 {TkpDrawMenuEntry - separator} {
1272
    catch {destroy .m1}
1273
    menu .m1
1274
    .m1 add separator
1275
    set tearoff [tkTearOffMenu .m1 40 40]
1276
    list [update] [destroy .m1]
1277
} {{} {}}
1278
test macMenu-40.19 {TkpDrawMenuEntry - standard} {
1279
    catch {destroy .mb}
1280
    menu .m1
1281
    .m1 add command -label foo
1282
    set tearoff [tkTearOffMenu .m1 40 40]
1283
    list [update] [destroy .m1]
1284
} {{} {}}
1285
test macMenu-40.20 {TkpDrawMenuEntry - disabled cascade item} {
1286
    catch {destroy .m1}
1287
    menu .m1
1288
    .m1 add cascade -label File -menu .m1.file
1289
    menu .m1.file
1290
    .m1.file add command -label foo
1291
    .m1 entryconfigure File -state disabled
1292
    set tearoff [tkTearOffMenu .m1 40 40]
1293
    list [update] [destroy .m1]
1294
} {{} {}}
1295
test macMenu-40.21 {TkpDrawMenuEntry - indicator} {
1296
    catch {destroy .m1}
1297
    menu .m1
1298
    .m1 add checkbutton -label macMenu-40.20
1299
    .m1 invoke 0
1300
    set tearoff [tkTearOffMenu .m1 40 40]
1301
    list [update] [destroy .m1]
1302
} {{} {}}
1303
test macMenu-40.22 {TkpDrawMenuEntry - indicator - hideMargin} {
1304
    catch {destroy .m1}
1305
    menu .m1
1306
    .m1 add checkbutton -label macMenu-40.21 -hidemargin 1
1307
    .m1 invoke 0
1308
    set tearoff [tkTearOffMenu .m1 40 40]
1309
    list [update] [destroy .m1]
1310
} {{} {}}
1311
 
1312
test macMenu-41.1 {TkpComputeStandardMenuGeometry - no entries} {
1313
    catch {destroy .m1}
1314
    menu .m1
1315
    list [update idletasks] [destroy .m1]
1316
} {{} {}}
1317
test macMenu-41.2 {TkpComputeStandardMenuGeometry - one entry} {
1318
    catch {destroy .m1}
1319
    menu .m1
1320
    .m1 add command -label "one"
1321
    list [update idletasks] [destroy .m1]
1322
} {{} {}}
1323
test macMenu-41.3 {TkpComputeStandardMenuGeometry - more than one entry} {
1324
    catch {destroy .m1}
1325
    menu .m1
1326
    .m1 add command -label "one"
1327
    .m1 add command -label "two"
1328
    list [update idletasks] [destroy .m1]
1329
} {{} {}}
1330
test macMenu-41.4 {TkpComputeStandardMenuGeometry - separator} {
1331
    catch {destroy .m1}
1332
    menu .m1
1333
    .m1 add separator
1334
    list [update idletasks] [destroy .m1]
1335
} {{} {}}
1336
test macMenu-41.5 {TkpComputeStandardMenuGeometry - standard label geometry} {
1337
    catch {destroy .m1}
1338
    menu .m1
1339
    .m1 add command -label "test"
1340
    list [update idletasks] [destroy .m1]
1341
} {{} {}}
1342
test macMenu-41.6 {TkpComputeStandardMenuGeometry - different font for entry} {
1343
    catch {destroy .m1}
1344
    menu .m1 -font "Helvetica 12"
1345
    .m1 add command -label "test" -font "Courier 12"
1346
    list [update idletasks] [destroy .m1]
1347
} {{} {}}
1348
test macMenu-41.7 {TkpComputeStandardMenuGeometry - second entry larger} {
1349
    catch {destroy .m1}
1350
    menu .m1
1351
    .m1 add command -label "test"
1352
    .m1 add command -label "test test"
1353
    list [update idletasks] [destroy .m1]
1354
} {{} {}}
1355
test macMenu-41.8 {TkpComputeStandardMenuGeometry - first entry larger} {
1356
    catch {destroy .m1}
1357
    menu .m1
1358
    .m1 add command -label "test test"
1359
    .m1 add command -label "test"
1360
    list [update idletasks] [destroy .m1]
1361
} {{} {}}
1362
test macMenu-41.9 {TkpComputeStandardMenuGeometry - accelerator} {
1363
    catch {destroy .m1}
1364
    menu .m1
1365
    .m1 add command -label "test" -accel "Ctrl+S"
1366
    list [update idletasks] [destroy .m1]
1367
} {{} {}}
1368
test macMenu-41.10 {TkpComputeStandardMenuGeometry - second accel larger} {
1369
    catch {destroy .m1}
1370
    menu .m1
1371
    .m1 add command -label "test" -accel "1"
1372
    .m1 add command -label "test" -accel "1 1"
1373
    list [update idletasks] [destroy .m1]
1374
} {{} {}}
1375
test macMenu-41.11 {TkpComputeStandardMenuGeometry - second accel smaller} {
1376
    catch {destroy .m1}
1377
    menu .m1
1378
    .m1 add command -label "test" -accel "1 1"
1379
    .m1 add command -label "test" -accel "1"
1380
    list [update idletasks] [destroy .m1]
1381
} {{} {}}
1382
test macMenu-41.12 {TkpComputeStandardMenuGeometry - indicator} {
1383
    catch {destroy .m1}
1384
    menu .m1
1385
    .m1 add checkbutton -label test
1386
    .m1 invoke 1
1387
    list [update idletasks] [destroy .m1]
1388
} {{} {}}
1389
test macMenu-41.13 {TkpComputeStandardMenuGeometry - second indicator less or equal } {
1390
    catch {destroy .m1}
1391
    catch {image delete image1}
1392
    image create test image1
1393
    menu .m1
1394
    .m1 add checkbutton -image image1
1395
    .m1 invoke 1
1396
    .m1 add checkbutton -label test
1397
    .m1 invoke 2
1398
    list [update idletasks] [destroy .m1] [image delete image1]
1399
} {{} {} {}}
1400
test macMenu-41.14 {TkpComputeStandardMenuGeometry - hidden margin} {
1401
    catch {destroy .m1}
1402
    menu .m1
1403
    .m1 add checkbutton -label macMenu-41.15 -hidemargin 1
1404
    .m1 invoke macMenu-41.15
1405
    list [update idletasks] [destroy .m1]
1406
} {{} {}}
1407
test macMenu-41.15 {TkpComputeStandardMenuGeometry - zero sized menus} {
1408
    catch {destroy .m1}
1409
    menu .m1 -tearoff 0
1410
    list [update idletasks] [destroy .m1]
1411
} {{} {}}
1412
test macMenu-41.16 {TkpComputeStandardMenuGeometry - first column bigger} {
1413
    catch {destroy .m1}
1414
    menu .m1
1415
    .m1 add command -label one
1416
    .m1 add command -label two
1417
    .m1 add command -label three -columnbreak 1
1418
    list [update idletasks] [destroy .m1]
1419
} {{} {}}
1420
test macMenu-41.17 {TkpComputeStandardMenuGeometry - second column bigger} {
1421
    catch {destroy .m1}
1422
    menu .m1 -tearoff 0
1423
    .m1 add command -label one
1424
    .m1 add command -label two -columnbreak 1
1425
    .m1 add command -label three
1426
    list [update idletasks] [destroy .m1]
1427
} {{} {}}
1428
test macMenu-41.18 {TkpComputeStandardMenuGeometry - three columns} {
1429
    catch {destroy .m1}
1430
    menu .m1 -tearoff 0
1431
    .m1 add command -label one
1432
    .m1 add command -label two -columnbreak 1
1433
    .m1 add command -label three
1434
    .m1 add command -label four
1435
    .m1 add command -label five -columnbreak 1
1436
    .m1 add command -label six
1437
    list [update idletasks] [destroy .m1]
1438
} {{} {}}
1439
test macMenu-41.19 {TkpComputeStandardMenuGeometry - entry without accel long} {
1440
    catch {destroy .m1}
1441
    menu .m1 -tearoff 0
1442
    .m1 add command -label "This is a long item with no accel."
1443
    .m1 add command -label foo -accel "Cmd+S"
1444
    list [update idletasks] [destroy .m1]
1445
} {{} {}}
1446
test macMenu-41.20 {TkpComputeStandardMenuGeometry - entry with accel long} {
1447
    catch {destroy .m1}
1448
    menu .m1 -tearoff 0
1449
    .m1 add command -label foo
1450
    .m1 add command -label "This is a long label with an accel." -accel "Cmd+W"
1451
    list [update idletasks] [destroy .m1]
1452
} {{} {}}
1453
 
1454
test macMenu-42.1 {DrawMenuEntryLabel - setting indicatorSpace} {
1455
    catch {destroy .m1}
1456
    menu .m1
1457
    .m1 add command -label "foo"
1458
    set tearoff [tkTearOffMenu .m1]
1459
    list [update idletasks] [destroy .m1]
1460
} {{} {}}
1461
test macMenu-42.2 {DrawMenuEntryLabel - drawing image} {
1462
    catch {destroy .m1}
1463
    catch {image delete image1}
1464
    image create test image1
1465
    menu .m1
1466
    .m1 add command -image image1
1467
    set tearoff [tkTearOffMenu .m1]
1468
    list [update idletasks] [destroy .m1] [image delete image1]
1469
} {{} {} {}}
1470
test macMenu-42.3 {DrawMenuEntryLabel - drawing select image} {
1471
    catch {destroy .m1}
1472
    catch {eval image delete [image names]}
1473
    image create test image1
1474
    image create test image2
1475
    menu .m1
1476
    .m1 add checkbutton -image image1 -selectimage image2
1477
    .m1 invoke 1
1478
    set tearoff [tkTearOffMenu .m1]
1479
    list [update idletasks] [destroy .m1] [eval image delete [image names]]
1480
} {{} {} {}}
1481
test macMenu-42.4 {DrawMenuEntryLabel - drawing a bitmap} {
1482
    catch {destroy .m1}
1483
    menu .m1
1484
    .m1 add command -bitmap questhead
1485
    set tearoff [tkTearOffMenu .m1]
1486
    list [update idletasks] [destroy .m1]
1487
} {{} {}}
1488
test macMenu-42.5 {DrawMenuEntryLabel - drawing null label} {
1489
    catch {destroy .m1}
1490
    menu .m1
1491
    .m1 add command
1492
    set tearoff [tkTearOffMenu .m1]
1493
    list [update idletasks] [destroy .m1]
1494
} {{} {}}
1495
test macMenu-42.6 {DrawMenuEntryLabel - drawing real label} {
1496
    catch {destroy .m1}
1497
    menu .m1
1498
    .m1 add command -label "This is a long label" -underline 3
1499
    set tearoff [tkTearOffMenu .m1]
1500
    list [update idletasks] [destroy .m1]
1501
} {{} {}}
1502
test macMenu-42.7 {DrawMenuEntryLabel - drawing disabled label} {
1503
        catch {destroy .m1}
1504
        menu .m1 -disabledforeground ""
1505
        .m1 add command -label "This is a long label" -state disabled
1506
        set tearoff [tkTearOffMenu .m1]
1507
        list [update idletasks] [destroy .m1]
1508
} {{} {}}
1509
test macMenu-42.8 {DrawMenuEntryLabel - disabled images} {
1510
        catch {destroy .m1}
1511
        catch {image delete image1}
1512
        image create test image1
1513
        menu .m1
1514
        .m1 add command -image image1 -state disabled
1515
        set tearoff [tkTearOffMenu .m1 100 100]
1516
        list [update idletasks] [destroy .m1] [image delete image1]
1517
} {{} {} {}}
1518
 
1519
test macMenu-43.1 {GetMenuLabelGeometry - image} {
1520
    catch {destroy .m1}
1521
    catch {image delete image1}
1522
    menu .m1
1523
    image create test image1
1524
    .m1 add command -image image1
1525
    list [update idletasks] [destroy .m1] [image delete image1]
1526
} {{} {} {}}
1527
test macMenu-43.2 {GetMenuLabelGeometry - bitmap} {
1528
    catch {destroy .m1}
1529
    menu .m1
1530
    .m1 add command -bitmap questhead
1531
    list [update idletasks] [destroy .m1]
1532
} {{} {}}
1533
test macMenu-43.3 {GetMenuLabelGeometry - no text} {
1534
    catch {destroy .m1}
1535
    menu .m1
1536
    .m1 add command
1537
    list [update idletasks] [destroy .m1]
1538
} {{} {}}
1539
test macMenu-43.4 {GetMenuLabelGeometry - text} {
1540
    catch {destroy .m1}
1541
    menu .m1
1542
    .m1 add command -label "This is a test."
1543
    list [update idletasks] [destroy .m1]
1544
} {{} {}}
1545
 
1546
test macMenu-44.1 {DrawMenuEntryBackground} {
1547
    catch {destroy .m1}
1548
    menu .m1
1549
    .m1 add command -label foo
1550
    set tearoff [tkTearOffMenu .m1 40 40]
1551
    list [update] [destroy .m1]
1552
} {{} {}}
1553
test macMenu-44.2 {DrawMenuEntryBackground} {
1554
    catch {destroy .m1}
1555
    menu .m1
1556
    .m1 add command -label foo
1557
    set tearoff [tkTearOffMenu .m1 40 40]
1558
    $tearoff activate 0
1559
    list [update] [destroy .m1]
1560
} {{} {}}
1561
 
1562
test macMenu-45.1 {TkpMenuInit - called at boot time} {} {}
1563
 
1564
deleteWindows
1565
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.