# This file is a Tcl script to test out [incr Widgets] Scrolledframe 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: scrolledframe.test,v 1.4 2001/08/22 19:08:38 smithc Exp $ 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 Scrolledframe-1.$c {Scrolledframe construction} { iwidgets::Scrolledframe .sf pack .sf -padx 10 -pady 10 -fill both -expand yes update } {} incr c # # Option tests which are successful. # test Scrolledframe-2.$o {configuration option} { llength [.sf configure] } {28} incr o foreach test { {-borderwidth 3 3} {-height 180 180} {-labeltext "Scrolled Frame" "Scrolled Frame"} {-labelpos nw nw} {-labelpos ne ne} {-labelpos en en} {-labelpos e e} {-labelpos es es} {-labelpos se se} {-labelpos s s} {-labelpos sw sw} {-labelpos wn wn} {-labelpos w w} {-labelpos ws ws} {-labelpos n n} {-hscrollmode static static} {-hscrollmode none none} {-hscrollmode dynamic dynamic} {-relief raised raised} {-sbwidth 20 20} {-relief sunken sunken} {-scrollmargin 10 10} {-sticky w w} {-sticky nw nw} {-sticky n n} {-sticky ne ne} {-sticky e e} {-sticky se se} {-sticky s s} {-sticky sw sw} {-sticky news news} {-vscrollmode static static} {-vscrollmode none none} {-vscrollmode dynamic dynamic} {-width 150 150}} { set option [lindex $test 0] test Scrolledframe-2.$o "configuration options, $option" { .sf configure $option [lindex $test 1] lindex [.sf configure $option] 4 } [lindex $test 2] update incr o } # # Option tests which fail and produce errors. # foreach test { {-vscrollmode bogus {bad vscrollmode option "bogus": should be static, dynamic, or none}} {-hscrollmode bogus {bad hscrollmode option "bogus": should be static, dynamic, or none}}} { set option [lindex $test 0] test Scrolledframe-2.$o "configuration options, $option" { list [catch {.sf configure $option [lindex $test 1]} msg] $msg } [list 1 [lindex $test 2]] incr o } # # Method tests which are successful. # foreach test { {{.sf childsite} {.sf.lwchildsite.clipper.canvas.sfchildsite}} {{.sf xview moveto .5} {}} {{.sf yview moveto .5} {}} {{.sf justify left} {}} {{.sf justify right} {}} {{.sf justify top} {}} {{.sf justify bottom} {}}} { set method [lindex [lindex $test 0] 1] test Scrolledframe-3.$m "object methods, $method" { list [catch {eval [lindex $test 0]} msg] $msg } [list 0 [lindex $test 1]] update incr m } # # Creation of children tests. # test Scrolledframe-1.$c {Scrolledframe children} { pack [button [.sf childsite].b1 -text Hello] -pady 10 update } {} incr c test Scrolledframe-1.$c {Scrolledframe children} { pack [button [.sf childsite].b2 -text World] -pady 10 update } {} incr c test Scrolledframe-1.$c {Scrolledframe children} { pack [button [.sf childsite].b3 -text "This is a test"] -pady 10 update } {} incr c test Scrolledframe-1.$c {Scrolledframe children} { pack [button [.sf childsite].b4 -text "This is a really big button"] -pady 10 update } {} incr c test Scrolledframe-1.$c {Scrolledframe children} { pack [button [.sf childsite].b5 -text "This is another really big button"] -pady 10 update } {} incr c test Scrolledframe-1.$c {Scrolledframe children} { pack [button [.sf childsite].b6 -text "This is the last really big button"] -pady 10 update } {} incr c # # Conclusion of constrcution/destruction tests # test Scrolledframe-1.$c {Scrolledframe destruction} { foreach child [winfo children [.sf childsite]] { destroy $child } destroy .sf update } {} incr c test Scrolledframe-1.$c {Scrolledframe construction} { iwidgets::scrolledframe .sf -width 150 -height 180 \ -labelpos nw -labeltext Scrolledframe \ -vscrollmode static -hscrollmode dynamic pack .sf -padx 10 -pady 10 -fill both -expand yes update } {} incr c test Scrolledframe-1.$c {Scrolledframe destruction} { destroy .sf update } {} incr c test Scrolledframe-1.$c {Scrolledframe destruction} { iwidgets::scrolledframe .sf pack .sf destroy .sf update } {} ::tcltest::cleanupTests exit