Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / static_vs_dynamic2.c
blob30562fcc528229adfdcbe4d14d41cab05faffdce
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 * create(by tag) "mc1" in static depth;
21 * create(by AS) "dup" in dynamic depth;
22 * swap them;
23 * try to move and remove the DisplayObject in static depth;
25 * TODO: add test for REPLACE.
26 * Question: how to REPLACE a DisplayObject?
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <ming.h>
34 #include "ming_utils.h"
36 #define OUTPUT_VERSION 6
37 #define OUTPUT_FILENAME "static_vs_dynamic2.swf"
40 int
41 main(int argc, char** argv)
43 SWFMovie mo;
44 SWFMovieClip mc1, mc2, dejagnuclip;
45 SWFDisplayItem it;
46 SWFShape sh;
48 const char *srcdir=".";
49 if ( argc>1 )
50 srcdir=argv[1];
51 else
53 fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
54 return 1;
57 Ming_init();
58 mo = newSWFMovieWithVersion(OUTPUT_VERSION);
59 SWFMovie_setDimension(mo, 800, 600);
60 SWFMovie_setRate (mo, 12.0);
62 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
63 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
64 SWFMovie_nextFrame(mo);
66 mc1 = newSWFMovieClip();
67 sh = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
68 SWFMovieClip_add(mc1, (SWFBlock)sh);
69 SWFMovieClip_nextFrame(mc1);
71 it = SWFMovie_add(mo, (SWFBlock)mc1);
72 SWFDisplayItem_setDepth(it, 2);
73 SWFDisplayItem_setName(it, "mc1");
75 add_actions(mo, "duplicateMovieClip('mc1', 'dup', 1);"
76 "check_equals(mc1.getDepth(), -16382);"
77 "check_equals(dup.getDepth(), 1);"
78 "mc1.swapDepths(dup);"
79 "check_equals(mc1.getDepth(), 1);"
80 "check_equals(dup.getDepth(), -16382);"
81 "check_equals(mc1._x, 0);"
82 "check_equals(dup._x, 0);");
83 SWFMovie_nextFrame(mo);
85 /* PlaceObject2 can not move an as-created movieClip */
86 SWFDisplayItem_move(it, 100, 100);
87 check_equals(mo, "mc1._x", "0");
88 check_equals(mo, "dup._x", "0");
89 SWFMovie_nextFrame(mo);
91 /* PlaceObject2 can not move an as-created movieClip */
92 SWFDisplayItem_moveTo(it, 300, 300);
93 check_equals(mo, "mc1._x", "0");
94 check_equals(mo, "dup._x", "0");
95 SWFMovie_nextFrame(mo);
97 /* RemoveObject2 */
98 SWFDisplayItem_remove(it);
99 /* "mc1" keeps alive as it has been swapped to a dynamic depth */
100 check_equals(mo, "typeof(mc1)", "'movieclip'");
101 /* "dup" got removed by the RemoveObject2 tag */
102 check_equals(mo, "typeof(dup)", "'undefined'");
103 SWFMovie_nextFrame(mo);
107 * some more tests about removing a movieClip
109 mc2 = newSWFMovieClip();
110 sh = make_fill_square (300, 300, 30, 30, 255, 0, 0, 255, 0, 0);
111 SWFMovieClip_add(mc2, (SWFBlock)sh);
112 SWFMovieClip_nextFrame(mc2);
114 it = SWFMovie_add(mo, (SWFBlock)mc2);
115 SWFDisplayItem_setDepth(it, 3);
116 SWFDisplayItem_setName(it, "mc2");
117 SWFMovie_nextFrame(mo);
119 check_equals(mo, "typeof(mc2)", "'movieclip'");
120 add_actions(mo, "removeMovieClip(mc2);");
121 /* can not remove a tag-created movieclip in static depth */
122 check_equals(mo, "typeof(mc2)", "'movieclip'");
123 add_actions(mo, "mc2.swapDepths(3);");
124 add_actions(mo, "removeMovieClip(mc2);");
125 /* tag-created movieclip can be removed in dynamic depth */
126 check_equals(mo, "typeof(mc2)", "'undefined'");
127 SWFMovie_nextFrame(mo);
129 add_actions(mo, " _root.totals(); stop();" );
130 SWFMovie_nextFrame(mo);
132 //Output movie
133 puts("Saving " OUTPUT_FILENAME );
134 SWFMovie_save(mo, OUTPUT_FILENAME);
136 return 0;