Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / loop / loop_test.c
blob8abd0e2308a328843af309c9034426a7d43a8e32
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 * Test for movie loop.
24 * Timeline:
26 * Frame | 1 | 2 | 3 |
27 * --------+---+---+---+
28 * Event |PP | | M |
30 * P = place (by PlaceObject2)
31 * M = move to another depth (by swapDepth)
33 * Description:
35 * frame1: two static DisplayObjects are placed
36 * frame3: the two DisplayObjects are depth-swapped
38 * Expected behaviour:
40 * Normally, you can see both the red and black squares overlap each
41 * other with equal time.
42 * A single instance of the two DisplayObjects is created.
44 * run as ./loop_test
48 #include <stdlib.h>
49 #include <stdio.h>
50 #include <ming.h>
52 #include "ming_utils.h"
54 #define OUTPUT_VERSION 6
55 #define OUTPUT_FILENAME "loop_test.swf"
57 //actions in _root movie, the last frame
58 SWFAction action_in_root(void);
59 SWFAction action_in_root()
61 SWFAction ac;
62 ac = compileSWFActionCode(
63 "var mc1_depth = movieClip1.getDepth();"
64 "var mc2_depth = movieClip2.getDepth();"
65 "movieClip1.swapDepths(movieClip2);"
66 "_root.check_equals(movieClip1.getDepth(), mc2_depth);"
67 "_root.check_equals(movieClip2.getDepth(), mc1_depth);"
68 "if ( ++runs > 5 ) {"
69 " _root.check_equals(mc1Constructed, 1);"
70 " _root.check_equals(mc2Constructed, 1);"
71 " _root.check_equals(mc1Unloaded, undefined);"
72 " _root.check_equals(mc2Unloaded, undefined);"
73 " _root.check_equals(mc1Executed, 1);"
74 " _root.check_equals(mc2Executed, 1);"
75 " totals();"
76 " stop();"
77 "}"
79 return ac;
83 int
84 main(int argc, char** argv)
86 SWFMovie mo;
87 SWFMovieClip mc1, mc2, dejagnuclip;
88 SWFShape sh1,sh2;
89 SWFAction ac;
91 const char *srcdir=".";
92 if (argc > 1) srcdir=argv[1];
94 Ming_init();
95 Ming_useSWFVersion (OUTPUT_VERSION);
97 mo = newSWFMovie();
98 SWFMovie_setDimension(mo, 800, 600);
99 SWFMovie_setRate(mo, 6);
101 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
102 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
105 sh1 = make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
106 mc1 = newSWFMovieClip();
107 SWFMovieClip_add(mc1, (SWFBlock)sh1);
108 SWFMovieClip_add(mc1, (SWFBlock)newSWFAction("_root.mc1Executed++;"));
109 SWFMovieClip_nextFrame(mc1);
111 sh2 = make_fill_square (330, 270, 120, 120, 0, 0, 0, 0, 0, 0);
112 mc2 = newSWFMovieClip();
113 SWFMovieClip_add(mc2, (SWFBlock)sh2);
114 SWFMovieClip_add(mc2, (SWFBlock)newSWFAction("_root.mc2Executed++;"));
115 SWFMovieClip_nextFrame(mc2);
117 SWFDisplayItem it1, it2;
118 it1 = SWFMovie_add(mo, (SWFBlock)mc1); //add movieClip1 to the _root
119 SWFDisplayItem_setDepth(it1, 64000);
120 SWFDisplayItem_setName(it1, "movieClip1"); //name movieClip1
121 SWFDisplayItem_addAction(it1, newSWFAction("_root.mc1Constructed++;"),
122 SWFACTION_CONSTRUCT);
123 SWFDisplayItem_addAction(it1, newSWFAction("_root.mc1Unloaded++;"),
124 SWFACTION_UNLOAD);
126 it2 = SWFMovie_add(mo, (SWFBlock)mc2); //add movieClip2 to the _root
127 SWFDisplayItem_setName(it2, "movieClip2"); //name movieClip2
128 SWFDisplayItem_addAction(it2, newSWFAction("_root.mc2Constructed++;"),
129 SWFACTION_CONSTRUCT);
130 SWFDisplayItem_addAction(it2, newSWFAction("_root.mc2Unloaded++;"),
131 SWFACTION_UNLOAD);
133 SWFMovie_nextFrame(mo);
134 SWFMovie_nextFrame(mo);
136 ac = action_in_root();
137 SWFMovie_add(mo, (SWFBlock)ac);
138 SWFMovie_nextFrame(mo);
140 //Output movie
141 puts("Saving " OUTPUT_FILENAME );
142 SWFMovie_save(mo, OUTPUT_FILENAME);
144 return 0;