Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / DepthLimitsTest.c
blobb8d71945cf44997bfefa159187825bf2da72cfba
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
18 */
21 * Test MovieClip.attachMovie().
23 * Exports a 'redsquare' symbol and then attach it to main timeline 4 times
24 * at depths 70+[0..3] and with xoffset 70*[0..3]
26 * run as ./attachMovieTest
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <ming.h>
33 #include "ming_utils.h"
35 #define OUTPUT_VERSION 6
36 #define OUTPUT_FILENAME "DepthLimitsTest.swf"
38 void addRedSquareExport(SWFMovie mo);
40 void
41 addRedSquareExport(SWFMovie mo)
43 SWFShape sh;
44 SWFMovieClip mc;
46 sh = make_fill_square (0, 0, 60, 60, 255, 0, 0, 255, 0, 0);
47 mc = newSWFMovieClip();
49 SWFMovieClip_add(mc, (SWFBlock)sh);
50 /* This is here just to turn the clip into an active one */
51 add_clip_actions(mc, "onRollOver = function() {};");
52 add_clip_actions(mc, "onMouseDown = function() { _root.mouseDown++; _root.note(_name+' mouseDown '+_root.mouseDown); };");
53 add_clip_actions(mc, "onMouseUp = function() { _root.mouseUp++; _root.note(_name+' mouseUp '+_root.mouseUp); };");
54 SWFMovieClip_nextFrame(mc);
56 SWFMovie_addExport(mo, (SWFBlock)mc, "redsquare");
58 SWFMovie_writeExports(mo);
61 int
62 main(int argc, char** argv)
64 SWFMovie mo;
65 const char *srcdir=".";
66 SWFMovieClip dejagnuclip;
69 /*********************************************
71 * Initialization
73 *********************************************/
75 if ( argc>1 ) srcdir=argv[1];
76 else
78 fprintf(stderr, "Usage: %s\n", argv[0]);
79 return 1;
82 puts("Setting things up");
84 Ming_init();
85 Ming_useSWFVersion (OUTPUT_VERSION);
86 Ming_setScale(20.0); /* let's talk pixels */
88 mo = newSWFMovie();
89 SWFMovie_setRate(mo, 12);
90 //SWFMovie_setDimension(mo, 6400, 4000);
91 SWFMovie_setDimension(mo, 640, 400);
93 /*********************************************
95 * Body
97 *********************************************/
99 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600);
100 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
102 addRedSquareExport(mo);
103 /* it seems we need a SHOWFRAME for this to be effective */
104 /* (maybe it's related to loop-back handling ?) */
105 SWFMovie_nextFrame(mo);
107 /* A load of tests for depth */
109 add_actions(mo, "attachMovie('redsquare', 'depthtest', -16, initObj);"
110 "d = depthtest.getDepth();");
111 check_equals(mo, "d", "-16");
114 add_actions(mo, "attachMovie('redsquare', 'depthtest', -16384, initObj);"
115 "d = depthtest.getDepth();");
116 check_equals(mo, "d", "-16384");
118 /* Less than -16384 fails */
119 add_actions(mo, "attachMovie('redsquare', 'depthtest2', -20000, initObj);"
120 "d = depthtest2.getDepth();");
121 check_equals(mo, "d", "undefined");
123 /* It really does */
124 add_actions(mo, "attachMovie('redsquare', 'depthtest2', -16385, initObj);"
125 "d = depthtest2.getDepth();");
126 check_equals(mo, "d", "undefined");
128 /* Up to 2130690044 works */
129 add_actions(mo, "attachMovie('redsquare', 'depthtest2', 1147483648, initObj);"
130 "d = depthtest2.getDepth();");
131 check_equals(mo, "d", "1147483648");
133 /* Up to 2130690044 works */
134 add_actions(mo, "attachMovie('redsquare', 'depthtest3', 2130690044, initObj);"
135 "d = depthtest3.getDepth();");
136 check_equals(mo, "d", "2130690044");
138 /* 2130690045 doesn't work */
139 add_actions(mo, "attachMovie('redsquare', 'depthtest4', 2130690045, initObj);"
140 "d = depthtest4.getDepth();");
141 check_equals(mo, "d", "undefined");
143 /* duplicateMovieClip */
144 /* Same limits... */
146 add_actions(mo, "createEmptyMovieClip('original', 10);");
148 add_actions(mo, "duplicateMovieClip('original', 'dup1', -1);"
149 "d = dup1.getDepth();");
150 check_equals(mo, "d", "-1");
152 add_actions(mo, "original.duplicateMovieClip('odup1', -1);"
153 "d = odup1.getDepth();");
154 check_equals(mo, "d", "-1");
156 add_actions(mo, "duplicateMovieClip('original', 'dup2', -16384);"
157 "d = dup2.getDepth();");
158 check_equals(mo, "d", "-16384");
160 add_actions(mo, "original.duplicateMovieClip('odup2', -16384);"
161 "d = odup2.getDepth();");
162 check_equals(mo, "d", "-16384");
164 add_actions(mo, "duplicateMovieClip('original', 'dup3', -16385);"
165 "d = dup3.getDepth();");
166 check_equals(mo, "d", "undefined");
168 add_actions(mo, "original.duplicateMovieClip('odup3', -16385);"
169 "d = odup3.getDepth();");
170 check_equals(mo, "d", "undefined");
172 add_actions(mo, "duplicateMovieClip('original', 'dup4', 2130690044);"
173 "d = dup4.getDepth();");
174 check_equals(mo, "d", "2130690044");
176 add_actions(mo, "original.duplicateMovieClip('odup4', 2130690044);"
177 "d = odup4.getDepth();");
178 check_equals(mo, "d", "2130690044");
180 add_actions(mo, "duplicateMovieClip('original', 'dup5', 2130690045);"
181 "d = dup5.getDepth();");
182 check_equals(mo, "d", "undefined");
184 add_actions(mo, "original.duplicateMovieClip('odup5', 2130690045);"
185 "d = odup5.getDepth();");
186 check_equals(mo, "d", "undefined");
188 add_actions(mo, "totals(); stop();");
190 SWFMovie_nextFrame(mo); /* showFrame */
192 /*****************************************************
194 * Output movie
196 *****************************************************/
198 puts("Saving " OUTPUT_FILENAME );
200 SWFMovie_save(mo, OUTPUT_FILENAME);
202 return 0;