1 # This file is a Tcl script to test the procedures in the file
2 # tkWindow.c. It is organized in the standard fashion for Tcl tests.
4 # Copyright (c) 1995 Sun Microsystems, Inc.
5 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 package require tcltest 2.1
11 namespace import -force tcltest::configure
12 namespace import -force tcltest::testsDirectory
13 configure -testdir [file join [pwd] [file dirname [info script]]]
14 configure -loadfile [file join [testsDirectory] constraints.tcl]
15 tcltest::loadTestedCommands
19 # XXX This file is woefully incomplete. Right now it only tests
20 # a few parts of a few procedures in tkWindow.c
22 test window-1.1 {Tk_CreateWindowFromPath procedure, parent dead} {
25 set x [list $msg $errorInfo]
29 frame .t -width 100 -height 50
31 bind .t <Destroy> {button .t.b -text hello; pack .t.b}
37 } {{can't create window: parent has been destroyed} {can't create window: parent has been destroyed
39 "button .t.b -text hello"
40 (command bound to event)}}
42 # Most of the tests below don't produce meaningful results; they
43 # will simply dump core if there are bugs.
45 test window-2.1 {Tk_DestroyWindow procedure, destroy handler deletes parent} {
46 toplevel .t -width 300 -height 200
48 frame .t.f -width 200 -height 200 -relief raised -bd 2
50 frame .t.f.f -width 100 -height 100 -relief raised -bd 2
51 place .t.f.f -relx 1 -rely 1 -anchor se
52 bind .t.f <Destroy> {destroy .t}
56 test window-2.2 {Tk_DestroyWindow procedure, destroy handler deletes parent} {
57 toplevel .t -width 300 -height 200
59 frame .t.f -width 200 -height 200 -relief raised -bd 2
61 frame .t.f.f -width 100 -height 100 -relief raised -bd 2
62 place .t.f.f -relx 1 -rely 1 -anchor se
63 bind .t.f.f <Destroy> {destroy .t}
67 test window-2.3 {Tk_DestroyWindow procedure, destroy handler deletes parent} {
68 frame .f -width 80 -height 120 -relief raised -bd 2
69 place .f -relx 0.5 -rely 0.5 -anchor center
70 toplevel .f.t -width 300 -height 200
72 frame .f.t.f -width 200 -height 200 -relief raised -bd 2
73 place .f.t.f -x 0 -y 0
74 frame .f.t.f.f -width 100 -height 100 -relief raised -bd 2
75 place .f.t.f.f -relx 1 -rely 1 -anchor se
80 # Some tests require the testmenubar command
81 testConstraint testmenubar [llength [info commands testmenubar]]
83 test window-3.1 {Tk_MakeWindowExist procedure, stacking order and menubars} \
84 {unixOnly testmenubar} {
86 toplevel .t -width 300 -height 200
89 frame .t.f -bd 2 -relief raised
90 testmenubar window .t .t.f
92 # If stacking order isn't handle properly, generates an X error.
94 test window-3.2 {Tk_MakeWindowExist procedure, stacking order and menubars} \
95 {unixOnly testmenubar} {
97 toplevel .t -width 300 -height 200
102 frame .t.f -bd 2 -relief raised
104 testmenubar window .t .t.f
106 # If stacking order isn't handled properly, generates an X error.
109 test window-4.1 {Tk_NameToWindow procedure} {testmenubar} {
111 list [catch {winfo geometry .t} msg] $msg
112 } {1 {bad window path name ".t"}}
113 test window-4.2 {Tk_NameToWindow procedure} {testmenubar} {
115 frame .t -width 100 -height 50
118 list [catch {winfo geometry .t} msg] $msg
121 test window-5.1 {Tk_MakeWindowExist procedure, stacking order and menubars} \
122 {unixOnly testmenubar} {
124 toplevel .t -width 300 -height 200
128 frame .t.f -bd 2 -relief raised
129 testmenubar window .t .t.f
133 # If stacking order isn't handled properly, generates an X error.
137 ::tcltest::cleanupTests