Fix invalid octal number in expansion of macro MING_VERSION_CODE
[gnash.git] / testsuite / misc-ming.all / ming_utils.h
blobdd6c6186d53666a3f1e30fb24ff00dcf00f0d7c5
1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 * Free Software Foundation, Inc.
4 *
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.
9 *
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
21 #ifndef GNASH_MING_UTILS_H
22 #define GNASH_MING_UTILS_H
24 #include <ming.h>
26 #if MING_VERSION_CODE >= 40004
27 # define MING_SUPPORTS_INIT_ACTIONS
28 #endif
31 * Add symbol from ming src/movie.h as that header file is missing
32 * from the ming -dev package.
34 void SWFMovie_writeExports(SWFMovie movie);
37 * This is to avoid the annoying warnings
38 * coming from Ming when using the deprecated
39 * compileSWFActionCode interface.
40 * A cleaner approach is likely switch to
41 * using newSWFAction always and change the
42 * macro to make it output compileSWFActionCode
43 * when MING_VERSION_CODE < 40004
45 #if MING_VERSION_CODE >= 40004
46 # define compileSWFActionCode newSWFAction
47 #else
48 # define newSWFAction compileSWFActionCode
49 #endif
52 * 'callFrame' was drop as a keyword since Ming-0.4.0.beta5
53 * and replaced by 'call'. Before that version 'call' would
54 * never be recognized as a "callframe" action
56 #if MING_VERSION_CODE >= 40006
57 # define CALLFRAME "call"
58 #else
59 # define CALLFRAME "callFrame"
60 #endif
63 /* Missing define to allow using older Ming releases */
65 #ifndef SWFACTION_INIT
66 # define SWFACTION_INIT (1<<9)
67 #endif
69 #ifndef SWFACTION_PRESS
70 # define SWFACTION_PRESS (1<<10)
71 #endif
73 #ifndef SWFACTION_RELEASE
74 # define SWFACTION_RELEASE (1<<11)
75 #endif
77 #ifndef SWFACTION_RELEASEOUTSIDE
78 # define SWFACTION_RELEASEOUTSIDE (1<<12)
79 #endif
81 #ifndef SWFACTION_ROLLOVER
82 # define SWFACTION_ROLLOVER (1<<13)
83 #endif
85 #ifndef SWFACTION_ROLLOUT
86 # define SWFACTION_ROLLOUT (1<<14)
87 #endif
89 #ifndef SWFACTION_DRAGOVER
90 # define SWFACTION_DRAGOVER (1<<15)
91 #endif
93 #ifndef SWFACTION_DRAGOUT
94 # define SWFACTION_DRAGOUT (1<<16)
95 #endif
97 #ifndef SWFACTION_KEYPRESS
98 # define SWFACTION_KEYPRESS (1<<17)
99 #endif
101 #ifndef SWFACTION_CONSTRUCT
102 # define SWFACTION_CONSTRUCT (1<<18)
103 #endif
106 /** \brief
107 * Get the default font for Gnash testcases.
109 * @param mediadir
110 * the 'media' directory under testsuite/ dir of
111 * Gnash source tree.
113 SWFFont get_default_font(const char* mediadir);
115 /** \brief
116 * Add 'check', 'xcheck', 'check_equals', 'xcheck_equals' ActionScript
117 * functions for use by embedded-swf tests, and a textfield to print
118 * results of the checks to (results will additionally be 'traced').
119 * The textfield uses embedded fonts (only ascii chars loaded).
121 * Note that the x, y, width and height parameters will depend on
122 * the currently set Ming scale (see Ming_setScale). By default
123 * they are pixels (twips*20).
125 void add_dejagnu_functions(SWFMovie mo, SWFBlock font, int depth, int x, int y, int width, int height);
127 /** \brief
128 * Return a 'dejagnu' clip. This is like add_dejagnu_functions but
129 * embeds the functionalities in a movieclip, ready for export.
131 * The Dejagnu.c file uses this function to create a Dejagnu.swf
132 * file that exports a 'dejagnu' symbol.
133 * The architecture still needs a bit of tuning for general use (the goal
134 * is making it easy for flash coders to produce standard testcases), anyway
136 * A quick test revealed that it is possible, with an SWF targeted
137 * at version 5, to 'import' the Dejagnu.swf file and use it's functionalities.
139 * For importing it using the command-line actionscript compiler:
141 * makeswf -o test.swf -v5 -iDejagnu.swf:dejagnu 0.as test.as
143 * Note that the '0.as' is just a placeholder to have a first frame
144 * with no actions. This is needed because actions in the main movie
145 * (the "importer") are executed *before* actions in the loaded movie
146 * (the "exported": Dejagnu.swf). So, in order to use functions defined
147 * in the "imported" movie we have to wait the second frame.
150 SWFMovieClip get_dejagnu_clip(SWFBlock font, int depth, int x, int y, int width, int height);
152 /** \brief
153 * Evaluate ActionScript 'expr' expression updating the global TestState
154 * (make sure you called add_dejagnu_functions before using this function)
156 * @param mo
157 * The SWFMovie to add the DO_ACTION block to
159 * @param expr
160 * The ActionScript expression
162 #define check(m, expr) \
163 SWFMovie_add(m, (SWFBlock)compile_actions("\
164 if ( %s ) pass( \"%s [%s:%d]\"); \
165 else fail( \"%s [%s:%d] \"); \
166 ", expr, expr, __FILE__, __LINE__, expr, __FILE__, __LINE__));
168 /** \brief
169 * Evaluate ActionScript 'expr' expression updating the global TestState.
170 * Expect a failure.
171 * (make sure you called add_dejagnu_functions before using this function)
173 * @param mo
174 * The SWFMovie to add the DO_ACTION block to
176 * @param expr
177 * The ActionScript expression
179 #define xcheck(m, expr) \
180 SWFMovie_add(m, (SWFBlock)compile_actions("\
181 if ( %s ) xpass( \"%s [%s:%d]\"); \
182 else xfail( \"%s [%s:%d] \"); \
183 ", expr, expr, __FILE__, __LINE__, expr, __FILE__, __LINE__));
186 /** \brief
187 * Evaluate equality of two ActionScript expressions updating the global
188 * TestState accordingly.
189 * (make sure you called add_dejagnu_functions before using this function)
191 * @param mo
192 * The SWFMovie to add the DO_ACTION block to
194 * @param obtained
195 * The ActionScript expression we are testing
197 * @param expected
198 * The ActionScript expression we expect to equal the obtained one
201 #define check_equals(m, obt, exp) \
202 SWFMovie_add(m, (SWFBlock)compile_actions("\
203 if ( %s == %s ) pass( \"%s == %s [%s:%d]\"); \
204 else fail( \"expected: %s obtained: \" + %s + \" [%s:%d] \"); \
205 ", obt, exp, obt, exp, __FILE__, __LINE__, exp, obt, __FILE__, __LINE__));
207 /** \brief
208 * Evaluate equality of two ActionScript expressions updating the global
209 * TestState accordingly. Expect a failure.
210 * (make sure you called add_dejagnu_functions before using this function)
212 * @param mo
213 * The SWFMovie to add the DO_ACTION block to
215 * @param obtained
216 * The ActionScript expression we are testing
218 * @param expected
219 * The ActionScript expression we expect to equal the obtained one
222 #define xcheck_equals(m, obt, exp) \
223 SWFMovie_add(m, (SWFBlock)compile_actions("\
224 if ( %s == %s ) xpass( \"%s == %s [%s:%d]\"); \
225 else xfail( \"expected: %s obtained: \" + %s + \" [%s:%d] \"); \
226 ", obt, exp, obt, exp, __FILE__, __LINE__, exp, obt, __FILE__, __LINE__));
230 /** \brief
231 * Print TestState total summary.
232 * (make sure you called add_dejagnu_functions before using this function)
234 * @param mo
235 * The SWFMovie to add the DO_ACTION block to
237 void print_tests_summary(SWFMovie mo);
239 /** \brief
240 * Compile ActionScript code using printf-like formatting
242 SWFAction compile_actions(const char* fmt, ...);
244 /** \brief
245 * Add an arbitrary ActionScript code in the given movie
247 * @param mo
248 * The SWFMovie to add the DO_ACTION block to.
250 * @param code
251 * ActionScript code to be compiled in.
253 void add_actions(SWFMovie mo, const char* code);
255 /** \brief
256 * Add an arbitrary ActionScript code in the given movieclip
258 * @param mc
259 * The SWFMovieClip to add the DO_ACTION block to.
261 * @param code
262 * ActionScript code to be compiled in.
264 void add_clip_actions(SWFMovieClip mc, const char* code);
267 #ifdef MING_SUPPORTS_INIT_ACTIONS
268 /** \brief
269 * Add an Init ActionScript code in the given movieclip
271 * @param mc
272 * The SWFMovieClip to add the DO_INITACTION block to.
274 * @param code
275 * Init ActionScript code to be compiled in.
277 void add_clip_init_actions(SWFMovieClip mo, const char* code);
278 #endif // MING_SUPPORTS_INIT_ACTIONS
280 /** \brief
281 * Create an outline square shape with given offset, size and colors
283 SWFShape make_square(int x, int y, int width, int height, byte r, byte g, byte b);
285 /** \brief
286 * Create a filled square shape with given offset, size and colors
288 SWFShape make_fill_square(int x, int y, int width, int height, byte outline_r, byte outline_g, byte outline_b, byte fill_r, byte fill_g, byte fill_b);
290 #endif // GNASH_MING_UTILS_H