big merge from master, fix rpm creation, drop fetching swfdec
[gnash.git] / testsuite / misc-ming.all / replace_shapes1test_runner.cpp
blob3d7d18ced1fba1d6ceb99684cecf925d8d7701b3
1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
21 #define INPUT_FILENAME "replace_shapes1test.swf"
23 #include "MovieTester.h"
24 #include "MovieClip.h"
25 #include "DisplayObject.h"
26 #include "DisplayList.h"
27 #include "log.h"
29 #include "check.h"
30 #include <string>
31 #include <cassert>
33 using namespace gnash;
34 using namespace std;
35 using namespace gnash::geometry;
37 int
38 main(int /*argc*/, char** /*argv*/)
40 typedef gnash::geometry::SnappingRanges2d<int> Ranges;
41 typedef gnash::geometry::Range2d<int> Bounds;
43 string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
44 MovieTester tester(filename);
46 gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
47 dbglogfile.setVerbosity(1);
49 // Colors we'll use during the test
50 rgba red(255,0,0,255);
51 rgba green(0,255,0,255);
52 rgba white(255,255,255,255);
54 // Ranges we'll use during the test
55 Range2d<int> redRange(100,300,160,360);
56 Range2d<int> greenRange(130,330,190,390);
58 Ranges invalidated;
59 MovieClip* root = tester.getRootMovie();
60 assert(root);
62 // FRAME 1 (start)
64 check_equals(root->get_frame_count(), 4);
65 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
66 check_equals(root->get_current_frame(), 0);
67 check_equals(root->getDisplayList().size(), 1); // dejagnu clip
68 invalidated = tester.getInvalidatedRanges();
69 check( invalidated.contains(76, 4) ); // the "-xtrace enabled-" label...
71 tester.advance(); // FRAME 2, place DisplayObject
72 invalidated = tester.getInvalidatedRanges();
74 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
75 check_equals(root->get_current_frame(), 1);
76 check_equals(root->getDisplayList().size(), 2); // dejagnu + red char
78 // check invalidated bounds contain the red instance (100,300 - 160,360)
79 check( invalidated.contains(redRange) );
81 // check that we have a red square at (100,300 - 160,360)
82 check_pixel(104, 304, 2, red, 2); // UL
83 check_pixel(156, 304, 2, red, 2); // UR
84 check_pixel(156, 356, 2, red, 2); // LL
85 check_pixel(104, 356, 2, red, 2); // LR
87 // and nothing around it...
88 check_pixel( 96, 330, 2, white, 2); // Left
89 check_pixel(164, 330, 2, white, 2); // Right
90 check_pixel(130, 296, 2, white, 2); // Top
91 check_pixel(130, 364, 2, white, 2); // Bottom
93 tester.advance(); // FRAME 3, replace DisplayObject
94 invalidated = tester.getInvalidatedRanges();
96 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
97 check_equals(root->get_current_frame(), 2);
98 check_equals(root->getDisplayList().size(), 2); // dejagnu + green char
100 // check invalidated bounds to contain:
101 // - the green square (added)
102 // - the red square (removed)
104 check( invalidated.contains(redRange) );
105 check( invalidated.contains(greenRange) );
107 // check that we have a green square at (130,330 - 190,390)
108 check_pixel(134, 334, 2, green, 2); // UL
109 check_pixel(186, 334, 2, green, 2); // UR
110 check_pixel(186, 386, 2, green, 2); // LL
111 check_pixel(134, 386, 2, green, 2); // LR
113 // and nothing around it...
114 check_pixel(126, 360, 2, white, 2); // Left
115 check_pixel(194, 360, 2, white, 2); // Right
116 check_pixel(160, 326, 2, white, 2); // Top
117 check_pixel(160, 394, 2, white, 2); // Bottom
119 tester.advance(); // FRAME 4, jump to frame 2 and stop
120 invalidated = tester.getInvalidatedRanges();
122 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
123 check_equals(root->get_current_frame(), 1);
124 check_equals(root->getDisplayList().size(), 2); // dejagnu + red char
126 // check invalidated bounds to contain:
127 // - the green square (removed)
128 // - the red square (added)
130 check( invalidated.contains(redRange) );
131 check( invalidated.contains(greenRange) );
133 // check that we have a red square at (100,300 - 160,360)
134 check_pixel(104, 304, 2, red, 2); // UL
135 check_pixel(156, 304, 2, red, 2); // UR
136 check_pixel(156, 356, 2, red, 2); // LL
137 check_pixel(104, 356, 2, red, 2); // LR
139 // and nothing around it...
140 check_pixel( 96, 330, 2, white, 2); // Left
141 check_pixel(164, 330, 2, white, 2); // Right
142 check_pixel(130, 296, 2, white, 2); // Top
143 check_pixel(130, 364, 2, white, 2); // Bottom