Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / place_and_remove_object_insane_test.c
blob5325702f32608a5c76f5abd8df8e38bc27e99255
1 /*
2 * Copyright (C) 2005, 2006, 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 * Zou Lunkai, zoulunkai@gmail.com
22 * Timeline:
24 * Frame | 1 | 2 | 3 |
25 * --------+----+----+----+
26 * Event |PPP |RRR |PPPP|
28 * P = place (by PlaceObject2)
29 * R = remove (by RemoveObject)
31 * Description:
33 * frame1: place mc_red at depth3, mc_blue at depth30, mc_black at depth40
34 * frame2: remove mc_red, mc_blue, mc_black
35 * frame3: place mc_red at depth3 again with a different ratio; place mc_blue
36 * at depth30 again with the same ratio; place mc_black at depth40 again
37 * but with a different name; place mc_green at depth4.
39 * Observed:
41 * loop back obeys the same rule as jump back.
43 * run as ./place_and_remove_object_insane_test
46 #include <stdlib.h>
47 #include <stdio.h>
48 #include <ming.h>
50 #include "ming_utils.h"
52 #define OUTPUT_VERSION 6
53 #define OUTPUT_FILENAME "place_and_remove_object_insane_test.swf"
57 int
58 main(int argc, char** argv)
60 SWFMovie mo;
61 SWFMovieClip mc_red, mc_green, mc_blue, mc_black, dejagnuclip;
62 SWFShape sh_red, sh_green, sh_blue, sh_black;
64 const char *srcdir=".";
65 if ( argc>1 )
66 srcdir=argv[1];
67 else
69 fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
70 return 1;
73 Ming_init();
74 mo = newSWFMovieWithVersion(OUTPUT_VERSION);
75 SWFMovie_setDimension(mo, 800, 600);
76 SWFMovie_setRate (mo, 12.0);
78 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
79 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
81 mc_red = newSWFMovieClip();
82 sh_red = make_fill_square (0, 300, 60, 60, 255, 0, 0, 255, 0, 0);
83 SWFMovieClip_add(mc_red, (SWFBlock)sh_red);
84 SWFMovieClip_nextFrame(mc_red);
86 mc_green = newSWFMovieClip();
87 sh_green = make_fill_square (200, 300, 60, 60, 255, 0, 0, 0, 255, 0);
88 SWFMovieClip_add(mc_green, (SWFBlock)sh_green);
89 SWFMovieClip_nextFrame(mc_green);
91 mc_blue = newSWFMovieClip();
92 sh_blue = make_fill_square (400, 300, 60, 60, 255, 0, 0, 0, 0, 255);
93 SWFMovieClip_add(mc_blue, (SWFBlock)sh_blue);
94 SWFMovieClip_nextFrame(mc_blue);
96 mc_black = newSWFMovieClip();
97 sh_black = make_fill_square (600, 300, 60, 60, 255, 0, 0, 0, 0, 0);
98 SWFMovieClip_add(mc_black, (SWFBlock)sh_black);
99 SWFMovieClip_nextFrame(mc_black);
101 SWFDisplayItem it_red;
102 SWFDisplayItem it_blue;
103 SWFDisplayItem it_green;
104 SWFDisplayItem it_black;
106 it_red = SWFMovie_add(mo, (SWFBlock)mc_red); //add mc_red to the 1st frame at depth 3
107 SWFDisplayItem_setDepth(it_red, 3);
108 SWFDisplayItem_setName(it_red, "mc_red");
110 it_blue = SWFMovie_add(mo, (SWFBlock)mc_blue); //add mc_blue to the 1st frame at depth 30
111 SWFDisplayItem_setDepth(it_blue, 30);
112 SWFDisplayItem_setName(it_blue, "mc_blue");
114 it_black = SWFMovie_add(mo, (SWFBlock)mc_black); //add mc_black to the 1st frame at depth 40
115 SWFDisplayItem_setDepth(it_black, 40);
116 SWFDisplayItem_setName(it_black, "mc_black");
118 check_equals(mo, "typeof(_root.mc_red)", "'movieclip'");
119 check_equals(mo, "typeof(_root.mc_blue)", "'movieclip'");
121 check_equals(mo, "_root.mc_green", "undefined");
123 add_actions(mo, " _root.mc_red._x += 10; \
124 if(counter == undefined) \
126 check_equals(_root.mc_blue._x, 0); \
127 }else if(counter == 1) \
129 check_equals(_root.mc_blue._x, 60); \
130 check_equals(typeof(_root.mc_black), 'undefined'); \
131 check_equals(typeof(_root.mc_black_name_changed), 'movieclip'); \
132 } ");
133 // This one is normal. mc_red._x should *not* be 20 when restart.
134 // Note that mc_red has been removed at the 2nd frame, so when
135 // restart, it will be reconstructed.
136 check_equals(mo, " _root.mc_red._x", "10");
137 SWFMovie_nextFrame(mo);
138 //------------end of 1st frame---------------------------------
141 SWFMovie_remove(mo, it_red); //remove mc_red at the 2nd frame
142 SWFMovie_remove(mo, it_blue); //remove mc_blue at the 2nd frame
143 SWFMovie_remove(mo, it_black); //remove mc_black at the 2nd frame
144 check_equals(mo, "typeof(_root.mc_red)", "'undefined'");
145 check_equals(mo, "typeof(_root.mc_blue)", "'undefined'");
146 check_equals(mo, "typeof(_root.mc_black)", "'undefined'");
147 check_equals(mo, "typeof(_root.mc_green)", "'undefined'");
148 SWFMovie_nextFrame(mo);
149 //------------end of 2nd frame---------------------------------
152 it_red = SWFMovie_add(mo, (SWFBlock)mc_red); //add mc_red to the 3rd frame at depth 3 again
153 SWFDisplayItem_setDepth(it_red, 3);
154 SWFDisplayItem_setName(it_red, "mc_red");
155 SWFDisplayItem_setRatio(it_red, 2.0);
157 it_blue = SWFMovie_add(mo, (SWFBlock)mc_blue); //add mc_blue to the 3rd frame at depth 30 again
158 SWFDisplayItem_setDepth(it_blue, 30);
159 SWFDisplayItem_setName(it_blue, "mc_blue");
161 it_black = SWFMovie_add(mo, (SWFBlock)mc_black); //add mc_black to the 3rd frame at depth 40 again
162 SWFDisplayItem_setDepth(it_black, 40);
163 SWFDisplayItem_setName(it_black, "mc_black_name_changed");
165 it_green = SWFMovie_add(mo, (SWFBlock)mc_green); //add mc_green to the 3rd frame at depth 4
166 SWFDisplayItem_setDepth(it_green, 4);
167 SWFDisplayItem_setName(it_green, "mc_green");
169 check_equals(mo, "typeof(_root.mc_red)", "'movieclip'");
170 check_equals(mo, "typeof(_root.mc_blue)", "'movieclip'");
172 add_actions(mo, " _root.mc_red._x += 60; _root.mc_blue._x += 60;");
173 add_actions(mo, "if ( ++counter > 1 ) { _root.totals(); stop(); }");
175 SWFMovie_nextFrame(mo);
176 //------------end of 3rd frame---------------------------------
178 //Output movie
179 puts("Saving " OUTPUT_FILENAME );
180 SWFMovie_save(mo, OUTPUT_FILENAME);
182 return 0;