1 # This file is a Tcl script to test out [incr Widgets] ScrolledListBox class.
2 # It is organized in the standard fashion for Tcl tests with the following
3 # notation for test case labels:
5 # 1.x - Construction/Destruction tests
6 # 2.x - Configuration option tests
9 # Copyright (c) 1995 DSC Technologies Corporation
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 package require tcltest
17 namespace import -force ::tcltest::*
19 if [catch {package require Iwidgets 4.0}] {
20 # Let's try modifying the auto_path. Note that the IWIDGETS_LIBRARY
21 # env var is initialized in the Makefile when doing a 'make test'.
22 # If sourcing this file independently, this variable must be set manually.
23 if ![info exists env(IWIDGETS_LIBRARY)] {
24 error "Unable to locate Iwidgets package. Set your IWIDGETS_LIBRARY\
25 environment\nvariable to the directory that contains iwidgets.tcl"
27 lappend auto_path $env(IWIDGETS_LIBRARY)
28 package require Iwidgets 4.0
31 if {[string compare test [info procs test]] == 1} {
43 # Initial construction test
45 test Scrolledcanvas-1.$c {Scrolledcanvas construction} {
46 iwidgets::Scrolledcanvas .sc
47 pack .sc -padx 10 -pady 10 -fill both -expand yes
54 # Option tests which are successful.
56 test Scrolledcanvas-2.$o {configuration option} {
57 llength [.sc configure]
66 {-background #d9d9d9 #d9d9d9}
68 {-closeenough 1.0 1.0}
72 {-hscrollmode none none}
73 {-hscrollmode static static}
74 {-hscrollmode dynamic dynamic}
75 {-labelfont 6x13 6x13}
76 {-labeltext scrolledcanvas scrolledcanvas}
90 {-relief raised raised}
91 {-relief sunken sunken}
93 {-xscrollincrement 10 10}
94 {-yscrollincrement 10 10}
96 {-scrollregion {0 0 0 0} {0 0 0 0}}
106 {-textbackground GhostWhite GhostWhite}
107 {-vscrollmode static static}
108 {-vscrollmode none none}
109 {-vscrollmode dynamic dynamic}
111 set option [lindex $test 0]
112 test Scrolledcanvas-2.$o "configuration options, $option" {
113 .sc configure $option [lindex $test 1]
114 lindex [.sc configure $option] 4
121 # Option tests which fail and produce errors.
124 {-vscrollmode bogus {bad vscrollmode option "bogus": should be static, dynamic, or none}}
125 {-hscrollmode bogus {bad hscrollmode option "bogus": should be static, dynamic, or none}}} {
126 set option [lindex $test 0]
127 test Scrolledcanvas-2.$o "configuration options, $option" {
128 list [catch {.sc configure $option [lindex $test 1]} msg] $msg
129 } [list 1 [lindex $test 2]]
134 # Method tests which are successful.
137 {{.sc create rectangle 100 100 400 400 -fill red} {1}}
138 {{.sc create rectangle 300 300 600 600 -fill green} {2}}
139 {{.sc create rectangle 200 200 500 500 -fill blue} {3}}
140 {{.sc bbox 1} {99 99 401 401}}
141 {{.sc coords 2} {300.0 300.0 600.0 600.0}}
143 {{.sc move 1 10 10} {}}
144 {{.sc scale 1 100 100 0.8 0.8} {}}
145 {{.sc xview moveto 0} {}}
146 {{.sc yview moveto 0} {}}
147 {{.sc childsite} {.sc.lwchildsite.clipper.canvas}}
148 {{.sc justify left} {}}
149 {{.sc justify right} {}}
150 {{.sc justify top} {}}
151 {{.sc justify bottom} {}}} {
152 set method [lindex [lindex $test 0] 1]
153 test Scrolledcanvas-3.$m "object methods, $method" {
154 list [catch {eval [lindex $test 0]} msg] $msg
155 } [list 0 [lindex $test 1]]
161 # Conclusion of constrcution/destruction tests
163 test Scrolledcanvas-1.$c {Scrolledcanvas destruction} {
170 test Scrolledcanvas-1.$c {Scrolledcanvas construction} {
171 iwidgets::Scrolledcanvas .sc -autoresize no -labelpos nw \
172 -vscrollmode static -hscrollmode dynamic -labeltext "Scrolledcanvas"
173 pack .sc -padx 10 -pady 10 -fill both -expand yes
179 test Scrolledcanvas-1.$c {Scrolledcanvas destruction} {
186 test Scrolledcanvas-1.$c {Scrolledcanvas destruction} {
187 iwidgets::scrolledcanvas .sc
193 ::tcltest::cleanupTests