Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / duplicate_movie_clip_test2.c
blob677bba9c27e9197654d5376e1f5d8a998e6e0301
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 */
21 * movieClips hiberarchy:
22 * _root (5 frames)
23 * |----dejagnuclip
24 * |----mc1
25 * | |----mc11
26 * |----mc2
28 * expected behaviour:
29 * (1)target path is supported in duplicateMovieClip, valid path formats
30 * are: a.b.c; a/b/c; a/b/c/; a/b/:c; a/b/:c/; /:a/:b/:c(odd);
31 * (2)the source movie clip should be within the same timeline as the new movie clip.
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <ming.h>
38 #include "ming_utils.h"
40 #define OUTPUT_VERSION 6
41 #define OUTPUT_FILENAME "duplicate_movie_clip_test2.swf"
44 int
45 main(int argc, char** argv)
47 SWFMovie mo;
48 SWFMovieClip mc1, mc11, mc2, dejagnuclip;
49 SWFDisplayItem it1, it11, it2;
51 const char *srcdir=".";
52 if ( argc>1 )
53 srcdir=argv[1];
54 else
56 fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
57 return 1;
60 Ming_init();
61 mo = newSWFMovieWithVersion(OUTPUT_VERSION);
62 SWFMovie_setDimension(mo, 800, 600);
63 SWFMovie_setRate (mo, 12.0);
65 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
66 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
67 SWFMovie_nextFrame(mo); // 1st frame
69 /* add mc1, mc2 to the main movie */
71 mc1 = newSWFMovieClip();
72 mc11 = newSWFMovieClip();
73 SWFMovieClip_nextFrame(mc11);
74 it11 = SWFMovieClip_add(mc1, (SWFBlock)mc11);
75 SWFDisplayItem_setDepth(it11, 10);
76 SWFDisplayItem_setName(it11, "mc11");
77 SWFMovieClip_nextFrame(mc1);
79 add_clip_actions(mc1,
80 "duplicateMovieClip('mc11', 'dup_ch1', 1);"
81 "_root.check_equals(typeof(dup_ch1), 'movieclip');"
83 "duplicateMovieClip('/_root/mc1/mc11', 'dup_ch2', 2);"
84 "_root.check_equals(typeof(dup_ch2), 'movieclip');"
86 "duplicateMovieClip('/:_root/:mc1/:mc11', 'dup_ch3', 3);"
87 "_root.check_equals(typeof(dup_ch3), 'movieclip');"
89 "duplicateMovieClip('mc2', 'dup_ch4', 4);"
90 // can not duplicate a movie clip in a different time
91 "_root.check_equals(typeof(dup_ch4), 'undefined');"
93 "duplicateMovieClip('/:mc2', 'dup_ch5', 5);"
94 // can not duplicate a movie clip in a different time
95 "_root.check_equals(typeof(dup_ch5), 'undefined');"
97 // Don't do this, duplicate a self-clip will crash the proprietary player"
98 // "duplicateMovieClip('/:mc1', 'dup_ch6', 6);"
99 "stop();"
101 SWFMovieClip_nextFrame(mc1);
103 mc2 = newSWFMovieClip();
104 SWFMovieClip_nextFrame(mc2);
106 it1 = SWFMovie_add(mo, (SWFBlock)mc1);
107 it2 = SWFMovie_add(mo, (SWFBlock)mc2);
108 SWFDisplayItem_setDepth(it1, 10);
109 SWFDisplayItem_setName(it1, "mc1");
110 SWFDisplayItem_setDepth(it2, 20);
111 SWFDisplayItem_setName(it2, "mc2");
112 SWFMovie_nextFrame(mo); // 2nd frame
115 add_actions(mo, "duplicateMovieClip('mc1', 'dup1', 1);");
116 check_equals(mo, "typeof(dup1)", "'movieclip'");
117 add_actions(mo, "removeMovieClip(dup1);");
118 check_equals(mo, "typeof(dup1)", "'undefined'");
120 add_actions(mo, "duplicateMovieClip('/:mc1', 'dup2', 2);");
121 check_equals(mo, "typeof(dup2)", "'movieclip'");
122 add_actions(mo, "removeMovieClip(dup2);");
123 check_equals(mo, "typeof(dup2)", "'undefined'");
125 add_actions(mo, "duplicateMovieClip('/:mc1/', 'dup3', 3);");
126 check_equals(mo, "typeof(dup3)", "'movieclip'");
127 add_actions(mo, "removeMovieClip(dup3);");
128 check_equals(mo, "typeof(dup3)", "'undefined'");
130 add_actions(mo, "duplicateMovieClip('/_root/mc1/', 'dup4', 4);");
131 check_equals(mo, "typeof(dup4)", "'movieclip'");
132 add_actions(mo, "removeMovieClip(dup4);");
133 check_equals(mo, "typeof(dup4)", "'undefined'");
135 add_actions(mo, "duplicateMovieClip('_root.mc1', 'dup5', 5);");
136 check_equals(mo, "typeof(dup5)", "'movieclip'");
137 add_actions(mo, "removeMovieClip(dup5);");
138 check_equals(mo, "typeof(dup5)", "'undefined'");
140 add_actions(mo, "duplicateMovieClip('_root.mc1.mc11', 'dup6', 6);");
141 // can not duplicate a movieclip in a different timeline
142 check_equals(mo, "typeof(dup6)", "'undefined'");
144 add_actions(mo, "duplicateMovieClip('/_root/mc1/:mc11', 'dup7', 7);");
145 // can not duplicate a movieclip in a different timeline
146 check_equals(mo, "typeof(dup7)", "'undefined'");
148 add_actions(mo, "duplicateMovieClip('/_root/mc1/mc11', 'dup8', 8);");
149 // can not duplicate a movieclip in a different timeline
150 check_equals(mo, "typeof(dup8)", "'undefined'");
151 SWFMovie_nextFrame(mo); // 3rd frame
153 add_actions(mo, " _root.totals(); stop(); ");
154 SWFMovie_nextFrame(mo); // 4th frame
156 //Output movie
157 puts("Saving " OUTPUT_FILENAME );
158 SWFMovie_save(mo, OUTPUT_FILENAME);
160 return 0;