Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / root_stop_test.c
blobb15f04634345a50db80a9af6a7830130e97bb953
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 stopping and playing the _root
24 * The _root movie has two frames.
25 * In frame1, there's a sprite which contains 3 frames.
26 * In each of the sprite's 3 frames, there is a red square.
27 * In frame2, there is black square.
29 * The sprite will check the counter defined in _root, and then
30 * conditionally stops and plays the _root.
32 * Normally, you can see both the red and black squares.
34 * run as ./root_stop_test
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <ming.h>
41 #include "ming_utils.h"
43 #define OUTPUT_VERSION 6
44 #define OUTPUT_FILENAME "root_stop_test.swf"
47 //actions in _root movie, defines a counter
48 SWFAction action_in_root(void);
49 SWFAction action_in_root()
51 SWFAction ac;
52 ac = compileSWFActionCode(" \
53 counter = 0; \
54 ");
55 return ac;
58 //actions in sprite, conditionally stops and plays the _root
59 SWFAction action_in_sprite(void);
60 SWFAction action_in_sprite()
62 SWFAction ac;
63 ac = compileSWFActionCode(" \
64 counter++; \
65 if(counter < 2) \
66 _root.stop(); \
67 else \
68 _root.play(); \
69 ");
70 return ac;
73 int
74 main(int argc, char** argv)
76 SWFMovie mo;
77 SWFMovieClip mc;
78 // SWFMovieClip dejagnuclip;
79 SWFShape sh1,sh2;
80 SWFAction ac1, ac2;
81 int i;
83 const char *srcdir=".";
84 if ( argc>1 )
85 srcdir=argv[1];
86 else
88 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
89 //return 1;
92 Ming_init();
93 mo = newSWFMovie();
94 SWFMovie_setDimension(mo, 800, 600);
96 //dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
97 //SWFMovie_add(mo, (SWFBlock)dejagnuclip);
98 //SWFMovie_nextFrame(mo);
100 ac2 = action_in_sprite();
101 sh2 = make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
102 mc = newSWFMovieClip();
104 for(i=0; i<3; i++)
106 SWFMovieClip_add(mc, (SWFBlock)sh2);
107 SWFMovieClip_add(mc, (SWFBlock)ac2);
108 SWFMovieClip_nextFrame(mc);
111 SWFDisplayItem it;
112 ac1 = action_in_root();
113 SWFMovie_add(mo, (SWFBlock)ac1);
114 it = SWFMovie_add(mo, (SWFBlock)mc); //add the movieClip to the _root
115 SWFDisplayItem_setName(it, "mc_in_root"); //name the movieclip
116 SWFMovie_nextFrame(mo);
119 sh1 = make_fill_square(270, 270, 120, 120, 255, 0, 0, 0, 0, 0);
120 SWFMovie_add(mo, (SWFBlock)sh1); //add the black square to the _root's 2nd frame
121 SWFMovie_nextFrame(mo);
123 //Output movie
124 puts("Saving " OUTPUT_FILENAME );
125 SWFMovie_save(mo, OUTPUT_FILENAME);
127 return 0;