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

Subversion Repositories or1k_old

[/] [or1k_old/] [tags/] [start/] [insight/] [itcl/] [itk/] [tests/] [option.test] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#
2
# Basic tests for [incr Tk] mega-widgets
3
# ----------------------------------------------------------------------
4
#   AUTHOR:  Michael J. McLennan
5
#            Bell Labs Innovations for Lucent Technologies
6
#            mmclennan@lucent.com
7
#            http://www.tcltk.com/itcl
8
#
9
#      RCS:  $Id: option.test,v 1.1.1.1 2002-01-16 10:24:48 markom Exp $
10
# ----------------------------------------------------------------------
11
#            Copyright (c) 1993-1998  Lucent Technologies, Inc.
12
# ======================================================================
13
# See the file "license.terms" for information on usage and
14
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
 
16
if {[string compare test [info procs test]] == 1} then {source defs}
17
 
18
# ----------------------------------------------------------------------
19
#  Component option processing
20
# ----------------------------------------------------------------------
21
test option-1.1 {create a widget for the following tests} {
22
    itcl::class TestOptComp {
23
        inherit itk::Widget
24
        constructor {args} {
25
            itk_component add test1 {
26
                label $itk_interior.t1
27
            } {
28
                keep -background -foreground -cursor
29
                keep -text
30
            }
31
            pack $itk_component(test1) -side left -padx 2
32
            eval itk_initialize $args
33
        }
34
        private variable status ""
35
        public method action {info} {
36
            lappend status $info
37
        }
38
        public method do {cmd} {
39
            eval $cmd
40
        }
41
        itk_option define -status status Status {} {
42
            lappend status $itk_option(-status)
43
        }
44
    }
45
 
46
    itcl::class TestOptWidget {
47
        inherit itk::Widget
48
        constructor {args} {
49
            itk_component add test1 {
50
                label $itk_interior.t1
51
            } {
52
                keep -background -foreground -cursor
53
                keep -text
54
            }
55
            pack $itk_component(test1) -side left -padx 2
56
            eval itk_initialize $args
57
        }
58
        public method do {cmd} {
59
            eval $cmd
60
        }
61
    }
62
    TestOptWidget .#auto
63
} {.testOptWidget0}
64
 
65
test option-1.2 {"keep" can be called more than once} {
66
    .testOptWidget0 do {
67
        itk_component add k0 {
68
            TestOptComp $itk_interior.k0 -status "create"
69
        } {
70
            keep -background -foreground -cursor
71
            keep -background -foreground -cursor
72
            keep -status
73
            keep -status
74
        }
75
        pack $itk_component(k0)
76
    }
77
    .testOptWidget0 configure -status "foo"
78
    .testOptWidget0 component k0 do {set status}
79
} {create foo}
80
 
81
test option-1.3 {"rename" can be called more than once} {
82
    .testOptWidget0 do {
83
        itk_component add k1 {
84
            TestOptComp $itk_interior.k1 -status "create"
85
        } {
86
            rename -status -test test Test
87
            rename -status -test test Test
88
        }
89
        pack $itk_component(k1)
90
    }
91
    .testOptWidget0 configure -test "bar"
92
    .testOptWidget0 component k1 do {set status}
93
} {create bar}
94
 
95
test option-1.4 {"ignore" overrides keep and rename} {
96
    .testOptWidget0 do {
97
        itk_component add k2 {
98
            TestOptComp $itk_interior.k2 -status "create"
99
        } {
100
            keep -status
101
            rename -status -test test Test
102
            ignore -status
103
        }
104
        pack $itk_component(k2)
105
    }
106
    .testOptWidget0 configure -status k2 -test k2
107
    .testOptWidget0 component k2 do {set status}
108
} {create foo bar}
109
 
110
# ----------------------------------------------------------------------
111
#  Option processing with "usual" command
112
# ----------------------------------------------------------------------
113
test option-2.1 {create a widget for the following tests} {
114
    TestOptComp .testUsual
115
} {.testUsual}
116
 
117
test option-2.2 {register some "usual" code} {
118
    usual TestOptComp-test {keep -cursor -foreground}
119
} {}
120
 
121
test option-2.3 {query back "usual" code} {
122
    usual TestOptComp-test
123
} {keep -cursor -foreground}
124
 
125
test option-2.4 {query back unknown "usual" code} {
126
    usual xyzzyxyzzy
127
} {}
128
 
129
test option-2.5 {add a component using "usual" code} {
130
    .testUsual do {
131
        itk_component add u0 {
132
            label $itk_interior.u0 -text "Usual Test #0"
133
        } {
134
            usual TestOptComp-test
135
        }
136
        pack $itk_component(u0)
137
    }
138
    .testUsual configure -foreground green -cursor gumby
139
 
140
    list [.testUsual component u0 cget -foreground] \
141
         [.testUsual component u0 cget -cursor]
142
} {green gumby}
143
 
144
test option-2.6 {override "usual" options} {
145
    .testUsual do {
146
        itk_component add u1 {
147
            label $itk_interior.u1 -text "Usual Test #1"
148
        } {
149
            usual TestOptComp-test
150
            ignore -cursor
151
            keep -background
152
        }
153
        pack $itk_component(u1)
154
    }
155
    .testUsual configure -foreground red -background white -cursor dot
156
 
157
    list [.testUsual component u1 cget -foreground] \
158
         [.testUsual component u1 cget -background] \
159
         [.testUsual component u1 cget -cursor]
160
} {red white gumby}
161
 
162
set unique 0
163
foreach widget {button canvas checkbutton entry frame label listbox
164
                menu menubutton message radiobutton scale scrollbar
165
                text toplevel} {
166
    set name "c[incr unique]"
167
    test option-2.7.$name {verify "usual" options for all Tk widgets} {
168
        .testUsual do [format {
169
            itk_component add %s {
170
                %s $itk_interior.%s
171
            }
172
        } $name $widget $name]
173
    } $name
174
}
175
 
176
# ----------------------------------------------------------------------
177
#  Clean up
178
# ----------------------------------------------------------------------
179
itcl::delete class TestOptComp TestOptWidget

powered by: WebSVN 2.1.0

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