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