Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / DrawingApiTestRunner.cpp
blobd4b9554d44b2cb77bd8ded6256af43587b2ccec0
1 /*
2 * Copyright (C) 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 "DrawingApiTest.swf"
24 #include "MovieTester.h"
25 #include "MovieClip.h"
26 #include "log.h"
27 #include "GnashKey.h" // for gnash::key::code
29 #include "check.h"
30 #include <string>
31 #include <cassert>
32 #include <sstream>
33 #include <math.h> // round
34 #include <cmath>
36 using namespace gnash;
37 using namespace gnash::geometry;
39 /// Return a Range2d<int> defining the square inscribed in a circle
41 /// @param radius
42 /// Radius in pixels
43 ///
44 Range2d<int>
45 inscribedRect(int x, int y, int radius)
47 Range2d<int> ret;
49 int side = int(::round((float)radius * std::sqrt(2.0f)));
50 int halfside = int(side/2.0); // round toward zero
52 // Simply constructing a stringstream fixes an optimization
53 // bug with GCC-4.1.2 resulting in absurd values !
54 // See https://savannah.gnu.org/bugs/?20853
55 std::stringstream work_around_GCC_412_bug;
57 // upper-left corner
58 int ULx = x-halfside;
59 int ULy = y-halfside;
61 // lower-right corner
62 int LRx = x+halfside;
63 int LRy = y+halfside;
65 ret.expandTo(ULx, ULy);
66 ret.expandTo(LRx, LRy);
68 return ret;
71 TRYMAIN(_runtest);
72 int
73 trymain(int /*argc*/, char** /*argv*/)
75 std::string filename =
76 std::string(TGTDIR) + "/" + std::string(INPUT_FILENAME);
77 MovieTester tester(filename);
79 gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
80 dbglogfile.setVerbosity(1);
82 MovieClip* root = tester.getRootMovie();
83 assert(root);
85 check_equals(root->get_frame_count(), 2);
86 check_equals(root->get_current_frame(), 0);
88 // advance to the second frame, first frame is an empty frame.
90 // Don't use the Dejagnuclip for this test, the EditText box in it
91 // would violates many checks(invalidatedBound...) here.
93 tester.advance();
95 rgba white(255, 255, 255, 255);
96 rgba blue(0, 0, 255, 255);
97 rgba cyan(0, 255, 255, 255);
98 rgba green(0, 255, 0, 255);
99 rgba green_alpha80(120, 248, 120, 255);
100 rgba light_green(128, 255, 128, 255);
101 // Two greens at 50% alpha overlapping
102 rgba overlapping_light_green(64, 255, 64, 255);
103 rgba red(255, 0, 0, 255);
104 rgba yellow(255, 255, 0, 255);
105 rgba black(0, 0, 0, 255);
106 rgba gray(127, 127, 127, 255);
107 rgba violet(255, 0, 255, 255);
108 rgba halftrans_violet(255, 128, 255, 255);
110 // Out of any drawing
111 tester.movePointerTo(50, 50);
112 check(!tester.isMouseOverMouseEntity());
113 check_pixel(50, 50, 2, white, 1);
115 // Inside bottom-left blue fill
116 tester.movePointerTo(60, 215);
117 check(tester.isMouseOverMouseEntity());
118 check_pixel(60, 215, 2, blue, 1);
120 // Inside bottom-left blue fill but in the
121 // curve internal to check if the point_test
122 // works for filled curves
123 tester.movePointerTo(40, 205);
124 check(tester.isMouseOverMouseEntity());
125 check_pixel(40, 205, 2, blue, 1);
127 // Inside cyan clockwise fill
128 tester.movePointerTo(190, 112);
129 // this fails since Udo's rewrite of Shape_def::point_test
130 // won't turn it into an 'expected' change as reverting the point_test
131 // would fix it.
132 check(tester.isMouseOverMouseEntity());
133 check_pixel(190, 112, 2, cyan, 1);
135 // Inside green counterclockwise fill
136 tester.movePointerTo(220, 112);
137 check(tester.isMouseOverMouseEntity());
138 check_pixel(220, 112, 2, green_alpha80, 1);
140 // Inside violet fill
141 tester.movePointerTo(250, 112);
142 check(tester.isMouseOverMouseEntity());
143 check_pixel(250, 112, 2, violet, 1);
145 // Inside red "thick" line
146 tester.movePointerTo(146, 146);
147 check(tester.isMouseOverMouseEntity());
148 check_pixel(146, 146, 2, red, 2);
150 // Over the black "hairlined" line
151 tester.movePointerTo(250, 180);
152 check(tester.isMouseOverMouseEntity());
153 // pixel at 250,180 is black
154 check_pixel(250, 180, 1, black, 2);
155 // pixels above and below 180 are white
156 check_pixel(250, 179, 1, white, 2);
157 check_pixel(250, 181, 1, white, 2);
159 // Over the transparent line (150,100)
160 tester.movePointerTo(150, 100);
161 check(!tester.isMouseOverMouseEntity());
162 check_pixel(150, 100, 2, white, 2);
164 // Over the violet line (146,224)
165 tester.movePointerTo(146, 224);
166 check(tester.isMouseOverMouseEntity());
167 check_pixel(146, 224, 1, halftrans_violet, 2);
169 // Inside the yellow line
170 tester.movePointerTo(270, 232);
171 check(tester.isMouseOverMouseEntity());
172 check_pixel(270, 232, 2, yellow, 2);
174 // Inside the black vertical line
175 tester.movePointerTo(82, 127);
176 check(tester.isMouseOverMouseEntity());
177 check_pixel(82, 127, 2, black, 2);
179 // In the middle of an imaginary line between
180 // first and last point of the green curve
181 tester.movePointerTo(376, 180);
182 check(!tester.isMouseOverMouseEntity()); // failed due to edge::withinSquareDistance bug
183 check_pixel(376, 180, 2, white, 2);
185 // Over the green curve
186 tester.movePointerTo(376, 139);
187 check(tester.isMouseOverMouseEntity()); // failed due to edge::withinSquareDistance bug
188 check_pixel(376, 139, 2, green, 2); // failed due to bug in AGG
190 // Over the center of the green circle fill
191 tester.movePointerTo(330, 160);
192 check(tester.isMouseOverMouseEntity());
193 check_pixel(330, 160, 2, green, 2);
195 // Over the boundary of the green circle fill
196 tester.movePointerTo(363, 174);
197 check(tester.isMouseOverMouseEntity()); // failed due to edge::withinSquareDistance bug
198 check_pixel(363, 174, 2, black, 2);
200 // Check that nothing is drawin in the bottom line
201 check_pixel(47, 280, 10, white, 2);
202 check_pixel(101, 280, 10, white, 2);
203 check_pixel(151, 280, 10, white, 2);
204 check_pixel(201, 280, 10, white, 2);
205 check_pixel(250, 280, 10, white, 2);
206 check_pixel(303, 280, 10, white, 2);
207 check_pixel(351, 280, 10, white, 2);
208 check_pixel(400, 280, 10, white, 2);
210 tester.advance();
212 // TODO: check bounds of the child, and hitTest
214 // Check that the invalidated bounds to contain the first circle bounds
215 check(tester.getInvalidatedRanges().contains(inscribedRect(47, 280, 10)));
217 // Check that first circle has been drawn
218 check_pixel(47, 280, 3, yellow, 2);
219 check_pixel(101, 280, 10, white, 2);
220 check_pixel(151, 280, 10, white, 2);
221 check_pixel(201, 280, 10, white, 2);
222 check_pixel(250, 280, 10, white, 2);
223 check_pixel(303, 280, 10, white, 2);
224 check_pixel(351, 280, 10, white, 2);
225 check_pixel(400, 280, 10, white, 2);
227 tester.advance();
229 // TODO: check bounds of the child, and hitTest
231 // Check invalidated bounds to contain the first and second circle bounds
232 check(tester.getInvalidatedRanges().contains(inscribedRect(47, 280, 10)));
233 check(tester.getInvalidatedRanges().contains(inscribedRect(101, 280, 10)));
235 // Check that only the second circle is visible
236 check_pixel(47, 280, 10, white, 2);
237 check_pixel(101, 280, 3, yellow, 2);
238 check_pixel(151, 280, 10, white, 2);
239 check_pixel(201, 280, 10, white, 2);
240 check_pixel(250, 280, 10, white, 2);
241 check_pixel(303, 280, 10, white, 2);
242 check_pixel(351, 280, 10, white, 2);
243 check_pixel(400, 280, 10, white, 2);
245 tester.advance();
247 // TODO: check bounds of the child, and hitTest
249 // Check invalidated bounds to contain the second and third circle bounds
250 check(tester.getInvalidatedRanges().contains(inscribedRect(101, 280, 10)));
251 check(tester.getInvalidatedRanges().contains(inscribedRect(151, 280, 10)));
253 // Check that only the third circle is visible
254 check_pixel(47, 280, 10, white, 2);
255 check_pixel(101, 280, 10, white, 2);
256 check_pixel(151, 280, 3, yellow, 2);
257 check_pixel(201, 280, 10, white, 2);
258 check_pixel(250, 280, 10, white, 2);
259 check_pixel(303, 280, 10, white, 2);
260 check_pixel(351, 280, 10, white, 2);
261 check_pixel(400, 280, 10, white, 2);
263 tester.advance();
265 // TODO: check bounds of the child, and hitTest
267 // Check invalidated bounds to contain the third and fourth circle bounds
268 check(tester.getInvalidatedRanges().contains(inscribedRect(151, 280, 10)));
269 check(tester.getInvalidatedRanges().contains(inscribedRect(201, 280, 10)));
271 // Check that only the fourth circle is visible
272 check_pixel(47, 280, 10, white, 2);
273 check_pixel(101, 280, 10, white, 2);
274 check_pixel(151, 280, 10, white, 2);
275 check_pixel(201, 280, 3, yellow, 2);
276 check_pixel(250, 280, 10, white, 2);
277 check_pixel(303, 280, 10, white, 2);
278 check_pixel(351, 280, 10, white, 2);
279 check_pixel(400, 280, 10, white, 2);
281 tester.advance();
283 // TODO: check bounds of the child, and hitTest
285 // Check invalidated bounds to contain the fourth and fifth circle bounds
286 check(tester.getInvalidatedRanges().contains(inscribedRect(201, 280, 10)));
287 check(tester.getInvalidatedRanges().contains(inscribedRect(250, 280, 10)));
289 // Check that only the fifth circle is visible
290 check_pixel(47, 280, 10, white, 2);
291 check_pixel(101, 280, 10, white, 2);
292 check_pixel(151, 280, 10, white, 2);
293 check_pixel(201, 280, 10, white, 2);
294 check_pixel(250, 280, 3, yellow, 2);
295 check_pixel(303, 280, 10, white, 2);
296 check_pixel(351, 280, 10, white, 2);
297 check_pixel(400, 280, 10, white, 2);
299 tester.advance();
301 // TODO: check bounds of the child, and hitTest
303 // Check invalidated bounds to contain the fifth and sixth circle bounds
304 check(tester.getInvalidatedRanges().contains(inscribedRect(250, 280, 10)));
305 check(tester.getInvalidatedRanges().contains(inscribedRect(303, 280, 10)));
307 // Check that only the sixth circle is visible
308 check_pixel(47, 280, 10, white, 2);
309 check_pixel(101, 280, 10, white, 2);
310 check_pixel(151, 280, 10, white, 2);
311 check_pixel(201, 280, 10, white, 2);
312 check_pixel(250, 280, 10, white, 2);
313 check_pixel(303, 280, 3, yellow, 2);
314 check_pixel(351, 280, 10, white, 2);
315 check_pixel(400, 280, 10, white, 2);
317 tester.advance();
319 // TODO: check bounds of the child, and hitTest
321 // Check invalidated bounds to contain the sixth and seventh circle bounds
322 check(tester.getInvalidatedRanges().contains(inscribedRect(303, 280, 10)));
323 check(tester.getInvalidatedRanges().contains(inscribedRect(351, 280, 10)));
325 // Check that only the seventh circle is visible
326 check_pixel(47, 280, 10, white, 2);
327 check_pixel(101, 280, 10, white, 2);
328 check_pixel(151, 280, 10, white, 2);
329 check_pixel(201, 280, 10, white, 2);
330 check_pixel(250, 280, 10, white, 2);
331 check_pixel(303, 280, 10, white, 2);
332 check_pixel(351, 280, 3, yellow, 2);
333 check_pixel(400, 280, 10, white, 2);
335 tester.advance();
337 // TODO: check bounds of the child, and hitTest
339 // Check invalidated bounds to contain the seventh and eighth circle bounds
340 check(tester.getInvalidatedRanges().contains(inscribedRect(351, 280, 10)));
341 check(tester.getInvalidatedRanges().contains(inscribedRect(400, 280, 10)));
343 // Check that only the eighth circle is visible
344 check_pixel(47, 280, 10, white, 2);
345 check_pixel(101, 280, 10, white, 2);
346 check_pixel(151, 280, 10, white, 2);
347 check_pixel(201, 280, 10, white, 2);
348 check_pixel(250, 280, 10, white, 2);
349 check_pixel(303, 280, 10, white, 2);
350 check_pixel(351, 280, 10, white, 2);
351 check_pixel(400, 280, 3, yellow, 2);
353 tester.advance();
355 // TODO: check bounds of the child, and hitTest
357 // Check that no bounds have been invalidated
358 check(tester.getInvalidatedRanges().isNull());
360 // Check that only the eighth circle is visible
361 check_pixel(47, 280, 10, white, 2);
362 check_pixel(101, 280, 10, white, 2);
363 check_pixel(151, 280, 10, white, 2);
364 check_pixel(201, 280, 10, white, 2);
365 check_pixel(250, 280, 10, white, 2);
366 check_pixel(303, 280, 10, white, 2);
367 check_pixel(351, 280, 10, white, 2);
368 check_pixel(400, 280, 3, yellow, 2);
370 //--------------------------------------------------------------
371 // Check hitdetector bounds and reactions on mouse movement
372 //--------------------------------------------------------------
374 struct IntPoint {
375 int x;
376 int y;
377 IntPoint(int nx, int ny)
379 x(nx), y(ny)
383 IntPoint c1s(6, 346); // top-right of first yellow circle (in when small)
384 IntPoint c1b(16, 329); // top-right of first yellow circle (in when big, out when small)
385 IntPoint c2s(66, 340); // top-right of second yellow circle (in when small)
386 IntPoint c2b(75, 332); // top-right of second yellow circle (in when big, out when small)
387 IntPoint c3s(129, 340); // top-right of third yellow circle (in when small)
388 IntPoint c3b(133, 330); // top-right of third yellow circle (in when big, out when small)
390 // Disjoint cursor's and drawing's bounding boxes
391 tester.movePointerTo(50, 50);
392 tester.advance(); // hitTest runs onEnterFrame
394 check_pixel(c1s.x, c1s.y, 1, yellow, 2);
395 check_pixel(c1b.x, c1b.y, 1, white, 2);
397 check_pixel(c2s.x, c2s.y, 1, yellow, 2);
398 check_pixel(c2b.x, c2b.y, 1, white, 2);
400 check_pixel(c3s.x, c3s.y, 1, yellow, 2);
401 check_pixel(c3b.x, c3b.y, 1, white, 2);
403 // Cursor's and drawing's bounding box intersection
405 // NOTE: shapes don't intersect, the cursor is a circle,
406 // and only the top-left corner of it's bounding box
407 // intersects the drawing's bounding box
408 // NOTE: one pixel down or one pixel right and they would not intersect anymore
410 tester.movePointerTo(424, 304);
411 tester.advance(); // hitTest runs onEnterFrame
413 check_pixel(c1s.x, c1s.y, 1, yellow, 2);
414 check(tester.getInvalidatedRanges().contains(c1b.x, c1b.y));
415 check_pixel(c1b.x, c1b.y, 1, yellow, 2);
417 check(!tester.getInvalidatedRanges().contains(c2s.x, c2s.y)); // failure won't impact correctness, only performance
418 check(!tester.getInvalidatedRanges().contains(c2b.x, c2b.y)); // failure won't impact correctness, only performance
419 check_pixel(c2s.x, c2s.y, 1, yellow, 2);
420 check_pixel(c2b.x, c2b.y, 1, white, 2);
422 check(!tester.getInvalidatedRanges().contains(c3s.x, c3s.y)); // failure won't impact correctness, only performance
423 check(!tester.getInvalidatedRanges().contains(c3b.x, c3b.y)); // failure won't impact correctness, only performance
424 check_pixel(c3s.x, c3s.y, 1, yellow, 2);
425 check_pixel(c3b.x, c3b.y, 1, white, 2);
427 // Pointer inside drawing's bounding box
428 // (pointer itself, not the cursor)
429 tester.movePointerTo(221, 84);
430 tester.advance(); // hitTest runs onEnterFrame
432 check(!tester.getInvalidatedRanges().contains(c1s.x, c1s.y)); // failure won't impact correctness, only performance
433 check(!tester.getInvalidatedRanges().contains(c1b.x, c1b.y)); // failure won't impact correctness, only performance
434 check_pixel(c1s.x, c1s.y, 1, yellow, 2);
435 check_pixel(c1b.x, c1b.y, 1, yellow, 2);
437 check_pixel(c2s.x, c2s.y, 1, yellow, 2);
438 check(tester.getInvalidatedRanges().contains(c2b.x, c2b.y));
439 check_pixel(c2b.x, c2b.y, 1, yellow, 2);
441 check(!tester.getInvalidatedRanges().contains(c3s.x, c3s.y)); // failure won't impact correctness, only performance
442 check(!tester.getInvalidatedRanges().contains(c3b.x, c3b.y)); // failure won't impact correctness, only performance
443 check_pixel(c3s.x, c3s.y, 1, yellow, 2);
444 check_pixel(c3b.x, c3b.y, 1, white, 2);
446 // Pointer inside drawing's shape
447 tester.movePointerTo(167, 170); // the thik red line
448 tester.advance(); // hitTest runs onEnterFrame
450 check(!tester.getInvalidatedRanges().contains(c1s.x, c1s.y)); // failure won't impact correctness, only performance
451 check(!tester.getInvalidatedRanges().contains(c1b.x, c1b.y)); // failure won't impact correctness, only performance
452 check_pixel(c1s.x, c1s.y, 1, yellow, 2);
453 check_pixel(c1b.x, c1b.y, 1, yellow, 2);
455 check(!tester.getInvalidatedRanges().contains(c2s.x, c2s.y)); // failure won't impact correctness, only performance
456 check(!tester.getInvalidatedRanges().contains(c2b.x, c2b.y)); // failure won't impact correctness, only performance
457 check_pixel(c2s.x, c2s.y, 1, yellow, 2);
458 check_pixel(c2b.x, c2b.y, 1, yellow, 2);
460 check_pixel(c3s.x, c3s.y, 1, yellow, 2);
461 check(tester.getInvalidatedRanges().contains(c3b.x, c3b.y));
462 check_pixel(c3b.x, c3b.y, 1, yellow, 2);
464 //--------------------------------------------------------------
465 // Check _visible toggling effects
466 // (triggered onKeyDown 'h', effects visible after advance)
467 //--------------------------------------------------------------
469 check_pixel(330, 160, 2, green, 2);
470 tester.pressKey(gnash::key::h); tester.advance();
471 check_pixel(330, 160, 2, white, 2);
472 tester.pressKey(gnash::key::h); tester.advance();
473 check_pixel(330, 160, 2, green, 2);
475 //--------------------------------------------------------------
476 // Check setMask effect
477 // (triggered onMouseDown, effects visible after advance)
478 //--------------------------------------------------------------
480 tester.click(); // this should enable cursor shape masking drawing
482 tester.movePointerTo(50, 50); // out of any drawing
483 tester.advance();
485 // Inside bottom-left blue fill
486 check_pixel(60, 215, 2, white, 2);
487 tester.movePointerTo(60, 215); tester.advance(); // move the mask over it...
488 check_pixel(60, 215, 2, blue, 2);
490 // Inside violet fill
491 check_pixel(250, 112, 2, white, 2);
492 tester.movePointerTo(250, 112); tester.advance(); // move the mask over it
493 check_pixel(250, 112, 2, violet, 2);
495 // Inside red "thick" line
496 check_pixel(146, 146, 2, white, 2);
497 tester.movePointerTo(146, 146); tester.advance(); // move the mask over it
498 check_pixel(146, 146, 2, red, 2);
500 // Inside the violet fill
501 check_pixel(250, 112, 2, white, 2);
502 tester.click(); // this should disable the mask
503 check_pixel(250, 112, 2, violet, 2);
505 //--------------------------------------------------------------
506 // Check setMask on invisible shape
507 //--------------------------------------------------------------
509 tester.movePointerTo(146, 146); // move pointer over red shape
510 tester.click(); // enable the mask
511 tester.advance(); // commit all of the above
512 check_pixel(146, 146, 2, red, 2);
514 tester.pressKey(gnash::key::h); // make it invisible
515 tester.advance(); // commit
516 check_pixel(146, 146, 2, white, 2); // gnash failed drawing invisible dynamic maskees !
518 tester.pressKey(gnash::key::h); // make it visible again
519 tester.advance(); // commit
520 check_pixel(146, 146, 2, red, 2);
522 tester.click(); // disable the mask
523 tester.advance(); // commit
526 //--------------------------------------------------------------
527 // Go to drawing #2 (hit the '2' ascii key)
528 // and test rendering of those invalid shapes.
529 //--------------------------------------------------------------
531 tester.pressKey(gnash::key::_2); // go to second drawing
532 tester.advance(); // commit
534 //--------------------------------------------------------------
535 // The double "EL"s case
536 //--------------------------------------------------------------
538 // In the right green 'el' shape (not explicitly closed fill)
539 check_pixel(80, 170, 2, green, 2);
541 // Outside the right green 'el' shape
542 // (but close to the auto-closing edge)
543 check_pixel(90, 144, 2, white, 2);
545 // In the left green horizontally flipped 'el' shape
546 // (not explicitly closed fill)
547 check_pixel(30, 170, 2, green, 2);
549 // Outside the left green 'el' shape
550 // (but close to the auto-closing edge)
551 check_pixel(20, 144, 2, white, 2);
553 // Between the two 'el' shapes
554 check_pixel(56, 170, 2, white, 2);
556 //--------------------------------------------------------------
557 // The red crossing edges case
558 //--------------------------------------------------------------
560 // In the left niche
561 check_pixel(46, 60, 2, white, 2);
563 // In the right niche
564 check_pixel(74, 60, 2, white, 2);
566 // In the upper niche
567 check_pixel(60, 48, 2, red, 2);
569 // In the lower niche
570 check_pixel(60, 72, 2, red, 2);
572 //--------------------------------------------------------------
573 // The four-in-a-row case (there should be no visible fill)
574 //--------------------------------------------------------------
576 // upper-left
577 check_pixel(136, 35, 2, white, 2);
578 // center-left
579 check_pixel(136, 56, 2, white, 2);
580 // lower-left
581 check_pixel(136, 75, 2, white, 2);
582 // lower-center
583 check_pixel(156, 75, 2, white, 2);
584 // lower-right
585 check_pixel(175, 75, 2, white, 2);
586 // center-right
587 check_pixel(175, 56, 2, white, 2);
588 // upper-right
589 check_pixel(175, 35, 2, white, 2);
590 // upper-center
591 check_pixel(156, 35, 2, white, 2);
592 // center
593 check_pixel(156, 57, 2, white, 2);
595 //--------------------------------------------------------------
596 // The nested squares cases
597 //--------------------------------------------------------------
600 //--------------------------------------------------------------
601 // First nested squares case (hole)
602 //--------------------------------------------------------------
604 // X (145..160..175)
605 // Y (145..160..175)
607 // center-left
608 check_pixel(145, 160, 2, green, 2);
609 // center-right
610 check_pixel(175, 160, 2, green, 2);
611 // upper-center
612 check_pixel(160, 145, 2, green, 2);
613 // lower-center
614 check_pixel(160, 175, 2, green, 2);
615 // center-center (hole)
616 check_pixel(160, 160, 2, white, 2);
618 //--------------------------------------------------------------
619 // Second nested squares case (hole)
620 //--------------------------------------------------------------
622 // X (194..210..226)
623 // Y (145..160..175)
625 // center-left
626 check_pixel(194, 160, 2, green, 2);
627 // center-right
628 check_pixel(226, 160, 2, green, 2);
629 // upper-center
630 check_pixel(210, 145, 2, green, 2);
631 // lower-center
632 check_pixel(210, 175, 2, green, 2);
633 // center-center (hole)
634 check_pixel(210, 160, 2, white, 2);
636 //--------------------------------------------------------------
637 // Third nested squares case (subshape)
638 //--------------------------------------------------------------
640 // X (244..260..276)
641 // Y (145..160..175)
643 // center-left
644 check_pixel(244, 160, 2, green, 2);
645 // center-right
646 check_pixel(276, 160, 2, green, 2);
647 // upper-center
648 check_pixel(260, 145, 2, green, 2);
649 // lower-center
650 check_pixel(260, 175, 2, green, 2);
651 // center-center (two overlapping subshapes)
652 check_pixel(260, 160, 2, green, 2);
654 tester.pressKey(gnash::key::MINUS); // alpha goes down to 75
655 tester.pressKey(gnash::key::MINUS); // alpha goes down to 50
656 tester.advance(); // commit
658 // center-left
659 check_pixel(244, 160, 2, light_green, 2);
660 // center-right
661 check_pixel(276, 160, 2, light_green, 2);
662 // upper-center
663 check_pixel(260, 145, 2, light_green, 2);
664 // lower-center
665 check_pixel(260, 175, 2, light_green, 2);
666 // center-center (two overlapping subshapes)
667 check_pixel(260, 160, 2, overlapping_light_green, 2);
669 tester.pressKey(gnash::key::PLUS); // alpha goes up to 75
670 tester.pressKey(gnash::key::PLUS); // alpha goes up to 100
671 tester.advance(); // commit
673 //--------------------------------------------------------------
674 // Fourth nested squares case (subshape)
675 //--------------------------------------------------------------
677 // X (293..309..325)
678 // Y (145..160..175)
680 // center-left
681 check_pixel(294, 160, 2, green, 2);
682 // center-right
683 check_pixel(325, 160, 2, green, 2);
684 // upper-center
685 check_pixel(309, 145, 2, green, 2);
686 // lower-center
687 check_pixel(309, 175, 2, green, 2);
688 // center-center (two overlapping subshapes)
689 check_pixel(309, 160, 2, green, 2);
691 tester.pressKey(gnash::key::MINUS); // alpha goes down to 75
692 tester.pressKey(gnash::key::MINUS); // alpha goes down to 50
693 tester.advance(); // commit
695 // center-left
696 check_pixel(294, 160, 2, light_green, 2);
697 // center-right
698 check_pixel(325, 160, 2, light_green, 2);
699 // upper-center
700 check_pixel(309, 145, 2, light_green, 2);
701 // lower-center
702 check_pixel(309, 175, 2, light_green, 2);
703 // center-center (two overlapping subshapes)
704 check_pixel(309, 160, 2, overlapping_light_green, 2);
706 tester.pressKey(gnash::key::PLUS); // alpha goes up to 75
707 tester.pressKey(gnash::key::PLUS); // alpha goes up to 100
708 tester.advance(); // commit
710 //--------------------------------------------------------------
711 // Complex single-path crossing:
713 // 10 5----4,0----------1
714 // |#####|###########|
715 // |#####|###########|
716 // 20 6-----+----7######|
717 // | |######|
718 // | |######|
719 // 30 9----8######|
720 // |###########|
721 // 40 3-----------2
723 // 10 20 30 40
725 // {X,Y} Scale : 200
726 // X offset : 200
727 //--------------------------------------------------------------
729 int scale = 2;
730 int xo = 200;
731 int yo = 0;
733 // Upper-Left
734 check_pixel(xo + (15*scale), yo + (15*scale), 2, red, 2);
735 // Upper-Center
736 check_pixel(xo + (25*scale), yo + (15*scale), 2, red, 2);
737 // Upper-On_09_stroke
738 // AGG fails rendering a white stroke on the red background.
739 // Cairo succeeds.
740 check_pixel(xo + (20*scale), yo + (15*scale), 2, red, 2);
741 // Upper-Right
742 check_pixel(xo + (35*scale), yo + (15*scale), 2, red, 2);
744 // Center-Left
745 check_pixel(xo + (15*scale), yo + (25*scale), 2, white, 2);
746 // Center-Center
747 check_pixel(xo + (25*scale), yo + (25*scale), 2, white, 2);
748 // Center-Right
749 check_pixel(xo + (35*scale), yo + (25*scale), 2, red, 2);
751 // Lower-Left
752 check_pixel(xo + (15*scale), yo + (35*scale), 2, white, 2);
753 // Lower-Lower
754 check_pixel(xo + (25*scale), yo + (35*scale), 2, red, 2);
755 // Lower-Right
756 check_pixel(xo + (35*scale), yo + (35*scale), 2, red, 2);
758 // On the 0-9 stroke, out of fill
759 // AGG fails rendering a white stroke on the red background.
760 // Cairo succeeds.
761 check_pixel(xo + (20*scale), yo + (25*scale), 3, white, 2);
763 // Test picture 3
764 tester.pressKey(gnash::key::_3); tester.advance();
766 const int w = 100, h = 100;
768 int x = 20, y = 20;
770 // Shape 1
772 // Bottom left corner (green line).
773 check_pixel(x, y + h, 2, green, 2);
774 // Bottom left fill (red)
775 check_pixel(x + 20, y + 60, 2, red, 2);
776 // Top right fill (red)
777 check_pixel(x + 80, y + 20, 2, red, 2);
778 // Dead centre fill (red)
779 xcheck_pixel(x + w / 2, y + h / 2, 2, red, 2);
780 // Top right corner (blue line)
781 check_pixel(x + w, y, 2, blue, 2);
783 // Shape 2
785 x += 200;
787 // Bottom left corner (green line).
788 check_pixel(x, y + h, 2, green, 2);
789 // Bottom left fill (red)
790 check_pixel(x + 20, y + 60, 2, red, 2);
791 // Top right fill (red)
792 xcheck_pixel(x + 80, y + 20, 2, red, 2);
793 // Dead centre fill (red)
794 xcheck_pixel(x + w / 2, y + h / 2, 2, red, 2);
795 // Top right corner (blue line, is correct to be over black line ending)
796 check_pixel(x + w, y, 2, blue, 2);
797 // Top centre (black line)
798 check_pixel(x + w / 2, y, 2, black, 2);
800 // Shape 3
802 x += 200;
804 // Bottom left corner (black line).
805 check_pixel(x, y + h, 2, black, 2);
806 // Bottom left fill (none)
807 check_pixel(x + 20, y + 60, 2, white, 2);
808 // Top right fill (none)
809 check_pixel(x + 80, y + 20, 2, white, 2);
810 // Dead centre fill (none)
811 check_pixel(x + w / 2, y + h / 2, 2, white, 2);
812 // Top right corner (nothing)
813 check_pixel(x + w, y, 2, white, 2);
815 // Shape 4
817 x = 20;
818 y += 150;
820 // Should look the same as Shape 3
822 // Bottom left corner (black line).
823 check_pixel(x, y + h, 2, black, 2);
824 // Bottom left fill (none)
825 check_pixel(x + 20, y + 60, 2, white, 2);
826 // Top right fill (none)
827 check_pixel(x + 80, y + 20, 2, white, 2);
828 // Dead centre fill (none)
829 check_pixel(x + w / 2, y + h / 2, 2, white, 2);
830 // Top right corner (nothing)
831 check_pixel(x + w, y, 2, white, 2);
833 // Shape 5
835 x += 200;
837 // Bottom left corner (black line).
838 check_pixel(x, y + h, 2, black, 2);
839 // Bottom left fill (black)
840 check_pixel(x + 20, y + 60, 2, black, 2);
841 // Top right fill (none)
842 check_pixel(x + 80, y + 20, 2, white, 2);
843 // Dead centre (black line)
844 check_pixel(x + w / 2, y + h / 2, 2, black, 2);
845 // Top right corner (nothing)
846 check_pixel(x + w, y, 2, white, 2);
848 // Shape 6
850 x += 200;
852 // NB: the rendering of this shape is not consistent
853 // across different versions of the pp. It doesn't seem
854 // like a sane case, so there is probably no need
855 // to worry about compatibility.
857 // Bottom left corner (yellow line).
858 check_pixel(x, y + h, 2, yellow, 2);
859 // Bottom left fill (green)
860 check_pixel(x + 20, y + 60, 2, green, 2);
862 // The following tests are possibly meaningless:
864 // Top right fill (blue)
865 check_pixel(x + 80, y + 20, 2, blue, 2);
866 // Dead centre (yellow line)
867 check_pixel(x + w / 2, y + h / 2, 2, yellow, 2);
868 // Top right corner (yellow line)
869 check_pixel(x + w, y, 2, yellow, 2);
871 // Test picture 4
872 tester.pressKey(gnash::key::_4); tester.advance();
874 // The shapes are 90x90, spaced in a 100x100 pixel grid with 6 shapes in
875 // each row.
877 x = 0;
878 y = 0;
880 // Shape 1
881 // Check each corner. The gradient is much too spread out, so should be
882 // practically the same blue-white everywhere.
883 rgba lightblue(120, 129, 248, 255);
884 check_pixel(x + 2, y + 2, 2, lightblue, 2);
885 check_pixel(x + 2, y + 90 - 2, 2, lightblue, 2);
886 check_pixel(x + 90 - 2, y + 2, 2, lightblue, 2);
887 check_pixel(x + 90 - 2, y + 90 - 2, 2, lightblue, 2);
889 // Shape 2
890 // Check each corner
891 x += 100;
892 check_pixel(x + 2, y + 2, 2, blue, 2);
893 check_pixel(x + 2, y + 90 - 2, 2, blue, 2);
894 check_pixel(x + 90 - 2, y + 2, 2, white, 2);
895 check_pixel(x + 90 - 2, y + 90 - 2, 2, white, 2);
897 // Shape 3
898 // Check each corner
899 x += 100;
900 check_pixel(x + 2, y + 2, 2, blue, 2);
901 check_pixel(x + 2, y + 90 - 2, 2, white, 2);
902 check_pixel(x + 90 - 2, y + 2, 2, white, 2);
903 check_pixel(x + 90 - 2, y + 90 - 2, 2, violet, 2);
905 // Shape 4
906 // Check each corner
907 x += 100;
908 rgba whiteblue(70,70,248,255);
909 check_pixel(x + 2, y + 2, 2, blue, 2);
910 check_pixel(x + 2, y + 90 - 2, 2, whiteblue, 2);
911 check_pixel(x + 90 - 2, y + 2, 2, whiteblue, 2);
912 check_pixel(x + 90 - 2, y + 90 - 2, 2, white, 2);
914 // Shape 5
915 // Check each corner
916 x += 100;
917 rgba whitegreen(80,248,80,255);
918 check_pixel(x + 2, y + 2, 2, white, 2);
919 check_pixel(x + 2, y + 90 - 2, 2, whitegreen, 2);
920 check_pixel(x + 90 - 2, y + 2, 2, whiteblue, 2);
921 check_pixel(x + 90 - 2, y + 90 - 2, 2, white, 2);
923 // Shape 6
924 // Check each row
925 x += 100;
926 int row = 90 / 5;
927 check_pixel(x + 45, y + 1, 2, blue, 2);
928 check_pixel(x + 45, y + row, 2, white, 2);
929 check_pixel(x + 45, y + row * 2, 2, green, 2);
931 // Note that these two have a lower alpha value and the rgba value we
932 // expect is that combined with the white background and surrounding
933 // fill colours..
934 check_pixel(x + 45, y + row * 3, 2, rgba(240,120,244,255), 2);
935 check_pixel(x + 45, y + row * 4 , 2, rgba(184,240,240,255), 2);
937 // I'm fairly sure this should be plain yellow, but we render it with
938 // alpha.
939 xcheck_pixel(x + 45, y + 89, 2, yellow, 2);
941 y += 100;
942 x = 0;
944 // Shape 7
945 // Check each corner and centre. The gradient is much too spread out,
946 // so should be almost the same blue-white everywhere.
947 rgba otherblue(24,24,248,255);
948 rgba otherblue2(56,56,248,255);
949 check_pixel(x + 2, y + 2, 2, otherblue, 2);
950 check_pixel(x + 2, y + 90 - 2, 2, otherblue2, 2);
951 check_pixel(x + 90 - 2, y + 2, 2, otherblue, 2);
952 check_pixel(x + 90 - 2, y + 90 - 2, 2, otherblue2, 2);
953 check_pixel(x + 45, y + 45, 2, otherblue, 2);
955 // Shape 8
956 x += 100;
957 check_pixel(x + 2, y + 2, 2, white, 2);
958 check_pixel(x + 2, y + 90 - 2, 2, white, 2);
959 check_pixel(x + 90 - 2, y + 2, 2, white, 2);
960 check_pixel(x + 90 - 2, y + 90 - 2, 2, white, 2);
961 check_pixel(x + 45, y + 45, 2, blue, 2);
963 // Shape 9
964 x += 100;
965 check_pixel(x + 2, y + 2, 2, violet, 2);
966 check_pixel(x + 2, y + 90 - 2, 2, violet, 2);
967 check_pixel(x + 90 - 2, y + 2, 2, violet, 2);
968 check_pixel(x + 90 - 2, y + 90 - 2, 2, violet, 2);
969 check_pixel(x + 45, y + 45, 2, blue, 2);
970 // Inner white circle
971 check_pixel(x + 45, y + 45 / 2, 2, white, 2)
973 // Shape 10
974 x += 100;
975 check_pixel(x + 2, y + 2, 2, violet, 2);
976 check_pixel(x + 2, y + 90 - 2, 2, violet, 2);
977 check_pixel(x + 90 - 2, y + 2, 2, violet, 2);
978 check_pixel(x + 90 - 2, y + 90 - 2, 2, blue, 2);
980 check_pixel(x + 90, y + 45, 2, white, 2);
981 check_pixel(x + 45, y + 90, 2, white, 2);
984 // Shape 11
985 x += 100;
986 check_pixel(x + 2, y + 2, 2, blue, 2);
987 check_pixel(x + 2, y + 90 - 2, 2, green, 2);
988 check_pixel(x + 90 - 2, y + 2, 2, green, 2);
989 check_pixel(x + 90 - 2, y + 90 - 2, 2, green, 2);
991 check_pixel(x + 45, y + 1, 2, white, 2);
992 check_pixel(x + 1, y + 45, 2, white, 2);
994 // Shape 12
995 x += 100;
996 check_pixel(x + 2, y + 2, 2, yellow, 2);
997 check_pixel(x + 2, y + 90 - 2, 2, yellow, 2);
998 check_pixel(x + 90 - 2, y + 2, 2, yellow, 2);
999 check_pixel(x + 90 - 2, y + 90 - 2, 2, yellow, 2);
1000 check_pixel(x + 45, y + 45, 2, blue, 2);
1002 // Shape 13
1003 y += 100;
1004 x = 0;
1005 check_pixel(x + 7, y + 2, 2, green, 2);
1006 check_pixel(x + 7, y + 90 - 2, 2, green, 2);
1007 check_pixel(x + 90 - 2, y + 2, 2, green, 2);
1008 check_pixel(x + 90 - 2, y + 90 - 2, 2, green, 2);
1010 // Shape 14
1011 x += 100;
1012 check_pixel(x + 7, y + 2, 2, red, 2);
1013 check_pixel(x + 7, y + 90 - 2, 2, red, 2);
1014 check_pixel(x + 90 - 2, y + 2, 2, red, 2);
1015 check_pixel(x + 90 - 2, y + 90 - 2, 2, red, 2);
1017 // Shape 15
1018 x += 100;
1019 check_pixel(x + 7, y + 2, 2, green, 2);
1020 check_pixel(x + 7, y + 90 - 2, 2, green, 2);
1021 check_pixel(x + 90 - 2, y + 2, 2, green, 2);
1022 check_pixel(x + 90 - 2, y + 90 - 2, 2, green, 2);
1024 // 3 invalid fills follow
1026 // Shape 16
1027 x += 100;
1028 check_pixel(x + 7, y + 2, 2, white, 2);
1029 check_pixel(x + 7, y + 90 - 2, 2, white, 2);
1030 check_pixel(x + 90 - 2, y + 2, 2, white, 2);
1031 check_pixel(x + 90 - 2, y + 90 - 2, 2, white, 2);
1033 // Shape 17
1034 x += 100;
1035 check_pixel(x + 7, y + 2, 2, white, 2);
1036 check_pixel(x + 7, y + 90 - 2, 2, white, 2);
1037 check_pixel(x + 90 - 2, y + 2, 2, white, 2);
1038 check_pixel(x + 90 - 2, y + 90 - 2, 2, white, 2);
1040 x = 0;
1041 y += 100;
1043 // Shape 18
1044 check_pixel(x + 7, y + 2, 2, white, 2);
1045 check_pixel(x + 7, y + 90 - 2, 2, white, 2);
1046 check_pixel(x + 90 - 2, y + 2, 2, white, 2);
1047 check_pixel(x + 90 - 2, y + 90 - 2, 2, white, 2);
1049 //----------------------------------------------------------
1050 // TODO: check startDrag/stopDrag on the hit detector
1051 // (hit 'd' key to toggle)
1052 //----------------------------------------------------------
1056 return 0;