Update with current status
[gnash.git] / testsuite / misc-ming.all / replace_buttons1test_runner.cpp
blob3da3a57932d9a78872ee5993af2b814d9050a29a
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_buttons1test.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 white(255,255,255,255);
55 // Ranges we'll use during the test
56 Range2d<int> redRange1(100,300,160,360);
57 Range2d<int> redRange2(130,330,190,390);
59 Ranges invalidated;
60 MovieClip* root = tester.getRootMovie();
61 assert(root);
63 // FRAME 1 (start)
65 check_equals(root->get_frame_count(), 4);
66 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
67 check_equals(root->get_current_frame(), 0);
68 check_equals(root->getDisplayList().size(), 1); // dejagnu clip
69 invalidated = tester.getInvalidatedRanges();
70 check( invalidated.contains(76, 4) ); // the "-xtrace enabled-" label...
72 tester.advance(); // FRAME 2, place DisplayObject
73 invalidated = tester.getInvalidatedRanges();
75 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
76 check_equals(root->get_current_frame(), 1);
77 check_equals(root->getDisplayList().size(), 2); // dejagnu + red square
79 // check invalidated bounds contain the red square at (100,300 - 160,360)
80 check( invalidated.contains(redRange1) );
82 // check that we have a red square at (100,300 - 160,360)
83 check_pixel(104, 304, 2, red, 2); // UL
84 check_pixel(156, 304, 2, red, 2); // UR
85 check_pixel(156, 356, 2, red, 2); // LL
86 check_pixel(104, 356, 2, red, 2); // LR
88 // and nothing around it...
89 check_pixel( 96, 330, 2, white, 2); // Left
90 check_pixel(164, 330, 2, white, 2); // Right
91 check_pixel(130, 296, 2, white, 2); // Top
92 check_pixel(130, 364, 2, white, 2); // Bottom
94 tester.advance(); // FRAME 3, replace DisplayObject
95 invalidated = tester.getInvalidatedRanges();
97 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
98 check_equals(root->get_current_frame(), 2);
99 check_equals(root->getDisplayList().size(), 2); // dejagnu + red square
101 // check invalidated bounds to contain:
102 // - the red square (moved)
103 // - the red square (original)
105 check( invalidated.contains(redRange1) );
106 check( invalidated.contains(redRange2) );
108 // check that we have a red square at (130,330 - 190,390)
109 // Gnash fails here becase it does a *real* replace, while it
110 // seems we're not supposed to replace, just to move (who knows why?!)
111 check_pixel(134, 334, 2, red, 2); // UL
112 check_pixel(186, 334, 2, red, 2); // UR
113 check_pixel(186, 386, 2, red, 2); // LL
114 check_pixel(134, 386, 2, red, 2); // LR
116 // and nothing around it...
117 check_pixel(126, 360, 2, white, 2); // Left
118 check_pixel(194, 360, 2, white, 2); // Right
119 check_pixel(160, 326, 2, white, 2); // Top
120 check_pixel(160, 394, 2, white, 2); // Bottom
122 tester.advance(); // FRAME 4, jump to frame 2 and stop
123 invalidated = tester.getInvalidatedRanges();
125 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
126 check_equals(root->get_current_frame(), 1);
127 check_equals(root->getDisplayList().size(), 2); // dejagnu + red square
129 // check invalidated bounds to contain:
130 // - the red square (moved)
131 // - the red square (original)
133 check( invalidated.contains(redRange1) );
134 check( invalidated.contains(redRange2) );
136 // check that we have a red square at (100,300 - 160,360)
137 check_pixel(104, 304, 2, red, 2); // UL
138 check_pixel(156, 304, 2, red, 2); // UR
139 check_pixel(156, 356, 2, red, 2); // LL
140 check_pixel(104, 356, 2, red, 2); // LR
142 // and nothing around it...
143 check_pixel( 96, 330, 2, white, 2); // Left
144 check_pixel(164, 330, 2, white, 2); // Right
145 check_pixel(130, 296, 2, white, 2); // Top
146 check_pixel(130, 364, 2, white, 2); // Bottom
148 return 0;