1# 2# ttk::radiobutton widget tests. 3# 4 5package require Tk 6package require tcltest ; namespace import -force tcltest::* 7loadTestedCommands 8 9test radiobutton-1.1 "Radiobutton check" -body { 10 pack \ 11 [ttk::radiobutton .rb1 -text "One" -variable choice -value 1] \ 12 [ttk::radiobutton .rb2 -text "Two" -variable choice -value 2] \ 13 [ttk::radiobutton .rb3 -text "Three" -variable choice -value 3] \ 14 ; 15} 16test radiobutton-1.2 "Radiobutton invoke" -body { 17 .rb1 invoke 18 set ::choice 19} -result 1 20 21test radiobutton-1.3 "Radiobutton state" -body { 22 .rb1 instate selected 23} -result 1 24 25test radiobutton-1.4 "Other radiobutton invoke" -body { 26 .rb2 invoke 27 set ::choice 28} -result 2 29 30test radiobutton-1.5 "Other radiobutton state" -body { 31 .rb2 instate selected 32} -result 1 33 34test radiobutton-1.6 "First radiobutton state" -body { 35 .rb1 instate selected 36} -result 0 37 38test radiobutton-1.7 "Unset radiobutton variable" -body { 39 unset ::choice 40 list [info exists ::choice] [.rb1 instate alternate] [.rb2 instate alternate] 41} -result {0 1 1} 42 43test radiobutton-1.8 "Reset radiobutton variable" -body { 44 set ::choice 2 45 list [info exists ::choice] [.rb1 instate alternate] [.rb2 instate alternate] 46} -result {1 0 0} 47 48tcltest::cleanupTests 49