Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / path_format_test.c
blobdb424e1715b39eb4fcaee241994f93bbad761003
1 /*
2 * Copyright (C) 2005, 2006, 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 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.
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 */
20 _root
21 |------mc1
22 | |------mc11
23 |-------3 (mvoieClip with a integral number name)
24 | |-------1(mvoieClip with a integral number name)
25 |-------4.1 (movieClip with a float number name )
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <ming.h>
32 #include "ming_utils.h"
34 #define OUTPUT_VERSION 6
35 #define OUTPUT_FILENAME "path_format_test.swf"
38 int
39 main(int argc, char** argv)
42 SWFMovie mo;
44 SWFMovieClip mc1, mc11;
45 SWFMovieClip int_named_parent, int_named_child;
46 SWFMovieClip float_named_mc;
47 SWFMovieClip dejagnuclip;
49 SWFDisplayItem it1, it11;
50 SWFDisplayItem int_named_parent_it, int_named_child_it;
51 SWFDisplayItem float_named_it;
53 SWFShape sh_red;
56 const char *srcdir=".";
57 if ( argc>1 )
58 srcdir=argv[1];
59 else
61 fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
62 return 1;
65 Ming_init();
66 mo = newSWFMovieWithVersion(OUTPUT_VERSION);
67 SWFMovie_setDimension(mo, 800, 600);
68 SWFMovie_setRate (mo, 12.0);
70 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
71 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
72 add_actions(mo, " x1=0; x2=0; x3=0; x4=0; x5=0; x6=0; x7=0; x8=0; x9=0; x10=0; ");
73 SWFMovie_nextFrame(mo); /* 1st frame of _root */
76 mc11 = newSWFMovieClip();
77 sh_red = make_fill_square (400, 200, 30, 30, 0, 0, 0, 0, 0, 0);
78 SWFMovieClip_add(mc11, (SWFBlock)sh_red);
79 add_clip_actions(mc11, "stop();");
80 SWFMovieClip_nextFrame(mc11);
81 SWFMovieClip_nextFrame(mc11);
82 SWFMovieClip_nextFrame(mc11);
84 add_clip_actions(mc11, "_root.x1 = 'mc11_frame4'; stop(); ");
85 SWFMovieClip_labelFrame(mc11, "frame4");
86 SWFMovieClip_nextFrame(mc11);
87 add_clip_actions(mc11, "_root.x2 = 'mc11_frame5'; stop(); ");
88 SWFMovieClip_labelFrame(mc11, "frame5");
89 SWFMovieClip_nextFrame(mc11);
90 add_clip_actions(mc11, "_root.x3 = 'mc11_frame6'; stop(); ");
91 SWFMovieClip_labelFrame(mc11, "frame6");
92 SWFMovieClip_nextFrame(mc11);
95 mc1 = newSWFMovieClip();
96 sh_red = make_fill_square (300, 200, 60, 60, 255, 0, 0, 255, 0, 0);
97 SWFMovieClip_add(mc1, (SWFBlock)sh_red);
98 add_clip_actions(mc1, "stop();");
99 it11 = SWFMovieClip_add(mc1, (SWFBlock)mc11);
100 SWFDisplayItem_setDepth(it11, 10);
101 SWFDisplayItem_setName(it11, "mc11");
102 SWFMovieClip_nextFrame(mc1);
103 SWFMovieClip_nextFrame(mc1);
104 SWFMovieClip_nextFrame(mc1);
106 add_clip_actions(mc1, "_root.x4 = 'mc1_frame4'; stop(); ");
107 SWFMovieClip_labelFrame(mc1, "frame4");
108 SWFMovieClip_nextFrame(mc1);
109 add_clip_actions(mc1, "_root.x5 = 'mc1_frame5'; stop(); ");
110 SWFMovieClip_labelFrame(mc1, "frame5");
111 SWFMovieClip_nextFrame(mc1);
112 add_clip_actions(mc1, "_root.x6 = 'mc1_frame6'; stop(); ");
113 SWFMovieClip_labelFrame(mc1, "frame6");
114 SWFMovieClip_nextFrame(mc1);
117 /* construct a movieClip named by a integral number 1 */
118 int_named_child = newSWFMovieClip();
119 sh_red = make_fill_square (400, 300, 30, 30, 0, 0, 0, 0, 0, 0);
120 SWFMovieClip_add(int_named_child, (SWFBlock)sh_red);
121 add_clip_actions(int_named_child, " stop(); "
122 " _root.x9 = this._name; " );
123 SWFMovieClip_nextFrame(int_named_child);
125 /* construct a movieClip named by a integral number 3 */
126 int_named_parent = newSWFMovieClip();
127 sh_red = make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
128 SWFMovieClip_add(int_named_parent, (SWFBlock)sh_red);
129 add_clip_actions(int_named_parent, " stop(); "
130 " _root.x7 = this._name; " );
131 SWFMovieClip_nextFrame(int_named_parent);
133 /* add movieClip "1" to movieClip "3" */
134 int_named_child_it = SWFMovieClip_add(int_named_parent, (SWFBlock)int_named_child);
135 SWFDisplayItem_setDepth(int_named_child_it, 3);
136 SWFDisplayItem_setName(int_named_child_it, "1");
139 /* construct a movieClip named by a float number */
140 float_named_mc = newSWFMovieClip();
141 sh_red = make_fill_square (300, 400, 60, 60, 255, 0, 0, 255, 0, 0);
142 SWFMovieClip_add(float_named_mc, (SWFBlock)sh_red);
143 add_clip_actions(float_named_mc, " stop(); "
144 " _root.x8 = this._name; " );
145 SWFMovieClip_nextFrame(float_named_mc);
148 /* place _root.mc1, give it a name "mc1" */
149 it1 = SWFMovie_add(mo, (SWFBlock)mc1);
150 SWFDisplayItem_setDepth(it1, 20);
151 SWFDisplayItem_setName(it1, "mc1");
153 /* place _root.int_named_parent, give it a name "3" */
154 int_named_parent_it = SWFMovie_add(mo, (SWFBlock)int_named_parent);
155 SWFDisplayItem_setDepth(int_named_parent_it, 21);
156 SWFDisplayItem_setName(int_named_parent_it, "3");
158 /* place _root.float_named_mc, give it a name "4.1" */
159 float_named_it = SWFMovie_add(mo, (SWFBlock)float_named_mc);
160 SWFDisplayItem_setDepth(float_named_it, 21);
161 SWFDisplayItem_setName(float_named_it, "4.1");
163 SWFMovie_nextFrame(mo); /* 2nd frame of _root */
165 check_equals(mo, "typeOf(_root.mc1)", "'movieclip'");
166 check_equals(mo, "typeOf(_root.mc1.mc11)", "'movieclip'");
167 check_equals(mo, "_root.x7", "'3'"); // check for movieClip "3"
168 check_equals(mo, "_root.x9", "0"); // check for movieClip "3"."1"
169 if( OUTPUT_VERSION == 5)
171 xcheck_equals(mo, "_root.x8", "'4.1'"); //check for moveiClip "4.1"
173 else
175 check_equals(mo, "_root.x8", "0");
178 if(OUTPUT_VERSION == 5)
180 xcheck_equals(mo, "_root.x8", "'4.1'");
182 else if(OUTPUT_VERSION >= 6)
184 check_equals(mo, "_root.x8", "0");
188 add_actions(mo, "asm{"
189 " push 'x10' "
190 " push '_root.3' "
191 " getvariable "
192 " typeof "
193 " setvariable "
194 " }; ");
195 /* seems we could access _root.3(movieClip) successfully!!! */
196 check_equals(mo, "_root.x10", "'movieclip'" );
198 add_actions(mo, "asm{"
199 " push 'x10' "
200 " push '_root.4.1' "
201 " getvariable "
202 " typeof "
203 " setvariable "
204 " }; ");
205 /* accessing _root.4.1 failed */
206 check_equals(mo, "_root.x10", "'undefined'" );
208 add_actions(mo, "asm{"
209 " push 'x10' "
210 " push '/4.1' "
211 " getvariable "
212 " typeof "
213 " setvariable "
214 " }; ");
215 /* accessing _root.4.1 failed */
216 check_equals(mo, "_root.x10", "'undefined'" );
218 add_actions(mo, "asm{"
219 " push 'x10' "
220 " push '_root.3.1' "
221 " getvariable "
222 " typeof "
223 " setvariable "
224 " }; ");
225 /* Notice that _root.3.1 is not even displayed on screen
226 with all versions. accessing _root.3.1 failed! */
227 check_equals(mo, "_root.x10", "'undefined'" );
230 add_actions(mo, "asm{"
231 " push 'x10' "
232 " push '/3/1' "
233 " getvariable "
234 " typeof "
235 " setvariable "
236 " }; ");
237 /* Notice that _root.3.1 is not even displayed on screen
238 with all versions. accessing _root.3.1 failed! */
239 check_equals(mo, "_root.x10", "'undefined'" );
240 add_actions(mo, CALLFRAME"('/mc1/mc11/:4');");
241 /* the above path format is supported */
242 check_equals(mo, "_root.x1", "'mc11_frame4'" );
244 /* reset _root.x1 to 0*/
245 add_actions(mo, "_root.x1 = 0;");
246 add_actions(mo, CALLFRAME"('_root.mc1.mc11.4');");
247 /* the above path format is supported */
248 check_equals(mo, "_root.x1", "'mc11_frame4'" );
250 /* reset _root.x1 to 0*/
251 add_actions(mo, "_root.x1 = 0;");
252 add_actions(mo, CALLFRAME"('_root.mc1.mc11:4');");
253 /* the above path format is supported */
254 check_equals(mo, "_root.x1", "'mc11_frame4'" );
256 /* reset _root.x1 to 0*/
257 add_actions(mo, "_root.x1 = 0;");
258 add_actions(mo, CALLFRAME"('/mc1/mc11/4');");
259 /* the above path format is not supported */
260 check_equals(mo, "_root.x1", "0" );
262 /* reset _root.x1~10 to 0 */
263 add_actions(mo, CALLFRAME"('/:1');");
265 /* test valid path format for ActionGotoExpression */
266 add_actions(mo, " path = '/mc1/mc11/4'; " // not supported
267 " gotoAndStop(path); "
268 " path = '/mc1/mc11/frame5'; " // not supported
269 " gotoAndStop(path); "
270 " path = '/mc1/mc11/:frame6'; " // supported format
271 " gotoAndStop(path); "
272 " path = '_root.mc1.4';" // supported format
273 " gotoAndStop(path);"
274 " path = '_root.mc1.frame5'; " // supported format
275 " gotoAndStop(path); "
276 " path = '_root.mc1:frame6'; " // supported format
277 " gotoAndStop(path); " );
278 SWFMovie_nextFrame(mo); /* 3rd frame of _root */
281 /* checks */
282 check_equals(mo, "_root.x1", "0");
283 check_equals(mo, "_root.x2", "0");
284 check_equals(mo, "_root.x3", "'mc11_frame6'");
285 check_equals(mo, "_root.x4", "'mc1_frame4'");
286 check_equals(mo, "_root.x5", "'mc1_frame5'");
287 check_equals(mo, "_root.x6", "'mc1_frame6'");
289 add_actions(mo, " checkpoint = 100;"
290 "asm{"
291 " push 'checkpoint' "
292 " push '/_root/x1' " // not supported
293 " getvariable "
294 " setvariable "
295 "};");
296 check_equals(mo, "checkpoint", "undefined");
298 add_actions(mo, " checkpoint = 100;"
299 "asm{"
300 " push 'checkpoint' "
301 " push '_root.x1' "
302 " getvariable "
303 " setvariable "
304 "};");
305 check_equals(mo, "checkpoint", "0");
307 add_actions(mo, " checkpoint = 100;"
308 "asm{"
309 " push 'checkpoint' "
310 " push '_root:x1' "
311 " getvariable "
312 " setvariable "
313 "};");
314 check_equals(mo, "checkpoint", "0");
316 add_actions(mo, " _root.totals(); stop(); ");
317 SWFMovie_nextFrame(mo); /* 4th frame of _root */
320 //Output movie
321 puts("Saving " OUTPUT_FILENAME );
322 SWFMovie_save(mo, OUTPUT_FILENAME);
324 return 0;