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

Subversion Repositories or1k_old

[/] [or1k_old/] [tags/] [start/] [insight/] [itcl/] [iwidgets3.0.0/] [tests/] [selectionbox.test] - Blame information for rev 578

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

Line No. Rev Author Line
1 578 markom
# This file is a Tcl script to test out [incr Widgets] Selectionbox class.
2
# It is organized in the standard fashion for Tcl tests with the following
3
# notation for test case labels:
4
#
5
#   1.x - Construction/Destruction tests
6
#   2.x - Configuration option tests
7
#   3.x - Method tests
8
#
9
# Copyright (c) 1995 DSC Technologies Corporation
10
#
11
# See the file "license.terms" for information on usage and redistribution
12
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13
#
14
# @(#) $Id: selectionbox.test,v 1.1.1.1 2002-01-16 10:24:51 markom Exp $
15
 
16
package require Iwidgets 3.0
17
 
18
if {[string compare test [info procs test]] == 1} {
19
    source defs
20
}
21
 
22
wm geometry . {}
23
raise .
24
 
25
set c 1
26
set o 1
27
set m 1
28
 
29
#
30
# Initial construction test
31
#
32
test Selectionbox-1.$c {Selectionbox construction} {
33
    iwidgets::Selectionbox .sb
34
    .sb insert items end Hello {Out There} World
35
    set cs [label [.sb childsite].label -text "Child Site"]
36
    pack $cs -fill x -padx 10 -pady 10
37
    pack .sb -padx 10 -pady 10 -fill both -expand yes
38
    update
39
} {}
40
 
41
incr c
42
 
43
#
44
# Option tests which are successful.
45
#
46
test Selectionbox-2.$o {configuration option} {
47
    llength [.sb configure]
48
} {35}
49
 
50
incr o
51
 
52
foreach test {
53
    {-width 280 280}
54
    {-height 340 340}
55
    {-activebackground #ececec #ececec}
56
    {-activerelief raised raised}
57
    {-background #d9d9d9 #d9d9d9}
58
    {-textbackground GhostWhite GhostWhite}
59
    {-borderwidth 2 2}
60
    {-childsitepos n n}
61
    {-childsitepos s s}
62
    {-childsitepos e e}
63
    {-childsitepos w w}
64
    {-childsitepos center center}
65
    {-cursor gumby gumby}
66
    {-dblclickcommand {.sb configure -background blue} {.sb configure -background blue}}
67
    {-exportselection 1 1}
68
    {-foreground Black Black}
69
    {-highlightcolor Black Black}
70
    {-highlightthickness 2 2}
71
    {-insertbackground Black Black}
72
    {-insertborderwidth 0 0}
73
    {-insertofftime 300 300}
74
    {-insertontime  600 600}
75
    {-insertwidth 2 2}
76
    {-itemslabel "Items Label" "Items Label"}
77
    {-itemson no no}
78
    {-labelfont -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*}
79
    {-margin 10 10}
80
    {-itemson yes yes}
81
    {-selectbackground #c3c3c3 #c3c3c3}
82
    {-selectborderwidth 1 1}
83
    {-itemscommand {.sb selectitem} {.sb selectitem}}
84
    {-selectforeground Black Black}
85
    {-selectioncommand _command _command}
86
    {-selectionlabel "Selection Label" "Selection Label"}
87
    {-selectionon no no}
88
    {-selectionon yes yes}
89
    {-textfont 6x13 6x13}
90
    {-width 0 0}
91
    {-height 0 0}} {
92
        set option [lindex $test 0]
93
        test Selectionbox-2.$o "configuration options, $option" {
94
            .sb configure $option [lindex $test 1]
95
            lindex [.sb configure $option] 4
96
        } [lindex $test 2]
97
        update
98
        incr o
99
}
100
 
101
#
102
# Method tests which are successful.
103
#
104
foreach test {
105
    {{.sb childsite} {.sb.sbchildsite}}
106
    {{destroy [.sb childsite]} {}}
107
    {{.sb delete Hello 1} {}}
108
    {{.sb delete 0} {}}
109
    {{.sb insert items 0 One Two Three Four Five Six} {}}
110
    {{.sb component items get 0 end} {One Two Three Four Five Six}}
111
    {{.sb size} 6}
112
    {{.sb clear selection} {}}
113
    {{.sb insert selection 0 One} {}}
114
    {{.sb get} One}
115
    {{.sb index end} 6}
116
    {{.sb index Six} 5}
117
    {{.sb selection set 1} {}}
118
    {{.sb selectitem} {}}
119
    {{.sb curselection} 1}
120
    {{.sb get} Two}
121
    {{.sb delete Three} {}}
122
    {{.sb clear items} {}}} {
123
        set method [lindex [lindex $test 0] 1]
124
        test Selectionbox-3.$m "object methods, $method" {
125
            list [catch {eval [lindex $test 0]} msg] $msg
126
        } [list 0 [lindex $test 1]]
127
        update
128
        incr m
129
}
130
 
131
#
132
# Method tests which fail and produce errors
133
#
134
foreach test {
135
    {{.sb clear bogus} {bad clear argument "bogus": should be selection or items}}} {
136
        set method [lindex [lindex $test 0] 1]
137
        test Selectionbox-3.$m "object methods, $method" {
138
            list [catch {eval [lindex $test 0]} msg] $msg
139
        } [list 1 [lindex $test 1]]
140
        incr m
141
}
142
 
143
#
144
# Conclusion of constrcution/destruction tests
145
#
146
test Selectionbox-1.$c {Selectionbox destruction} {
147
    destroy .sb
148
    update
149
} {}
150
 
151
incr c
152
 
153
test Selectionbox-1.$c {Selectionbox construction} {
154
    iwidgets::selectionbox .sb
155
    .sb component items configure -vscrollmode none -hscrollmode none
156
    pack .sb -padx 10 -pady 10 -fill both -expand yes
157
    update
158
} {}
159
 
160
incr c
161
 
162
test Selectionbox-1.$c {Selectionbox destruction} {
163
    destroy .sb
164
    update
165
} {}
166
 
167
incr c
168
 
169
test Selectionbox-1.$c {Selectionbox destruction} {
170
    iwidgets::selectionbox .sb
171
    pack .sb
172
    destroy .sb
173
    update
174
} {}

powered by: WebSVN 2.1.0

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