2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 * 2011 Free Software Foundation, Inc.
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.
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
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"
36 using namespace gnash
;
39 void testAll(MovieTester
& tester
);
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);
59 void testAll(MovieTester
& tester
)
61 typedef gnash::geometry::SnappingRanges2d
<int> Ranges
;
62 typedef gnash::geometry::Range2d
<int> Bounds
;
65 MovieClip
* root
= tester
.getRootMovie();
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
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)) );