summaryrefslogtreecommitdiffstats
path: root/tests/ttk/checkbutton.test
blob: 1ff6320e8b5c555c391e11326c6cbd5c252df7cf (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
# $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