big merge from master, fix rpm creation, drop fetching swfdec
[gnash.git] / testsuite / misc-ming.all / DefineTextTest-Runner.cpp
blobd12269350b2287ad092ef78d684dc3683646a1cc
1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 * 2011 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 "DefineTextTest.swf"
24 #include "MovieTester.h"
25 #include "MovieClip.h"
26 #include "DisplayObject.h"
27 #include "DisplayList.h"
28 #include "log.h"
29 #include "VM.h"
30 #include "string_table.h"
32 #include "check.h"
33 #include <string>
34 #include <cassert>
36 using namespace gnash;
37 using namespace std;
39 int
40 main(int /*argc*/, char** /*argv*/)
42 string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
43 MovieTester tester(filename);
45 gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
46 dbglogfile.setVerbosity(1);
48 MovieClip* root = tester.getRootMovie();
49 assert(root);
51 check_equals(root->get_frame_count(), 4);
52 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
53 check_equals(root->get_current_frame(), 0);
55 rgba white(255,255,255,255);
56 rgba red(255,0,0,255);
57 rgba green(0,255,0,255);
59 geometry::Point2d cXmm(220,327); // DisplayObject X center
60 geometry::Point2d cXum(220,440); // DisplayObject X underline/middle
62 geometry::Point2d cOmr(135,326); // DisplayObject O middle/right
63 geometry::Point2d cOml(21,330); // DisplayObject O middle/left
64 geometry::Point2d cOmm(77,327); // DisplayObject O center
65 geometry::Point2d cOum(78,440); // DisplayObject O underline/middle
68 tester.advance(); // first frame only contains dejagnu
69 check_equals(root->get_current_frame(), 1);
71 check_pixel(cXmm.x, cXmm.y, 4, red, 2); // X cross
72 check_pixel(cXum.x, cXum.y, 20, white, 2); // X underline (none)
74 check_pixel(cOmm.x, cOmm.y, 8, white, 2); // O hole
75 check_pixel(cOml.x, cOml.y, 4, green, 2); // O left side
76 check_pixel(cOmr.x, cOmr.y, 4, green, 2); // O right side
77 check_pixel(cOum.x, cOum.y, 20, white, 2); // O underline (none)
79 tester.advance();
81 // Move to left part of O
82 tester.movePointerTo(cOml.x, cOml.y);
84 // Click there
85 tester.click();
87 // Move to centre of O
88 tester.movePointerTo(cOmm.x, cOmm.y);
90 // Click there a lot (shouldn't be registered)
91 tester.click();
92 tester.click();
93 tester.click();
94 tester.click();
95 tester.click();
96 tester.click();
97 tester.click();
98 tester.click();
100 // Move to right part of O
101 tester.movePointerTo(cOmr.x, cOmr.y);
103 // Click there.
104 tester.click();
105 tester.movePointerTo(1, 1);
107 // Just for fun. These shouldn't be registered.
108 tester.click();
109 tester.click();
110 tester.click();
111 tester.click();
112 tester.click();
114 for (int i=0; i<3; ++i) tester.advance(); // get to the end
116 VM& vm = tester.vm();
118 as_value eot;
119 bool endOfTestFound = getObject(root)->get_member(getURI(vm, "endoftest"), &eot);
120 check(endOfTestFound);
121 check(eot.is_bool());
122 check(eot.to_bool(8));
124 // TODO: use check_pixel for checking bacground colors