1 # This file is a Tcl script to test out the procedures in the file
2 # tkMacEmbed.c. It is organized in the standard fashion for Tcl
5 # Copyright (c) 1997 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 macEmbed-1.1 {TkpUseWindow procedure, bad window identifier} {macOnly} {
20 list [catch {toplevel .t -use xyz} msg] $msg
21 } {1 {expected integer but got "xyz"}}
22 test macEmbed-1.2 {TkpUseWindow procedure, bad window identifier} {macOnly} {
24 list [catch {toplevel .t -use 47} msg] $msg
25 } {1 {The window ID 47 does not correspond to a valid Tk Window.}}
27 test macEmbed-1.3 {TkpUseWindow procedure, creating Container records} {testembed macOnly} {
29 frame .f1 -container 1 -width 200 -height 50
30 frame .f2 -container 1 -width 200 -height 50
34 list [testembed] [expr [lindex [lindex [testembed all] 1] 0] - $w]
35 } {{{XXX .f2 {} {}} {XXX .f1 XXX .t}} 0}
36 test macEmbed-1.4 {TkpUseWindow procedure, creating Container records} {testembed macOnly} {
38 frame .f1 -container 1 -width 200 -height 50
39 frame .f2 -container 1 -width 200 -height 50
46 } {{XXX .f2 XXX .t2} {XXX .f1 XXX .t1}}
48 # Can't think of any way to test the procedures TkpMakeWindow,
49 # TkpMakeContainer, or EmbedErrorProc.
51 test macEmbed-2.1 {EmbeddedEventProc procedure} {testembed macOnly} {
53 frame .f1 -container 1 -width 200 -height 50
62 test macEmbed-2.2 {EmbeddedEventProc procedure} {testembed macOnly} {
64 frame .f1 -container 1 -width 200 -height 50
66 toplevel .t1 -use [winfo id .f1]
71 test macEmbed-2.3 {EmbeddedEventProc procedure} {testembed macOnly} {
73 frame .f1 -container 1 -width 200 -height 50
75 toplevel .t1 -use [winfo id .f1]
79 list [testembed] [winfo children .]
82 test macEmbed-3.1 {EmbeddedEventProc procedure, detect creation} {testembed macOnly} {
84 frame .f1 -container 1 -width 200 -height 50
91 } {{{XXX .f1 {} {}}} {{XXX .f1 XXX .t1}}}
92 test macEmbed-3.2 {EmbeddedEventProc procedure, disallow position changes} \
95 frame .f1 -container 1 -width 200 -height 50
98 toplevel .t1 -use $w1 -bd 2 -relief raised
100 wm geometry .t1 +30+40
104 test macEmbed-3.3 {EmbeddedEventProc procedure, disallow position changes} \
107 frame .f1 -container 1 -width 200 -height 50
109 set w1 [winfo id .f1]
110 toplevel .t1 -use $w1
112 wm geometry .t1 300x100+30+40
116 test macEmbed-3.4 {EmbeddedEventProc procedure, geometry requests} {macOnly} {
118 toplevel .t1 -container 1 -width 200 -height 50
119 set w1 [winfo id .t1]
120 toplevel .t2 -use $w1
122 .t1 configure -width 300 -height 80
124 list [winfo width .t1] [winfo height .t1] [wm geometry .t2]
125 } {300 80 300x80+0+0}
126 test macEmbed-3.5 {EmbeddedEventProc procedure, map requests} {macOnly} {
128 frame .f1 -container 1 -width 200 -height 50
130 set w1 [winfo id .f1]
131 toplevel .t1 -use $w1
133 bind .t1 <Map> {set x mapped}
139 test macEmbed-3.6 {EmbeddedEventProc procedure, destroy events} {macOnly} {
141 frame .f1 -container 1 -width 200 -height 50
143 set w1 [winfo id .f1]
144 bind .f1 <Destroy> {set x dead}
146 toplevel .t1 -use $w1
150 list $x [winfo exists .f1]
153 test macEmbed-4.1 {EmbedStructureProc procedure, configure events} {macOnly} {
155 frame .f1 -container 1 -width 200 -height 50
157 set w1 [winfo id .f1]
158 toplevel .t1 -use $w1
160 .t1 configure -width 180 -height 100
164 test macEmbed-4.2 {EmbedStructureProc procedure, destroy events} {testembed macOnly} {
166 frame .f1 -container 1 -width 200 -height 50
168 set w1 [winfo id .f1]
169 toplevel .t1 -use $w1
174 } {{{XXX .f1 XXX .t1}} {}}
176 # Can't think up any tests for TkpGetOtherWindow procedure.
178 test unixEmbed-5.1 {TkpClaimFocus procedure} {macOnly tempNotMac} {
179 catch {interp delete child}
181 frame .f1 -container 1 -width 200 -height 50
182 frame .f2 -width 200 -height 50
185 child eval "set argv {-use [winfo id .f1]}"
188 . configure -bd 2 -highlightthickness 2 -relief sunken
199 catch {interp delete child}
201 test macEmbed-6.1 {EmbedWindowDeleted procedure, check parentPtr} {testembed macOnly} {
203 frame .f1 -container 1 -width 200 -height 50
204 frame .f2 -container 1 -width 200 -height 50
205 frame .f3 -container 1 -width 200 -height 50
206 frame .f4 -container 1 -width 200 -height 50
209 lappend x [testembed]
210 foreach w {.f3 .f4 .f1 .f2} {
212 lappend x [testembed]
215 } {{{XXX .f4 {} {}} {XXX .f3 {} {}} {XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f4 {} {}} {XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f2 {} {}}} {}}
216 test macEmbed-6.2 {EmbedWindowDeleted procedure, check embeddedPtr} {testembed macOnly} {
218 frame .f1 -container 1 -width 200 -height 50
220 set w1 [winfo id .f1]
221 toplevel .t1 -use $w1 -highlightthickness 2 -bd 2 -relief sunken
223 lappend x [testembed]
226 lappend x [testembed]
227 } {{{XXX .f1 XXX .t1}} {}}
229 test macEmbed-7.1 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} {macOnly} {
231 frame .f1 -container 1 -width 200 -height 50
233 toplevel .t1 -use [winfo id .f1] -width 150 -height 80
235 wm geometry .t1 +40+50
239 test macEmbed-7.2 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} {macOnly} {
241 frame .f1 -container 1 -width 200 -height 50
243 toplevel .t1 -use [winfo id .f1] -width 150 -height 80
245 wm geometry .t1 70x300+10+20
255 ::tcltest::cleanupTests