Defines | Functions

ming_utils.h File Reference

#include <ming.h>

Go to the source code of this file.

Defines

#define newSWFAction   compileSWFActionCode
#define CALLFRAME   "callFrame"
#define SWFACTION_INIT   (1<<9)
#define SWFACTION_PRESS   (1<<10)
#define SWFACTION_RELEASE   (1<<11)
#define SWFACTION_RELEASEOUTSIDE   (1<<12)
#define SWFACTION_ROLLOVER   (1<<13)
#define SWFACTION_ROLLOUT   (1<<14)
#define SWFACTION_DRAGOVER   (1<<15)
#define SWFACTION_DRAGOUT   (1<<16)
#define SWFACTION_KEYPRESS   (1<<17)
#define SWFACTION_CONSTRUCT   (1<<18)
#define check(m, expr)   SWFMovie_add(m, (SWFBlock)compile_actions("\ if ( %s ) pass( \"%s [%s:%d]\"); \ else fail( \"%s [%s:%d] \"); \ ", expr, expr, __FILE__, __LINE__, expr, __FILE__, __LINE__));
 Evaluate ActionScript 'expr' expression updating the global TestState (make sure you called add_dejagnu_functions before using this function).
#define xcheck(m, expr)   SWFMovie_add(m, (SWFBlock)compile_actions("\ if ( %s ) xpass( \"%s [%s:%d]\"); \ else xfail( \"%s [%s:%d] \"); \ ", expr, expr, __FILE__, __LINE__, expr, __FILE__, __LINE__));
 Evaluate ActionScript 'expr' expression updating the global TestState. Expect a failure. (make sure you called add_dejagnu_functions before using this function).
#define check_equals(m, obt, exp)   SWFMovie_add(m, (SWFBlock)compile_actions("\ if ( %s == %s ) pass( \"%s == %s [%s:%d]\"); \ else fail( \"expected: %s obtained: \" + %s + \" [%s:%d] \"); \ ", obt, exp, obt, exp, __FILE__, __LINE__, exp, obt, __FILE__, __LINE__));
 Evaluate equality of two ActionScript expressions updating the global TestState accordingly. (make sure you called add_dejagnu_functions before using this function).
#define xcheck_equals(m, obt, exp)   SWFMovie_add(m, (SWFBlock)compile_actions("\ if ( %s == %s ) xpass( \"%s == %s [%s:%d]\"); \ else xfail( \"expected: %s obtained: \" + %s + \" [%s:%d] \"); \ ", obt, exp, obt, exp, __FILE__, __LINE__, exp, obt, __FILE__, __LINE__));
 Evaluate equality of two ActionScript expressions updating the global TestState accordingly. Expect a failure. (make sure you called add_dejagnu_functions before using this function).

Functions

void SWFMovie_writeExports (SWFMovie movie)
SWFFont get_default_font (const char *mediadir)
 Get the default font for Gnash testcases.
void add_dejagnu_functions (SWFMovie mo, SWFBlock font, int depth, int x, int y, int width, int height)
 Add 'check', 'xcheck', 'check_equals', 'xcheck_equals' ActionScript functions for use by embedded-swf tests, and a textfield to print results of the checks to (results will additionally be 'traced'). The textfield uses embedded fonts (only ascii chars loaded).
SWFMovieClip get_dejagnu_clip (SWFBlock font, int depth, int x, int y, int width, int height)
 Return a 'dejagnu' clip. This is like add_dejagnu_functions but embeds the functionalities in a movieclip, ready for export.
void print_tests_summary (SWFMovie mo)
 Print TestState total summary. (make sure you called add_dejagnu_functions before using this function).
SWFAction compile_actions (const char *fmt,...)
 Compile ActionScript code using printf-like formatting.
void add_actions (SWFMovie mo, const char *code)
 Add an arbitrary ActionScript code in the given movie.
void add_clip_actions (SWFMovieClip mc, const char *code)
 Add an arbitrary ActionScript code in the given movieclip.
SWFShape make_square (int x, int y, int width, int height, byte r, byte g, byte b)
 Create an outline square shape with given offset, size and colors.
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)
 Create a filled square shape with given offset, size and colors.

Define Documentation

#define CALLFRAME   "callFrame"

Referenced by main().

#define check (   m,
  expr 
)    SWFMovie_add(m, (SWFBlock)compile_actions("\ if ( %s ) pass( \"%s [%s:%d]\"); \ else fail( \"%s [%s:%d] \"); \ ", expr, expr, __FILE__, __LINE__, expr, __FILE__, __LINE__));

Evaluate ActionScript 'expr' expression updating the global TestState (make sure you called add_dejagnu_functions before using this function).

Parameters:
mo The SWFMovie to add the DO_ACTION block to
expr The ActionScript expression
#define check_equals (   m,
  obt,
  exp 
)    SWFMovie_add(m, (SWFBlock)compile_actions("\ if ( %s == %s ) pass( \"%s == %s [%s:%d]\"); \ else fail( \"expected: %s obtained: \" + %s + \" [%s:%d] \"); \ ", obt, exp, obt, exp, __FILE__, __LINE__, exp, obt, __FILE__, __LINE__));

Evaluate equality of two ActionScript expressions updating the global TestState accordingly. (make sure you called add_dejagnu_functions before using this function).

Parameters:
mo The SWFMovie to add the DO_ACTION block to
obtained The ActionScript expression we are testing
expected The ActionScript expression we expect to equal the obtained one
#define newSWFAction   compileSWFActionCode
#define SWFACTION_CONSTRUCT   (1<<18)

Referenced by add_static_mc(), and main().

