Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / loop / loop_test10.c
blobb5c999b3c405168a720e4251f664124c181291a0
1 /*
2 * Copyright (C) 2007, 2009, 2010, 2011 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 2 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.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
19 /*
20 * ==case1==
22 * Timeline:
24 * Frame | 1 | 2 | 3 | 4 | 5 | 6 |
25 * --------+---+---+---+---+---+---+
26 * Event | |P |RP | RP| * | J |
28 * P = place (by PlaceObject2)
29 * R = remove (by RemoveObject2)
30 * J = jump
31 * * = jump target
33 * Description:
35 * frame2: place mc1 at depth 100 with ratio 0
36 * frame3: remove mc1, place mc2 at depth 100 with ratio 0.1
37 * frame4: remove mc2, place mc3 at depth 100 with ratio 0.2
38 * frame5: do nothing
39 * frame6: jump to frame5
41 * Observed behaviour:
43 * (1)mc1 initialized and unloaded twice;
44 * (2)mc2 initialized and unloaded twice;
45 * (3)mc3 initialized only *ONCE*, never unloaded.
47 * Deduction:
49 * we need a temporary displaylist when jumping back, otherwise cann't keep mc3 alive
50 * in the current design attempt.
53 * ==case2==
55 * timeline:
57 * Frame | 1 | 2 |
58 * --------+---+---+
59 * Event | P | R |
61 * Description:
63 * frame1: place an unnamed sprite
64 * frame2: remove the sprite
66 * Observed behaviour:
68 * (1)before loop-back, the sprite has a synthesized name instance4
69 * (2)after loop-back, the sprite has a synthesized name instance5
72 * ==case3==
74 * timeline:
76 * Frame | 1 | 2 |
77 * --------+---+---+
78 * Event | P | |
80 * Description:
82 * frame1: place an unnamed sprite
83 * frame2: do nothing
85 * Observed behaviour:
87 * (1)before loop-back, the sprite has a synthesized name instance7
88 * (2)after loop-back, the sprite still has the name instance7
90 * (3)but when placing another unnamed sprite after the loop back,
91 * the new instance gets a name instance9.
93 * Deduction on (3): instance8 was created and discarded during the loop-back.
97 #include <stdlib.h>
98 #include <stdio.h>
99 #include <ming.h>
101 #include "ming_utils.h"
103 #define OUTPUT_VERSION 7
104 #define OUTPUT_FILENAME "loop_test10.swf"
108 main(int argc, char** argv)
110 SWFMovie mo;
111 SWFDisplayItem it1, it2, it3;
112 SWFDisplayItem it41;
113 SWFDisplayItem it51;
114 SWFMovieClip mc1, mc2, mc3, dejagnuclip;
115 SWFMovieClip mc4, mc41;
116 SWFMovieClip mc5, mc51;
117 SWFShape sh1, sh2, sh3;
119 const char *srcdir=".";
120 if ( argc>1 )
121 srcdir=argv[1];
122 else
124 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
125 //return 1;
128 Ming_init();
129 Ming_useSWFVersion (OUTPUT_VERSION);
131 mo = newSWFMovie();
132 SWFMovie_setDimension(mo, 800, 600);
133 SWFMovie_setRate(mo, 12);
135 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
136 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
137 add_actions(mo, " haslooped1=false; haslooped2=false; haslooped3=false;"
138 " mc1Initialized=0; mc1Unloaded=0;"
139 " mc2Initialized=0; mc2Unloaded=0;"
140 " mc3Initialized=0; mc3Unloaded=0;"
141 " asOrder='0+';");
142 SWFMovie_nextFrame(mo); // frame1
145 sh1 = make_fill_square (100, 100, 60, 60, 255, 0, 0, 255, 0, 0);
146 mc1 = newSWFMovieClip();
147 SWFMovieClip_add(mc1, (SWFBlock)sh1);
148 SWFMovieClip_nextFrame(mc1);
150 sh2 = make_fill_square (200, 200, 60, 60, 0, 0, 0, 0, 0, 0);
151 mc2 = newSWFMovieClip();
152 SWFMovieClip_add(mc2, (SWFBlock)sh2);
153 SWFMovieClip_nextFrame(mc2);
155 sh3 = make_fill_square (300, 300, 60, 60, 0, 0, 0, 0, 0, 0);
156 mc3 = newSWFMovieClip();
157 SWFMovieClip_add(mc3, (SWFBlock)sh3);
158 SWFMovieClip_nextFrame(mc3);
160 it1 = SWFMovie_add(mo, (SWFBlock)mc1);
161 SWFDisplayItem_setName(it1, "mc1");
162 SWFDisplayItem_setDepth(it1, 100);
163 SWFDisplayItem_addAction(it1, newSWFAction(
164 "_root.note(this+' initialized');"
165 "_root.mc1Initialized++;"
166 "_root.asOrder += '1+';"
167 ), SWFACTION_INIT);
168 SWFDisplayItem_addAction(it1, newSWFAction(
169 "_root.note(this+' unloaded');"
170 "_root.mc1Unloaded++;"
171 "_root.asOrder += '3+';"
172 ), SWFACTION_UNLOAD);
173 SWFMovie_nextFrame(mo); // frame2
176 SWFDisplayItem_remove(it1);
177 it2 = SWFMovie_add(mo, (SWFBlock)mc2);
178 SWFDisplayItem_setName(it2, "mc2");
179 SWFDisplayItem_setRatio(it2, 0.1);
180 SWFDisplayItem_setDepth(it2, 100);
181 SWFDisplayItem_addAction(it2, newSWFAction(
182 "_root.note(this+' initialized');"
183 "_root.mc2Initialized++;"
184 "_root.asOrder += '2+';"
185 ), SWFACTION_INIT);
186 SWFDisplayItem_addAction(it2, newSWFAction(
187 "_root.note(this+' unloaded');"
188 "_root.mc2Unloaded++;"
189 "_root.asOrder += '5+';"
190 ), SWFACTION_UNLOAD);
191 SWFMovie_nextFrame(mo); // frame3
194 SWFDisplayItem_remove(it2);
195 it3 = SWFMovie_add(mo, (SWFBlock)mc3);
196 SWFDisplayItem_setName(it3, "mc3");
197 SWFDisplayItem_setRatio(it3, 0.2);
198 SWFDisplayItem_setDepth(it3, 100);
199 SWFDisplayItem_addAction(it3, newSWFAction(
200 "_root.note(this+' initialized');"
201 "_root.mc3Initialized++;"
202 "_root.asOrder += '4+';"
203 ), SWFACTION_INIT);
204 SWFDisplayItem_addAction(it3, newSWFAction(
205 "_root.note(this+' unloaded');"
206 "_root.mc3Unloaded++;"
207 ), SWFACTION_UNLOAD);
208 SWFMovie_nextFrame(mo); // frame4
211 SWFMovie_nextFrame(mo); // frame 5
214 add_actions(mo, "if(! haslooped1) {"
215 " gotoAndPlay(5);"
216 " haslooped1 = true;"
217 "}" );
218 SWFMovie_nextFrame(mo); // frame 6
221 check_equals(mo, "mc1Initialized", "2");
222 check_equals(mo, "mc2Initialized", "2");
223 check_equals(mo, "mc3Initialized", "1");
224 check_equals(mo, "mc1Unloaded", "2");
225 check_equals(mo, "mc2Unloaded", "2");
226 check_equals(mo, "mc3Unloaded", "0");
228 xcheck_equals(mo, "asOrder", "'0+1+2+3+4+5+1+2+3+5+'");
229 SWFMovie_nextFrame(mo); // frame 7
232 // ==case 2==
234 mc4 = newSWFMovieClip();
235 mc41 = newSWFMovieClip();
236 SWFMovieClip_nextFrame(mc41);
238 it41 = SWFMovieClip_add(mc4, (SWFBlock)mc41);
239 add_clip_actions(mc4,
240 "_root.check_equals(this._target, '/instance3');"
241 "inst = this.getInstanceAtDepth(-16383);"
242 "if(! haslooped2) {"
243 " haslooped2 = true;"
244 " _root.check_equals(inst._target, '/instance3/instance4');"
245 "} else {"
246 " _root.check_equals(inst._target, '/instance3/instance5');"
247 " stop();"
250 SWFMovieClip_nextFrame(mc4);
251 SWFDisplayItem_remove(it41);
252 SWFMovieClip_nextFrame(mc4);
254 SWFMovie_add(mo, mc4);
255 SWFMovie_nextFrame(mo); // frame 9
257 SWFMovie_nextFrame(mo); // frame 10
260 // ==case 3==
262 mc5 = newSWFMovieClip();
263 mc51 = newSWFMovieClip();
264 SWFMovieClip_nextFrame(mc51);
266 it51 = SWFMovieClip_add(mc5, (SWFBlock)mc51);
267 add_clip_actions(mc5,
268 "_root.check_equals(this._target, '/instance6');"
269 "inst = this.getInstanceAtDepth(-16383);"
270 "if(! haslooped3) {"
271 " haslooped3 = true;"
272 " _root.check_equals(inst._target, '/instance6/instance7');"
273 "} else {"
274 " _root.check_equals(inst._target, '/instance6/instance7');"
275 " stop();"
278 SWFMovieClip_nextFrame(mc5);
279 SWFMovieClip_nextFrame(mc5);
281 SWFMovie_add(mo, mc5);
282 SWFMovie_nextFrame(mo); // frame 11
284 SWFMovie_nextFrame(mo); // frame 12
286 SWFMovie_nextFrame(mo); // frame 13
288 mc5 = newSWFMovieClip();
289 add_clip_actions(mc5, "_root.check_equals(this._target, '/instance9');");
290 SWFMovieClip_nextFrame(mc5);
292 SWFMovie_add(mo, mc5);
293 SWFMovie_nextFrame(mo); // frame 14
295 add_actions(mo, "totals(16); stop();");
296 SWFMovie_nextFrame(mo); // frame 15
297 //Output movie
298 puts("Saving " OUTPUT_FILENAME );
299 SWFMovie_save(mo, OUTPUT_FILENAME);
301 return 0;