OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / 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 package require tcltest 2.2
14 namespace import ::tcltest::*
15 tcltest::configure {*}$argv
16 tcltest::loadTestedCommands
17
18 set testPWD [pwd]
19 catch {unset data foo}
20
21 proc cleanup {} {
22     global testPWD
23
24     set err0 [catch {
25             cd $testPWD
26     } msg0]
27
28     set err1 [catch {
29             if [file exists ./~nosuchuser1] {
30                 file delete ./~nosuchuser1
31             }
32     } msg1]
33
34     set err2 [catch {
35             if [file exists ./~nosuchuser2] {
36                 file delete ./~nosuchuser2
37             }
38     } msg2]
39
40     set err3 [catch {
41             if [file exists ./~nosuchuser3] {
42                 file delete ./~nosuchuser3
43             }
44     } msg3]
45
46     set err4 [catch {
47             if [file exists ./~nosuchuser4] {
48                 file delete ./~nosuchuser4
49             }
50     } msg4]
51
52     if {$err0 || $err1 || $err2 || $err3 || $err4} {
53             error [list $msg0 $msg1 $msg2 $msg3 $msg4]
54     }
55     catch {unset foo}
56     destroy .foo
57 }
58
59 # ----------------------------------------------------------------------
60
61 test xmfbox-1.1 {tk::MotifFDialog_Create, -parent switch} -constraints {
62     unix
63 } -setup {
64     catch {unset foo}
65 } -body {
66     set x [tk::MotifFDialog_Create foo open {-parent .}]
67 } -cleanup {
68     destroy $x
69 } -result {.foo}
70
71 test xmfbox-1.2 {tk::MotifFDialog_Create, -parent switch} -constraints {
72     unix
73 } -setup {
74     catch {unset foo}
75     deleteWindows
76 } -body {
77     toplevel .bar
78     wm geometry .bar +0+0
79     set x [tk::MotifFDialog_Create foo open {-parent .bar}]
80 } -cleanup {
81     destroy $x
82     destroy .bar
83 }  -result {.bar.foo}
84
85
86 test xmfbox-2.1 {tk::MotifFDialog_InterpFilter, ~ in dir names} -constraints {
87     unix
88 } -body {
89     cleanup
90     file mkdir ./~nosuchuser1
91     set x [tk::MotifFDialog_Create foo open {}]
92     $::tk::dialog::file::foo(fEnt) delete 0 end
93     $::tk::dialog::file::foo(fEnt) insert 0 [pwd]/~nosuchuser1
94     set kk [tk::MotifFDialog_InterpFilter $x]
95 } -result "$testPWD/~nosuchuser1 *"
96
97 test xmfbox-2.2 {tk::MotifFDialog_InterpFilter, ~ in file names} -constraints {
98     unix
99 } -body {
100     cleanup
101     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
102     set x [tk::MotifFDialog_Create foo open {}]
103     $::tk::dialog::file::foo(fEnt) delete 0 end
104     $::tk::dialog::file::foo(fEnt) insert 0 [pwd]/~nosuchuser1
105     set kk [tk::MotifFDialog_InterpFilter $x]
106 } -result "$testPWD ./~nosuchuser1"
107
108 test xmfbox-2.3 {tk::MotifFDialog_Update, ~ in file names} -constraints {
109     unix
110 } -body {
111     cleanup
112     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
113     set x [tk::MotifFDialog_Create foo open {}]
114     $::tk::dialog::file::foo(fEnt) delete 0 end
115     $::tk::dialog::file::foo(fEnt) insert 0 [pwd]/~nosuchuser1
116     tk::MotifFDialog_InterpFilter $x
117     tk::MotifFDialog_Update $x
118     $::tk::dialog::file::foo(fList) get end
119 } -result {~nosuchuser1}
120
121 test xmfbox-2.4 {tk::MotifFDialog_LoadFile, ~ in file names} -constraints {
122     unix
123 } -body {
124     cleanup
125     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
126     set x [tk::MotifFDialog_Create foo open {}]
127     set i [lsearch [$::tk::dialog::file::foo(fList) get 0 end] ~nosuchuser1]
128     expr {$i >= 0}
129 } -result 1
130
131 test xmfbox-2.5 {tk::MotifFDialog_BrowseFList, ~ in file names} -constraints {
132     unix
133 } -body {
134     cleanup
135     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
136     set x [tk::MotifFDialog_Create foo open {}]
137     set i [lsearch [$::tk::dialog::file::foo(fList) get 0 end] ~nosuchuser1]
138     $::tk::dialog::file::foo(fList) selection clear 0 end
139     $::tk::dialog::file::foo(fList) selection set $i
140     tk::MotifFDialog_BrowseFList $x
141     $::tk::dialog::file::foo(sEnt) get
142 } -result "$testPWD/~nosuchuser1"
143
144 test xmfbox-2.6 {tk::MotifFDialog_ActivateFList, ~ in file names} -constraints {
145     unix
146 } -body {
147     cleanup
148     close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
149     set x [tk::MotifFDialog_Create foo open {}]
150     set i [lsearch [$::tk::dialog::file::foo(fList) get 0 end] ~nosuchuser1]
151     $::tk::dialog::file::foo(fList) selection clear 0 end
152     $::tk::dialog::file::foo(fList) selection set $i
153     tk::MotifFDialog_BrowseFList $x
154     tk::MotifFDialog_ActivateFList $x
155     list $::tk::dialog::file::foo(selectPath) \
156             $::tk::dialog::file::foo(selectFile) $tk::Priv(selectFilePath)
157 } -result "$testPWD ~nosuchuser1 $testPWD/~nosuchuser1"
158
159 # cleanup
160 cleanup
161 cleanupTests
162 return
163
164 # Local variables:
165 # mode: tcl
166 # End: