2478
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1447
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
222
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#GraphicDrawingTest
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
2382
|
11 |
category:'tests-Regression-Graphics-Basic'
|
222
|
12 |
!
|
|
13 |
|
|
14 |
|
|
15 |
!GraphicDrawingTest methodsFor:'tests'!
|
|
16 |
|
|
17 |
_testDraw:drawBlock thenCheck:checkBlock
|
|
18 |
|form|
|
|
19 |
|
|
20 |
form := Form width:30 height:30 depth:(Display depth) onDevice:Display.
|
|
21 |
form clear.
|
2478
|
22 |
form fill:Color black.
|
222
|
23 |
drawBlock value:form.
|
|
24 |
|
|
25 |
checkBlock value:form.
|
|
26 |
!
|
|
27 |
|
|
28 |
test_01_Clear
|
1447
|
29 |
self
|
|
30 |
_testDraw:[:form | ]
|
|
31 |
thenCheck:[:form |
|
|
32 |
|blackPixel whitePixel pix|
|
222
|
33 |
|
1447
|
34 |
blackPixel := (Color black onDevice:Display) colorId.
|
|
35 |
whitePixel := (Color white onDevice:Display) colorId.
|
222
|
36 |
|
1447
|
37 |
0 to:form height-1 do:[:y |
|
|
38 |
0 to:form width-1 do:[:x |
|
|
39 |
pix := form atX:x y:y.
|
|
40 |
self assert:( pix == blackPixel )
|
|
41 |
]
|
|
42 |
]
|
|
43 |
]
|
222
|
44 |
|
|
45 |
"
|
|
46 |
self new test_01_Clear
|
|
47 |
"
|
|
48 |
!
|
|
49 |
|
|
50 |
test_02_DrawHLine
|
1447
|
51 |
self
|
|
52 |
_testDraw:[:form |
|
|
53 |
form paint:Color white.
|
|
54 |
form displayLineFromX:1 y:0 toX:form width-1-1 y:0.
|
|
55 |
]
|
|
56 |
thenCheck:[:form |
|
|
57 |
|blackPixel whitePixel pix|
|
222
|
58 |
|
1447
|
59 |
blackPixel := (Color black onDevice:Display) colorId.
|
|
60 |
whitePixel := (Color white onDevice:Display) colorId.
|
222
|
61 |
|
1447
|
62 |
1 to:form height-1 do:[:y |
|
|
63 |
0 to:form width-1 do:[:x |
|
|
64 |
pix := form atX:x y:y.
|
|
65 |
self assert:( pix == blackPixel )
|
|
66 |
]
|
|
67 |
].
|
222
|
68 |
|
1447
|
69 |
pix := form atX:0 y:0.
|
|
70 |
self assert:( pix == blackPixel ).
|
|
71 |
pix := form atX:(form width-1) y:0.
|
|
72 |
self assert:( pix == blackPixel ).
|
222
|
73 |
|
1447
|
74 |
1 to:form width-2 do:[:x |
|
|
75 |
pix := form atX:x y:0.
|
|
76 |
self assert:( pix == whitePixel )
|
|
77 |
]
|
|
78 |
]
|
222
|
79 |
|
|
80 |
"
|
|
81 |
self new test_02_DrawHLine
|
|
82 |
"
|
|
83 |
!
|
|
84 |
|
|
85 |
test_03_DrawRectangle
|
1447
|
86 |
self
|
|
87 |
_testDraw:[:form |
|
|
88 |
form paint:Color white.
|
|
89 |
form displayRectangleX:1 y:1 width:(form width-1-1) height:(form height-1-1).
|
|
90 |
]
|
|
91 |
thenCheck:[:form |
|
|
92 |
|blackPixel whitePixel pix|
|
222
|
93 |
|
1447
|
94 |
blackPixel := (Color black onDevice:Display) colorId.
|
|
95 |
whitePixel := (Color white onDevice:Display) colorId.
|
222
|
96 |
|
1447
|
97 |
2 to:form height-1-1-1 do:[:y |
|
|
98 |
2 to:form width-1-1-1 do:[:x |
|
|
99 |
pix := form atX:x y:y.
|
|
100 |
self assert:( pix == blackPixel )
|
|
101 |
]
|
|
102 |
].
|
222
|
103 |
|
1447
|
104 |
0 to:form width-1 do:[:x |
|
|
105 |
pix := form atX:x y:0.
|
|
106 |
self assert:( pix == blackPixel )
|
|
107 |
].
|
|
108 |
0 to:form width-1 do:[:x |
|
|
109 |
pix := form atX:x y:(form height-1).
|
|
110 |
self assert:( pix == blackPixel )
|
|
111 |
].
|
|
112 |
0 to:form height-1 do:[:y |
|
|
113 |
pix := form atX:0 y:y.
|
|
114 |
self assert:( pix == blackPixel )
|
|
115 |
].
|
|
116 |
0 to:form height-1 do:[:y |
|
|
117 |
pix := form atX:(form width-1) y:y.
|
|
118 |
self assert:( pix == blackPixel )
|
|
119 |
].
|
222
|
120 |
|
1447
|
121 |
1 to:form width-1-1 do:[:x |
|
|
122 |
pix := form atX:x y:1.
|
|
123 |
self assert:( pix == whitePixel )
|
|
124 |
].
|
|
125 |
1 to:form width-1-1 do:[:x |
|
|
126 |
pix := form atX:x y:(form height-2).
|
|
127 |
self assert:( pix == whitePixel )
|
|
128 |
].
|
222
|
129 |
|
1447
|
130 |
]
|
222
|
131 |
|
|
132 |
"
|
|
133 |
self new test_03_DrawRectangle
|
|
134 |
"
|
|
135 |
!
|
|
136 |
|
|
137 |
test_03_DrawVLine
|
1447
|
138 |
self
|
|
139 |
_testDraw:[:form |
|
|
140 |
form paint:Color white.
|
|
141 |
form displayLineFromX:0 y:1 toX:0 y:form height-1-1.
|
|
142 |
]
|
|
143 |
thenCheck:[:form |
|
|
144 |
|blackPixel whitePixel pix|
|
222
|
145 |
|
1447
|
146 |
blackPixel := (Color black onDevice:Display) colorId.
|
|
147 |
whitePixel := (Color white onDevice:Display) colorId.
|
222
|
148 |
|
1447
|
149 |
0 to:form height-1 do:[:y |
|
|
150 |
1 to:form width-1 do:[:x |
|
|
151 |
pix := form atX:x y:y.
|
|
152 |
self assert:( pix == blackPixel )
|
|
153 |
]
|
|
154 |
].
|
222
|
155 |
|
1447
|
156 |
pix := form atX:0 y:0.
|
|
157 |
self assert:( pix == blackPixel ).
|
|
158 |
pix := form atX:0 y:(form height-1).
|
|
159 |
self assert:( pix == blackPixel ).
|
222
|
160 |
|
1447
|
161 |
1 to:form height-2 do:[:y |
|
|
162 |
pix := form atX:0 y:y.
|
|
163 |
self assert:( pix == whitePixel )
|
|
164 |
]
|
|
165 |
]
|
222
|
166 |
|
|
167 |
"
|
|
168 |
self new test_03_DrawVLine
|
|
169 |
"
|
|
170 |
! !
|
|
171 |
|
|
172 |
!GraphicDrawingTest class methodsFor:'documentation'!
|
|
173 |
|
|
174 |
version
|
|
175 |
^ '$Header$'
|
|
176 |
! !
|
2382
|
177 |
|