Update with current status
[gnash.git] / testsuite / misc-ming.all / place_object_test.c
bloba8a8ecd975d0966e8a0367ee416fd9d402669574
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 tag PlaceObject2
24 * To see what happens if placing two shapes at the same depths.
26 * Obeserved behaviour:
27 * *both* shapes get rendered!
29 * run as ./place_object_test
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <ming.h>
36 #include "ming_utils.h"
38 #define OUTPUT_VERSION 6
39 #define OUTPUT_FILENAME "place_object_test.swf"
44 int
45 main(int argc, char** argv)
47 SWFMovie mo;
48 SWFMovieClip mc1, mc2, dejagnuclip;
49 SWFDisplayItem it;
50 SWFShape sh1,sh2;
52 const char *srcdir=".";
53 if ( argc>1 )
54 srcdir=argv[1];
55 else
57 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
58 //return 1;
61 Ming_init();
62 mo = newSWFMovie();
63 SWFMovie_setDimension(mo, 800, 600);
64 SWFMovie_setRate (mo, 1.0);
66 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
67 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
68 SWFMovie_nextFrame(mo);
70 sh1 = make_fill_square (0, 220, 60, 60, 255, 0, 0, 255, 0, 0);
71 sh2 = make_fill_square (30, 250, 60, 60, 255, 0, 0, 0, 0, 0);
73 it = SWFMovie_add(mo, (SWFBlock)sh1);
74 SWFDisplayItem_setName(it, "sh1");
75 SWFDisplayItem_setDepth(it, 3); //place the sh1 DisplayObject at depth 3
77 it = SWFMovie_add(mo, (SWFBlock)sh2);
78 SWFDisplayItem_setName(it, "sh2");
79 SWFDisplayItem_setDepth(it, 3); //place the sh2 DisplayObject at depth 3 again!
81 add_actions(mo, "note('Placed red shape sh1 and black shape sh2 at the same depth 3. Should both be visible, red on top.');");
83 xcheck_equals(mo, "sh1", "sh2");
84 check_equals(mo, "typeof(sh1)", "'movieclip'");
85 xcheck_equals(mo, "typeof(sh2)", "'movieclip'");
87 SWFMovie_nextFrame(mo);
89 mc1 = newSWFMovieClip();
90 it = SWFMovieClip_add(mc1, (SWFBlock)sh1);
91 SWFDisplayItem_setName(it, "sh1");
92 SWFDisplayItem_moveTo(it, 100, 0);
93 SWFMovieClip_nextFrame(mc1);
95 mc2 = newSWFMovieClip();
96 it = SWFMovieClip_add(mc2, (SWFBlock)sh2);
97 SWFDisplayItem_setName(it, "sh1");
98 SWFDisplayItem_moveTo(it, 100, 0);
99 SWFMovieClip_nextFrame(mc2);
101 it = SWFMovie_add(mo, (SWFBlock)mc2);
102 SWFDisplayItem_setName(it, "mc2");
103 SWFDisplayItem_setDepth(it, 4); //place the mc2 sprite at depth 3 again!
105 it = SWFMovie_add(mo, (SWFBlock)mc1);
106 SWFDisplayItem_setName(it, "mc1");
107 SWFDisplayItem_setDepth(it, 4); //place the mc1 sprite at depth 3
109 add_actions(mo, "note('Placed red sprite mc1 and black sprite mc2 at the same depth 4. Should both be visible, black on top.');");
111 xcheck_equals(mo, "typeof(mc1)", "'movieclip'");
112 check_equals(mo, "typeof(mc2)", "'movieclip'");
113 check(mo, "mc1._name != mc2._name");
114 check_equals(mo, "mc1.getDepth()", "mc2.getDepth()");
116 // TODO: use SWFMovie_replace and see if it would replace
117 // only one or both DisplayObjects at target depth
118 // (not that we can trust Ming stability here..)
120 add_actions(mo, "_root.totals(7); stop();");
122 SWFMovie_nextFrame(mo);
125 //Output movie
126 puts("Saving " OUTPUT_FILENAME );
127 SWFMovie_save(mo, OUTPUT_FILENAME);
129 return 0;