big merge from master, fix rpm creation, drop fetching swfdec
[gnash.git] / testsuite / misc-ming.all / displaylist_depths / displaylist_depths_test8.c
blob1b750c0ed2d42036f3e42e2a364626914ece34d0
1 /*
2 * Copyright (C) 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 * Sandro Santilli, strk@keybit.net
22 * Test "Jumping backward to the start of a DisplayObject's lifetime after dynamic transformation"
24 * run as ./displaylist_depths_test8
26 * Timeline:
28 * Frame | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
29 * --------+---+---+---+---+---+---+---+
30 * Event | |Pt*| | T | | | J |
32 * P = place (by PlaceObject2)
33 * T = transform matrix (by PlaceObject2)
34 * t = transform matrix (by ActionScript)
35 * M = move to another (or same) depth (by swapDepth)
36 * J = jump
37 * * = jump target
39 * Description:
41 * frame2: DisplayObject placed at depth -16381 at position (10,200);
42 * increment _y += 2 using ActionScript.
43 * frame4: try to transform the DisplayObject to the right (50,200)
44 * frame7: jump back to frame 2
46 * Expected behaviour:
48 * * In frame 2 the instance is positioned at 10,202
49 * ActionScript matrix transform in frame2 prevent subsequent static transformations to apply:
50 * * In frames 4,5,6 and 7 the instance is still positioned at 10,202
51 * (static transformations are disabled as the instance has been transformed by script in frame 2)
52 * * After the jump we have the same instances at depth -16381, still positioned at 10,202
53 * * A single instance has been constructed in total.
54 * * Actions in jump-target frame are executed after actions following the gotoAndPlay() call.
58 #include "ming_utils.h"
60 #include <stdlib.h>
61 #include <stdio.h>
62 #include <ming.h>
64 #define OUTPUT_VERSION 6
65 #define OUTPUT_FILENAME "displaylist_depths_test8.swf"
67 SWFDisplayItem add_static_mc(SWFMovie mo, const char* name, int depth, int x, int y, int width, int height);
69 SWFDisplayItem
70 add_static_mc(SWFMovie mo, const char* name, int depth, int x, int y, int width, int height)
72 SWFShape sh;
73 SWFMovieClip mc;
74 SWFDisplayItem it;
76 sh = make_fill_square (-(width/2), -(height/2), width, height, 255, 0, 0, 255, 0, 0);
77 mc = newSWFMovieClip();
78 SWFMovieClip_add(mc, (SWFBlock)sh);
80 SWFMovieClip_nextFrame(mc);
82 it = SWFMovie_add(mo, (SWFBlock)mc);
83 SWFDisplayItem_setDepth(it, depth);
84 SWFDisplayItem_moveTo(it, x, y);
85 SWFDisplayItem_setName(it, name);
87 return it;
91 int
92 main(int argc, char** argv)
94 SWFMovie mo;
95 SWFMovieClip dejagnuclip;
96 SWFDisplayItem it1;
99 const char *srcdir=".";
100 if ( argc>1 )
101 srcdir=argv[1];
102 else
104 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
105 //return 1;
108 Ming_init();
109 mo = newSWFMovieWithVersion(OUTPUT_VERSION);
110 SWFMovie_setDimension(mo, 800, 600);
111 SWFMovie_setRate (mo, 2);
113 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
114 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
115 SWFMovie_nextFrame(mo);
117 // Frame 2: Add a static movieclip at depth 3 with origin at 10,200, then change it's _y to 202 with AS code.
118 it1 = add_static_mc(mo, "static3", 3, 10, 200, 20, 20);
119 add_actions(mo,
120 "check_equals(static3.getDepth(), -16381);"
121 "static3.myThing = 'guess';"
122 // dynamically transform it
123 "static3._y += 2;"
125 SWFMovie_nextFrame(mo);
127 // Frame 3: nothing new, just checks, and end of test on second run
128 SWFMovie_nextFrame(mo);
129 add_actions(mo,
130 "if ( typeof(_root.runs) == 'undefined' ) {"
131 " check_equals(static3._y, 202);"
132 " _root.runs=1;"
133 "} else {"
134 " check_equals(static3._y, 204);"
135 " totals();"
136 " stop();"
140 // Frame 4: move DisplayObject at depth 3 to position 50,200
141 SWFDisplayItem_moveTo(it1, 50, 200);
142 add_actions(mo,
143 // immune to MOVE after _y set by AS
144 "check_equals(static3._x, 10);"
145 "check_equals(static3.getDepth(), -16381);"
147 SWFMovie_nextFrame(mo);
149 // Frame 5: nothing new
150 SWFMovie_nextFrame(mo);
152 // Frame 6: nothing new
153 SWFMovie_nextFrame(mo);
155 // Frame 7: go to frame 2 and playe (movie will end on second execution of frame 3 actions)
156 add_actions(mo,
158 " gotoAndPlay(2); " // The movie will be ended in frame 5
160 // Static3 refers to same instance
161 "check_equals(static3.myThing, 'guess');"
162 "check_equals(static3._x, 10);" // Probably PlaceObject was a no-op...
164 // actions in frame 2 would be executed again, making this a 204, but only *after* this action block terminates..
165 "check_equals(static3._y, 202);"
167 "check_equals(static3.getDepth(), -16381);"
169 SWFMovie_nextFrame(mo);
171 //Output movie
172 puts("Saving " OUTPUT_FILENAME );
173 SWFMovie_save(mo, OUTPUT_FILENAME);
175 return 0;