OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [tests/] [general/] [combobox.tcl] - Blame information for rev 1781

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# combobox.tcl --
2
#
3
#       Tests the ComboBox widget.
4
#
5
# Copyright (c) 1996, Expert Interface Technologies
6
#
7
# See the file "license.terms" for information on usage and redistribution
8
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9
#
10
 
11
proc About {} {
12
    return "Testing the ComboBox widget."
13
}
14
 
15
proc cbTest_Command {args} {
16
    global cbTest_selected
17
 
18
    set cbTest_selected [tixEvent value]
19
}
20
 
21
proc cbTest_ListCmd {w} {
22
    global counter
23
 
24
    incr counter
25
 
26
    $w subwidget listbox delete 0 end
27
    $w subwidget listbox insert end 0
28
    $w subwidget listbox insert end 1
29
    $w subwidget listbox insert end 2
30
}
31
 
32
 
33
proc Test {} {
34
    global cbTest_selected
35
 
36
    for {set dropdown 1} {$dropdown >= 0} {incr dropdown -1} {
37
 
38
        TestBlock combo-1.1 {Config -value} {
39
            set w [tixComboBox .c -command cbTest_Command -dropdown $dropdown \
40
                -editable true]
41
            pack $w
42
            update
43
            set val "Testing some value .."
44
            $w config -value $val
45
            Assert {[tixStrEq "$cbTest_selected" $val]}
46
        }
47
 
48
        TestBlock combo-1.2 {selection from listbox} {
49
            $w subwidget listbox insert end "entry 0"
50
            $w subwidget listbox insert end "entry 1"
51
            $w subwidget listbox insert end "entry 2"
52
 
53
            for {set x 0} {$x <= 2} {incr x} {
54
                Click [$w subwidget arrow]
55
                update
56
 
57
                if $dropdown {
58
                    ClickListboxEntry [$w subwidget listbox] $x single
59
                } else {
60
                    ClickListboxEntry [$w subwidget listbox] $x single
61
                    ClickListboxEntry [$w subwidget listbox] $x double
62
                }
63
                update
64
 
65
                Assert {[tixStrEq "$cbTest_selected" "entry $x"]}
66
            }
67
        }
68
 
69
        TestBlock combo-1.3 {invokation by keyboard} {
70
            set val "Testing by key with \\ slashes"
71
            KeyboardString [$w subwidget entry] $val
72
            KeyboardEvent [$w subwidget entry] <Return>
73
            update
74
 
75
            Assert {[tixStrEq "$cbTest_selected" "$val"]}
76
        }
77
 
78
        catch {
79
            destroy $w
80
        }
81
    }
82
 
83
    TestBlock combo-2.1 {-listcmd of ComboBox} {
84
        global counter
85
        set counter 0
86
        tixComboBox .c -listcmd "cbTest_ListCmd .c"
87
        pack .c -expand yes -fill both
88
        update
89
 
90
        Click [.c subwidget arrow]
91
        update
92
        Assert {$counter == 1}
93
        Click [.c subwidget arrow]
94
        update
95
 
96
        Click [.c subwidget arrow]
97
        update
98
        Click [.c subwidget arrow]
99
        update
100
        Assert {$counter == 2}
101
 
102
 
103
        Assert {[.c subwidget listbox get 0] == "0"}
104
        Assert {[.c subwidget listbox get 1] == "1"}
105
        Assert {[.c subwidget listbox get 2] == "2"}
106
    }
107
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.