Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / masks_testrunner.cpp
blobccd647d2c6b2179c48bf91a2a4a4fb877c010ba3
1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 * Free Software Foundation, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
22 #define INPUT_FILENAME "masks_test.swf"
24 #include "MovieTester.h"
25 #include "MovieClip.h"
26 #include "DisplayObject.h"
27 #include "DisplayList.h"
28 #include "log.h"
30 #include "check.h"
31 #include <string>
32 #include <cassert>
34 using namespace gnash;
35 using namespace std;
37 TRYMAIN(_runtest);
38 int
39 trymain(int /*argc*/, char** /*argv*/)
41 typedef gnash::geometry::SnappingRanges2d<int> Ranges;
42 typedef gnash::geometry::Range2d<int> Bounds;
44 string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
45 MovieTester tester(filename);
47 gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
48 dbglogfile.setVerbosity(1);
50 Ranges invalidated;
51 MovieClip* root = tester.getRootMovie();
52 assert(root);
54 // FRAME 1 (start)
56 check_equals(root->get_frame_count(), 6);
57 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
58 check_equals(root->get_current_frame(), 0);
59 check_equals(root->getDisplayList().size(), 1); // dejagnu clip
60 invalidated = tester.getInvalidatedRanges();
61 check( invalidated.contains(76, 4) ); // the "-xtrace enabled-" label...
63 // FRAME 2 -- masks at different depth ranges
64 tester.advance();
66 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
67 check_equals(root->get_current_frame(), 1); // 0-based
68 check_equals(root->getDisplayList().size(), 9);
69 std::cout << root->getDisplayList() << "\n";
70 check( tester.findDisplayItemByName(*root, "staticmc2") );
71 check( tester.findDisplayItemByName(*root, "staticmc3") );
72 check( tester.findDisplayItemByName(*root, "staticmc4") );
73 check( tester.findDisplayItemByName(*root, "staticmc5") );
74 check( tester.findDisplayItemByName(*root, "dynamicmc2") );
75 check( tester.findDisplayItemByName(*root, "dynamicmc3") );
76 check( tester.findDisplayItemByName(*root, "dynamicmc4") );
77 check( tester.findDisplayItemByName(*root, "dynamicmc5") );
78 invalidated = tester.getInvalidatedRanges();
80 rgba white(255,255,255,255);
81 rgba red(255,0,0,255);
82 rgba green(0,255,0,255);
83 rgba green_trans(120,248,120,255);
84 rgba blue(0,0,255,255);
85 rgba yellow(255,255,0,255);
86 rgba cyan(0,255,255,255);
87 rgba violet(255,0,255,255);
88 rgba dark_green(0,128,0,255);
89 rgba dark_green_trans(120,184,120,255);
90 rgba light_blue(0,128,255,255);
92 // 14,232 = red
93 check( invalidated.contains(14, 232) );
94 check_pixel(14,232, 2, red, 2);
95 // 48,232 = yellow (red behind)
96 check( invalidated.contains(48, 232) );
97 check_pixel(48,232, 2, yellow, 2);
98 // 80,232 = yellow
99 check( invalidated.contains(80, 232) );
100 check_pixel(80,232, 2, yellow, 2);
102 // 214,232 = green
103 check( invalidated.contains(214, 232) );
104 check_pixel(214,232, 2, green, 2);
105 // 248,232 = cyan (green behind)
106 check( invalidated.contains(248, 232) );
107 check_pixel(248,232, 2, cyan, 2);
108 // 276,232 = cyan
109 check( invalidated.contains(276, 232) );
110 check_pixel(276,232, 2, cyan, 2);
112 // 14,331 = blue
113 check( invalidated.contains(14, 331) );
114 check_pixel(14,331, 2, blue, 2);
115 // 48,331 = violet (blue behind)
116 check( invalidated.contains(48, 331) );
117 check_pixel(48,331, 2, violet, 2);
118 // 80,331 = violet
119 check( invalidated.contains(80, 331) );
120 check_pixel(80,331, 2, violet, 2);
122 // 214,331 = dark_green
123 check( invalidated.contains(214, 331) );
124 check_pixel(214,331, 2, dark_green, 2);
125 // 248,331 = light_blue (dark_green behind)
126 check( invalidated.contains(248, 331) );
127 check_pixel(248,331, 2, light_blue, 2);
128 // 276,331 = light_blue
129 check( invalidated.contains(276, 331) );
130 check_pixel(276,331, 2, light_blue, 2);
132 // FRAME 3
133 tester.pressKey(gnash::key::ENTER);
134 tester.releaseKey(gnash::key::ENTER);
135 tester.advance();
136 check_equals(root->get_current_frame(), 2); // 0-based
138 // test effects of setMask here
140 // 14,232 = white (red not covered by its yellow mask)
141 check( invalidated.contains(14, 232) );
142 check_pixel(14,232, 2, white, 2);
143 // 48,232 = red (visible in the yellow mask)
144 check( invalidated.contains(48, 232) );
145 check_pixel(48,232, 2, red, 2);
146 // 80,232 = white (red not covered by its yellow mask)
147 check( invalidated.contains(80, 232) );
148 check_pixel(80,232, 2, white, 2);
150 // 214,232 = white (cyan not covered by its green mask)
151 check( invalidated.contains(214, 232) );
152 check_pixel(214,232, 2, white, 2);
153 // 248,232 = cyan (visible in its green mask)
154 check( invalidated.contains(248, 232) );
155 check_pixel(248,232, 2, cyan, 2);
156 // 276,232 = white (cyan not covered by its green mask)
157 check( invalidated.contains(276, 232) );
158 check_pixel(276,232, 2, white, 2);
160 // 14,331 = white (blue not covered by its violet mask)
161 check( invalidated.contains(14, 331) );
162 check_pixel(14,331, 2, white, 2);
163 // 48,331 = blue (visible in its violet mask)
164 check( invalidated.contains(48, 331) );
165 check_pixel(48,331, 2, blue, 2);
166 // 80,331 = white (blue not covered by its violet mask)
167 check( invalidated.contains(80, 331) );
168 check_pixel(80,331, 2, white, 2);
170 // 214,331 = white (light_blue not covered by its dark_green mask)
171 check( invalidated.contains(214, 331) );
172 check_pixel(214,331, 2, white, 2);
173 // 248,331 = light_blue (visible in its dark_green mask)
174 check( invalidated.contains(248, 331) );
175 check_pixel(248,331, 2, light_blue, 2);
176 // 276,331 = white (light_blue not covered by its dark_green mask)
177 check( invalidated.contains(276, 331) );
178 check_pixel(276,331, 2, white, 2);
180 // FRAME 4
181 tester.pressKey(gnash::key::ENTER);
182 tester.releaseKey(gnash::key::ENTER);
183 tester.advance();
184 check_equals(root->get_current_frame(), 3); // 0-based
186 // test effects of swapDepth (should be none)
188 // 14,232 = white (red not covered by its yellow mask)
189 check( invalidated.contains(14, 232) );
190 check_pixel(14,232, 2, white, 2);
191 // 48,232 = red (visible in the yellow mask)
192 check( invalidated.contains(48, 232) );
193 check_pixel(48,232, 2, red, 2);
194 // 80,232 = white (red not covered by its yellow mask)
195 check( invalidated.contains(80, 232) );
196 check_pixel(80,232, 2, white, 2);
198 // 214,232 = white (cyan not covered by its green mask)
199 check( invalidated.contains(214, 232) );
200 check_pixel(214,232, 2, white, 2);
201 // 248,232 = cyan (visible in its green mask)
202 check( invalidated.contains(248, 232) );
203 check_pixel(248,232, 2, cyan, 2);
204 // 276,232 = white (cyan not covered by its green mask)
205 check( invalidated.contains(276, 232) );
206 check_pixel(276,232, 2, white, 2);
208 // 14,331 = white (blue not covered by its violet mask)
209 check( invalidated.contains(14, 331) );
210 check_pixel(14,331, 2, white, 2);
211 // 48,331 = blue (visible in its violet mask)
212 check( invalidated.contains(48, 331) );
213 check_pixel(48,331, 2, blue, 2);
214 // 80,331 = white (blue not covered by its violet mask)
215 check( invalidated.contains(80, 331) );
216 check_pixel(80,331, 2, white, 2);
218 // 214,331 = white (light_blue not covered by its dark_green mask)
219 check( invalidated.contains(214, 331) );
220 check_pixel(214,331, 2, white, 2);
221 // 248,331 = light_blue (visible in its dark_green mask)
222 check( invalidated.contains(248, 331) );
223 check_pixel(248,331, 2, light_blue, 2);
224 // 276,331 = white (light_blue not covered by its dark_green mask)
225 check( invalidated.contains(276, 331) );
226 check_pixel(276,331, 2, white, 2);
228 // FRAME 5
229 tester.pressKey(gnash::key::ENTER);
230 tester.releaseKey(gnash::key::ENTER);
231 tester.advance();
232 check_equals(root->get_current_frame(), 4); // 0-based
234 // 14,232 = white (yellow not covered by its red mask)
235 check( invalidated.contains(14, 232) );
236 check_pixel(14,232, 2, white, 2);
237 // 48,232 = yellow (visible in the red mask)
238 check( invalidated.contains(48, 232) );
239 check_pixel(48,232, 2, yellow, 2);
240 // 80,232 = white (yellow not covered by its red mask)
241 check( invalidated.contains(80, 232) );
242 check_pixel(80,232, 2, white, 3);
244 // 214,232 = white (green not covered by its cyan mask)
245 check( invalidated.contains(214, 232) );
246 check_pixel(214,232, 2, white, 2);
247 // 248,232 = green (visible in its cyan mask)
248 check( invalidated.contains(248, 232) );
249 check_pixel(248,232, 2, green, 2);
250 // 276,232 = white (green not covered by its cyan mask)
251 check( invalidated.contains(276, 232) );
252 check_pixel(276,232, 2, white, 2);
254 // 14,331 = white (violet not covered by its blue mask)
255 check( invalidated.contains(14, 331) );
256 check_pixel(14,331, 2, white, 2);
257 // 48,331 = violet (visible in its blue mask)
258 check( invalidated.contains(48, 331) );
259 check_pixel(48,331, 2, violet, 2);
260 // 80,331 = white (violet not covered by its blue mask)
261 check( invalidated.contains(80, 331) );
262 check_pixel(80,331, 2, white, 2);
264 // 214,331 = white (dark_green not covered by its light_blue mask)
265 check( invalidated.contains(214, 331) );
266 check_pixel(214,331, 2, white, 2);
267 // 248,331 = dark_green (visible in its light_blue mask)
268 check( invalidated.contains(248, 331) );
269 check_pixel(248,331, 2, dark_green, 2);
270 // 276,331 = white (dark_green not covered by its light_blue mask)
271 check( invalidated.contains(276, 331) );
272 check_pixel(276,331, 2, white, 2);
274 // FRAME 6
275 tester.pressKey(gnash::key::ENTER);
276 tester.releaseKey(gnash::key::ENTER);
277 tester.advance();
278 check_equals(root->get_current_frame(), 5); // 0-based
280 //----------------------------------------------
281 // Red-Yellow couple
282 //----------------------------------------------
284 // 14,232 = white (on the red mask)
285 check( invalidated.contains(14, 232) );
286 check_pixel(14,232, 2, white, 2);
287 // 48,232 = yellow (visible in the red mask)
288 check( invalidated.contains(48, 232) );
289 check_pixel(48,232, 2, yellow, 2);
290 // 80,232 = white (yellow not covered by its red mask)
291 check( invalidated.contains(80, 232) );
292 check_pixel(80,232, 2, white, 3);
294 tester.movePointerTo(14,232); // on the red mask
295 check( tester.isMouseOverMouseEntity() ) // the mask is still sensible to mouse
296 check_pixel(48,232, 2, yellow, 2); // it's the red alpha changing, not the yellow one
298 tester.movePointerTo(48,232); // on the yellow exposed area
299 check( tester.isMouseOverMouseEntity() ) // sensible to mouse
300 check_pixel(48,232, 2, yellow, 2); // it's the red alpha changing, not the yellow one
302 tester.movePointerTo(80,232); // yellow not covered by its red mask
303 check( ! tester.isMouseOverMouseEntity() ) // not covered area is not sensible to mouse
304 check_pixel(48,232, 2, yellow, 2); // it's the red alpha changing, not the yellow one
306 //----------------------------------------------
307 // Green-Cyan couple
308 //----------------------------------------------
310 // 214,232 = white (green not covered by its cyan mask)
311 check( invalidated.contains(214, 232) );
312 check_pixel(214,232, 2, white, 2);
313 // 248,232 = green (visible in its cyan mask)
314 check( invalidated.contains(248, 232) );
315 check_pixel(248,232, 2, green, 2);
316 // 276,232 = white (green not covered by its cyan mask)
317 check( invalidated.contains(276, 232) );
318 check_pixel(276,232, 2, white, 2);
320 tester.movePointerTo(214,232); // green not covered by cyan mask
321 check( ! tester.isMouseOverMouseEntity() ) // not covered area is not sensible to mouse
323 tester.movePointerTo(248,232); // green exposed by cyan mask
324 check( tester.isMouseOverMouseEntity() ) // not covered area is not sensible to mouse
325 check( invalidated.contains(248, 232) );
326 check_pixel(248,232, 2, green_trans, 2);
328 tester.movePointerTo(276,232); // on the cyan mask, out of green
329 check( invalidated.contains(248, 232) );
330 check_pixel(248,232, 2, green, 2);
331 check( tester.isMouseOverMouseEntity() ) // mask still sensible to mouse
333 //----------------------------------------------
334 // Blue-Violet couple
335 //----------------------------------------------
337 // 14,331 = white (violet not covered by its blue mask)
338 check( invalidated.contains(14, 331) );
339 check_pixel(14,331, 2, white, 2);
340 // 48,331 = violet (visible in its blue mask)
341 check( invalidated.contains(48, 331) );
342 check_pixel(48,331, 2, violet, 2);
343 // 80,331 = white (violet not covered by its blue mask)
344 check( invalidated.contains(80, 331) );
345 check_pixel(80,331, 2, white, 2);
347 tester.movePointerTo(14,331); // on the blue mask
348 check( tester.isMouseOverMouseEntity() ) // the mask is still sensible to mouse
349 check_pixel(48,331, 2, violet, 2); // it's the blue alpha changing, not violet
351 tester.movePointerTo(48,331); // on the violet exposed area
352 check( tester.isMouseOverMouseEntity() ) // sensible to mouse
353 check_pixel(48,331, 2, violet, 2); // it's the blue alpha changing, not violet
355 tester.movePointerTo(80,331); // violet not covered by its blue mask
356 check( ! tester.isMouseOverMouseEntity() ) // not covered area is not sensible to mouse
357 check_pixel(48,331, 2, violet, 2); // it's the red alpha changing, not the yellow one
359 //----------------------------------------------
360 // DarkGreen-LightBlue couple
361 //----------------------------------------------
363 // 214,331 = white (dark_green not covered by its light_blue mask)
364 check( invalidated.contains(214, 331) );
365 check_pixel(214,331, 2, white, 2);
366 // 248,331 = dark_green (visible in its light_blue mask)
367 check( invalidated.contains(248, 331) );
368 check_pixel(248,331, 2, dark_green, 2);
369 // 276,331 = white (dark_green not covered by its light_blue mask)
370 check( invalidated.contains(276, 331) );
371 check_pixel(276,331, 2, white, 2);
373 tester.movePointerTo(214,331); // DarkGreen not covered by LightBlue mask
374 check( ! tester.isMouseOverMouseEntity() ) // not covered area is not sensible to mouse
376 tester.movePointerTo(248,331); // DarkGreen exposed by LightBlue mask
377 check( tester.isMouseOverMouseEntity() ) // not covered area is not sensible to mouse
378 check( invalidated.contains(248, 331) );
379 check_pixel(248,331, 2, dark_green_trans, 2);
381 tester.movePointerTo(276,331); // on the LightBlue mask, out of DarkGreen
382 check( invalidated.contains(248, 331) );
383 check_pixel(248,331, 2, dark_green, 2);
384 check( tester.isMouseOverMouseEntity() ) // mask still sensible to mouse
385 return 0;