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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [iwidgets3.0.0/] [tests/] [timefield.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] Timefield 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: timefield.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 Timefield-1.$c {Timefield construction} {
33
    iwidgets::Timefield .tf -labeltext "Date Field"
34
    pack .tf -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 Timefield-2.$o {configuration option} {
44
    llength [.tf configure]
45
} {27}
46
 
47
incr o
48
 
49
foreach test {
50
    {-background #d9d9d9 #d9d9d9}
51
    {-borderwidth 4 4}
52
    {-borderwidth 2 2}
53
    {-command {.tf configure -background red} {.tf 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
    {-textbackground GhostWhite GhostWhite}
78
    {-textbackground #d9d9d9 #d9d9d9}} {
79
        set option [lindex $test 0]
80
        test Timefield-2.$o "configuration options, $option" {
81
            .tf configure $option [lindex $test 1]
82
            lindex [.tf configure $option] 4
83
        } [lindex $test 2]
84
        update
85
        incr o
86
}
87
 
88
#
89
# Option tests which fail and produce errors.
90
#
91
foreach test {
92
  {-childsitepos bogus {bad childsite option "bogus": should be n, e, s, or w}}} {
93
        set option [lindex $test 0]
94
        test Timefield-2.$o "configuration options, $option" {
95
            list [catch {.tf configure $option [lindex $test 1]} msg] $msg
96
        } [list 1 [lindex $test 2]]
97
        incr o
98
}
99
 
100
#
101
# Method tests which are successful.
102
#
103
foreach test {
104
    {{.tf childsite} {.tf.lwchildsite}}
105
    {{.tf show "11:45:00 AM"} {11:45:00 AM}}
106
    {{.tf get} {11:45:00 AM}}
107
    {{.tf get -string} {11:45:00 AM}}
108
    {{.tf isvalid} {1}}
109
    {{.tf component time delete 0 end} {}}
110
    {{.tf component time insert end "44:44:44 PM"} {}}
111
    {{.tf isvalid} {0}}
112
    {{.tf show now; list} {}}} {
113
        set method [lindex [lindex $test 0] 1]
114
        test Timefield-3.$m "object methods, $method" {
115
            list [catch {eval [lindex $test 0]} msg] $msg
116
        } [list 0 [lindex $test 1]]
117
        update
118
        incr m
119
}
120
 
121
test Timefield-3.$m "object methods, clock clicks" {
122
    set clicks [clock scan "3:15:00 PM"]
123
    .tf show $clicks
124
    update
125
    .tf get
126
} {03:15:00 PM}
127
incr m
128
 
129
#
130
# Method tests which fail and produce errors
131
#
132
foreach test {
133
    {{.tf get bogus} {bad format option "bogus": should be -string or -clicks}}
134
    {{.tf show bogus} {bad time: "bogus", must be a valid time  string, clock clicks value or the keyword now}}} {
135
        set method [lindex [lindex $test 0] 1]
136
        test Timefield-3.$m "object methods, $method" {
137
            list [catch {eval [lindex $test 0]} msg] $msg
138
        } [list 1 [lindex $test 1]]
139
        incr m
140
}
141
 
142
#
143
# Conclusion of constrcution/destruction tests
144
#
145
test Timefield-1.$c {Timefield destruction} {
146
    destroy .tf
147
    update
148
} {}
149
 
150
incr c
151
 
152
test Timefield-1.$c {Timefield construction} {
153
    iwidgets::timefield .tf
154
    pack .tf -padx 10 -pady 10
155
    update
156
} {}
157
 
158
incr c
159
 
160
test Timefield-1.$c {Timefield destruction} {
161
    destroy .tf
162
    update
163
} {}

powered by: WebSVN 2.1.0

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