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 * all frame numbers are 1-based and reference the _root.
23 * expected order(or behaviour) is like this(player version higher than 4):
25 * (1) execute actions in 2nd frame, since "check"!=1, then do nothing;
26 * (2) set "check" to 1, jump back to the second frame;
27 * (3) execute actions in 2nd frame, since "check"==1 now, jump to the 4th frame;
28 * (4) "mc1" is placed in the 4th frame, frame1 actions of mc1 get executed,
29 * which is the "_root.gotoAndStop(6);"
30 * (5) As "mc1" is removed in the 5th frmae, and "mc2" is removed in the 6th frame,
31 * the 6th frame of _root should be visually empty.
33 * expected behaviour of player4:
35 * (1)(2)(3) are the same as the above;
36 * (4) "mc1" is placed in the 4th frame, frame1 actions get executed
37 * but has no effect(player4 does not support mc.gotoAndStop). _root
38 * still advances to the 5th frame.
39 * (5) "mc1" is removed in the 5th frame. mc2 is placed in the 5th frame and
40 * frame1 actions of mc2 get executed. Then the message 'your player version
41 * is lower than 5' is printed on the screen.
43 * TODO: generate SWF4 and SWF5 targets to automate test for both !
52 #include "ming_utils.h"
54 #define DEF_OUTPUT_VERSION 6
55 #define OUTPUT_FILENAME_FMT "action_execution_order_test8-v%d.swf"
59 main(int argc
, char *argv
[])
62 SWFMovieClip mc1
, mc2
, dejagnuclip
;
63 SWFDisplayItem it1
, it2
;
64 int outputVersion
= DEF_OUTPUT_VERSION
;
66 const char *srcdir
= ".";
70 if (argc
> 2) outputVersion
= strtol(argv
[2], NULL
, 0);
74 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
79 mo
= newSWFMovieWithVersion(outputVersion
);
80 SWFMovie_setDimension(mo
, 800, 600);
81 SWFMovie_setRate (mo
, 12.0);
83 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
84 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
85 SWFMovie_nextFrame(mo
); /* 1st frame */
90 " _root.note('root frame '+_root._currentframe+'. About to call gotoAndPlay(4)');"
93 " _root.note('root frame '+_root._currentframe);"
95 SWFMovie_nextFrame(mo
); /* 2nd frame */
97 add_actions(mo
, " _root.note('root frame '+_root._currentframe+'. About to call gotoAndPlay(2).');");
98 add_actions(mo
, " check = 1; gotoAndPlay(2); ");
99 SWFMovie_nextFrame(mo
); /* 3rd frame */
102 mc1
= newSWFMovieClip(); // will only exist in frame4
103 add_clip_actions(mc1
,
104 " _root.note('about to invoke _root.gotoAndStop(6)');"
105 " _root.gotoAndStop(6);"
106 " _root.note('mc1 actions still running after _root.gotoAndStop(6), _root is '+_root);"
107 " _root.x = 100; " );
108 SWFMovieClip_nextFrame(mc1
);
110 /* add mc1 to _root and name it as "mc1" */
111 it1
= SWFMovie_add(mo
, (SWFBlock
)mc1
);
112 SWFDisplayItem_setDepth(it1
, 3);
113 SWFDisplayItem_setName(it1
, "mc1");
114 add_actions(mo
, "_root.note('root frame '+_root._currentframe);");
115 check_equals(mo
,"typeof(_root.x)", "'undefined'");
116 add_actions(mo
, "_root.x = 200; ");
118 SWFMovie_nextFrame(mo
); /* 4th frame */
121 /* Remove mc1 in frame 4 (from depth 3) */
122 SWFDisplayItem_remove(it1
);
124 mc2
= newSWFMovieClip();
126 /* these actions are expected to be skipped with SWF version higher then 4 */
127 add_clip_actions(mc2
, " _root.note('mc2 frame '+this._currentframe);");
128 add_clip_actions(mc2
, " _root.xfail('This actions should not be executed with SWF5+');");
129 SWFMovieClip_nextFrame(mc2
);
131 /* Place mc2 in frame 4 (at depth 3) */
132 it2
= SWFMovie_add(mo
, (SWFBlock
)mc2
);
133 SWFDisplayItem_setDepth(it2
, 3);
134 SWFDisplayItem_setName(it2
, "mc2");
136 add_actions(mo
, " _root.note('root frame '+_root._currentframe);");
137 add_actions(mo
, " stop(); ");
139 SWFMovie_nextFrame(mo
); /* 5th frame */
141 /* Remove mc2 in frame 5 (from depth 3) */
142 SWFDisplayItem_remove(it2
);
144 check_equals(mo
, "_root.x", "200");
145 add_actions(mo
, " _root.note('root frame '+_root._currentframe);");
146 add_actions(mo
, " _root.totals(); stop(); ");
148 SWFMovie_nextFrame(mo
); /* 6th frame */
150 char outputFilename
[256];
151 snprintf(outputFilename
, 255, OUTPUT_FILENAME_FMT
, outputVersion
);
152 printf("Saving %s\n", outputFilename
);
153 SWFMovie_save(mo
, outputFilename
);