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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [iwidgets3.0.0/] [tests/] [scrolledlistbox.test] - Blame information for rev 1770

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] Scrolledlistbox 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: scrolledlistbox.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 Scrolledlistbox-1.$c {Scrolledlistbox construction} {
33
    iwidgets::Scrolledlistbox .slb -height 300 -width 300
34
    pack .slb -padx 10 -pady 10 -fill both -expand yes
35
    .slb insert end {Hello World} {Hello World}
36
    update
37
} {}
38
 
39
incr c
40
 
41
#
42
# Option tests which are successful.
43
#
44
test Scrolledlistbox-2.$o {configuration option} {
45
    llength [.slb configure]
46
} {38}
47
 
48
incr o
49
 
50
foreach test {
51
    {-labeltext Scrolledlistbox Scrolledlistbox}
52
    {-height 200 200}
53
    {-width 200 200}
54
    {-labelpos nw nw}
55
    {-labelpos ne ne}
56
    {-labelpos en en}
57
    {-labelpos e e}
58
    {-labelpos es es}
59
    {-labelpos se se}
60
    {-labelpos s s}
61
    {-labelpos sw sw}
62
    {-labelpos wn wn}
63
    {-labelpos w w}
64
    {-labelpos ws ws}
65
    {-labelpos n n}
66
    {-borderwidth 3 3}
67
    {-hscrollmode none none}
68
    {-hscrollmode static static}
69
    {-hscrollmode dynamic dynamic}
70
    {-relief raised raised}
71
    {-relief sunken sunken}
72
    {-sbwidth 20 20}
73
    {-sbwidth 15 15}
74
    {-textbackground GhostWhite GhostWhite}
75
    {-scrollmargin 10 10}
76
    {-selectborderwidth 3 3}
77
    {-selectforeground blue blue}
78
    {-selectmode browse browse}
79
    {-selectmode extended extended}
80
    {-selectmode single single}
81
    {-selectmode multiple multiple}
82
    {-textfont 6x13 6x13}
83
    {-vscrollmode none none}
84
    {-vscrollmode static static}
85
    {-vscrollmode dynamic dynamic}
86
    {-visibleitems 30x20 30x20}
87
    {-width 0 0}
88
    {-height 0 0}} {
89
        set option [lindex $test 0]
90
        test Scrolledlistbox-2.$o "configuration options, $option" {
91
            .slb configure $option [lindex $test 1]
92
            lindex [.slb configure $option] 4
93
        } [lindex $test 2]
94
        update
95
        incr o
96
}
97
 
98
#
99
# Option tests which fail and produce errors.
100
#
101
foreach test {
102
  {-visibleitems bogus {bad visibleitems option "bogus": should be widthxheight}}
103
  {-vscrollmode bogus {bad vscrollmode option "bogus": should be static, dynamic, or none}}
104
  {-hscrollmode bogus {bad hscrollmode option "bogus": should be static, dynamic, or none}}} {
105
        set option [lindex $test 0]
106
        test Scrolledlistbox-2.$o "configuration options, $option" {
107
            list [catch {.slb configure $option [lindex $test 1]} msg] $msg
108
        } [list 1 [lindex $test 2]]
109
        incr o
110
}
111
 
112
#
113
# Method tests which are successful.
114
#
115
foreach test {
116
    {{.slb insert 0 Test Test Test Test} {}}
117
    {{.slb insert end {More Test}} {}}
118
    {{.slb delete 1} {}}
119
    {{.slb delete 0 3} {}}
120
    {{.slb insert end World} {}}
121
    {{.slb selection set World} {}}
122
    {{.slb selection set World {More Test}} {}}
123
    {{.slb getcurselection} {{More Test} World}}
124
    {{.slb selecteditemcount} {2}}
125
    {{.slb selection clear 0 end} {}}
126
    {{.slb selecteditemcount} {0}}
127
    {{.slb clear} {}}
128
    {{.slb size} {0}}
129
    {{.slb insert end {Test} {Test} {Long String Test}} {}}
130
    {{.slb size} {3}}
131
    {{.slb insert 0 {Test} {Test} {Long String Test}} {}}
132
    {{.slb size} {6}}
133
    {{.slb insert 1 {Test} {Test} {Long String Test}} {}}
134
    {{.slb size} {9}}
135
    {{.slb insert 5 {Test} {Test} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}} {}}
136
    {{.slb size} {12}}
137
    {{.slb get end} {Long String Test}}
138
    {{.slb justify left} {}}
139
    {{.slb justify right} {}}
140
    {{.slb justify top} {}}
141
    {{.slb justify bottom} {}}
142
    {{.slb sort ascending} {}}
143
    {{.slb sort descending} {}}
144
    {{.slb sort increasing} {}}
145
    {{.slb sort decreasing} {}}} {
146
        set method [lindex [lindex $test 0] 1]
147
        test Scrolledlistbox-3.$m "object methods, $method" {
148
            list [catch {eval [lindex $test 0]} msg] $msg
149
        } [list 0 [lindex $test 1]]
150
        update
151
        incr m
152
}
153
 
154
#
155
# Method tests which fail and produce errors
156
#
157
foreach test {
158
    {{.slb index bogus} {bad Scrolledlistbox index "bogus": must be active, anchor, end, @x,y, number, or a pattern}}
159
    {{.slb justify bogus} {bad justify argument "bogus": should be left, right, top, or bottom}}
160
    {{.slb sort bogus} {bad sort argument "bogus": should be ascending, descending, increasing, or decreasing}}} {
161
        set method [lindex [lindex $test 0] 1]
162
        test Scrolledlistbox-3.$m "object methods, $method" {
163
            list [catch {eval [lindex $test 0]} msg] $msg
164
        } [list 1 [lindex $test 1]]
165
        incr m
166
}
167
 
168
#
169
# Conclusion of constrcution/destruction tests
170
#
171
test Scrolledlistbox-1.$c {Scrolledlistbox destruction} {
172
    destroy .slb
173
    update
174
} {}
175
 
176
incr c
177
 
178
test Scrolledlistbox-1.$c {Scrolledlistbox construction} {
179
    iwidgets::scrolledlistbox .slb -selectmode extended \
180
        -vscrollmode static -hscrollmode dynamic -labeltext "List" \
181
        -labelpos nw
182
    pack .slb -padx 10 -pady 10 -fill both -expand yes
183
    update
184
} {}
185
 
186
incr c
187
 
188
test Scrolledlistbox-1.$c {Scrolledlistbox destruction} {
189
    destroy .slb
190
    update
191
} {}
192
 
193
incr c
194
 
195
test Scrolledlistbox-1.$c {Scrolledlistbox destruction} {
196
    iwidgets::scrolledlistbox .slb
197
    pack .slb
198
    destroy .slb
199
    update
200
} {}

powered by: WebSVN 2.1.0

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