diff options
Diffstat (limited to 'itcl/iwidgets/tests/fileselectiondialog.test')
-rw-r--r-- | itcl/iwidgets/tests/fileselectiondialog.test | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/itcl/iwidgets/tests/fileselectiondialog.test b/itcl/iwidgets/tests/fileselectiondialog.test new file mode 100644 index 00000000000..ae3eb07639c --- /dev/null +++ b/itcl/iwidgets/tests/fileselectiondialog.test @@ -0,0 +1,219 @@ +# This file is a Tcl script to test out [incr Widgets] Fileselectiondialog +# class. It is organized in the standard fashion for Tcl tests with the +# following notation for test case labels: +# +# 1.x - Construction/Destruction tests +# 2.x - Configuration option tests +# 3.x - Method tests +# 4.x - Other tests +# +# Copyright (c) 1995 DSC Technologies Corporation +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# +# @(#) $Id$ + +package require tcltest +namespace import -force ::tcltest::* + +if [catch {package require Iwidgets 4.0}] { + # Let's try modifying the auto_path. Note that the IWIDGETS_LIBRARY + # env var is initialized in the Makefile when doing a 'make test'. + # If sourcing this file independently, this variable must be set manually. + if ![info exists env(IWIDGETS_LIBRARY)] { + error "Unable to locate Iwidgets package. Set your IWIDGETS_LIBRARY\ + environment\nvariable to the directory that contains iwidgets.tcl" + } + lappend auto_path $env(IWIDGETS_LIBRARY) + package require Iwidgets 4.0 +} + +if {[string compare test [info procs test]] == 1} { + source defs +} + +wm geometry . {} +raise . + +set c 1 +set o 1 +set m 1 + +# +# Initial construction test +# +test Fileselectiondialog-1.$c {Fileselectiondialog construction} { + iwidgets::Fileselectiondialog .fsd + .fsd activate +} {} + +incr c + +# +# Option tests which are successful. +# +test Fileselectiondialog-2.$o {configuration option} { + llength [.fsd configure] +} {51} + +incr o + +foreach test { + {-activebackground #ececec #ececec} + {-borderwidth 2 2} + {-childsitepos n n} + {-childsitepos s s} + {-childsitepos e e} + {-childsitepos w w} + {-childsitepos top top} + {-childsitepos bottom bottom} + {-childsitepos center center} + {-cursor gumby gumby} + {-directory {..} {..}} + {-textbackground GhostWhite GhostWhite} + {-foreground Black Black} + {-insertbackground Black Black} + {-insertborderwidth 1 1} + {-insertofftime 200 200} + {-insertontime 500 500} + {-insertwidth 3 3} + {-dirslabel "Dirs Label" "Dirs Label"} + {-dirson no no} + {-dirson yes yes} + {-fileslabel "Files Label" "Files Label"} + {-fileson no no} + {-directory ../tests ../tests} + {-mask *.* *.*} + {-nomatchstring {No Files} {No Files}} + {-fileson yes yes} + {-filetype any any} + {-filetype directory directory} + {-filetype regular regular} + {-filterlabel "Filter Label" "Filter Label"} + {-filteron no no} + {-filteron yes yes} + {-selectbackground #c3c3c3 #c3c3c3} + {-selectionlabel "Selection Label" "Selection Label"} + {-selectionon no no} + {-selectionon yes yes} + {-textfont -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*} + {-background #d9d9d9 #d9d9d9} + {-buttonboxpos n n} + {-buttonboxpos e e} + {-buttonboxpos w w} + {-buttonboxpos s s} + {-cursor gumby gumby} + {-modality global global} + {-modality application application} + {-modality none none} + {-padx 15 15} + {-pady 15 15} + {-separator off off} + {-thickness 4 4} + {-separator on on} + {-title Fileselectiondialog Fileselectiondialog}} { + set option [lindex $test 0] + test Fileselectiondialog-2.$o "configuration options, $option" { + .fsd configure $option [lindex $test 1] + lindex [.fsd configure $option] 4 + } [lindex $test 2] + update + incr o +} + +# +# Option tests which fail and produce errors. +# +foreach test { + {-directory bogus {bad directory option "bogus": directory does not exist}} + {-filetype bogus {bad filetype option "bogus": should be regular, directory, or any}}} { + set option [lindex $test 0] + test FileSelectionBox-2.$o "configuration options, $option" { + list [catch {.fsd configure $option [lindex $test 1]} msg] $msg + } [list 1 [lindex $test 2]] + incr o +} + +# +# Method tests which are successful. +# +foreach test { + {{.fsd childsite} {.fsd.shellchildsite.dschildsite.fsb.fsbchildsite}} + {{.fsd hide Help} {}} + {{.fsd hide Cancel} {}} + {{.fsd default Apply} {}} + {{.fsd show Cancel} {}} + {{.fsd deactivate} {}}} { + set method [lindex [lindex $test 0] 1] + test Fileselectiondialog-3.$m "object methods, $method" { + list [catch {eval [lindex $test 0]} msg] $msg + } [list 0 [lindex $test 1]] + update + incr m +} + +# +# Conclusion of constrcution/destruction tests +# +test Fileselectiondialog-1.$c {Fileselectiondialog destruction} { + destroy .fsd + update +} {} + +incr c + +test Fileselectiondialog-1.$c {Fileselectiondialog construction} { + iwidgets::fileselectiondialog .fsd + update +} {} + +incr c + +test Fileselectiondialog-1.$c {Fileselectiondialog destruction} { + destroy .fsd + update +} {} + +incr c + +test Fileselectiondialog-1.$c {Fileselectiondialog destruction} { + iwidgets::fileselectiondialog .fsd + destroy .fsd + update +} {} + +# +# Childsite tests +# +incr o + +test Fileselectiondialog-1.$o {Fileselectiondialog -childsitepos} { + iwidgets::fileselectiondialog .fsd + .fsd activate + update + label [.fsd childsite].lb -background red -text CS + pack [.fsd childsite].lb -fill both -expand yes + update + + .fsd configure -childsitepos n + update + .fsd configure -childsitepos s + update + .fsd configure -childsitepos e + update + .fsd configure -childsitepos w + update + .fsd configure -childsitepos top + update + .fsd configure -childsitepos bottom + update + .fsd configure -childsitepos center + update + .fsd deactivate + update + destroy .fsd +} {} + +::tcltest::cleanupTests +exit |