diff options
Diffstat (limited to 'iwidgets/tests/panedwindow.test')
-rw-r--r-- | iwidgets/tests/panedwindow.test | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/iwidgets/tests/panedwindow.test b/iwidgets/tests/panedwindow.test new file mode 100644 index 00000000000..8c6f28b8dec --- /dev/null +++ b/iwidgets/tests/panedwindow.test @@ -0,0 +1,175 @@ +# This file is a Tcl script to test out [incr Widgets] Panedwindow 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 +# +# 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 Panedwindow-1.$c {Panedwindow construction} { + iwidgets::Panedwindow .pw -width 200 -height 200 + .pw add top + .pw add bottom + pack .pw -fill both -expand yes + update +} {} + +incr c + +# +# Option tests which are successful. +# +test Panedwindow-2.$o {configuration option} { + llength [.pw configure] +} {13} + +incr o + +foreach test { + {-background #d9d9d9 #d9d9d9} + {-cursor gumby gumby} + {-height 300 300} + {-orient vertical vertical} + {-sashborderwidth 3 3} + {-sashcursor arrow arrow} + {-sashheight 12 12} + {-sashindent -20 -20} + {-sashwidth 12 12} + {-showhandle 0 0} + {-showhandle 1 1} + {-thickness 5 5} + {-orient horizontal horizontal} + {-width 300 300}} { + set option [lindex $test 0] + test Panedwindow-2.$o "configuration options, $option" { + .pw configure $option [lindex $test 1] + lindex [.pw configure $option] 4 + } [lindex $test 2] + update + incr o +} + +# +# Method tests which are successful. +# +foreach test { + {{.pw index 0} {0}} + {{.pw index end} {1}} + {{.pw index top} {0}} + {{.pw index b*} {1}} + {{.pw childsite 0} {.pw.pane0.childsite}} + {{.pw childsite end} {.pw.pane1.childsite}} + {{.pw childsite 1} {.pw.pane1.childsite}} + {{.pw childsite} {.pw.pane0.childsite .pw.pane1.childsite}} + {{.pw fraction 25 75} {}} + {{.pw add middle -margin 10 -minimum 10} {.pw.pane2}} + {{.pw delete middle} {}} + {{.pw insert 1 middle} {.pw.pane3}} + {{.pw fraction 20 30 50} {}} + {{.pw reset} {}} + {{.pw hide end} {}} + {{.pw show bottom} {}} + {{.pw paneconfigure 0 -minimum} {-minimum minimum Minimum 10 10}} + {{.pw paneconfigure end -margin 10} {}}} { + set method [lindex [lindex $test 0] 1] + test Panedwindow-3.$m "object methods, $method" { + list [catch {eval [lindex $test 0]} msg] $msg + } [list 0 [lindex $test 1]] + update + incr m +} + +# +# Method tests which fail and produce errors +# +foreach test { + {{.pw index 5} {Panedwindow index "5" is out of range}} + {{.pw index bogus} {bad Panedwindow index "bogus": must be number, end, or pattern}} + {{.pw configure -showhandle foo} {Invalid option for -showhandle: foo. Must be 1 or 0.}} + {{.pw fraction 10 20 30} {bad fraction arguments "10 20 30": they should add up to 100}}} { + set method [lindex [lindex $test 0] 1] + test Panedwindow-3.$m "object methods, $method" { + list [catch {eval [lindex $test 0]} msg] $msg + } [list 1 [lindex $test 1]] + incr m +} + +# +# Conclusion of constrcution/destruction tests +# +test Panedwindow-1.$c {Panedwindow destruction} { + destroy .pw + update +} {} + +incr c + +test Panedwindow-1.$c {Panedwindow construction} { + iwidgets::panedwindow .pw -width 200 -height 300 + .pw add pane0 + .pw add pane1 + .pw add pane2 + .pw add pane3 + foreach pane [.pw childsite] { + button $pane.b -text $pane -relief raised -borderwidth 3 + pack $pane.b -fill both -expand yes + } + .pw fraction 20 20 30 30 + pack .pw -fill both -expand yes + update +} {} + +incr c + +test Panedwindow-1.$c {Panedwindow destruction} { + destroy .pw + update +} {} + +incr c + +test Panedwindow-1.$c {Panedwindow destruction} { + iwidgets::panedwindow .pw + pack .pw + destroy .pw + update +} {} + +::tcltest::cleanupTests +exit |