OSDN Git Service

Merge branch 'master' of git://github.com/monaka/binutils
[pf3gnuchains/pf3gnuchains3x.git] / tk / tests / xmfbox.test
1 # xmfbox.test -- 
2 #
3 #       This file is a Tcl script to test the file dialog that's used
4 #       when the tk_strictMotif flag is set. Because the file dialog
5 #       runs in a modal loop, the only way to test it sufficiently is
6 #       to call the internal Tcl procedures in xmfbox.tcl directly.
7 #
8 # Copyright (c) 1997 Sun Microsystems, Inc.
9 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 # Contributions from Don Porter, NIST, 2002.  (not subject to US copyright)
11 # All rights reserved.
12 #
13 # RCS: @(#) $Id$
14
15 package require tcltest 2.1
16 namespace import -force tcltest::configure
17 namespace import -force tcltest::testsDirectory
18 configure -testdir [file join [pwd] [file dirname [info script]]]
19 configure -loadfile [file join [testsDirectory] constraints.tcl]
20 tcltest::loadTestedCommands
21
22 set testPWD [pwd]
23 catch {unset foo}
24
25 catch {unset data foo}
26
27 proc cleanup {} {
28     global testPWD
29
30     set err0 [catch {
31         cd $testPWD
32     } msg0]
33
34     set err1 [catch {
35         if [file exists ./~nosuchuser1] {
36             file delete ./~nosuchuser1
37         }
38     } msg1]
39
40     set err2 [catch {
41         if [file exists ./~nosuchuser2] {
42             file delete ./~nosuchuser2
43         }
44     } msg2]
45
46     set err3 [catch {
47         if [file exists ./~nosuchuser3] {
48             file delete ./~nosuchuser3
49         }
50     } msg3]
51
52     set err4 [catch {
53         if [file exists ./~nosuchuser4] {
54             file delete ./~nosuchuser4
55         }
56     } msg4]
57
58     if {$err0 || $err1 || $err2 || $err3 || $err4} {
59         error [list $msg0 $msg1 $msg2 $msg3 $msg4] 
60     }
61     catch {unset foo}
62     catch {destroy .foo}
63 }
64
65 test xmfbox-1.1 {tk::MotifFDialog_Create, -parent switch} {unixOnly} {
66     catch {unset foo}
67     set x [tk::MotifFDialog_Create foo open {-parent .}]
68     catch {destroy $x}
69     set x
70 } .foo
71
72 test xmfbox-1.2 {tk::MotifFDialog_Create, -parent switch} {unixOnly} {
73     catch {unset foo}
74     toplevel .bar
75     wm geometry .bar +0+0
76     set x [tk::MotifFDialog_Create foo open {-parent .bar}]
77     catch {destroy $x}
78     catch {destroy .bar}
79     set x
80 } .bar.foo
81
82 test xmfbox-2.1 {tk::MotifFDialog_InterpFilter, ~ in dir names} {unixOnly} {
83     cleanup
84     file mkdir ./~nosuchuser1
85     set x [tk::MotifFDialog_Create foo open {}]
86     $::tk::dialog::file::foo(fEnt) delete 0 end
87     $::tk::dialog::file::foo(fEnt) insert 0 [pwd]/~nosuchuser1
88     set kk [tk::MotifFDialog_InterpFilter $x]
89 } [list $testPWD/~nosuchuser1 *]
90
91 test xmfbox-2.2 {tk::MotifFDialog_InterpFilter, ~ in file names} {unixOnly} {
92     cleanup
93     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
94     set x [tk::MotifFDialog_Create foo open {}]
95     $::tk::dialog::file::foo(fEnt) delete 0 end
96     $::tk::dialog::file::foo(fEnt) insert 0 [pwd]/~nosuchuser1
97     set kk [tk::MotifFDialog_InterpFilter $x]
98 } [list $testPWD ./~nosuchuser1]
99
100 test xmfbox-2.3 {tk::MotifFDialog_Update, ~ in file names} {unixOnly} {
101     cleanup
102     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
103     set x [tk::MotifFDialog_Create foo open {}]
104     $::tk::dialog::file::foo(fEnt) delete 0 end
105     $::tk::dialog::file::foo(fEnt) insert 0 [pwd]/~nosuchuser1
106     tk::MotifFDialog_InterpFilter $x
107     tk::MotifFDialog_Update $x
108     $::tk::dialog::file::foo(fList) get end
109 } ~nosuchuser1
110
111 test xmfbox-2.4 {tk::MotifFDialog_LoadFile, ~ in file names} {unixOnly} {
112     cleanup
113     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
114     set x [tk::MotifFDialog_Create foo open {}]
115     set i [lsearch [$::tk::dialog::file::foo(fList) get 0 end] ~nosuchuser1]
116     expr {$i >= 0}
117 } 1
118
119 test xmfbox-2.5 {tk::MotifFDialog_BrowseFList, ~ in file names} {unixOnly} {
120     cleanup
121     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
122     set x [tk::MotifFDialog_Create foo open {}]
123     set i [lsearch [$::tk::dialog::file::foo(fList) get 0 end] ~nosuchuser1]
124     $::tk::dialog::file::foo(fList) selection clear 0 end
125     $::tk::dialog::file::foo(fList) selection set $i
126     tk::MotifFDialog_BrowseFList $x
127     $::tk::dialog::file::foo(sEnt) get
128 } $testPWD/~nosuchuser1
129
130 test xmfbox-2.6 {tk::MotifFDialog_ActivateFList, ~ in file names} {unixOnly} {
131     cleanup
132     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
133     set x [tk::MotifFDialog_Create foo open {}]
134     set i [lsearch [$::tk::dialog::file::foo(fList) get 0 end] ~nosuchuser1]
135     $::tk::dialog::file::foo(fList) selection clear 0 end
136     $::tk::dialog::file::foo(fList) selection set $i
137     tk::MotifFDialog_BrowseFList $x
138     tk::MotifFDialog_ActivateFList $x
139     list $::tk::dialog::file::foo(selectPath) \
140             $::tk::dialog::file::foo(selectFile) $tk::Priv(selectFilePath)
141 } [list $testPWD ~nosuchuser1 $testPWD/~nosuchuser1]
142
143 # cleanup
144 cleanup
145 ::tcltest::cleanupTests
146 return
147
148
149
150
151
152
153
154
155
156
157
158