Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / empty_clip_action_test.c
blob1577c5ea4423d3ee5255bb341e66bc40e115961b
1 /*
2 * Copyright (C) 2005-2013 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 #include <stdlib.h>
21 #include <stdio.h>
22 #include <ming.h>
23 #include <assert.h>
25 #include "ming_utils.h"
27 #define OUTPUT_VERSION 6
28 #define OUTPUT_FILENAME "empty_clip_action_test.swf"
30 // So this is about as hacky as you get. The idea is that we change the
31 // CHANGEOBJECT2 tag so that the first action (containing just a single
32 // null-byte) is truncated to nothing: event_length is updated to zero, the
33 // following two bytes are skipped and then of course the tag length itself has
34 // to be reduced by one.
36 // So far as I'm aware you can't do this programmatically in Ming, but of
37 // course if the output stream ever changes this will be completely broken.
38 void spesiulOutputMethod(byte b, void *data);
39 void spesiulOutputMethod(byte b, void *data)
41 static long count = 0;
42 byte c = b;
43 FILE *f = (FILE *)data;
45 if (count == 0x293b) {
46 assert( b == 122);
47 c = 120;
49 if (count == 0x2953) {
50 assert( b == 2);
51 c = 0;
53 if (count == 0x2954 || count == 0x2955) {
54 assert( b == 0);
55 ++count;
56 return;
59 fputc(c, f);
60 ++count;
65 int
66 main(int argc, char** argv)
68 SWFMovie mo;
69 SWFMovieClip mc2, dejagnuclip;
70 SWFDisplayItem it2;
71 FILE* fh;
73 const char *srcdir=".";
74 if ( argc>1 )
75 srcdir=argv[1];
76 else
78 fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
79 return 1;
82 Ming_init();
83 mo = newSWFMovieWithVersion(OUTPUT_VERSION);
84 SWFMovie_setDimension(mo, 800, 600);
85 SWFMovie_setRate (mo, 12.0);
87 dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
88 SWFMovie_add(mo, (SWFBlock)dejagnuclip);
89 add_actions(mo, "x2=0;");
90 SWFMovie_nextFrame(mo); /* 1st frame */
93 mc2 = newSWFMovieClip();
95 it2 = SWFMovie_add(mo, (SWFBlock)mc2);
96 SWFDisplayItem_setDepth(it2, 20);
97 SWFDisplayItem_setName(it2, "mc2");
98 SWFDisplayItem_addAction(it2,
99 compileSWFActionCode(""),
100 SWFACTION_KEYPRESS);
101 SWFDisplayItem_addAction(it2,
102 compileSWFActionCode(" _root.note('onClipEnterFrame triggered'); "
103 " _root.x2 = 14; "),
104 SWFACTION_ENTERFRAME);
106 SWFMovie_nextFrame(mo); /* 2nd frame */
108 check_equals(mo, "_root.x2", "14");
109 SWFMovie_nextFrame(mo); /* 3rd frame */
111 SWFDisplayItem_remove(it2);
113 SWFMovie_nextFrame(mo); /* 4th frame */
115 add_actions(mo, " _root.totals(); stop(); ");
116 SWFMovie_nextFrame(mo); /* 5th frame */
118 // Output movie
119 puts("Saving " OUTPUT_FILENAME );
121 // ..but wait! Now entering crazy-land.
122 fh = fopen(OUTPUT_FILENAME, "w");
123 SWFMovie_output(mo, spesiulOutputMethod, fh);
124 fclose(fh);
125 return 0;