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.
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.
13 package require tcltest 2.2
14 namespace import ::tcltest::*
15 tcltest::configure {*}$argv
16 tcltest::loadTestedCommands
19 catch {unset data foo}
29 if [file exists ./~nosuchuser1] {
30 file delete ./~nosuchuser1
35 if [file exists ./~nosuchuser2] {
36 file delete ./~nosuchuser2
41 if [file exists ./~nosuchuser3] {
42 file delete ./~nosuchuser3
47 if [file exists ./~nosuchuser4] {
48 file delete ./~nosuchuser4
52 if {$err0 || $err1 || $err2 || $err3 || $err4} {
53 error [list $msg0 $msg1 $msg2 $msg3 $msg4]
59 # ----------------------------------------------------------------------
61 test xmfbox-1.1 {tk::MotifFDialog_Create, -parent switch} -constraints {
66 set x [tk::MotifFDialog_Create foo open {-parent .}]
71 test xmfbox-1.2 {tk::MotifFDialog_Create, -parent switch} -constraints {
79 set x [tk::MotifFDialog_Create foo open {-parent .bar}]
86 test xmfbox-2.1 {tk::MotifFDialog_InterpFilter, ~ in dir names} -constraints {
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 *"
97 test xmfbox-2.2 {tk::MotifFDialog_InterpFilter, ~ in file names} -constraints {
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"
108 test xmfbox-2.3 {tk::MotifFDialog_Update, ~ in file names} -constraints {
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}
121 test xmfbox-2.4 {tk::MotifFDialog_LoadFile, ~ in file names} -constraints {
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]
131 test xmfbox-2.5 {tk::MotifFDialog_BrowseFList, ~ in file names} -constraints {
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"
144 test xmfbox-2.6 {tk::MotifFDialog_ActivateFList, ~ in file names} -constraints {
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"