blob: 185a89449b0f84d52bdeb3589ff10257e813dbda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# This file is a Tcl script to test out the procedures in the file
# tkBorder.c. It is organized in the standard fashion for Tcl tests.
#
# Copyright (c) 1998 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: border.test,v 1.6 2004/06/17 22:38:57 dkf Exp $
package require tcltest 2.1
eval tcltest::configure $argv
tcltest::loadTestedCommands
if {[testConstraint pseudocolor8]} {
toplevel .t -visual {pseudocolor 8} -colormap new
wm geom .t +0+0
}
test border-1.1 {Tk_AllocBorderFromObj - converting internal reps} testborder {
set x orange
lindex $x 0
destroy .b1
button .b1 -bg $x -text .b1
lindex $x 0
testborder orange
} {{1 0}}
test border-1.3 {Tk_AllocBorderFromObj - discard stale border} testborder {
set x orange
destroy .b1 .b2
button .b1 -bg $x -text First
destroy .b1
set result {}
lappend result [testborder orange]
button .b2 -bg $x -text Second
lappend result [testborder orange]
} {{} {{1 1}}}
test border-1.2 {Tk_AllocBorderFromObj - reuse existing border} testborder {
set x orange
destroy .b1 .b2
button .b1 -bg $x -text First
set result {}
lappend result [testborder orange]
button .b2 -bg $x -text Second
pack .b1 .b2 -side top
lappend result [testborder orange]
} {{{1 1}} {{2 1}}}
test border-1.4 {Tk_AllocBorderFromObj - try other borders in list} {pseudocolor8 testborder} {
set x purple
destroy .b1 .b2 .t.b
button .b1 -bg $x -text First
pack .b1 -side top
set result {}
lappend result [testborder purple]
button .t.b -bg $x -text Second
pack .t.b -side top
lappend result [testborder purple]
button .b2 -bg $x -text Third
pack .b2 -side top
lappend result [testborder purple]
} {{{1 1}} {{1 1} {1 0}} {{1 0} {2 1}}}
test border-3.1 {Tk_Free3DBorder - reference counts} {pseudocolor8 testborder} {
set x purple
destroy .b1 .b2 .t.b
button .b1 -bg $x -text First
pack .b1 -side top
button .t.b -bg $x -text Second
pack .t.b -side top
button .b2 -bg $x -text Third
pack .b2 -side top
set result {}
lappend result [testborder purple]
destroy .b1
lappend result [testborder purple]
destroy .b2
lappend result [testborder purple]
destroy .t.b
lappend result [testborder purple]
} {{{1 0} {2 1}} {{1 0} {1 1}} {{1 0}} {}}
test border-3.4 {Tk_Free3DBorder - unlinking from list} {pseudocolor8 testborder} {
destroy .b .t.b .t2 .t3
toplevel .t2 -visual {pseudocolor 8} -colormap new
toplevel .t3 -visual {pseudocolor 8} -colormap new
set x purple
button .b -bg $x -text .b1
button .t.b1 -bg $x -text .t.b1
button .t.b2 -bg $x -text .t.b2
button .t2.b1 -bg $x -text .t2.b1
button .t2.b2 -bg $x -text .t2.b2
button .t2.b3 -bg $x -text .t2.b3
button .t3.b1 -bg $x -text .t3.b1
button .t3.b2 -bg $x -text .t3.b2
button .t3.b3 -bg $x -text .t3.b3
button .t3.b4 -bg $x -text .t3.b4
set result {}
lappend result [testborder purple]
destroy .t2
lappend result [testborder purple]
destroy .b
lappend result [testborder purple]
destroy .t3
lappend result [testborder purple]
destroy .t
lappend result [testborder purple]
} {{{4 1} {3 0} {2 0} {1 0}} {{4 1} {2 0} {1 0}} {{4 1} {2 0}} {{2 0}} {}}
test border-4.1 {FreeBorderObjProc} testborder {
destroy .b
set x [format purple]
button .b -bg $x -text .b1
set y [format purple]
.b configure -bg $y
set z [format purple]
.b configure -bg $z
set result {}
lappend result [testborder purple]
set x red
lappend result [testborder purple]
set z 32
lappend result [testborder purple]
destroy .b
lappend result [testborder purple]
set y bogus
set result
} {{{1 3}} {{1 2}} {{1 1}} {}}
catch {destroy .b}
button .b
test get-2.1 {Tk_GetReliefFromObj} {
.b configure -relief flat
.b cget -relief
} {flat}
test get-2.2 {Tk_GetReliefFromObj} {
.b configure -relief groove
.b cget -relief
} {groove}
test get-2.3 {Tk_GetReliefFromObj} {
.b configure -relief raised
.b cget -relief
} {raised}
test get-2.3 {Tk_GetReliefFromObj} {
.b configure -relief ridge
.b cget -relief
} {ridge}
test get-2.3 {Tk_GetReliefFromObj} {
.b configure -relief solid
.b cget -relief
} {solid}
test get-2.3 {Tk_GetReliefFromObj} {
.b configure -relief sunken
.b cget -relief
} {sunken}
test get-2.4 {Tk_GetReliefFromObj - error} {
list [catch {.b configure -relief upanddown} msg] $msg
} {1 {bad relief "upanddown": must be flat, groove, raised, ridge, solid, or sunken}}
if {[testConstraint pseudocolor8]} {
destroy .t
}
# cleanup
cleanupTests
return
|