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

Subversion Repositories or1k

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

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] Messagebox 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: messagebox.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 Messagebox-1.$c {Messagebox construction} {
33
    iwidgets::Messagebox .mb
34
    pack .mb -padx 10 -pady 10 -fill both -expand yes
35
    update
36
} {}
37
 
38
incr c
39
 
40
#
41
# Option tests which are successful.
42
#
43
test Messagebox-2.$o {configuration option} {
44
    llength [.mb configure]
45
} {40}
46
 
47
incr o
48
 
49
foreach test {
50
    {-activebackground #ececec #ececec}
51
    {-activeforeground Black Black}
52
    {-background #d9d9d9 #d9d9d9}
53
    {-borderwidth 3 3}
54
    {-cursor gumby gumby}
55
    {-exportselection 0 0}
56
    {-exportselection 1 1}
57
    {-filename /tmp/foo /tmp/foo}
58
    {-foreground Black Black}
59
    {-height 0 0}
60
    {-width 0 0}
61
    {-width 550 550}
62
    {-height 120 120}
63
    {-highlightcolor Black Black}
64
    {-highlightthickness 2 2}
65
    {-labelmargin 5 5}
66
    {-labeltext Label Label}
67
    {-labelpos nw nw}
68
    {-labelpos ne ne}
69
    {-labelpos en en}
70
    {-labelpos e e}
71
    {-labelpos es es}
72
    {-labelpos se se}
73
    {-labelpos s s}
74
    {-labelpos sw sw}
75
    {-labelpos wn wn}
76
    {-labelpos w w}
77
    {-labelpos ws ws}
78
    {-labelpos n n}
79
    {-relief raised raised}
80
    {-relief sunken sunken}
81
    {-vscrollmode none none}
82
    {-vscrollmode static static}
83
    {-vscrollmode dynamic dynamic}
84
    {-hscrollmode none none}
85
    {-hscrollmode static static}
86
    {-hscrollmode dynamic dynamic}
87
    {-maxlines 1200 1200}
88
    {-sbwidth 20 20}
89
    {-savedir /tmp /tmp}
90
    {-scrollmargin 5 5}
91
    {-textbackground GhostWhite GhostWhite}} {
92
        set option [lindex $test 0]
93
        test Messagebox-2.$o "configuration options, $option" {
94
            .mb configure $option [lindex $test 1]
95
            lindex [.mb configure $option] 4
96
        } [lindex $test 2]
97
        update
98
        incr o
99
}
100
 
101
#
102
# Option tests which fail and produce errors.
103
#
104
foreach test {
105
  {-visibleitems bogus {bad visibleitems option "bogus": should be widthxheight}}
106
  {-hscrollmode bogus {bad hscrollmode option "bogus": should be static, dynamic, or none}}
107
  {-vscrollmode bogus {bad vscrollmode option "bogus": should be static, dynamic, or none}}} {
108
        set option [lindex $test 0]
109
        test Messagebox-2.$o "configuration options, $option" {
110
            list [catch {.mb configure $option [lindex $test 1]} msg] $msg
111
        } [list 1 [lindex $test 2]]
112
        incr o
113
}
114
 
115
#
116
# Method tests which are successful.
117
#
118
foreach test {
119
    {{.mb issue "Default test"} {}}
120
    {{.mb type add ERROR -background red -foreground white -bell 1} {ERROR}}
121
    {{.mb issue "ERROR test" ERROR} {}}
122
    {{.mb type configure ERROR -font 7x13 -show 0} {}}
123
    {{.mb issue "ERROR test" ERROR} {}}
124
    {{.mb type cget ERROR -background} {red}}
125
    {{.mb type remove ERROR} {}}
126
    {{.mb clear} {}}} {
127
        set method [lindex [lindex $test 0] 1]
128
        test Messagebox-3.$m "object methods, $method" {
129
            list [catch {eval [lindex $test 0]} msg] $msg
130
        } [list 0 [lindex $test 1]]
131
        update
132
        incr m
133
}
134
 
135
#
136
# Method tests which fail and produce errors
137
#
138
foreach test {
139
    {{.mb type bogus bogus} {bad type operation: "bogus", should be add, remove, configure or cget}}
140
    {{.mb issue foo bogus} {bad message type: "bogus", use the type command to create a new types}}} {
141
        set method [lindex [lindex $test 0] 1]
142
        test Messagebox-3.$m "object methods, $method" {
143
            list [catch {eval [lindex $test 0]} msg] $msg
144
        } [list 1 [lindex $test 1]]
145
        incr m
146
}
147
 
148
#
149
# Conclusion of constrcution/destruction tests
150
#
151
test Messagebox-1.$c {Messagebox destruction} {
152
    destroy .mb
153
    update
154
} {}
155
 
156
incr c
157
 
158
test Messagebox-1.$c {Messagebox construction} {
159
    iwidgets::messagebox .mb -hscrollmode dynamic -labeltext "Label" \
160
            -labelpos n -labelmargin 5
161
    pack .mb -padx 10 -pady 10 -fill both -expand yes
162
    update
163
} {}
164
 
165
incr c
166
 
167
test Messagebox-1.$c {Messagebox destruction} {
168
    destroy .mb
169
    update
170
} {}
171
 
172
incr c
173
 
174
test Messagebox-1.$c {Messagebox destruction} {
175
    iwidgets::messagebox .mb
176
    pack .mb
177
    destroy .mb
178
    update
179
} {}

powered by: WebSVN 2.1.0

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