summaryrefslogtreecommitdiffstats
path: root/tests/xmfbox.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/xmfbox.test')
-rw-r--r--tests/xmfbox.test146
1 files changed, 146 insertions, 0 deletions
diff --git a/tests/xmfbox.test b/tests/xmfbox.test
new file mode 100644
index 0000000..d6b54ee
--- /dev/null
+++ b/tests/xmfbox.test
@@ -0,0 +1,146 @@
+# xmfbox.test --
+#
+# This file is a Tcl script to test the file dialog that's used
+# when the tk_strictMotif flag is set. Because the file dialog
+# runs in a modal loop, the only way to test it sufficiently is
+# to call the internal Tcl procedures in xmfbox.tcl directly.
+#
+# Copyright (c) 1997 Sun Microsystems, Inc.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# SCCS: @(#) xmfbox.test 1.3 98/01/07 16:44:17
+
+if {[string compare test [info procs test]] == 1} {
+ source defs
+}
+
+if {$tcl_platform(platform) != "unix"} {
+ # This test is needed only on Unix platforms. Windows and Mac
+ # have their own Native file dialogs.
+ return
+}
+
+set testPWD [pwd]
+eval destroy [winfo children .]
+catch {unset foo}
+
+catch {unset data foo}
+
+proc cleanup {} {
+ global testPWD
+
+ set err0 [catch {
+ cd $testPWD
+ } msg0]
+
+ set err1 [catch {
+ if [file exists ./~nosuchuser1] {
+ file delete ./~nosuchuser1
+ }
+ } msg1]
+
+ set err2 [catch {
+ if [file exists ./~nosuchuser2] {
+ file delete ./~nosuchuser2
+ }
+ } msg2]
+
+ set err3 [catch {
+ if [file exists ./~nosuchuser3] {
+ file delete ./~nosuchuser3
+ }
+ } msg3]
+
+ set err4 [catch {
+ if [file exists ./~nosuchuser4] {
+ file delete ./~nosuchuser4
+ }
+ } msg4]
+
+ if {$err0 || $err1 || $err2 || $err3 || $err4} {
+ error [list $msg0 $msg1 $msg2 $msg3 $msg4]
+ }
+ catch {unset foo}
+ catch {destroy .foo}
+}
+
+test xmfbox-1.1 {tkMotifFDialog_Create, -parent switch} {
+ catch {unset foo}
+ set x [tkMotifFDialog_Create foo open {-parent .}]
+ catch {destroy $x}
+ set x
+} .foo
+
+test xmfbox-1.2 {tkMotifFDialog_Create, -parent switch} {
+ catch {unset foo}
+ toplevel .bar
+ set x [tkMotifFDialog_Create foo open {-parent .bar}]
+ catch {destroy $x}
+ catch {destroy .bar}
+ set x
+} .bar.foo
+
+test xmfbox-2.1 {tkMotifFDialog_InterpFilter, ~ in dir names} {
+ cleanup
+ file mkdir ./~nosuchuser1
+ set x [tkMotifFDialog_Create foo open {}]
+ $foo(fEnt) delete 0 end
+ $foo(fEnt) insert 0 [pwd]/~nosuchuser1
+ set kk [tkMotifFDialog_InterpFilter $x]
+} [list $testPWD/~nosuchuser1 *]
+
+test xmfbox-2.2 {tkMotifFDialog_InterpFilter, ~ in file names} {
+ cleanup
+ close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
+ set x [tkMotifFDialog_Create foo open {}]
+ $foo(fEnt) delete 0 end
+ $foo(fEnt) insert 0 [pwd]/~nosuchuser1
+ set kk [tkMotifFDialog_InterpFilter $x]
+} [list $testPWD ./~nosuchuser1]
+
+test xmfbox-2.3 {tkMotifFDialog_Update, ~ in file names} {
+ cleanup
+ close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
+ set x [tkMotifFDialog_Create foo open {}]
+ $foo(fEnt) delete 0 end
+ $foo(fEnt) insert 0 [pwd]/~nosuchuser1
+ tkMotifFDialog_InterpFilter $x
+ tkMotifFDialog_Update $x
+ $foo(fList) get end
+} ~nosuchuser1
+
+test xmfbox-2.4 {tkMotifFDialog_LoadFile, ~ in file names} {
+ cleanup
+ close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
+ set x [tkMotifFDialog_Create foo open {}]
+ set i [lsearch [$foo(fList) get 0 end] ~nosuchuser1]
+ expr {$i >= 0}
+} 1
+
+test xmfbox-2.5 {tkMotifFDialog_BrowseFList, ~ in file names} {
+ cleanup
+ close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
+ set x [tkMotifFDialog_Create foo open {}]
+ set i [lsearch [$foo(fList) get 0 end] ~nosuchuser1]
+ $foo(fList) selection clear 0 end
+ $foo(fList) selection set $i
+ tkMotifFDialog_BrowseFList $x
+ $foo(sEnt) get
+} $testPWD/~nosuchuser1
+
+test xmfbox-2.5 {tkMotifFDialog_ActivateFList, ~ in file names} {
+ cleanup
+ close [open ./~nosuchuser1 {CREAT TRUNC WRONLY}]
+ set x [tkMotifFDialog_Create foo open {}]
+ set i [lsearch [$foo(fList) get 0 end] ~nosuchuser1]
+ $foo(fList) selection clear 0 end
+ $foo(fList) selection set $i
+ tkMotifFDialog_BrowseFList $x
+ tkMotifFDialog_ActivateFList $x
+ list $foo(selectPath) $foo(selectFile) $tkPriv(selectFilePath)
+} [list $testPWD ~nosuchuser1 $testPWD/~nosuchuser1]
+
+cleanup
+return