1# 2# ttk::combobox widget tests 3# 4 5package require Tk 8.5 6package require tcltest ; namespace import -force tcltest::* 7loadTestedCommands 8 9test combobox-1.0 "Combobox tests -- setup" -body { 10 ttk::combobox .cb 11} -result .cb 12 13test combobox-1.1 "Bad -values list" -body { 14 .cb configure -values "bad \{list" 15} -result "unmatched open brace in list" -returnCodes 1 16 17test combobox-1.end "Combobox tests -- cleanup" -body { 18 destroy .cb 19} 20 21test combobox-2.0 "current command" -body { 22 ttk::combobox .cb -values [list a b c d e a] 23 .cb current 24} -result -1 25 26test combobox-2.1 "current -- set index" -body { 27 .cb current 5 28 .cb get 29} -result a 30 31test combobox-2.2 "current -- change -values" -body { 32 .cb configure -values [list c b a d e] 33 .cb current 34} -result 2 35 36test combobox-2.3 "current -- change value" -body { 37 .cb set "b" 38 .cb current 39} -result 1 40 41test combobox-2.4 "current -- value not in list" -body { 42 .cb set "z" 43 .cb current 44} -result -1 45 46test combobox-2.end "Cleanup" -body { destroy .cb } 47 48 49test combobox-1890211 "ComboboxSelected event after listbox unposted" -body { 50 # whitebox test... 51 pack [ttk::combobox .cb -values [list a b c]] 52 set result [list] 53 bind .cb <<ComboboxSelected>> { 54 lappend result Event [winfo ismapped .cb.popdown] [.cb get] 55 } 56 lappend result Start 0 [.cb get] 57 ttk::combobox::Post .cb 58 lappend result Post [winfo ismapped .cb.popdown] [.cb get] 59 .cb.popdown.f.l selection clear 0 end; .cb.popdown.f.l selection set 1 60 ttk::combobox::LBSelected .cb.popdown.f.l 61 lappend result Select [winfo ismapped .cb.popdown] [.cb get] 62 update 63 set result 64} -result [list Start 0 {} Post 1 {} Select 0 b Event 0 b] -cleanup { 65 destroy .cb 66} 67 68tcltest::cleanupTests 69