OSDN Git Service

touched all tk files to ease next import
[pf3gnuchains/pf3gnuchains4x.git] / tk / tests / macWinMenu.test
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.
4 #
5 # Copyright (c) 1995-1996 Sun Microsystems, Inc.
6 # Copyright (c) 1998-1999 by Scriptics Corporation.
7 # All rights reserved.
8 #
9 # RCS: @(#) $Id$
10
11 if {[lsearch [namespace children] ::tcltest] == -1} {
12     source [file join [pwd] [file dirname [info script]] defs.tcl]
13 }
14
15 if {[lsearch [image types] test] < 0} {
16     puts "This application hasn't been compiled with the \"test\" image"
17     puts "type, so I can't run this test.  Are you sure you're using"
18     puts "tktest instead of wish?"
19     ::tcltest::cleanupTests
20     return
21 }
22
23 # Some tests require user interaction on non-unix platform
24 set ::tcltest::testConfig(nonUnixUserInteraction) \
25     [expr {$::tcltest::testConfig(userInteraction) || \
26         $::tcltest::testConfig(unixOnly)}]
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 macWinMenu-1.1 {PreprocessMenu} {macOrPc nonUnixUserInteraction} {
39     catch {destroy .m1}
40     menu .m1 -postcommand "destroy .m1"
41     .m1 add command -label "macWinMenu-1.1: Hit Escape"
42     list [catch {.m1 post 40 40} msg] $msg
43 } {0 {}}
44 test macWinMenu-1.2 {PreprocessMenu} {macOrPc nonUnixUserInteraction} {
45     catch {destroy .m1}
46     catch {destroy .m2}
47     set foo1 foo
48     set foo2 foo
49     menu .m1 -postcommand "set foo1 .m1"
50     .m1 add cascade -menu .m2 -label "macWinMenu-1.2: Hit Escape"
51     menu .m2 -postcommand "set foo2 .m2"
52     update idletasks
53     list [catch {.m1 post 40 40} msg] $msg [set foo1] [set foo2] \
54             [destroy .m1 .m2] [catch {unset foo1}] [catch {unset foo2}]
55 } {0 .m2 .m1 .m2 {} 0 0}
56
57 test macWinMenu-1.3 {PreprocessMenu} {macOrPc nonUnixUserInteraction} {
58     catch {destroy .l1}
59     catch {destroy .m1}
60     catch {destroy .m2}
61     catch {destroy .m3}
62     label .l1 -text "Preparing menus..."
63     pack .l1
64     update idletasks
65     menu .m1 -postcommand ".l1 configure -text \"Destroying .m1...\"; update idletasks; destroy .m1"
66     menu .m2 -postcommand ".l1 configure -text \"Destroying .m2...\"; update idletasks; destroy .m2"
67     menu .m3 -postcommand ".l1 configure -text \"Destroying .m3...\"; update idletasks; destroy .m3"
68     .m1 add cascade -menu .m2 -label "macWinMenu-1.3: Hit Escape (.m2)"
69     .m1 add cascade -menu .m3 -label ".m3"
70     update idletasks
71     list [catch {.m1 post 40 40} msg] $msg [destroy .l1 .m2 .m3]
72 } {0 {} {}}
73 test macWinMenu-1.4 {PreprocessMenu} {macOrPc} {
74     catch {destroy .l1}
75     catch {destroy .m1}
76     catch {destroy .m2}
77     catch {destroy .m3}
78     catch {destroy .m4}
79     label .l1 -text "Preparing menus..."
80     pack .l1
81     update idletasks
82     menu .m1 -postcommand ".l1 configure -text \"Destroying .m1...\"; update idletasks; destroy .m1"
83     .m1 add cascade -menu .m2 -label "macWinMenu-1.4: Hit Escape (.m2)"
84     .m1 add cascade -menu .m3 -label ".m3"
85     menu .m2 -postcommand ".l1 configure -text \"Destroying .m2...\"; update idletasks; destroy .m2"
86     .m2 add cascade -menu .m4 -label ".m4"
87     menu .m3 -postcommand ".l1 configure -text \"Destroying .m3...\"; update idletasks; destroy .m3"
88     menu .m4 -postcommand ".l1 configure -text \"Destroying .m4...\"; update idletasks; destroy .m4"
89     update idletasks
90     list [catch {.m1 post 40 40} msg] $msg [destroy .l1 .m2 .m3 .m4]
91 } {0 {} {}}
92 test macWinMenu-1.5 {PreprocessMenu} {macOrPc} {
93     catch {destroy .m1}
94     catch {destroy .m2}
95     menu .m1
96     .m1 add cascade -menu .m2 -label "You may need to hit Escape to get this menu to go away."
97     menu .m2 -postcommand glorp
98     list [catch {.m1 post 40 40} msg] $msg [destroy .m1 .m2]
99 } {1 {invalid command name "glorp"} {}}
100
101 test macWinMenu-2.1 {TkPreprocessMenu} {macOrPc nonUnixUserInteraction} {
102     catch {destroy .m1}
103     set foo test
104     menu .m1 -postcommand "set foo 2.1"
105     .m1 add command -label "macWinMenu-2.1: Hit Escape"
106     list [catch {.m1 post 40 40} msg] $msg [set foo] [destroy .m1] [unset foo]
107 } {0 2.1 2.1 {} {}}
108
109 # cleanup
110 deleteWindows
111 ::tcltest::cleanupTests
112 return
113
114
115
116
117
118
119
120
121
122
123
124
125