An utility class for testing movie playback. More...
#include <MovieTester.h>
Public Member Functions | |
MovieTester (const std::string &filespec) | |
void | advance (bool updateClock=true) |
Advance the movie by one frame. | |
void | advanceClock (unsigned long ms) |
Advance the clock by the given amount of milliseconds. | |
void | redraw () |
Fully redraw of current frame. | |
geometry::SnappingRanges2d< int > | getInvalidatedRanges () const |
Return the invalidated ranges in PIXELS. | |
const DisplayObject * | findDisplayItemByName (const MovieClip &mc, const std::string &name) |
Find a DisplayObject in the display list of a sprite by name. | |
const DisplayObject * | findDisplayItemByDepth (const MovieClip &mc, int depth) |
Find a DisplayObject in the display list of a sprite by depth. | |
gnash::MovieClip * | getRootMovie () |
Get the topmost sprite instance of this movie. | |
void | movePointerTo (int x, int y) |
Notify mouse pointer movement to the given coordinate. | |
void | checkPixel (int x, int y, unsigned radius, const rgba &color, short unsigned tolerance, const std::string &label, bool expectFailure=false) const |
Check color of the average pixel under the mouse pointer. | |
void | pressMouseButton () |
Notify mouse button was pressed. | |
void | depressMouseButton () |
Notify mouse button was depressed. | |
void | click () |
Simulate a mouse click (press and depress mouse button). | |
void | scrollMouse (int delta) |
Simulate a mouse scroll. | |
void | pressKey (key::code k) |
Notify key press. | |
void | releaseKey (key::code k) |
Notify key release. | |
bool | isMouseOverMouseEntity () |
int | soundsStopped () |
Return the number of times a sound has been stopped, or 0 if sound testing is not supported. See canTestSound(). | |
int | soundsStarted () |
Return the number of times a sound has been started, or 0 if sound testing is not supported. See canTestSound(). | |
bool | canTestSound () const |
Return true if this build of MovieTester supports sound testing. | |
bool | canTestRendering () const |
Return true if this build of MovieTester supports pixel checking. | |
bool | canTestVideo () const |
Return true if this build of gnash supports video. | |
void | restart () |
Restart the movie. | |
void | resizeStage (int x, int y) |
Simulate a manually resized view. |
An utility class for testing movie playback.
This is a just born implementation and doesn't have much more then simply loading a movie and providing a function to find DisplayItems by name
More functions will be added when needed.
gnash::MovieTester::MovieTester | ( | const std::string & | filespec | ) |
Fully load the movie at the specified location and create an instance of it. Also, initialize any built renderer capable of in-memory rendering to allow testing of it. The renderer(s) will be initialized with a memory buffer with the size found in the SWF header
References _, gnash::SWF::addDefaultLoaders(), gnash::RcInitFile::addLocalSandboxPath(), gnash::dbglogfile, gnash::LogFile::getDefaultInstance(), gnash::RcInitFile::getDefaultInstance(), gnash::gnashInit(), gnash::movie_root::init(), gnash::noseek_fd_adapter::make_stream(), gnash::MovieFactory::makeMovie(), gnash::URL::path(), gnash::URL::protocol(), and gnash::LogFile::setVerbosity().
void gnash::MovieTester::advance | ( | bool | updateClock = true |
) |
Advance the movie by one frame.
updateClock | If true (the default), this method also advances the clock by the nominal delay expected between frame advancements before performing the actual playhead advancement. |
References gnash::movie_root::advance(), and advanceClock().
void gnash::MovieTester::advanceClock | ( | unsigned long | ms | ) |
Advance the clock by the given amount of milliseconds.
References gnash::ManualClock::advance(), gnash::key::n, and gnash::key::u.
bool gnash::MovieTester::canTestRendering | ( | ) | const [inline] |
Return true if this build of MovieTester supports pixel checking.
Pixel checking will be supported as long as a testing-capable render handler was compiled in. Testing-capable means capable of off-screen rendering, which is implementing the Renderer::initTestBuffer method.
Referenced by checkPixel(), and main().
bool gnash::MovieTester::canTestSound | ( | ) | const [inline] |
Return true if this build of MovieTester supports sound testing.
Sound will be supported as long as a sound handler was compiled in.
Referenced by canTestVideo(), and main().
bool gnash::MovieTester::canTestVideo | ( | ) | const |
void gnash::MovieTester::checkPixel | ( | int | x, | |
int | y, | |||
unsigned | radius, | |||
const rgba & | color, | |||
short unsigned | tolerance, | |||
const std::string & | label, | |||
bool | expectFailure = false | |||
) | const |
Check color of the average pixel under the mouse pointer.
This method will test any built renderer.
x | The x coordinate of the point being the center of the circle you want to compute the average color of. | |
y | The y coordinate of the point being the center of the circle you want to compute the average color of. | |
radius | Radius defining the average zone used. 1 means a single pixel. Behaviour of passing 0 is undefined. | |
color | The color we expect to find under the pointer. | |
tolerance | The tolerated difference of any r,g,b,a values. Note that the actual tolerance used for comparison might be bigger then the given one depending on the minimum tolerance supported by the renderers being tested, being a function of color depth. For example, comparisions against 16bpp renderers will use at tolerance of at least 8. | |
label | A label to use in test results. | |
expectFailure | Set to true if a failure is expected. Defaults to false. |
References canTestRendering(), gnash::exp2(), gnash::TestingRenderer::getName(), gnash::TestingRenderer::getRenderer(), gnash::rgba::toShortString(), and gnash::key::X.
void gnash::MovieTester::click | ( | ) |
Simulate a mouse click (press and depress mouse button).
References gnash::movie_root::mouseClick().
Referenced by main().
void gnash::MovieTester::depressMouseButton | ( | ) |
Notify mouse button was depressed.
References gnash::movie_root::mouseClick().
Referenced by main(), and test_mouse_activity().
const DisplayObject * gnash::MovieTester::findDisplayItemByDepth | ( | const MovieClip & | mc, | |
int | depth | |||
) |
Find a DisplayObject in the display list of a sprite by depth.
Return NULL if there's no DisplayObject at that depth in the sprite's display list.
References gnash::MovieClip::getDisplayList(), and gnash::DisplayList::getDisplayObjectAtDepth().
const DisplayObject * gnash::MovieTester::findDisplayItemByName | ( | const MovieClip & | mc, | |
const std::string & | name | |||
) |
Find a DisplayObject in the display list of a sprite by name.
Return NULL if there's no DisplayObject with that name in the sprite's display list.
References gnash::string_table::find(), gnash::MovieClip::getDisplayList(), gnash::DisplayList::getDisplayObjectByName(), gnash::getObject(), and gnash::getStringTable().
Referenced by main().
geometry::SnappingRanges2d< int > gnash::MovieTester::getInvalidatedRanges | ( | ) | const |
Return the invalidated ranges in PIXELS.
This is to debug/test partial rendering
References gnash::geometry::SnappingRanges2d< T >::scale().
gnash::MovieClip* gnash::MovieTester::getRootMovie | ( | ) | [inline] |
Get the topmost sprite instance of this movie.
We const_cast this because we don't care.
References gnash::movie_root::getRootMovie().
bool gnash::MovieTester::isMouseOverMouseEntity | ( | ) |
Return true if the currently active DisplayObject is over a DisplayObject that handles mouse events
References gnash::movie_root::getActiveEntityUnderPointer().
Referenced by main(), and test_mouse_activity().
void gnash::MovieTester::movePointerTo | ( | int | x, | |
int | y | |||
) |
Notify mouse pointer movement to the given coordinate.
Coordinates are in pixels
References gnash::movie_root::mouseMoved().
Referenced by main(), and test_mouse_activity().
void gnash::MovieTester::pressKey | ( | key::code | k | ) |
Notify key press.
See key codes in namespace gnash::key (gnash.h)
References gnash::movie_root::keyEvent().
Referenced by main().
void gnash::MovieTester::pressMouseButton | ( | ) |
Notify mouse button was pressed.
References gnash::movie_root::mouseClick().
Referenced by main(), and test_mouse_activity().
void gnash::MovieTester::redraw | ( | ) |
Fully redraw of current frame.
This function forces complete redraw in all testing renderers.
void gnash::MovieTester::releaseKey | ( | key::code | k | ) |
Notify key release.
See key codes in namespace gnash::key (gnash.h)
References gnash::movie_root::keyEvent().
Referenced by main().
void gnash::MovieTester::resizeStage | ( | int | x, | |
int | y | |||
) |
Simulate a manually resized view.
If scaleMode != noScale, the renderers are instructed to scale the view.
References gnash::TestingRenderer::getRenderer(), gnash::movie_root::getStageScaleMode(), gnash::Renderer::set_scale(), and gnash::movie_root::setDimensions().
void gnash::MovieTester::restart | ( | ) |
Restart the movie.
NOTE: the movie returned by getRootMovie() will likely be NOT the real root movie anymore, so call getRootMovie again after this call.
References gnash::movie_root::clear(), and gnash::movie_root::init().
Referenced by main().
void gnash::MovieTester::scrollMouse | ( | int | delta | ) |
Simulate a mouse scroll.
The only values seen so far are -1 and 1, but documented to be usually between -3 and 3. 1 is up, -1 is down.
References gnash::movie_root::mouseWheel().
Referenced by main().
int gnash::MovieTester::soundsStarted | ( | ) |
Return the number of times a sound has been started, or 0 if sound testing is not supported. See canTestSound().
Referenced by main().
int gnash::MovieTester::soundsStopped | ( | ) |
Return the number of times a sound has been stopped, or 0 if sound testing is not supported. See canTestSound().
Referenced by main().