big merge from master, fix rpm creation, drop fetching swfdec
[gnash.git] / testsuite / misc-ming.all / replace_buttons1test_runner.cpp
blobc4b750231804f335c025a12b46af5bba11831b12
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_buttons1test.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 white(255,255,255,255);
53 // Ranges we'll use during the test
54 Range2d<int> redRange1(100,300,160,360);
55 Range2d<int> redRange2(130,330,190,390);
57 Ranges invalidated;
58 MovieClip* root = tester.getRootMovie();
59 assert(root);
61 // FRAME 1 (start)
63 check_equals(root->get_frame_count(), 4);
64 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
65 check_equals(root->get_current_frame(), 0);
66 check_equals(root->getDisplayList().size(), 1); // dejagnu clip
67 invalidated = tester.getInvalidatedRanges();
68 check( invalidated.contains(76, 4) ); // the "-xtrace enabled-" label...
70 tester.advance(); // FRAME 2, place DisplayObject
71 invalidated = tester.getInvalidatedRanges();
73 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
74 check_equals(root->get_current_frame(), 1);
75 check_equals(root->getDisplayList().size(), 2); // dejagnu + red square
77 // check invalidated bounds contain the red square at (100,300 - 160,360)
78 check( invalidated.contains(redRange1) );
80 // check that we have a red square at (100,300 - 160,360)
81 check_pixel(104, 304, 2, red, 2); // UL
82 check_pixel(156, 304, 2, red, 2); // UR
83 check_pixel(156, 356, 2, red, 2); // LL
84 check_pixel(104, 356, 2, red, 2); // LR
86 // and nothing around it...
87 check_pixel( 96, 330, 2, white, 2); // Left
88 check_pixel(164, 330, 2, white, 2); // Right
89 check_pixel(130, 296, 2, white, 2); // Top
90 check_pixel(130, 364, 2, white, 2); // Bottom
92 tester.advance(); // FRAME 3, replace DisplayObject
93 invalidated = tester.getInvalidatedRanges();
95 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
96 check_equals(root->get_current_frame(), 2);
97 check_equals(root->getDisplayList().size(), 2); // dejagnu + red square
99 // check invalidated bounds to contain:
100 // - the red square (moved)
101 // - the red square (original)
103 check( invalidated.contains(redRange1) );
104 check( invalidated.contains(redRange2) );
106 // check that we have a red square at (130,330 - 190,390)
107 // Gnash fails here becase it does a *real* replace, while it
108 // seems we're not supposed to replace, just to move (who knows why?!)
109 check_pixel(134, 334, 2, red, 2); // UL
110 check_pixel(186, 334, 2, red, 2); // UR
111 check_pixel(186, 386, 2, red, 2); // LL
112 check_pixel(134, 386, 2, red, 2); // LR
114 // and nothing around it...
115 check_pixel(126, 360, 2, white, 2); // Left
116 check_pixel(194, 360, 2, white, 2); // Right
117 check_pixel(160, 326, 2, white, 2); // Top
118 check_pixel(160, 394, 2, white, 2); // Bottom
120 tester.advance(); // FRAME 4, jump to frame 2 and stop
121 invalidated = tester.getInvalidatedRanges();
123 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
124 check_equals(root->get_current_frame(), 1);
125 check_equals(root->getDisplayList().size(), 2); // dejagnu + red square
127 // check invalidated bounds to contain:
128 // - the red square (moved)
129 // - the red square (original)
131 check( invalidated.contains(redRange1) );
132 check( invalidated.contains(redRange2) );
134 // check that we have a red square at (100,300 - 160,360)
135 check_pixel(104, 304, 2, red, 2); // UL
136 check_pixel(156, 304, 2, red, 2); // UR
137 check_pixel(156, 356, 2, red, 2); // LL
138 check_pixel(104, 356, 2, red, 2); // LR
140 // and nothing around it...
141 check_pixel( 96, 330, 2, white, 2); // Left
142 check_pixel(164, 330, 2, white, 2); // Right
143 check_pixel(130, 296, 2, white, 2); // Top
144 check_pixel(130, 364, 2, white, 2); // Bottom