1 # This file is a Tcl script to test out [incr Widgets] Pushbutton 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 Pushbutton-1.$c {Pushbutton construction} {
46 iwidgets::Pushbutton .pb
47 pack .pb -padx 10 -pady 10
48 image create bitmap flagup -file $tk_library/demos/images/flagup.bmp
55 # Option tests which are successful.
57 test Pushbutton-2.$o {configuration option} {
58 llength [.pb configure]
64 {-activebackground #ececec #ececec}
65 {-activeforeground Black Black}
66 {-background #d9d9d9 #d9d9d9}
68 {-command {.pb configure -background Red} {.pb configure -background Red}}
73 {-image flagup flagup}
83 {-foreground Black Black}
87 {-highlightthickness 3 3}
88 {-highlightcolor blue blue}
89 {-highlightcolor black black}
90 {-highlightthickness 2 2}
91 {-state disabled disabled}
92 {-state normal normal}
95 set option [lindex $test 0]
96 test Pushbutton-2.$o "configuration options, $option" {
97 .pb configure $option [lindex $test 1]
98 lindex [.pb configure $option] 4
105 # Method tests which are successful.
110 set method [lindex [lindex $test 0] 1]
111 test Pushbutton-3.$m "object methods, $method" {
112 list [catch {eval [lindex $test 0]} msg] $msg
113 } [list 0 [lindex $test 1]]
119 # Conclusion of constrcution/destruction tests
121 test Pushbutton-1.$c {Pushbutton destruction} {
129 test Pushbutton-1.$c {Pushbutton construction} {
130 iwidgets::pushbutton .pb -text "Push Button" -defaultring yes
131 pack .pb -padx 10 -pady 10
137 test Pushbutton-1.$c {Pushbutton destruction} {
144 test Pushbutton-1.$c {Pushbutton destruction} {
145 iwidgets::pushbutton .pb
151 ::tcltest::cleanupTests