big merge from master, fix rpm creation, drop fetching swfdec
[gnash.git] / testsuite / misc-ming.all / runtime_vm_stack_test.c
blobf4a3d37279c811ceb9ca127a829850e5933967c6
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 */
21 * observed behaviour:
22 * (1) different timelines still share the same vm stack
23 * (2) vm stack should be cleared before next advancement.
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <ming.h>
31 #include "ming_utils.h"
33 #define OUTPUT_VERSION 6
34 #define OUTPUT_FILENAME "runtime_vm_stack_test.swf"
38 int
39 main(int argc, char** argv)
41 SWFMovie mo;
42 SWFMovieClip mc1, mc11, mc2, dejagnuclip;
43 SWFDisplayItem it1, it2;
45 const char *srcdir=".";
46 if ( argc>1 )
47 srcdir=argv[1];
48 else
50 fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
51 return 1;
54 Ming_init();
55 mo = newSWFMovieWithVersion(OUTPUT_VERSION);
56 SWFMovie_setDimension(mo, 800, 600);
57 SWFMovie_setRate (mo, 12.0);
59 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
60 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
61 add_actions(mo, "testvar1 = 0; testvar2 = 0; testvar3 = 0; ");
62 SWFMovie_nextFrame(mo); // frame1
65 add_actions(mo,
66 "asm{"
67 " push '_root.testvar1'"
68 "};");
69 mc1 = newSWFMovieClip();
70 add_clip_actions(mc1,
71 "asm{"
72 " push 1"
73 " setvariable"
74 " push '_root.testvar2'"
75 " push 2"
76 "};");
78 mc11 = newSWFMovieClip();
79 add_clip_actions(mc11,
80 "asm{"
81 " setvariable"
82 " push '_root.testvar3'"
83 " push 3"
84 "};");
85 SWFMovieClip_nextFrame(mc11);
86 SWFMovieClip_add(mc1, (SWFBlock)mc11);
87 SWFMovieClip_nextFrame(mc1);
89 mc2 = newSWFMovieClip();
90 add_clip_actions(mc2,
91 "asm{"
92 " setvariable"
93 "};");
94 SWFMovieClip_nextFrame(mc2);
96 // place mc1 and mc2
97 it1 = SWFMovie_add(mo, (SWFBlock)mc1);
98 SWFDisplayItem_setDepth(it1, 10);
99 it2 = SWFMovie_add(mo, (SWFBlock)mc2);
100 SWFDisplayItem_setDepth(it2, 20);
101 SWFMovie_nextFrame(mo); // frame2
103 check_equals(mo, "testvar1", "1");
104 check_equals(mo, "testvar2", "2");
105 check_equals(mo, "testvar3", "3");
106 add_actions(mo,
107 "asm{"
108 " push 'testvar1'"
109 " push 4"
110 " push 'testvar2'"
111 " push 5"
112 " push 'testvar3'"
113 " push 6"
114 "};");
115 SWFMovie_nextFrame(mo); // frame2
117 add_actions(mo,
118 "asm{"
119 " setvariable"
120 " setvariable"
121 " setvariable"
122 "};");
123 check_equals(mo, "testvar1", "1");
124 check_equals(mo, "testvar2", "2");
125 check_equals(mo, "testvar3", "3");
126 SWFMovie_nextFrame(mo); // frame3
128 add_actions(mo, " _root.totals(6); stop(); ");
129 SWFMovie_nextFrame(mo); // frame4
131 //Output movie
132 puts("Saving " OUTPUT_FILENAME );
133 SWFMovie_save(mo, OUTPUT_FILENAME);
135 return 0;