diff options
author | jenglish <jenglish@flightlab.com> | 2008-12-31 23:10:47 (GMT) |
---|---|---|
committer | jenglish <jenglish@flightlab.com> | 2008-12-31 23:10:47 (GMT) |
commit | b9039ab7be24d01ed44ff7052c83d5511f25f8b0 (patch) | |
tree | d93a434b6b1af4fe35b1d1daaa8a4161ce1b2898 /tests/ttk | |
parent | e74b92a66cb3c8d158ded0ddabf6740c1d038850 (diff) | |
download | tk-b9039ab7be24d01ed44ff7052c83d5511f25f8b0.zip tk-b9039ab7be24d01ed44ff7052c83d5511f25f8b0.tar.gz tk-b9039ab7be24d01ed44ff7052c83d5511f25f8b0.tar.bz2 |
tests/ttk/{checkbutton,radiobutton}.test: split out from ttk.test.
Diffstat (limited to 'tests/ttk')
-rw-r--r-- | tests/ttk/checkbutton.test | 49 | ||||
-rw-r--r-- | tests/ttk/radiobutton.test | 49 | ||||
-rw-r--r-- | tests/ttk/ttk.test | 91 |
3 files changed, 103 insertions, 86 deletions
diff --git a/tests/ttk/checkbutton.test b/tests/ttk/checkbutton.test new file mode 100644 index 0000000..1ff6320 --- /dev/null +++ b/tests/ttk/checkbutton.test @@ -0,0 +1,49 @@ +# $Id: checkbutton.test,v 1.1 2008/12/31 23:10:48 jenglish Exp $ +# +# ttk::checkbutton widget tests. +# + +package require Tk +package require tcltest ; namespace import -force tcltest::* +loadTestedCommands + +test checkbutton-1.1 "Checkbutton check" -body { + pack [ttk::checkbutton .cb -text "TCheckbutton" -variable cb] +} +test checkbutton-1.2 "Checkbutton invoke" -body { + .cb invoke + list [set ::cb] [.cb instate selected] +} -result [list 1 1] +test checkbutton-1.3 "Checkbutton reinvoke" -body { + .cb invoke + list [set ::cb] [.cb instate selected] +} -result [list 0 0] + +test checkbutton-1.4 "Checkbutton variable" -body { + set result [] + set ::cb 1 + lappend result [.cb instate selected] + set ::cb 0 + lappend result [.cb instate selected] +} -result {1 0} + +test checkbutton-1.5 "Unset checkbutton variable" -body { + set result [] + unset ::cb + lappend result [.cb instate alternate] [info exists ::cb] + set ::cb 1 + lappend result [.cb instate alternate] [info exists ::cb] +} -result {1 0 0 1} + +# See #1257319 +test checkbutton-1.6 "Checkbutton default variable" -body { + destroy .cb ; unset -nocomplain {} ; set result [list] + ttk::checkbutton .cb -onvalue on -offvalue off + lappend result [.cb cget -variable] [info exists .cb] [.cb state] + .cb invoke + lappend result [info exists .cb] [set .cb] [.cb state] + .cb invoke + lappend result [info exists .cb] [set .cb] [.cb state] +} -result [list .cb 0 alternate 1 on selected 1 off {}] + +tcltest::cleanupTests diff --git a/tests/ttk/radiobutton.test b/tests/ttk/radiobutton.test new file mode 100644 index 0000000..5daf83a --- /dev/null +++ b/tests/ttk/radiobutton.test @@ -0,0 +1,49 @@ +# $Id: radiobutton.test,v 1.1 2008/12/31 23:10:48 jenglish Exp $ +# +# ttk::radiobutton widget tests. +# + +package require Tk +package require tcltest ; namespace import -force tcltest::* +loadTestedCommands + +test radiobutton-1.1 "Radiobutton check" -body { + pack \ + [ttk::radiobutton .rb1 -text "One" -variable choice -value 1] \ + [ttk::radiobutton .rb2 -text "Two" -variable choice -value 2] \ + [ttk::radiobutton .rb3 -text "Three" -variable choice -value 3] \ + ; +} +test radiobutton-1.2 "Radiobutton invoke" -body { + .rb1 invoke + set ::choice +} -result 1 + +test radiobutton-1.3 "Radiobutton state" -body { + .rb1 instate selected +} -result 1 + +test radiobutton-1.4 "Other radiobutton invoke" -body { + .rb2 invoke + set ::choice +} -result 2 + +test radiobutton-1.5 "Other radiobutton state" -body { + .rb2 instate selected +} -result 1 + +test radiobutton-1.6 "First radiobutton state" -body { + .rb1 instate selected +} -result 0 + +test radiobutton-1.7 "Unset radiobutton variable" -body { + unset ::choice + list [info exists ::choice] [.rb1 instate alternate] [.rb2 instate alternate] +} -result {0 1 1} + +test radiobutton-1.8 "Reset radiobutton variable" -body { + set ::choice 2 + list [info exists ::choice] [.rb1 instate alternate] [.rb2 instate alternate] +} -result {1 0 0} + +tcltest::cleanupTests diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index 2bb3d04..2747727 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -129,7 +129,6 @@ test ttk-selfdestruct-ok-1 "Intentional self-destruction" -body { # # Basic tests. # - test ttk-1.1 "Create button" -body { pack [ttk::button .t] -expand true -fill both update @@ -139,7 +138,11 @@ test ttk-1.2 "Check style" -body { .t cget -style } -result {} -test ttk-1.4 "Restore default style" -body { +test ttk-1.3 "Set bad style" -body { + .t configure -style "nosuchstyle" +} -returnCodes 1 -result {Layout nosuchstyle not found} + +test ttk-1.4 "Original style preserved" -body { .t cget -style } -result "" @@ -266,90 +269,6 @@ test ttk-4.4 "Bad resource specifications" -body { } # -# checkbutton tests -# -test ttk-5.1 "Checkbutton check" -body { - pack [ttk::checkbutton .cb -text "TCheckbutton" -variable cb] -} -test ttk-5.2 "Checkbutton invoke" -body { - .cb invoke - list [set ::cb] [.cb instate selected] -} -result [list 1 1] -test ttk-5.3 "Checkbutton reinvoke" -body { - .cb invoke - list [set ::cb] [.cb instate selected] -} -result [list 0 0] - -test ttk-5.4 "Checkbutton variable" -body { - set result [] - set ::cb 1 - lappend result [.cb instate selected] - set ::cb 0 - lappend result [.cb instate selected] -} -result {1 0} - -test ttk-5.5 "Unset checkbutton variable" -body { - set result [] - unset ::cb - lappend result [.cb instate alternate] [info exists ::cb] - set ::cb 1 - lappend result [.cb instate alternate] [info exists ::cb] -} -result {1 0 0 1} - -# See #1257319 -test ttk-5.6 "Checkbutton default variable" -body { - destroy .cb ; unset -nocomplain {} ; set result [list] - ttk::checkbutton .cb -onvalue on -offvalue off - lappend result [.cb cget -variable] [info exists .cb] [.cb state] - .cb invoke - lappend result [info exists .cb] [set .cb] [.cb state] - .cb invoke - lappend result [info exists .cb] [set .cb] [.cb state] -} -result [list .cb 0 alternate 1 on selected 1 off {}] - -# -# radiobutton tests -# -test ttk-7.1 "Radiobutton check" -body { - pack \ - [ttk::radiobutton .rb1 -text "One" -variable choice -value 1] \ - [ttk::radiobutton .rb2 -text "Two" -variable choice -value 2] \ - [ttk::radiobutton .rb3 -text "Three" -variable choice -value 3] \ - ; -} -test ttk-7.2 "Radiobutton invoke" -body { - .rb1 invoke - set ::choice -} -result 1 - -test ttk-7.3 "Radiobutton state" -body { - .rb1 instate selected -} -result 1 - -test ttk-7.4 "Other radiobutton invoke" -body { - .rb2 invoke - set ::choice -} -result 2 - -test ttk-7.5 "Other radiobutton state" -body { - .rb2 instate selected -} -result 1 - -test ttk-7.6 "First radiobutton state" -body { - .rb1 instate selected -} -result 0 - -test ttk-7.7 "Unset radiobutton variable" -body { - unset ::choice - list [info exists ::choice] [.rb1 instate alternate] [.rb2 instate alternate] -} -result {0 1 1} - -test ttk-7.8 "Reset radiobutton variable" -body { - set ::choice 2 - list [info exists ::choice] [.rb1 instate alternate] [.rb2 instate alternate] -} -result {1 0 0} - -# # -compound tests: # variable iconData \ |