summaryrefslogtreecommitdiffstats
path: root/tests/ttk/radiobutton.test
blob: 29321c700dd40b210bb9257b0c98578214fe46b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#
# ttk::radiobutton widget tests.
#

package require tk
package require tcltest 2.2
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}

test radiobutton-2.1 "style command" -body {
    ttk::radiobutton .w
    list [.w cget -style] [.w style] [winfo class .w]
} -cleanup {
    destroy .w
} -result {{} TRadiobutton TRadiobutton}
test radiobutton-2.2 "style command" -body {
    ttk::style configure customStyle.TRadiobutton
    ttk::radiobutton .w -style customStyle.TRadiobutton
    list [.w cget -style] [.w style] [winfo class .w]
} -cleanup {
    destroy .w
} -result {customStyle.TRadiobutton customStyle.TRadiobutton TRadiobutton}

tcltest::cleanupTests