Update with current status
[gnash.git] / testsuite / misc-ming.all / DefineTextTest-Runner.cpp
blob07930957a8fd56138f527c83a74d081f3704b72f
1 /*
2 * Copyright (C) 2005, 2006, 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 "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 TRYMAIN(_runtest);
40 int
41 trymain(int /*argc*/, char** /*argv*/)
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 MovieClip* root = tester.getRootMovie();
50 assert(root);
52 check_equals(root->get_frame_count(), 4);
53 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
54 check_equals(root->get_current_frame(), 0);
56 rgba white(255,255,255,255);
57 rgba red(255,0,0,255);
58 rgba green(0,255,0,255);
60 geometry::Point2d cXmm(220,327); // DisplayObject X center
61 geometry::Point2d cXum(220,440); // DisplayObject X underline/middle
63 geometry::Point2d cOmr(135,326); // DisplayObject O middle/right
64 geometry::Point2d cOml(21,330); // DisplayObject O middle/left
65 geometry::Point2d cOmm(77,327); // DisplayObject O center
66 geometry::Point2d cOum(78,440); // DisplayObject O underline/middle
69 tester.advance(); // first frame only contains dejagnu
70 check_equals(root->get_current_frame(), 1);
72 check_pixel(cXmm.x, cXmm.y, 4, red, 2); // X cross
73 check_pixel(cXum.x, cXum.y, 20, white, 2); // X underline (none)
75 check_pixel(cOmm.x, cOmm.y, 8, white, 2); // O hole
76 check_pixel(cOml.x, cOml.y, 4, green, 2); // O left side
77 check_pixel(cOmr.x, cOmr.y, 4, green, 2); // O right side
78 check_pixel(cOum.x, cOum.y, 20, white, 2); // O underline (none)
80 tester.advance();
82 // Move to left part of O
83 tester.movePointerTo(cOml.x, cOml.y);
85 // Click there
86 tester.click();
88 // Move to centre of O
89 tester.movePointerTo(cOmm.x, cOmm.y);
91 // Click there a lot (shouldn't be registered)
92 tester.click();
93 tester.click();
94 tester.click();
95 tester.click();
96 tester.click();
97 tester.click();
98 tester.click();
99 tester.click();
101 // Move to right part of O
102 tester.movePointerTo(cOmr.x, cOmr.y);
104 // Click there.
105 tester.click();
106 tester.movePointerTo(1, 1);
108 // Just for fun. These shouldn't be registered.
109 tester.click();
110 tester.click();
111 tester.click();
112 tester.click();
113 tester.click();
115 for (int i=0; i<3; ++i) tester.advance(); // get to the end
117 VM& vm = tester.vm();
119 as_value eot;
120 bool endOfTestFound = getObject(root)->get_member(getURI(vm, "endoftest"), &eot);
121 check(endOfTestFound);
122 check(eot.is_bool());
123 check(eot.to_bool(8));
125 // TODO: use check_pixel for checking bacground colors
127 return 0;