Update with current status
[gnash.git] / testsuite / misc-ming.all / replace_shapes1test_runner.cpp
blobfce1f364dfa3ba5e71f5853709032b6f1e3dbc15
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 "replace_shapes1test.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;
36 using namespace gnash::geometry;
38 TRYMAIN(_runtest);
39 int
40 trymain(int /*argc*/, char** /*argv*/)
42 typedef gnash::geometry::SnappingRanges2d<int> Ranges;
43 typedef gnash::geometry::Range2d<int> Bounds;
45 string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
46 MovieTester tester(filename);
48 gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
49 dbglogfile.setVerbosity(1);
51 // Colors we'll use during the test
52 rgba red(255,0,0,255);
53 rgba green(0,255,0,255);
54 rgba white(255,255,255,255);
56 // Ranges we'll use during the test
57 Range2d<int> redRange(100,300,160,360);
58 Range2d<int> greenRange(130,330,190,390);
60 Ranges invalidated;
61 MovieClip* root = tester.getRootMovie();
62 assert(root);
64 // FRAME 1 (start)
66 check_equals(root->get_frame_count(), 4);
67 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
68 check_equals(root->get_current_frame(), 0);
69 check_equals(root->getDisplayList().size(), 1); // dejagnu clip
70 invalidated = tester.getInvalidatedRanges();
71 check( invalidated.contains(76, 4) ); // the "-xtrace enabled-" label...
73 tester.advance(); // FRAME 2, place DisplayObject
74 invalidated = tester.getInvalidatedRanges();
76 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
77 check_equals(root->get_current_frame(), 1);
78 check_equals(root->getDisplayList().size(), 2); // dejagnu + red char
80 // check invalidated bounds contain the red instance (100,300 - 160,360)
81 check( invalidated.contains(redRange) );
83 // check that we have a red square at (100,300 - 160,360)
84 check_pixel(104, 304, 2, red, 2); // UL
85 check_pixel(156, 304, 2, red, 2); // UR
86 check_pixel(156, 356, 2, red, 2); // LL
87 check_pixel(104, 356, 2, red, 2); // LR
89 // and nothing around it...
90 check_pixel( 96, 330, 2, white, 2); // Left
91 check_pixel(164, 330, 2, white, 2); // Right
92 check_pixel(130, 296, 2, white, 2); // Top
93 check_pixel(130, 364, 2, white, 2); // Bottom
95 tester.advance(); // FRAME 3, replace DisplayObject
96 invalidated = tester.getInvalidatedRanges();
98 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
99 check_equals(root->get_current_frame(), 2);
100 check_equals(root->getDisplayList().size(), 2); // dejagnu + green char
102 // check invalidated bounds to contain:
103 // - the green square (added)
104 // - the red square (removed)
106 check( invalidated.contains(redRange) );
107 check( invalidated.contains(greenRange) );
109 // check that we have a green square at (130,330 - 190,390)
110 check_pixel(134, 334, 2, green, 2); // UL
111 check_pixel(186, 334, 2, green, 2); // UR
112 check_pixel(186, 386, 2, green, 2); // LL
113 check_pixel(134, 386, 2, green, 2); // LR
115 // and nothing around it...
116 check_pixel(126, 360, 2, white, 2); // Left
117 check_pixel(194, 360, 2, white, 2); // Right
118 check_pixel(160, 326, 2, white, 2); // Top
119 check_pixel(160, 394, 2, white, 2); // Bottom
121 tester.advance(); // FRAME 4, jump to frame 2 and stop
122 invalidated = tester.getInvalidatedRanges();
124 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
125 check_equals(root->get_current_frame(), 1);
126 check_equals(root->getDisplayList().size(), 2); // dejagnu + red char
128 // check invalidated bounds to contain:
129 // - the green square (removed)
130 // - the red square (added)
132 check( invalidated.contains(redRange) );
133 check( invalidated.contains(greenRange) );
135 // check that we have a red square at (100,300 - 160,360)
136 check_pixel(104, 304, 2, red, 2); // UL
137 check_pixel(156, 304, 2, red, 2); // UR
138 check_pixel(156, 356, 2, red, 2); // LL
139 check_pixel(104, 356, 2, red, 2); // LR
141 // and nothing around it...
142 check_pixel( 96, 330, 2, white, 2); // Left
143 check_pixel(164, 330, 2, white, 2); // Right
144 check_pixel(130, 296, 2, white, 2); // Top
145 check_pixel(130, 364, 2, white, 2); // Bottom
147 return 0;