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.
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
25 catch {unset data foo}
35 if [file exists ./~nosuchuser1] {
36 file delete ./~nosuchuser1
41 if [file exists ./~nosuchuser2] {
42 file delete ./~nosuchuser2
47 if [file exists ./~nosuchuser3] {
48 file delete ./~nosuchuser3
53 if [file exists ./~nosuchuser4] {
54 file delete ./~nosuchuser4
58 if {$err0 || $err1 || $err2 || $err3 || $err4} {
59 error [list $msg0 $msg1 $msg2 $msg3 $msg4]
65 test xmfbox-1.1 {tk::MotifFDialog_Create, -parent switch} {unixOnly} {
67 set x [tk::MotifFDialog_Create foo open {-parent .}]
72 test xmfbox-1.2 {tk::MotifFDialog_Create, -parent switch} {unixOnly} {
76 set x [tk::MotifFDialog_Create foo open {-parent .bar}]
82 test xmfbox-2.1 {tk::MotifFDialog_InterpFilter, ~ in dir names} {unixOnly} {
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 *]
91 test xmfbox-2.2 {tk::MotifFDialog_InterpFilter, ~ in file names} {unixOnly} {
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]
100 test xmfbox-2.3 {tk::MotifFDialog_Update, ~ in file names} {unixOnly} {
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
111 test xmfbox-2.4 {tk::MotifFDialog_LoadFile, ~ in file names} {unixOnly} {
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]
119 test xmfbox-2.5 {tk::MotifFDialog_BrowseFList, ~ in file names} {unixOnly} {
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
130 test xmfbox-2.6 {tk::MotifFDialog_ActivateFList, ~ in file names} {unixOnly} {
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]
145 ::tcltest::cleanupTests