#define SWFACTION_DRAGOUT   (1<<16)
#define SWFACTION_DRAGOVER   (1<<15)
#define SWFACTION_INIT   (1<<9)

Referenced by main().

#define SWFACTION_KEYPRESS   (1<<17)
#define SWFACTION_PRESS   (1<<10)

Referenced by add_button().

#define SWFACTION_RELEASE   (1<<11)
#define SWFACTION_RELEASEOUTSIDE   (1<<12)
#define SWFACTION_ROLLOUT   (1<<14)

Referenced by add_coverart(), and add_window().

#define SWFACTION_ROLLOVER   (1<<13)

Referenced by add_coverart(), and add_window().

#define xcheck (   m,
  expr 
)    SWFMovie_add(m, (SWFBlock)compile_actions("\ if ( %s ) xpass( \"%s [%s:%d]\"); \ else xfail( \"%s [%s:%d] \"); \ ", expr, expr, __FILE__, __LINE__, expr, __FILE__, __LINE__));

Evaluate ActionScript 'expr' expression updating the global TestState. Expect a failure. (make sure you called add_dejagnu_functions before using this function).

Parameters:
mo The SWFMovie to add the DO_ACTION block to
expr The ActionScript expression
#define xcheck_equals (   m,
  obt,
  exp 
)    SWFMovie_add(m, (SWFBlock)compile_actions("\ if ( %s == %s ) xpass( \"%s == %s [%s:%d]\"); \ else xfail( \"expected: %s obtained: \" + %s + \" [%s:%d] \"); \ ", obt, exp, obt, exp, __FILE__, __LINE__, exp, obt, __FILE__, __LINE__));

Evaluate equality of two ActionScript expressions updating the global TestState accordingly. Expect a failure. (make sure you called add_dejagnu_functions before using this function).

Parameters:
mo The SWFMovie to add the DO_ACTION block to
obtained The ActionScript expression we are testing
expected The ActionScript expression we expect to equal the obtained one

Function Documentation

void add_actions ( SWFMovie  mo,
const char *  code 
)

Add an arbitrary ActionScript code in the given movie.

Parameters:
mo The SWFMovie to add the DO_ACTION block to.
code ActionScript code to be compiled in.

Referenced by add_xtrace_function(), endOfTests(), main(), pauseForNextTest(), print_tests_summary(), printFrameInfo(), runAttachedSoundsTest(), runMultipleSoundsTest(), runNoMultipleSoundsTest(), and runTrimmedSoundsTest().

void add_clip_actions ( SWFMovieClip  mc,
const char *  code 
)

Add an arbitrary ActionScript code in the given movieclip.

Parameters:
mc The SWFMovieClip to add the DO_ACTION block to.
code ActionScript code to be compiled in.

Referenced by add_static_mc(), add_xtrace_function_clip(), addRedSquareExport(), and main().

void add_dejagnu_functions ( SWFMovie  mo,
SWFBlock  font,
int  depth,
int  x,
int  y,
int  width,
int  height 
)

Add 'check', 'xcheck', 'check_equals', 'xcheck_equals' ActionScript functions for use by embedded-swf tests, and a textfield to print results of the checks to (results will additionally be 'traced'). The textfield uses embedded fonts (only ascii chars loaded).

Note that the x, y, width and height parameters will depend on the currently set Ming scale (see Ming_setScale). By default they are pixels (twips*20).

References add_xtrace_function().

Referenced by main().

SWFAction compile_actions ( const char *  fmt,
  ... 
)

Compile ActionScript code using printf-like formatting.

Referenced by add_dynamic_mc().

SWFFont get_default_font ( const char *  mediadir  ) 

Get the default font for Gnash testcases.

Parameters:
mediadir the 'media' directory under testsuite/ dir of Gnash source tree.
SWFMovieClip get_dejagnu_clip ( SWFBlock  font,
int  depth,
int  x,
int  y,
int  width,
int  height 
)

Return a 'dejagnu' clip. This is like add_dejagnu_functions but embeds the functionalities in a movieclip, ready for export.

The Dejagnu.c file uses this function to create a Dejagnu.swf file that exports a 'dejagnu' symbol. The architecture still needs a bit of tuning for general use (the goal is making it easy for flash coders to produce standard testcases), anyway

A quick test revealed that it is possible, with an SWF targeted at version 5, to 'import' the Dejagnu.swf file and use it's functionalities.

For importing it using the command-line actionscript compiler:

makeswf -o test.swf -v5 -iDejagnu.swf:dejagnu 0.as test.as

Note that the '0.as' is just a placeholder to have a first frame with no actions. This is needed because actions in the main movie (the "importer") are executed *before* actions in the loaded movie (the "exported": Dejagnu.swf). So, in order to use functions defined in the "imported" movie we have to wait the second frame.

References add_xtrace_function_clip().

Referenced by main(), and setupMovie().

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 
)

Create a filled square shape with given offset, size and colors.

Referenced by add_button(), add_square(), add_static_mask(), add_static_mc(), addRedSquareExport(), defineMovieclip(), get_button(), get_shape(), get_static_mc(), and main().

SWFShape make_square ( int  x,
int  y,
int  width,
int  height,
byte  r,
byte  g,
byte  b 
)

Create an outline square shape with given offset, size and colors.

Referenced by add_static_mc(), and main().

void print_tests_summary ( SWFMovie  mo  ) 

Print TestState total summary. (make sure you called add_dejagnu_functions before using this function).

Parameters:
mo The SWFMovie to add the DO_ACTION block to

References add_actions().

Referenced by main().

void SWFMovie_writeExports ( SWFMovie  movie  )