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/] [timeentry.test] - Blame information for rev 1765

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] Timeentry 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: timeentry.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 Timeentry-1.$c {Timeentry construction} {
33
    iwidgets::Timeentry .te -labeltext "Time Entry"
34
    pack .te -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 Timeentry-2.$o {configuration option} {
44
    llength [.te configure]
45
} {43}
46
 
47
incr o
48
 
49
foreach test {
50
    {-background #d9d9d9 #d9d9d9}
51
    {-borderwidth 4 4}
52
    {-borderwidth 2 2}
53
    {-command {.te configure -background red} {.te configure -background red}}
54
    {-cursor gumby gumby}
55
    {-exportselection 0 0}
56
    {-foreground Green Green}
57
    {-foreground Black Black}
58
    {-highlightcolor Red Red}
59
    {-highlightthickness 2 2}
60
    {-insertbackground Yellow Yellow}
61
    {-insertbackground Black Black}
62
    {-justify right right}
63
    {-justify center center}
64
    {-justify left left}
65
    {-labelmargin 5 5}
66
    {-labelpos w w}
67
    {-labelpos nw nw}
68
    {-labelpos n n}
69
    {-labelpos ne ne}
70
    {-labelpos e e}
71
    {-labelpos se se}
72
    {-labelpos s s}
73
    {-labelpos sw sw}
74
    {-labeltext Label Label}
75
    {-relief raised raised}
76
    {-relief sunken sunken}
77
    {-foreground black black}
78
    {-state disabled disabled}
79
    {-state normal normal}
80
    {-closetext Set Set}
81
    {-watchheight 200 200}
82
    {-watchwidth 200 200}
83
    {-hourradius .40 .40}
84
    {-hourcolor green green}
85
    {-minuteradius .90 .90}
86
    {-minutecolor blue blue}
87
    {-secondradius .99 .99}
88
    {-secondcolor red red}
89
    {-clockcolor brown brown}
90
    {-clockstipple error error}
91
    {-tickcolor purple purple}
92
    {-textbackground GhostWhite GhostWhite}
93
    {-textbackground #d9d9d9 #d9d9d9}} {
94
        set option [lindex $test 0]
95
        test Timeentry-2.$o "configuration options, $option" {
96
            .te configure $option [lindex $test 1]
97
            lindex [.te configure $option] 4
98
        } [lindex $test 2]
99
        update
100
        incr o
101
}
102
 
103
#
104
# Option tests which fail and produce errors.
105
#
106
foreach test {
107
  {-childsitepos bogus {bad childsite option "bogus": should be n, e, s, or w}}} {
108
        set option [lindex $test 0]
109
        test Timeentry-2.$o "configuration options, $option" {
110
            list [catch {.te 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
    {{.te childsite} {.te.lwchildsite}}
120
    {{.te show "11:11:11 PM"} {11:11:11 PM}}
121
    {{.te get} {11:11:11 PM}}
122
    {{.te get -string} {11:11:11 PM}}
123
    {{.te isvalid} {1}}
124
    {{.te component time delete 0 end} {}}
125
    {{.te component time insert end 44:44:44} {}}
126
    {{.te isvalid} {0}}
127
    {{.te show now; list} {}}} {
128
        set method [lindex [lindex $test 0] 1]
129
        test Timeentry-3.$m "object methods, $method" {
130
            list [catch {eval [lindex $test 0]} msg] $msg
131
        } [list 0 [lindex $test 1]]
132
        update
133
        incr m
134
}
135
 
136
test Timeentry-3.$m "object methods, clock clicks" {
137
    set clicks [clock scan "3:15:00 PM"]
138
    .te show $clicks
139
    update
140
    .te get
141
} {03:15:00 PM}
142
incr m
143
 
144
#
145
# Method tests which fail and produce errors
146
#
147
foreach test {
148
    {{.te get bogus} {bad format option "bogus": should be -string or -clicks}}
149
    {{.te show bogus} {bad time: "bogus", must be a valid time  string, clock clicks value or the keyword now}}} {
150
        set method [lindex [lindex $test 0] 1]
151
        test Timeentry-3.$m "object methods, $method" {
152
            list [catch {eval [lindex $test 0]} msg] $msg
153
        } [list 1 [lindex $test 1]]
154
        incr m
155
}
156
 
157
#
158
# Conclusion of constrcution/destruction tests
159
#
160
test Timeentry-1.$c {Timeentry destruction} {
161
    destroy .te
162
    update
163
} {}
164
 
165
incr c
166
 
167
test Timeentry-1.$c {Timeentry construction} {
168
    iwidgets::timeentry .te
169
    pack .te -padx 10 -pady 10
170
    update
171
} {}
172
 
173
incr c
174
 
175
test Timeentry-1.$c {Timeentry destruction} {
176
    destroy .te
177
    update
178
} {}

powered by: WebSVN 2.1.0

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