Update with current status
[gnash.git] / testsuite / samples / test_15bpp_bitmap-TestRunner.cpp
blob973b4ae5b1a8bcc87d596fd04d84d17178406588
1 /*
2 * Copyright (C) 2012 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
18 */
20 #define INPUT_FILENAME "test_15bpp_bitmap.swf"
22 #include "MovieTester.h"
23 #include "GnashException.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;
36 TRYMAIN(_runtest);
37 int
38 trymain(int /*argc*/, char** /*argv*/)
40 string filename = string(SRCDIR) + string("/") + string(INPUT_FILENAME);
41 unique_ptr<MovieTester> t;
43 gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
44 dbglogfile.setVerbosity(1);
46 try
48 t.reset(new MovieTester(filename));
50 catch (const GnashException& e)
52 std::cerr << "Error initializing MovieTester: " << e.what() << std::endl;
53 exit(EXIT_FAILURE);
56 MovieTester& tester = *t;
58 // Colors used for pixel checking
59 rgba gray(135, 135, 135, 255); /* bottom-left of the center */
60 rgba white(255, 255, 255, 255);
61 rgba black(0, 0, 0, 255);
62 rgba dark_cyan(0, 135, 135, 255);
63 rgba cyan(0, 255, 255, 255);
64 rgba dark_magenta(135, 0, 135, 255);
65 rgba magenta(255, 0, 255, 255);
66 rgba dark_yellow(135, 135, 0, 255);
67 rgba yellow(255, 255, 0, 255);
68 rgba middle_gray(127, 127, 127, 255); /* top-right of the center */
69 rgba dark_gray(71, 71, 71, 255); /* top-left & bottom-right */
70 rgba red(255, 0, 0, 255);
71 rgba green(0, 255, 0, 255);
72 rgba blue(0, 0, 255, 255);
73 rgba dark_blue(0, 0, 135, 255);
74 rgba dark_green(0, 135, 0, 255);
75 rgba dark_red(135, 0, 0, 255);
77 // Coordinates used for pixel checking
78 struct PT {
79 int x;
80 int y;
81 PT(int nx, int ny): x(nx), y(ny) {}
84 // from center to out
86 PT ul1( 204, 295); PT ur1( 307, ul1.y);
87 PT ul2(ul1.x-32, ul1.y-32); PT ur2(ur1.x+32, ul2.y);
88 PT ul3(ul2.x-32, ul2.y-32); PT ur3(ur2.x+32, ul3.y);
89 PT ul4(ul3.x-32, ul3.y-32); PT ur4(ur3.x+32, ul4.y);
90 PT ul5(ul4.x-32, ul4.y-32); PT ur5(ur4.x+32, ul5.y);
91 PT ul6(ul5.x-32, ul5.y-32); PT ur6(ur5.x+32, ul6.y);
92 PT ul7(ul6.x-32, ul6.y-32); PT ur7(ur6.x+32, ul7.y);
94 PT ll1(ul1.x, 314); PT lr1(ur1.x, ll1.y);
95 PT ll2(ul2.x, ll1.y+32); PT lr2(ur2.x, ll2.y);
96 PT ll3(ul3.x, ll2.y+32); PT lr3(ur3.x, ll3.y);
97 PT ll4(ul4.x, ll3.y+32); PT lr4(ur4.x, ll4.y);
98 PT ll5(ul5.x, ll4.y+32); PT lr5(ur5.x, ll5.y);
99 PT ll6(ul6.x, ll5.y+32); PT lr6(ur6.x, ll6.y);
100 PT ll7(ul7.x, ll6.y+32); PT lr7(ur7.x, ll7.y);
103 const MovieClip* root = tester.getRootMovie();
104 assert(root);
106 check_equals(root->get_frame_count(), 1);
108 check_pixel(ul1.x, ul1.y, 8, dark_gray, 1);
109 check_pixel(ul2.x, ul2.y, 8, dark_yellow, 1);
110 check_pixel(ul3.x, ul3.y, 8, dark_magenta, 1);
111 check_pixel(ul4.x, ul4.y, 8, dark_cyan, 1);
112 check_pixel(ul5.x, ul5.y, 8, black, 1);
113 check_pixel(ul6.x, ul6.y, 8, gray, 1);
114 check_pixel(ul6.x, ul7.y, 8, white, 1);
116 check_pixel(ur1.x, ur1.y, 8, middle_gray, 1);
117 check_pixel(ur2.x, ur2.y, 8, yellow, 1);
118 check_pixel(ur3.x, ur3.y, 8, magenta, 1);
119 check_pixel(ur4.x, ur4.y, 8, cyan, 1);
120 check_pixel(ur5.x, ur5.y, 8, black, 1);
121 check_pixel(ur6.x, ur6.y, 8, white, 1);
122 check_pixel(ur6.x, ur7.y, 8, white, 1);
124 check_pixel(ll1.x, ll1.y, 8, gray, 1);
125 check_pixel(ll2.x, ll2.y, 8, blue, 1);
126 check_pixel(ll3.x, ll3.y, 8, green, 1);
127 check_pixel(ll4.x, ll4.y, 8, red, 1);
128 check_pixel(ll5.x, ll5.y, 8, white, 1);
129 check_pixel(ll6.x, ll6.y, 8, black, 1);
130 check_pixel(ll6.x, ll7.y, 8, white, 1);
132 check_pixel(lr1.x, lr1.y, 8, dark_gray, 1);
133 check_pixel(lr2.x, lr2.y, 8, dark_blue, 1);
134 check_pixel(lr3.x, lr3.y, 8, dark_green, 1);
135 check_pixel(lr4.x, lr4.y, 8, dark_red, 1);
136 check_pixel(lr5.x, lr5.y, 8, gray, 1);
137 check_pixel(lr6.x, lr6.y, 8, black, 1);
138 check_pixel(lr6.x, lr7.y, 8, white, 1);
141 return 0;