Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / loop / simple_loop_testrunner.cpp
blob0b4313151926ca79a7db18612ef1d34911fe2d04
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 // TODO: fix invalidated bounds, which are clearly bogus !
24 #define INPUT_FILENAME "simple_loop_test.swf"
26 #include "MovieTester.h"
27 #include "MovieClip.h"
28 #include "DisplayObject.h"
29 #include "DisplayList.h"
30 #include "log.h"
32 #include "check.h"
33 #include <string>
34 #include <cassert>
36 using namespace gnash;
37 using namespace std;
39 void testAll(MovieTester& tester);
41 TRYMAIN(_runtest);
42 int
43 trymain(int /*argc*/, char** /*argv*/)
45 string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
46 MovieTester tester(filename);
48 gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
49 dbglogfile.setVerbosity(1);
51 testAll(tester);
52 tester.restart();
53 testAll(tester);
55 return 0;
59 void testAll(MovieTester& tester)
61 typedef gnash::geometry::SnappingRanges2d<int> Ranges;
62 typedef gnash::geometry::Range2d<int> Bounds;
64 Ranges invalidated;
65 MovieClip* root = tester.getRootMovie();
66 assert(root);
68 // FRAME 1/4 (start)
70 check_equals(root->get_frame_count(), 4);
71 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
72 check_equals(root->get_current_frame(), 0);
73 check_equals(root->getDisplayList().size(), 0); // no chars
74 invalidated = tester.getInvalidatedRanges();
75 // I think it makes sense for the first frame to have world
76 // inv bounds.
77 check( invalidated.isWorld() );
79 tester.advance(); // FRAME 2/4
81 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
82 check_equals(root->get_current_frame(), 1);
83 check_equals(root->getDisplayList().size(), 1);
84 check( tester.findDisplayItemByDepth(*root, 2+DisplayObject::staticDepthOffset) );
85 invalidated = tester.getInvalidatedRanges();
86 check( invalidated.contains(Bounds(0, 0, 60, 60)) );
88 tester.advance(); // FRAME 3/4
90 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
91 check_equals(root->get_current_frame(), 2);
92 check_equals(root->getDisplayList().size(), 2);
93 check( tester.findDisplayItemByDepth(*root, 2+DisplayObject::staticDepthOffset) );
94 check( tester.findDisplayItemByDepth(*root, 3+DisplayObject::staticDepthOffset) );
95 invalidated = tester.getInvalidatedRanges();
96 check( invalidated.contains(Bounds(60, 0, 120, 60)) );
98 tester.advance(); // FRAME 4/4
100 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
101 check_equals(root->get_current_frame(), 3);
102 check_equals(root->getDisplayList().size(), 3);
103 check( tester.findDisplayItemByDepth(*root, 2+DisplayObject::staticDepthOffset) );
104 check( tester.findDisplayItemByDepth(*root, 3+DisplayObject::staticDepthOffset) );
105 check( tester.findDisplayItemByDepth(*root, 4+DisplayObject::staticDepthOffset) );
106 invalidated = tester.getInvalidatedRanges();
107 check( invalidated.contains(Bounds(120, 0, 180, 60)) );
109 tester.advance(); // FRAME 1/4 (loop back)
111 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
112 check_equals(root->get_current_frame(), 0);
113 check_equals(root->getDisplayList().size(), 0);
114 invalidated = tester.getInvalidatedRanges();
115 check( invalidated.contains(Bounds(0, 0, 180, 60)) );
117 tester.advance(); // FRAME 2/4
119 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
120 check_equals(root->get_current_frame(), 1);
121 check_equals(root->getDisplayList().size(), 1);
122 check( tester.findDisplayItemByDepth(*root, 2+DisplayObject::staticDepthOffset) );
123 invalidated = tester.getInvalidatedRanges();
124 check( invalidated.contains(Bounds(0, 0, 60, 60)) );
126 tester.advance(); // FRAME 3/4
128 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
129 check_equals(root->get_current_frame(), 2);
130 check_equals(root->getDisplayList().size(), 2);
131 check( tester.findDisplayItemByDepth(*root, 2+DisplayObject::staticDepthOffset) );
132 check( tester.findDisplayItemByDepth(*root, 3+DisplayObject::staticDepthOffset) );
133 invalidated = tester.getInvalidatedRanges();
134 check( invalidated.contains(Bounds(60, 0, 120, 60)) );
136 tester.advance(); // FRAME 4/4
138 check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
139 check_equals(root->get_current_frame(), 3);
140 check_equals(root->getDisplayList().size(), 3);
141 check( tester.findDisplayItemByDepth(*root, 2+DisplayObject::staticDepthOffset) );
142 check( tester.findDisplayItemByDepth(*root, 3+DisplayObject::staticDepthOffset) );
143 check( tester.findDisplayItemByDepth(*root, 4+DisplayObject::staticDepthOffset) );
144 invalidated = tester.getInvalidatedRanges();
145 check( invalidated.contains(Bounds(120, 0, 180, 60)) );