Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash
[gnash.git] / testsuite / misc-ming.all / static_vs_dynamic1.c
blob85eb423a53d40da9416ea446a5895471bf741fa2
1 /*
2 * Copyright (C) 2005, 2006, 2007, 2009, 2010 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 * mc1 and mc2 are two movieClips created by PlaceObject2 tag;
21 * dup1 and dup2 are two movieClips created by AS;
22 * swap mc1 to the dynamic range depths;
23 * swap dup1 to the static range depths;
25 * expected behaviour after loopback:
26 * mc1 keep alive;
27 * mc2 get removed;
28 * dup1 get removed;
29 * dup2 keep alive;
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <ming.h>
36 #include "ming_utils.h"
38 #define OUTPUT_VERSION 6
39 #define OUTPUT_FILENAME "static_vs_dynamic1.swf"
44 int
45 main(int argc, char** argv)
47 SWFMovie mo;
48 SWFMovieClip mc1, mc2, dejagnuclip;
49 SWFDisplayItem it1, it2;
50 SWFShape sh1,sh2;
52 const char *srcdir=".";
53 if ( argc>1 )
54 srcdir=argv[1];
55 else
57 fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
58 return 1;
61 Ming_init();
62 mo = newSWFMovieWithVersion(OUTPUT_VERSION);
63 SWFMovie_setDimension(mo, 800, 600);
64 SWFMovie_setRate (mo, 12.0);
66 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
67 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
68 SWFMovie_nextFrame(mo);
70 add_actions(mo, " if(loopback == undefined) {" // first time play
71 " check_equals(typeof(mc1), 'undefined'); "
72 " check_equals(typeof(mc2), 'undefined'); "
73 " check_equals(typeof(dup1), 'undefined'); "
74 " check_equals(typeof(dup2), 'undefined'); "
75 "} else {" // loopback
76 " check_equals(typeof(mc1), 'movieclip');"
77 " check_equals(typeof(mc2), 'undefined');"
78 " check_equals(typeof(dup1), 'undefined');"
79 " check_equals(typeof(dup2), 'movieclip');"
80 "}" );
81 SWFMovie_nextFrame(mo);
83 mc1 = newSWFMovieClip();
84 mc2 = newSWFMovieClip();
85 sh1 = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
86 sh2 = make_fill_square (100, 300, 60, 60, 255, 0, 0, 0, 0, 0);
87 SWFMovieClip_add(mc1, (SWFBlock)sh1);
88 SWFMovieClip_add(mc2, (SWFBlock)sh2);
89 SWFMovieClip_nextFrame(mc1);
90 SWFMovieClip_nextFrame(mc2);
92 it1 = SWFMovie_add(mo, (SWFBlock)mc1);
93 SWFDisplayItem_setDepth(it1, 2);
94 SWFDisplayItem_setName(it1, "mc1");
96 it2 = SWFMovie_add(mo, (SWFBlock)mc2);
97 SWFDisplayItem_setDepth(it2, 3);
98 SWFDisplayItem_setName(it2, "mc2");
100 add_actions(mo, " if(loopback == undefined) {"
101 " duplicateMovieClip('mc1', 'dup1', 1);"
102 " duplicateMovieClip('mc2', 'dup2', 2);"
103 " check_equals(mc1.getDepth(), -16382);"
104 " check_equals(mc2.getDepth(), -16381);"
105 " check_equals(dup1.getDepth(), 1);"
106 " check_equals(dup2.getDepth(), 2);"
107 " mc1.swapDepths(10);"
108 " check_equals(mc1.getDepth(), 10);"
109 " dup1.swapDepths(-10);"
110 " check_equals(dup1.getDepth(), -10);"
111 "}");
112 SWFMovie_nextFrame(mo);
115 add_actions(mo, "if(loopback == undefined) {"
116 " loopback = 1;"
117 " gotoAndPlay(1);" //loopback
118 "} else {"
119 " _root.totals(); stop();"
120 "}");
121 SWFMovie_nextFrame(mo);
123 //Output movie
124 puts("Saving " OUTPUT_FILENAME );
125 SWFMovie_save(mo, OUTPUT_FILENAME);
127 return 0;