Tk Source Code

Artifact [2fff6866]
Login

Artifact 2fff6866df14ac79c65995c446d031c50530b8e7:

Attachment "tests.diff" to ticket [657656ff] added by davidw 2004-04-01 05:56:33.
? tests.diff
Index: filebox.test
===================================================================
RCS file: /cvsroot/tktoolkit/tk/tests/filebox.test,v
retrieving revision 1.14
diff -u -r1.14 filebox.test
--- filebox.test	1 Apr 2003 21:06:23 -0000	1.14
+++ filebox.test	31 Mar 2004 22:50:47 -0000
@@ -127,7 +127,7 @@
 }
 
 foreach mode $modes {
-
+    puts "Running tests  with tk_strictMotif $mode"
     #
     # Test both the motif version and the "tk" version of the file dialog
     # box on Unix.
@@ -201,23 +201,24 @@
         ToPressButton $parent cancel
         tk_getOpenFile -title "Press Cancel ($verylongstring)" -parent $parent
     } ""
-    
+
     set fileName $tmpFile
     set fileDir [pwd]
     set pathName [file join $fileDir $fileName]
-    
+
     test filebox-2.2 "tk_getOpenFile command" {nonUnixUserInteraction} {
         ToPressButton $parent ok
         set choice [tk_getOpenFile -title "Press Ok" \
-    		    -parent $parent -initialfile $fileName -initialdir $fileDir]
+			-parent $parent -initialfile $fileName \
+			-initialdir $fileDir]
     } $pathName
-    
+
     test filebox-2.3 "tk_getOpenFile command" {nonUnixUserInteraction} {
         ToEnterFileByKey $parent $fileName $fileDir
         set choice [tk_getOpenFile -title "Enter \"$fileName\" and press Ok" \
     		    -parent $parent -initialdir $fileDir]
     } $pathName
-    
+
     test filebox-2.4 "tk_getOpenFile command" {nonUnixUserInteraction} {
         ToPressButton $parent ok
         set choice [tk_getOpenFile -title "Enter \"$fileName\" and press Ok" \
@@ -257,11 +258,71 @@
         set choice
     } [list $pathName $pathName $pathName]
 
+    test filebox-2.7 "tk_getOpenFile command" {nonUnixUserInteraction} {
+        ToPressButton $parent cancel
+	catch {
+	    tk_getOpenFile -parent $parent -initialfile [glob *.c]
+	} err
+	set err
+    } {called -initialfile with more than one file, and -multiple is not set.}
+
+    test filebox-2.8 "tk_getOpenFile command" {nonUnixUserInteraction} {
+        ToPressButton $parent ok
+	set choice [tk_getOpenFile -parent $parent -multiple 1 \
+			-initialfile [glob *.c]]
+	set rslts {}
+	foreach fl $choice {
+	    lappend rslts [file tail $fl]
+	}
+	set rslts
+    } {tkAppInit.c tkUnix.c tkUnix3d.c tkUnixButton.c tkUnixColor.c tkUnixConfig.c tkUnixCursor.c tkUnixDialog.c tkUnixDraw.c tkUnixEmbed.c tkUnixEvent.c tkUnixFocus.c tkUnixFont.c tkUnixInit.c tkUnixKey.c tkUnixMenu.c tkUnixMenubu.c tkUnixRFont.c tkUnixScale.c tkUnixScrlbr.c tkUnixSelect.c tkUnixSend.c tkUnixWm.c tkUnixXId.c}
+
+    test filebox-2.85 "tk_getOpenFile with bad initialfile" {nonUnixUserInteraction} {
+	ToPressButton $parent ok
+	set ok 0
+	if { [catch {
+	    tk_getOpenFile -parent $parent -multiple 1 -initialfile "foo \{"
+	} err] } {
+	    set ok $err
+	} else {
+	    set ok 1
+	}
+	set ok
+    } {1}
+
+    test filebox-2.9 "tk_getOpenFile command" {nonUnixUserInteraction} {
+	after 500 {ToPressButton $parent cancel}
+	set ::Selections2_9 {}
+	if { $tk_strictMotif == 0 } {
+	    after 100 {
+		set ::Selections2_9 [::tk::IconList_Curselection \
+					 .__tk_filedialog.icons] }
+	} else {
+	    after 100 {
+		set ::Selections2_9 [.__tk_filedialog.top.f2.b.l curselection]
+	    }
+	}
+	catch {
+	    tk_getOpenFile -parent $parent -multiple 1 -initialfile [glob *.c] 
+	} err
+	set rslts {}
+	if { $tk_strictMotif == 0 } {
+	    foreach sel $::Selections2_9 {
+		lappend rslts [::tk::IconList_Get .__tk_filedialog.icons $sel]
+	    }
+	} else {
+	    foreach sel $::Selections2_9 {
+		lappend rslts [.__tk_filedialog.top.f2.b.l get $sel]
+	    }
+	}
+	set rslts
+    } {tkAppInit.c tkUnix.c tkUnix3d.c tkUnixButton.c tkUnixColor.c tkUnixConfig.c tkUnixCursor.c tkUnixDialog.c tkUnixDraw.c tkUnixEmbed.c tkUnixEvent.c tkUnixFocus.c tkUnixFont.c tkUnixInit.c tkUnixKey.c tkUnixMenu.c tkUnixMenubu.c tkUnixRFont.c tkUnixScale.c tkUnixScrlbr.c tkUnixSelect.c tkUnixSend.c tkUnixWm.c tkUnixXId.c}
+
     foreach x [lsort -integer [array names filters]] {
         test filebox-3.$x "tk_getOpenFile command" {nonUnixUserInteraction} {
-    	ToPressButton $parent ok
-    	set choice [tk_getOpenFile -title "Press Ok" -filetypes $filters($x)\
-    			-parent $parent -initialfile $fileName -initialdir $fileDir]
+	    ToPressButton $parent ok
+	    set choice [tk_getOpenFile -title "Press Ok" -filetypes $filters($x)\
+			    -parent $parent -initialfile $fileName -initialdir $fileDir]
         } $pathName
     }