1 # This file is a Tcl script to test menus in Tk. It is
2 # organized in the standard fashion for Tcl tests. It tests
3 # the common implementation of Macintosh and Windows menus.
5 # Copyright (c) 1995-1996 Sun Microsystems, Inc.
6 # Copyright (c) 1998-1999 by Scriptics Corporation.
11 package require tcltest 2.1
12 namespace import -force tcltest::configure
13 namespace import -force tcltest::testsDirectory
14 configure -testdir [file join [pwd] [file dirname [info script]]]
15 configure -loadfile [file join [testsDirectory] constraints.tcl]
16 tcltest::loadTestedCommands
18 test macWinMenu-1.1 {PreprocessMenu} {macOrPc nonUnixUserInteraction} {
20 menu .m1 -postcommand "destroy .m1"
21 .m1 add command -label "macWinMenu-1.1: Hit Escape"
22 list [catch {.m1 post 40 40} msg] $msg
24 test macWinMenu-1.2 {PreprocessMenu} {macOrPc nonUnixUserInteraction} {
29 menu .m1 -postcommand "set foo1 .m1"
30 .m1 add cascade -menu .m2 -label "macWinMenu-1.2: Hit Escape"
31 menu .m2 -postcommand "set foo2 .m2"
33 list [catch {.m1 post 40 40} msg] $msg [set foo1] [set foo2] \
34 [destroy .m1 .m2] [catch {unset foo1}] [catch {unset foo2}]
35 } {0 .m2 .m1 .m2 {} 0 0}
37 test macWinMenu-1.3 {PreprocessMenu} {macOrPc nonUnixUserInteraction} {
42 label .l1 -text "Preparing menus..."
45 menu .m1 -postcommand ".l1 configure -text \"Destroying .m1...\"; update idletasks; destroy .m1"
46 menu .m2 -postcommand ".l1 configure -text \"Destroying .m2...\"; update idletasks; destroy .m2"
47 menu .m3 -postcommand ".l1 configure -text \"Destroying .m3...\"; update idletasks; destroy .m3"
48 .m1 add cascade -menu .m2 -label "macWinMenu-1.3: Hit Escape (.m2)"
49 .m1 add cascade -menu .m3 -label ".m3"
51 list [catch {.m1 post 40 40} msg] $msg [destroy .l1 .m2 .m3]
53 test macWinMenu-1.4 {PreprocessMenu} {macOrPc} {
59 label .l1 -text "Preparing menus..."
62 menu .m1 -postcommand ".l1 configure -text \"Destroying .m1...\"; update idletasks; destroy .m1"
63 .m1 add cascade -menu .m2 -label "macWinMenu-1.4: Hit Escape (.m2)"
64 .m1 add cascade -menu .m3 -label ".m3"
65 menu .m2 -postcommand ".l1 configure -text \"Destroying .m2...\"; update idletasks; destroy .m2"
66 .m2 add cascade -menu .m4 -label ".m4"
67 menu .m3 -postcommand ".l1 configure -text \"Destroying .m3...\"; update idletasks; destroy .m3"
68 menu .m4 -postcommand ".l1 configure -text \"Destroying .m4...\"; update idletasks; destroy .m4"
70 list [catch {.m1 post 40 40} msg] $msg [destroy .l1 .m2 .m3 .m4]
72 test macWinMenu-1.5 {PreprocessMenu} {macOrPc} {
76 .m1 add cascade -menu .m2 -label "You may need to hit Escape to get this menu to go away."
77 menu .m2 -postcommand glorp
78 list [catch {.m1 post 40 40} msg] $msg [destroy .m1 .m2]
79 } {1 {invalid command name "glorp"} {}}
81 test macWinMenu-2.1 {TkPreprocessMenu} {macOrPc nonUnixUserInteraction} {
84 menu .m1 -postcommand "set foo 2.1"
85 .m1 add command -label "macWinMenu-2.1: Hit Escape"
86 list [catch {.m1 post 40 40} msg] $msg [set foo] [destroy .m1] [unset foo]
91 ::tcltest::cleanupTests