use ObjectURI more consistently
[gnash.git] / testsuite / movies.all / gravity_embedded-TestRunner.cpp
blob8bed48ac97425025bd7874df08ace3bfd4979278
1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 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 "gravity-embedded.swf"
23 #include "MovieTester.h"
24 #include "MovieClip.h"
25 #include "DisplayObject.h"
26 #include "DisplayList.h"
27 #include "log.h"
28 #include "VM.h"
29 #include "TextField.h"
31 #include "check.h"
32 #include <string>
33 #include <cassert>
34 #include <unistd.h> // for usleep
36 using namespace gnash;
37 using namespace std;
39 int
40 main(int /*argc*/, char** /*argv*/)
42 string filename = string(SRCDIR) + string("/") + string(INPUT_FILENAME);
43 MovieTester tester(filename);
45 gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
46 dbglogfile.setVerbosity(1);
48 const MovieClip* root = tester.getRootMovie();
49 assert(root);
51 check_equals(root->get_frame_count(), 1);
53 // wait for loader to get ball in
54 while ( ! tester.findDisplayItemByTarget("_level0.container.ball") ) {
55 usleep(1000);
56 tester.advance(); // have load processed
59 // used to get members
60 as_value tmp;
62 const DisplayObject* loaded = tester.findDisplayItemByDepth(*root, 0); // depends on getNextHighestDepth
63 check(loaded);
64 check_equals(loaded->parent(), root);
66 VM& vm = tester.vm();
68 const ObjectURI& xscale = getURI(vm, "_xscale");
69 const ObjectURI& yscale = getURI(vm, "_yscale");
70 // we need a const_cast as get_member *might* eventually
71 // change the DisplayObject (fetching _x shouldn't change it though)
72 check(getObject(const_cast<DisplayObject*>(loaded))->get_member(xscale, &tmp));
73 check(tmp.strictly_equals(50));
75 check_equals(loaded->getBounds().height(), 2056);
76 check_equals(loaded->getBounds().width(), 2056);
78 const TextField* text =
79 dynamic_cast<const TextField*>(
80 tester.findDisplayItemByDepth(
81 *root, 7 +DisplayObject::staticDepthOffset));
82 check(text);
84 check_equals(string(text->get_text_value()), "50");
85 check(!tester.isMouseOverMouseEntity());
87 // click some on the "smaller" button
88 as_object* obj = getObject(const_cast<DisplayObject*>(loaded));
89 tester.movePointerTo(474, 18);
90 check(tester.isMouseOverMouseEntity());
91 tester.pressMouseButton();
92 check_equals(string(text->get_text_value()), "50");
93 tester.depressMouseButton();
94 check_equals(string(text->get_text_value()), "48");
95 check(obj->get_member(xscale, &tmp));
96 check_equals(round(toNumber(tmp, vm)), 48);
97 check(obj->get_member(yscale, &tmp));
98 check_equals(round(toNumber(tmp, vm)), 48);
99 tester.pressMouseButton();
100 check_equals(string(text->get_text_value()), "48");
101 tester.depressMouseButton();
102 check_equals(string(text->get_text_value()), "46");
103 check(obj->get_member(xscale, &tmp));
104 check_equals(round(toNumber(tmp, vm)), 46);
105 check(obj->get_member(yscale, &tmp));
106 check_equals(round(toNumber(tmp, vm)), 46);
107 tester.pressMouseButton();
108 check_equals(string(text->get_text_value()), "46");
109 tester.depressMouseButton();
110 check_equals(string(text->get_text_value()), "44");
111 check(obj->get_member(xscale, &tmp));
112 check_equals(round(toNumber(tmp, vm)), 44);
113 check(obj->get_member(yscale, &tmp));
114 check_equals(round(toNumber(tmp, vm)), 44);
116 // click some on the "larger" button
117 tester.movePointerTo(580, 18);
118 check(tester.isMouseOverMouseEntity());
119 tester.pressMouseButton();
120 check_equals(string(text->get_text_value()), "44");
121 tester.depressMouseButton();
122 check_equals(string(text->get_text_value()), "46");
123 check(obj->get_member(xscale, &tmp));
124 check_equals(round(toNumber(tmp, vm)), 46);
125 check(obj->get_member(yscale, &tmp));
126 check_equals(round(toNumber(tmp, vm)), 46);
127 tester.pressMouseButton();
128 check_equals(string(text->get_text_value()), "46");
129 tester.depressMouseButton();
130 check_equals(string(text->get_text_value()), "48");
131 check(obj->get_member(xscale, &tmp));
132 check_equals(round(toNumber(tmp, vm)), 48);
133 check(obj->get_member(yscale, &tmp));
134 check_equals(round(toNumber(tmp, vm)), 48);
135 tester.pressMouseButton();
136 check_equals(string(text->get_text_value()), "48");
137 tester.depressMouseButton();
138 check_equals(string(text->get_text_value()), "50");
139 check(obj->get_member(xscale, &tmp));
140 check_equals(round(toNumber(tmp, vm)), 50);
141 check(obj->get_member(yscale, &tmp));
142 check_equals(round(toNumber(tmp, vm)), 50);
143 tester.pressMouseButton();
144 check_equals(string(text->get_text_value()), "50");
145 tester.depressMouseButton();
146 check_equals(string(text->get_text_value()), "52");
147 check(obj->get_member(xscale, &tmp));
148 check_equals(round(toNumber(tmp, vm)), 52);
149 check(obj->get_member(yscale, &tmp));
150 check_equals(round(toNumber(tmp, vm)), 52);