2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
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.
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
21 #define INPUT_FILENAME "loadMovieTest.swf"
23 #include "MovieTester.h"
24 #include "MovieClip.h"
25 #include "DisplayObject.h"
26 #include "DisplayList.h"
30 #include "string_table.h"
35 #include "GnashSystemIOHeaders.h"
37 using namespace gnash
;
40 std::auto_ptr
<MovieTester
> tester
;
46 DisplayObject
* coverartch
= const_cast<DisplayObject
*>(tester
->findDisplayItemByName(*root
, "coverart"));
47 MovieClip
* coverart
= coverartch
->to_movie();
49 //log_debug("Coverart is %p, displaylist is:", coverart);
50 //coverart->getDisplayList().dump();
58 MovieClip
* coverart
= getCoverArt();
60 size_t initial_child_count
= coverart
->getDisplayList().size();
62 tester
->movePointerTo(73, 204); // the "Scribble" button
63 check(tester
->isMouseOverMouseEntity());
64 for (int i
=1; i
<=5; ++i
) {
66 check_equals(coverart
->getDisplayList().size(), initial_child_count
+i
);
69 tester
->movePointerTo(59, 225); // the "clear" button
70 check(tester
->isMouseOverMouseEntity());
72 check_equals(coverart
->getDisplayList().size(), initial_child_count
);
76 main(int /*argc*/, char** /*argv*/)
78 gnash::LogFile
& dbglogfile
= gnash::LogFile::getDefaultInstance();
79 dbglogfile
.setVerbosity(1);
81 string filename
= string(TGTDIR
) + string("/") + string(INPUT_FILENAME
);
82 tester
.reset(new MovieTester(filename
));
84 URL
baseURL(filename
);
85 URL
mediaURL(MEDIADIR
"/");
86 URL
lynchURL("lynch.swf", mediaURL
);
87 URL
greenURL("green.jpg", mediaURL
);
88 URL
offspringURL("offspring.swf", mediaURL
);
91 gnash::RcInitFile
& rc
= gnash::RcInitFile::getDefaultInstance();
92 rc
.addLocalSandboxPath(MEDIADIR
);
96 root
= tester
->getRootMovie();
99 check_equals(root
->get_frame_count(), 2);
100 check_equals(root
->get_current_frame(), 0);
103 check_equals(root
->get_current_frame(), 1);
105 // Verify that 'coverart' exists and is empty
106 DisplayObject
* coverartch
= const_cast<DisplayObject
*>(tester
->findDisplayItemByName(*root
, "coverart"));
107 MovieClip
* coverart
= coverartch
->to_movie();
109 url
= coverart
->get_root()->url();
110 check_equals(coverart
->get_root()->url(), baseURL
.str());
112 // Check scribbling on the empty canvas
115 // Click on the first (lynch)
116 tester
->movePointerTo(80, 80);
117 check(tester
->isMouseOverMouseEntity());
118 tester
->pressMouseButton();
120 // Wait for the movie to load
121 // TODO: drop this test and use a self-containment instead
123 usleep(500); // give it some time...
124 tester
->advance(); // loads (should) happen on next advance
125 coverartch
= const_cast<DisplayObject
*>(tester
->findDisplayItemByName(*root
, "coverart"));
126 } while (coverartch
->to_movie() == coverart
);
128 coverart
= coverartch
->to_movie();
129 check_equals(coverart
->get_root()->url(), lynchURL
.str());
131 tester
->depressMouseButton();
133 // Check scribbling on the lynch
136 // Run 'coverart' tests..
137 tester
->movePointerTo(640,180);
138 tester
->click(); tester
->advance();
140 // Click on the second (green)
141 tester
->movePointerTo(280, 80);
142 check(tester
->isMouseOverMouseEntity());
145 // Wait for the movie to load
146 // TODO: drop this test and use a self-containment instead
148 usleep(500); // give it some time...
149 tester
->advance(); // loads (should) happen on next advance
150 coverartch
= const_cast<DisplayObject
*>(tester
->findDisplayItemByName(*root
, "coverart"));
151 } while (coverartch
->to_movie() == coverart
);
153 coverart
= coverartch
->to_movie();
154 check_equals(coverart
->get_root()->url(), greenURL
.str());
155 // TODO: find a way to test if the jpeg is really displayed
156 // (like turn it into a mouse-event-handling char and use isMouseOverActiveEntity ?)
158 // Check scribbling on the jpeg
161 // Run 'coverart' tests..
162 tester
->movePointerTo(640,180);
163 tester
->click(); tester
->advance();
165 // Click on the third (offspring)
166 tester
->movePointerTo(480, 80);
167 check(tester
->isMouseOverMouseEntity());
170 // Wait for the movie to load
171 // TODO: drop this test and use a self-containment instead
173 usleep(500); // give it some time...
174 tester
->advance(); // loads (should) happen on next advance
175 coverartch
= const_cast<DisplayObject
*>(tester
->findDisplayItemByName(*root
, "coverart"));
176 } while (coverartch
->to_movie() == coverart
);
178 coverart
= coverartch
->to_movie();
179 check_equals(coverart
->get_root()->url(), offspringURL
.str());
181 // Check scribbling on the offspring
184 // Run 'coverart' tests..
185 tester
->movePointerTo(640,180);
186 tester
->click(); tester
->advance();
189 tester
->pressKey(key::SHIFT
);
190 tester
->click(); tester
->advance();
191 tester
->releaseKey(key::SHIFT
);
193 // Consistency checking
194 VM
& vm
= getVM(*getObject(root
));
196 // It's an swf6, so lowercase 'END_OF_TEST'
197 bool endOfTestFound
= getObject(root
)->get_member(getURI(vm
, "end_of_test"), &eot
);
198 check(endOfTestFound
);
199 if ( endOfTestFound
)
201 check_equals(eot
.to_bool(8), true);