Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / PlaceObject2Test.c
blob45fee7f489d5fe2752507c9f76abe04b1504aac5
1 /***********************************************************************
3 * Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Test DLIST tags with dynamic depth zone specified
23 * Timeline:
25 * Frame | 1 | 2 | 3 | 4 |
26 * --------+---+---+---+---+
27 * Event | |PP |TT | RR|
29 * P = place (by PlaceObject2)
30 * T = transform (by PlaceObject2 tag)
31 * R = remove(by RemoveObject2 tag)
33 * Description:
35 * frame2: two static sprites are placed, both by PlaceObject2,
36 * one in depth 16384(0), one in depth 65535(49151)
37 * frame3: transform the sprites by PlaceObject2 tag
38 * frame4: remove the two sprites by RemoveObject2 tag
39 * frame5: place shape1 at depth 16384(0), shape2 at depth 65535(49151).
40 * frame6: replace shape1 with shape2
42 * Expected behaviour:
43 * DLIST tags manipulate DisplayObjects in dynamic zone as in static zone in this test.
45 * run as ./PlaceObject2Test
48 #include "ming_utils.h"
50 #include <stdio.h>
51 #include <ming.h>
53 #define OUTPUT_VERSION 7
54 #define OUTPUT_FILENAME "PlaceObject2Test.swf"
56 int
57 main(int argc, char** argv)
59 SWFMovie mo;
60 SWFMovieClip mc1, mc2, dejagnuclip;
61 SWFDisplayItem it1, it2;
62 SWFShape sh1,sh2;
63 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 Ming_useSWFVersion (OUTPUT_VERSION);
76 mo = newSWFMovie();
77 SWFMovie_setDimension(mo, 800, 600);
78 SWFMovie_setRate(mo, 6);
80 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
81 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
82 SWFMovie_nextFrame(mo); // frame 1
85 mc1 = newSWFMovieClip();
86 mc2 = newSWFMovieClip();
88 it1 = SWFMovie_add(mo, (SWFBlock)mc1); //add movieClip1 to _root
89 it2 = SWFMovie_add(mo, (SWFBlock)mc2); //add movieClip2 to _root
90 SWFDisplayItem_setName(it1, "Mc1");
91 SWFDisplayItem_setName(it2, "Mc2");
92 // place 2 sprites DisplayObjects at dynamic zone
93 SWFDisplayItem_setDepth(it1, 16384);
94 SWFDisplayItem_setDepth(it2, 65535);
96 check_equals(mo, "Mc1.getDepth()", "0");
97 check_equals(mo, "Mc2.getDepth()", "49151");
98 SWFMovie_nextFrame(mo); // frame 2
100 // move sprites at dynamic zone
101 SWFDisplayItem_move(it1, 0, 100);
102 SWFDisplayItem_move(it2, 100, 200);
103 check_equals(mo, "Mc1._y", "100");
104 check_equals(mo, "Mc2._y", "200");
105 SWFMovie_nextFrame(mo); // frame 3
107 // remove sprites at dynamic zone
108 SWFDisplayItem_remove(it1);
109 SWFDisplayItem_remove(it2);
110 check_equals(mo, "Mc1", "undefined");
111 check_equals(mo, "Mc2", "undefined");
112 SWFMovie_nextFrame(mo); // frame 4
114 // place a shape at dynamic zone
115 sh1 = make_fill_square (100, 300, 60, 60, 255, 0, 0, 255, 0, 0);
116 sh2 = make_fill_square (300, 300, 60, 60, 0, 255, 0, 0, 255, 0);
117 it1 = SWFMovie_add(mo, (SWFBlock)sh1);
118 it2 = SWFMovie_add(mo, (SWFBlock)sh2);
119 SWFDisplayItem_setDepth(it1, 16384);
120 SWFDisplayItem_setDepth(it2, 65535);
121 SWFMovie_nextFrame(mo); // frame 5
123 // replace the shape with another one
124 if ( SWFMovie_replace(mo, it1, (SWFBlock)sh2) )
126 return 1;
128 SWFMovie_nextFrame(mo); // frame 6
130 add_actions(mo, "totals(6); stop();");
131 SWFMovie_nextFrame(mo); // frame 6
132 puts("Saving " OUTPUT_FILENAME );
133 SWFMovie_save(mo, OUTPUT_FILENAME);
135 return 0;