2 * Copyright (C) 2005, 2006, 2007, 2009, 2010,
3 * 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * movieclips hierarchy:
27 * Testing variables are initialized to zero, and get set to 1 when related function
30 * Obeserved behaviour:
31 * ActionCallFunction supports path prefix before a function name.
38 #include "ming_utils.h"
40 #define OUTPUT_VERSION 6
41 #define OUTPUT_FILENAME "callFunction_test.swf"
45 main(int argc
, char** argv
)
49 SWFMovieClip dejagnuclip
;
50 SWFMovieClip mc1
, mc11
;
51 SWFDisplayItem it1
, it11
;
54 const char *srcdir
=".";
59 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
64 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
65 SWFMovie_setDimension(mo
, 800, 600);
66 SWFMovie_setRate (mo
, 12.0);
69 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
70 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
71 add_actions(mo
, " x1=0; x2=0; x3=0; x4=0; x5=0; x6=0; x7=0; x8=0; x9=0; x10=0; ");
72 SWFMovie_nextFrame(mo
);
75 // _root.frame2: define movieclips and some functions.
78 mc11
= newSWFMovieClip();
79 add_clip_actions(mc11
, " func1 = function () { _root.x1=1; _root.x2=this; }; "
81 SWFMovieClip_nextFrame(mc11
);
82 add_clip_actions(mc11
, "_root.x3 = 1; stop();");
83 SWFMovieClip_nextFrame(mc11
);
84 add_clip_actions(mc11
, "_root.x4 = 1; stop();");
85 SWFMovieClip_nextFrame(mc11
);
87 // Define mc1, add mc11 to mc1
88 mc1
= newSWFMovieClip();
89 it11
= SWFMovieClip_add(mc1
, (SWFBlock
)mc11
);
90 SWFDisplayItem_setDepth(it11
, 3);
91 SWFDisplayItem_setName(it11
, "mc11");
92 add_clip_actions(mc1
, " func2 = function () { _root.x5=1; _root.x6=this; }; "
94 SWFMovieClip_nextFrame(mc1
);
95 add_clip_actions(mc1
, "_root.x7 = 1; stop();");
96 SWFMovieClip_nextFrame(mc1
);
97 add_clip_actions(mc1
, "_root.x8 = 1; stop();");
98 SWFMovieClip_nextFrame(mc1
);
101 it1
= SWFMovie_add(mo
, (SWFBlock
)mc1
);
102 SWFDisplayItem_setDepth(it1
, 4);
103 SWFDisplayItem_setName(it1
, "mc1");
104 SWFMovie_nextFrame(mo
);
107 // _root.frame3: invoke function calls
109 add_actions(mo
, "asm{"
111 "push '_root.mc1.mc11.func1' " // valid format
114 add_actions(mo
, "asm{"
117 "push '_root.mc1.mc11.gotoAndStop' " // valid format
120 add_actions(mo
, "asm{"
122 "push '_root.mc1:func2' " // valid format
125 add_actions(mo
, "asm{"
128 "push '/mc1/:gotoAndStop' " // valid format
131 add_actions(mo
, "asm{"
134 "push '/_root/mc1/mc11/gotoAndStop' " // *invalid* format
137 add_actions(mo
, "asm{"
140 "push '_root:mc1:gotoAndStop' " // valid format
143 SWFMovie_nextFrame(mo
);
146 // _root.frame4: check if the function call succeeded
148 check_equals(mo
, "_root.x1", "1");
149 check_equals(mo
, "_root.x2", "_root.mc1.mc11");
150 check_equals(mo
, "_root.x3", "1");
151 check_equals(mo
, "_root.x4", "0");
152 check_equals(mo
, "_root.x5", "1");
153 check_equals(mo
, "_root.x6", "_root.mc1");
154 check_equals(mo
, "_root.x7", "1");
155 check_equals(mo
, "_root.x8", "1");
157 add_actions(mo
, " _root.totals(); stop(); ");
158 SWFMovie_nextFrame(mo
);
162 puts("Saving " OUTPUT_FILENAME
);
163 SWFMovie_save(mo
, OUTPUT_FILENAME
);