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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [tests/] [grid/] [Grid.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
# This tests the Grid widget.
2
#
3
#
4
#
5
proc About {} {
6
    return "Basic tests for the Grid widget"
7
}
8
 
9
proc Test {} {
10
    TestBlock grid-1.1 {Grid creation} {
11
        test {tixGrid} {args}
12
        test {tixGrid .g -ff} {unknown}
13
        test {tixGrid .g -width} {missing}
14
 
15
        Assert {[info command .g] == {}}
16
        Assert {![winfo exists .g]}
17
    }
18
 
19
    TestBlock grid-1.2 {Grid creation} {
20
        set g [tixGrid .g]
21
        pack $g -expand yes -fill both
22
        update
23
        destroy $g
24
    }
25
 
26
    TestBlock grid-2.1 {Grid widget commands} {
27
        set g [tixGrid .g]
28
        pack $g -expand yes -fill both
29
        test {$g} {args}
30
        set foo ""
31
    }
32
    TestBlock grid-2.2 {Grid widget commands} {
33
        $g config -selectmode browse
34
        Assert {[tixStrEq [$g cget -selectmode] browse]}
35
    }
36
 
37
    #----------------------------------------
38
    # Sites
39
    #----------------------------------------
40
    foreach cmd {anchor dragsite dropsite} {
41
        TestBlock grid-3.1 "Grid \"$cmd\" widget command" {
42
            test1 {$g $cmd} \
43
                "wrong # args: should be \".g $cmd option ?x y?\""
44
        }
45
        TestBlock grid-3.2 "Grid \"$cmd\" widget command" {
46
            test1 {$g $cmd foo} \
47
                {wrong option "foo", must be clear, get or set}
48
        }
49
        TestBlock grid-3.3 "Grid \"$cmd\" widget command" {
50
            test1 {$g $cmd clear bar} \
51
                "wrong # of arguments, must be: .g $cmd clear"
52
        }
53
        TestBlock grid-3.4 "Grid \"$cmd\" widget command" {
54
            test1 {$g $cmd set 0 0 bar} \
55
                "wrong # args: should be \".g $cmd option ?x y?\""
56
        }
57
        TestBlock grid-3.5 "Grid \"$cmd\" widget command" {
58
            test1 {$g $cmd set xxx 0} \
59
                {expected integer but got "xxx"}
60
        }
61
        TestBlock grid-3.6 "Grid \"$cmd\" widget command" {
62
            test1 {$g $cmd set 0 xxx} \
63
                {expected integer but got "xxx"}
64
        }
65
        foreach selunit {row column cell} {
66
            TestBlock grid-3.7 "Grid \"$cmd\" widget command" {
67
                $g config -selectunit $selunit
68
                $g $cmd set 0 0
69
                update
70
            }
71
        }
72
        TestBlock grid-3.8 "Grid \"$cmd\" widget command" {
73
            $g $cmd set 0 0
74
            Assert {[tixStrEq [$g $cmd get] "0 0"]}
75
        }
76
        TestBlock grid-3.9 "Grid \"$cmd\" widget command" {
77
            $g $cmd set -20 -0
78
            Assert {[tixStrEq [$g $cmd get] "0 0"]}
79
        }
80
        TestBlock grid-3.10 "Grid \"$cmd\" widget command" {
81
            $g $cmd set 10000000 100000000
82
            Assert {[tixStrEq [$g $cmd get] "10000000 100000000"]}
83
        }
84
    }
85
 
86
    #----------------------------------------
87
    # set
88
    #----------------------------------------
89
    TestBlock grid-4.1 {Grid "set" widget command} {
90
        test {$g set} {args}
91
        test {$g set 0 0 -foo} {missing}
92
        test {$g set 0 0 -foo bar} {unknown}
93
        test {$g set 0 0 -itemtype foo} {unknown}
94
        test {$g set 0 0 -itemtype imagetext -image foo} {image}
95
        test {$g set 0 0 -itemtype imagetext -text Hello -image \
96
            [tix getimage folder]
97
        }
98
        update
99
    }
100
 
101
    TestBlock grid-4.2 {Grid "set" widget command} {
102
        for {set x 0} {$x < 19} {incr x} {
103
            for {set y 0} {$y < 13} {incr y} {
104
                $g set $x $y -itemtype imagetext -text ($x,$y) \
105
                    -image [tix getimage folder]
106
            }
107
        }
108
        update
109
    }
110
 
111
    TestBlock grid-4.3 {Grid "unset" widget command} {
112
        for {set x 0} {$x < 23} {incr x} {
113
            for {set y 0} {$y < 19} {incr y} {
114
                $g unset $x $y
115
            }
116
        }
117
        update
118
    }
119
 
120
 
121
    #----------------------------------------
122
    # delete
123
    #----------------------------------------
124
    TestBlock grid-5.1 {Grid "delete" widget command} {
125
        for {set x 0} {$x < 19} {incr x} {
126
            for {set y 0} {$y < 13} {incr y} {
127
                $g set $x $y -itemtype imagetext -text ($x,$y) \
128
                    -image [tix getimage folder]
129
            }
130
        }
131
        foreach index {0 1 3 2 6 3 1 1 max 19 13 max} {
132
            $g delete row $index
133
            $g delete col $index
134
            update
135
        }
136
    }
137
    #----------------------------------------
138
    # move
139
    #----------------------------------------
140
    TestBlock grid-6.1 {Grid "move" widget command} {
141
        for {set x 0} {$x < 19} {incr x} {
142
            for {set y 0} {$y < 13} {incr y} {
143
                $g set $x $y -itemtype imagetext -text ($x,$y) \
144
                    -image [tix getimage folder]
145
            }
146
        }
147
        foreach index {0 1 3 2 6 3 1 1 max 19 13 max} {
148
            $g move row $index $index 3
149
            $g move col $index $index -2
150
            update
151
        }
152
    }
153
 
154
}
155
 

powered by: WebSVN 2.1.0

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