コード例 #1
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

    const size_t framecount = root->get_frame_count();

    // Sanity.
    check_equals(framecount, 5);

	if (!tester.canTestSound()) {
		cout << "UNTESTED: sounds can't be tested with this build." << endl;
		return EXIT_SUCCESS; // so testing doesn't abort
	} 

    // Shouldn't be streaming yet.
    check_equals(tester.streamingSound(), false);

    // 20 x 0.75 seconds = 15 in total. The sound should last
    // 13.74 seconds.
    for (size_t i = 0; i < 20; ++i) {
        if (root->get_current_frame() + 1 == framecount) break;
        tester.advance();
        check_equals(tester.streamingSound(), true);
    }

}
コード例 #2
0
void MovieClipTest::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
	MovieClip* mc = (MovieClip*) this->getChildByTag(this->curTag);
	if (!mc) return;
	mc->playOnce();
	//mc->removeFromParent();
	this->curTag++;
}
コード例 #3
0
MovieClip* MovieClip::create(const char* name, const char* fileType, const char* prefix)
{
	MovieClip* mc = new MovieClip();
	if (mc && mc->init(name, fileType, prefix))
	{
		mc->autorelease();
		return mc;
	}
	CC_SAFE_DELETE(mc);
	return NULL;
}
コード例 #4
0
ファイル: morph_test1runner.cpp プロジェクト: diocles/gnash
int
main(int /*argc*/, char** /*argv*/)
{
  //string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
  string filename = string(INPUT_FILENAME);
  MovieTester tester(filename);

  gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
  dbglogfile.setVerbosity(1);

  
  rgba red(255,0,0,255);   //start color
  rgba green(0,255,0,255); //end color

  MovieClip* root = tester.getRootMovie();
  assert(root);
  check_equals(root->get_frame_count(), 7);
  
  // FRAME 2 
  tester.advance(); 
  // fill color: 1.0*red + 0.0*green
  // center coordinates: <start_x+50, start_y+50>
  check_pixel(50, 50, 50, red, 2); // morph ratio = 0

  // FRAME 3
  tester.advance(); 
  // 0.8*red + 0.2*green
  // center coordinates: <0.8*start_x+0.2*end_x+50, 0.8*start_y+0.2*end_y+50>
  check_pixel(190, 150, 50, rgba(204,51,0,255), 2); // morph ratio = 0.2
  
  // FRAME 4
  tester.advance(); 
  // fill color: 0.6*red + 0.4*green
  check_pixel(330, 250, 50, rgba(153,102,0,255), 2); // morph ratio = 0.4

  // FRAME 5
  tester.advance(); 
  // fill color: 0.4*red + 0.6*green
  check_pixel(470, 350, 50, rgba(102,153,0,255), 2); // morph ratio = 0.6

  // FRAME 6
  tester.advance(); 
  // fill color: 0.2*red + 0.8*green
  check_pixel(610, 450, 50, rgba(51,204,0,255), 2); // morph ratio = 0.8

  // FRAME 7
  tester.advance(); 
  // fill color: 0.0*red + 1.0*green
  check_pixel(750, 550, 50, rgba(0,255,0,255), 2); // morph ratio = 1.0
}
コード例 #5
0
ファイル: loadMovieTestRunner.cpp プロジェクト: sunarto/gnash
int
main(int /*argc*/, char** /*argv*/)
{
	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	tester.reset(new MovieTester(filename));

	URL baseURL(filename);

	gnash::RcInitFile& rc = gnash::RcInitFile::getDefaultInstance();
	rc.addLocalSandboxPath(MEDIADIR);

	root = tester->getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 2);
	check_equals(root->get_current_frame(), 0);

	tester->advance();
	check_equals(root->get_current_frame(), 1);

	// Verify that 'coverart' exists and is empty
	MovieClip* coverart = getCoverArt();
	check(coverart);
	std::string url = coverart->get_root()->url();
	check_equals(coverart->get_root()->url(), baseURL.str());

	// Check scribbling on the empty canvas
	checkScribbling();

	clickCycle(coverart); // MovieClip::loadMovie
	clickCycle(coverart); // GETURL _level0.cont.coverart 
	clickCycle(coverart); // GETURL /cont/coverart
	//clickCycle(coverart); // GETURL _level0.coverart

	// Consistency checking
	VM& vm = getVM(*getObject(root));
	as_value eot;
	// It's an swf6, so lowercase 'END_OF_TEST'
	bool endOfTestFound = getObject(root)->get_member(getURI(vm, "end_of_test"), &eot);
	check(endOfTestFound);
	if ( endOfTestFound )
	{
		check_equals(eot.to_bool(8), true);
	}

}
コード例 #6
0
int
trymain(int /*argc*/, char** /*argv*/)
{
	//string filename = INPUT_FILENAME;
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 7);
	check_equals(root->get_current_frame(), 0);

    tester.advance();
	
    check_equals(root->get_current_frame(), 1);
    
    tester.advance();
    check_equals(root->get_current_frame(), 2);

    tester.movePointerTo(150, 150);
    tester.click();

    tester.advance();
    check_equals(root->get_current_frame(), 3);
    
    tester.movePointerTo(250, 250);
    tester.click();
    tester.advance();
    check_equals(root->get_current_frame(), 4);
    
    tester.movePointerTo(251, 251);
    tester.movePointerTo(252, 251);
    tester.movePointerTo(251, 252);
    tester.click();
    tester.advance();
    check_equals(root->get_current_frame(), 5);
    
    tester.advance();

	// last advance should not restart the loop (it's in STOP mode)
    check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
	check_equals(root->get_current_frame(), 6);

    return 0;
}
コード例 #7
0
ファイル: loadMovieTestRunner.cpp プロジェクト: diocles/gnash
void
checkScribbling()
{
	MovieClip* coverart = getCoverArt();

	size_t initial_child_count = coverart->getDisplayList().size();

	tester->movePointerTo(73, 204); // the "Scribble" button
	check(tester->isMouseOverMouseEntity());
	for (int i=1; i<=5; ++i) {
		tester->click();
		check_equals(coverart->getDisplayList().size(), initial_child_count+i);
	}

	tester->movePointerTo(59, 225); // the "clear" button
	check(tester->isMouseOverMouseEntity());
	tester->click();
	check_equals(coverart->getDisplayList().size(), initial_child_count);
}
コード例 #8
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 5);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 0);

	for (int i=0; i<30; ++i)
		tester.advance();

	// TODO: use check_pixel for checking bacground colors
}
コード例 #9
0
int
main(int /*argc*/, char** /*argv*/)
{
    string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);

    gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();

    MovieTester tester(filename);

    dbglogfile.setVerbosity(1);

    MovieClip* root = tester.getRootMovie();
    assert(root);

    check_equals(root->get_frame_count(), 48);

    if (!tester.canTestSound()) {
        cout << "UNTESTED: sounds can't be tested with this build." << endl;
        return EXIT_SUCCESS; // so testing doesn't abort
    } 

    check_equals(tester.streamingSound(), true);
    
    // The Movie contains a sprite with a streaming sound. The sprite
    // has 4 frames, the movie 8. We expect the streaming sound to play
    // twice through. 

    while (root->get_current_frame() < root->get_frame_count() - 1) {

        // Check twice per frame so we don't get out of sync.
        tester.advanceClock(10);
        tester.advance(false);

        check_equals(tester.streamingSound(), true);
    }

}
コード例 #10
0
ファイル: movie_clip.hpp プロジェクト: drunkenme/openswf
 inline void MovieNode::goto_named_frame(const char* name, MovieGoto status, int offset)
 {
     auto frame = m_sprite->get_frame(name);
     if( frame != 0 ) goto_frame(frame, status, offset);
 }
コード例 #11
0
ファイル: movie_clip.hpp プロジェクト: drunkenme/openswf
 inline uint16_t MovieNode::get_frame_count() const
 {
     return m_sprite->get_frame_count();
 }
コード例 #12
0
ファイル: DragDropTestRunner.cpp プロジェクト: diocles/gnash
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	// for variables lookup (consistency checking)
	VM& vm = getVM(*getObject(root));

	rgba white(255, 255, 255, 255); // background color
	rgba blue(0, 0, 255, 255);      // blue circles fill color
	rgba green(0, 255, 0, 255);     // green circles fill color
	rgba red(255, 0, 0, 255);       // red circles fill color

	point out(350, 100);  // out of any drawing

	point rc1(50, 50);    // first red circle
	point gc1(100, 50);   // first green circle
	point bc1(70, 100);   // first blue circle

	point rc2(150, 50);   // second red circle
	point gc2(200, 50);   // second green circle
	point bc2(170, 100);  // second blue circle

	point rc3(250, 50);   // third red circle
	point gc3(300, 50);   // third green circle
	point bc3(270, 100);  // third blue circle

	check_equals(root->get_frame_count(), 2);
	check_equals(root->get_current_frame(), 0);

	// first frame is just Dejagnu clip...
	tester.advance();

	check_equals(root->get_current_frame(), 1);

	// Wait for _level50 and loadedTarget to be loaded...
	unsigned long sleepTime = 100000; // microseconds
	unsigned int attempts=10;
	while (1)
	{
		// loads should happen on next advance...
		tester.advance();

		// if _root displaylist contains loadedTarget and loadedTarget
		// contains target100, we've loaded it
		const MovieClip* loadedTarget = 0;
		//const DisplayObject* ch = tester.findDisplayItemByName(*root, "loadedTarget");
		const DisplayObject* ch = tester.findDisplayItemByDepth(*root, 30);
		if ( ch ) loadedTarget = const_cast<DisplayObject*>(ch)->to_movie();
		if ( loadedTarget )
		{
			const DisplayObject* target100 = tester.findDisplayItemByName(*loadedTarget, "target100");
			if ( target100 ) break;
			else cerr << "target100 not yet found in loadedTarget" << endl;
		}
		else
		{
			cerr << "loadedTarget not yet not found" << endl;
		}

		if ( ! attempts-- )
		{
			check(!"loadTarget was never loaded");
			cerr << "Root display list is: " << endl;
			root->getDisplayList().dump();
			exit(EXIT_FAILURE);
		}

		usleep(sleepTime);
	}

	check_equals(root->get_current_frame(), 1);


	// 1. Click OUTSIDE of any drawing.
	tester.movePointerTo(out.x, out.y);
	tester.click();

	// 2. Click on the FIRST RED circle.
	tester.movePointerTo(rc1.x, rc1.y);
	tester.click(); 

	// 3. Click on the FIRST GREEN circle.
	tester.movePointerTo(gc1.x, gc1.y);
	tester.click(); 

	// 4. Click on the FIRST BLUE circle.
	tester.movePointerTo(bc1.x, bc1.y);
	tester.click(); 

	// 5. Click on the SECOND RED circle.
	tester.movePointerTo(rc2.x, rc2.y);
	tester.click(); 

	// 6. Click on the SECOND GREEN circle.
	tester.movePointerTo(gc2.x, gc2.y);
	tester.click(); 

	// 7. Click on the SECOND BLUE circle.
	tester.movePointerTo(bc2.x, bc2.y);
	tester.click(); 

	// 8. Click on the THIRD RED circle.
	tester.movePointerTo(rc3.x, rc3.y);
	tester.click(); 

	// 9. Click on the THIRD GREEN circle.
	tester.movePointerTo(gc3.x, gc3.y);
	tester.click(); 

	// 10. Click on the THIRD BLUE circle.
	tester.movePointerTo(bc3.x, bc3.y);
	tester.click(); 

	// 11. Click ANYWHERE OUT of the THIRD BLUE circle (on another circle makes a better test)
	tester.movePointerTo(rc1.x, rc1.y);
	tester.click();

	// Consistency check !!
	as_value eot;
	// It's an swf6, so lowercase 'ENDOFTEST'
	bool endOfTestFound = getObject(root)->get_member(getURI(vm, "endoftest"), &eot);
	check(endOfTestFound);
	if ( endOfTestFound )
	{
		cerr << eot << endl;
		check_equals(eot.to_bool(8), true);
	}
	else
	{
		cerr << "Didn't find ENDOFTEST... dumping all members" << endl;
		// root->dump_members();
	}

 return 0;
}
コード例 #13
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::RcInitFile& rc = gnash::RcInitFile::getDefaultInstance();
	rc.addLocalSandboxPath(MEDIADIR);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	if ( ! tester.canTestVideo() )
	{
		cout << "UNTESTED: NetStream video (not supported by this build)." << endl;
		return EXIT_SUCCESS;
	}

	// On NetStatus.Play.Stop we jump to last frame and stop,
	// so this loop is about equivalent to running a
	// generic self-contained test.
	//
	// When all possible tests are implemented as self-contained, we'll
	// add tests that can't be self-contained.
	//
	string_table& st = VM::get().getStringTable();
	string_table::key k = st.find("startNotified");
	as_value tmp;
	while (!getObject(root)->get_member(k, &tmp) )
	{
		tester.advance();

		// sleep to give the NetStream a chance to load
        // data and trigger notifications
		// needs more analisys to find a good way for doing this..
        // TODO: sleep less ! GnashSleep !
        gnashSleep(10000); // 10 milliseconds should be enough for loading
		//sleep(1);
	}

	cout << "Pressing space" << endl;
	tester.pressKey(key::SPACE);
	tester.releaseKey(key::SPACE);

    while (root->get_current_frame() < 2)
	{
		tester.advance();

		// sleep to give the NetStream a chance to load data and trigger notifications
		// needs more analisys to find a good way for doing this..
        // TODO: sleep less !!
        gnashSleep(10000); // 10 milliseconds should be enough for loading
		//sleep(1);
	}

	// Consistency check 
	as_value eot;
	bool endOfTestFound = getObject(root)->get_member(st.find("end_of_test"), &eot);
	check(endOfTestFound);

}
コード例 #14
0
int
main(int /*argc*/, char** /*argv*/)
{
	typedef gnash::geometry::SnappingRanges2d<int> Ranges;
	typedef gnash::geometry::Range2d<int> Bounds;

	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	// Colors we'll use during the test
	rgba red(255,0,0,255);
	rgba green(0,255,0,255);
	rgba white(255,255,255,255);

	// Ranges we'll use during the test
	Range2d<int> redRange(100,300,160,360);
	Range2d<int> greenRange(130,330,190,390);

	Ranges invalidated;
	MovieClip* root = tester.getRootMovie();
	assert(root);

	// FRAME 1 (start)

	check_equals(root->get_frame_count(), 4);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 0);
	check_equals(root->getDisplayList().size(), 1);  // dejagnu clip
	invalidated = tester.getInvalidatedRanges();
	check( invalidated.contains(76, 4) ); // the "-xtrace enabled-" label...

	tester.advance(); // FRAME 2, place DisplayObject
	invalidated = tester.getInvalidatedRanges();
	
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 1);
	check_equals(root->getDisplayList().size(), 2); // dejagnu + red char

	// check invalidated bounds contain the red instance (100,300 - 160,360)
	check( invalidated.contains(redRange) );
	
	// check that we have a red square at (100,300 - 160,360)
	check_pixel(104, 304, 2, red, 2); // UL
	check_pixel(156, 304, 2, red, 2); // UR
	check_pixel(156, 356, 2, red, 2); // LL
	check_pixel(104, 356, 2, red, 2); // LR

	// and nothing around it...
	check_pixel( 96, 330, 2, white, 2); // Left
	check_pixel(164, 330, 2, white, 2); // Right
	check_pixel(130, 296, 2, white, 2); // Top
	check_pixel(130, 364, 2, white, 2); // Bottom

	tester.advance(); // FRAME 3, replace DisplayObject
	invalidated = tester.getInvalidatedRanges();
	
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 2);
	check_equals(root->getDisplayList().size(), 2); // dejagnu + green char 

	// check invalidated bounds to contain:
	// 	- the green square (added)
	// 	- the red square (removed)
	//
	check( invalidated.contains(redRange) );
	check( invalidated.contains(greenRange) );
	
	// check that we have a green square at (130,330 - 190,390)
	check_pixel(134, 334, 2, green, 2); // UL
	check_pixel(186, 334, 2, green, 2); // UR
	check_pixel(186, 386, 2, green, 2); // LL
	check_pixel(134, 386, 2, green, 2); // LR

	// and nothing around it...
	check_pixel(126, 360, 2, white, 2); // Left
	check_pixel(194, 360, 2, white, 2); // Right
	check_pixel(160, 326, 2, white, 2); // Top
	check_pixel(160, 394, 2, white, 2); // Bottom

	tester.advance(); // FRAME 4, jump to frame 2 and stop
	invalidated = tester.getInvalidatedRanges();

	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
	check_equals(root->get_current_frame(), 1);
	check_equals(root->getDisplayList().size(), 2); // dejagnu + red char 

	// check invalidated bounds to contain:
	// 	- the green square (removed)
	// 	- the red square (added)
	//
	check( invalidated.contains(redRange) );
	check( invalidated.contains(greenRange) );

	// check that we have a red square at (100,300 - 160,360)
	check_pixel(104, 304, 2, red, 2); // UL
	check_pixel(156, 304, 2, red, 2); // UR
	check_pixel(156, 356, 2, red, 2); // LL
	check_pixel(104, 356, 2, red, 2); // LR

	// and nothing around it...
	check_pixel( 96, 330, 2, white, 2); // Left
	check_pixel(164, 330, 2, white, 2); // Right
	check_pixel(130, 296, 2, white, 2); // Top
	check_pixel(130, 364, 2, white, 2); // Bottom

}
コード例 #15
0
MovieClipTest::MovieClipTest()
{
	CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
	clock_t	time;
	time = clock();
	MovieClip* mc = NULL;
	CCArray* frameList = NULL;
	this->curTag = 0;
	for (int i = 0; i < 1; ++i)
	{
		if (!mc)
		{
			mc = MovieClip::create("spider", ".pvr.ccz");
			frameList = mc->getFrameList();
			mc->addEventListener(this, complete_selector(MovieClipTest::playComplete));
		}
		else
		{
			//mc = MovieClip::create("spider", ".pvr.ccz");
			mc = MovieClip::create(frameList);
		}
		mc->setPosition(ccp(ScreenUtil::getLeft() + 20 + (i * 120), ScreenUtil::getCenter().y));
		mc->play(.03f, true, true);
		this->addChild(mc);
		mc->setTag(i);
	}
	CCLOG("view time : %d ms", clock() - time);
	CCSprite* sp = CCSprite::create("node.png");
	this->addChild(sp);

	CCSprite* sp1 = CCSprite::create("node.png");
	this->addChild(sp1);
	sp1->setPosition(ccp(180, 126.65));

	CCSprite* sp2 = CCSprite::create("node.png");
	this->addChild(sp2);
	sp2->setPosition(ccp(293.05, 271.75));

	CCSprite* sp3 = CCSprite::create("node.png");
	this->addChild(sp3);
	sp3->setPosition(ccp(150.45, 54.5));

	CCSprite* sp4 = CCSprite::create("node.png");
	this->addChild(sp4);
	sp4->setPosition(ccp(150.45, 167.5));

	vector<float> vect;
	MathUtil::segmentsIntr(sp1->getPosition(), sp2->getPosition(), ccp(150.45, 54.5), ccp(150.45, 167.5), vect);
	CCLOG("%d", vect.size());

	sp->setOpacity(0xCC);
	if (vect.size() > 0)
	{
		sp->setPositionX(vect.at(0));
		sp->setPositionY(vect.at(1));
	}

	CCSprite* spt = CCSprite::create("effect/a1.png");
	CCSprite* mask = CCSprite::create("normal_body.png");
	CCSprite* maskMc;// = MaskUtil::createMaskedSprite(spt, mask, true);
	//maskMc->setPosition(ccp(200, 200));
	//this->addChild(maskMc);

	maskMc = MaskUtil::createMaskedSprite(mc, mask);
	maskMc->setPosition(ccp(500, 200));
	this->addChild(maskMc);
}
コード例 #16
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 4);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 0);

	rgba white(255,255,255,255);
	rgba red(255,0,0,255);
	rgba green(0,255,0,255);

	geometry::Point2d cXmm(220,327); // DisplayObject X center
	geometry::Point2d cXum(220,440); // DisplayObject X underline/middle

	geometry::Point2d cOmr(135,326); // DisplayObject O middle/right
	geometry::Point2d cOml(21,330); // DisplayObject O middle/left
	geometry::Point2d cOmm(77,327); // DisplayObject O center
	geometry::Point2d cOum(78,440); // DisplayObject O underline/middle


	tester.advance(); // first frame only contains dejagnu
	check_equals(root->get_current_frame(), 1);

	check_pixel(cXmm.x, cXmm.y, 4, red, 2); // X cross
	check_pixel(cXum.x, cXum.y, 20, white, 2); // X underline (none)

	check_pixel(cOmm.x, cOmm.y, 8, white, 2); // O hole
	check_pixel(cOml.x, cOml.y, 4, green, 2); // O left side
	check_pixel(cOmr.x, cOmr.y, 4, green, 2); // O right side
	check_pixel(cOum.x, cOum.y, 20, white, 2); // O underline (none)

    tester.advance();

    // Move to left part of O
    tester.movePointerTo(cOml.x, cOml.y);

    // Click there
    tester.click();

    // Move to centre of O
    tester.movePointerTo(cOmm.x, cOmm.y);

    // Click there a lot (shouldn't be registered)
    tester.click();
    tester.click();
    tester.click();
    tester.click();
    tester.click();
    tester.click();
    tester.click();
    tester.click();

    // Move to right part of O
    tester.movePointerTo(cOmr.x, cOmr.y);

    // Click there.
    tester.click();
    tester.movePointerTo(1, 1);

    // Just for fun. These shouldn't be registered.
    tester.click();
    tester.click();
    tester.click();
    tester.click();
    tester.click();

	for (int i=0; i<3; ++i) tester.advance(); // get to the end

	VM& vm = tester.vm();

	as_value eot;
	bool endOfTestFound = getObject(root)->get_member(getURI(vm, "endoftest"), &eot);
	check(endOfTestFound);
	check(eot.is_bool());
	check(eot.to_bool(8));

	// TODO: use check_pixel for checking bacground colors
}
コード例 #17
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	as_value tmp;

	MovieClip* root = tester.getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 2);
	check_equals(root->get_current_frame(), 0);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);

	tester.advanceClock(50); // "sleep" 50 milliseconds
	tester.advance(); // execute actions in second frame frame

	check_equals(root->get_current_frame(), 1);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);

	// Now timers are set and counters initialized

	VM& vm = tester.vm();
	const ObjectURI& thisCounter = getURI(vm, "this_counter");
	const ObjectURI& thatCounter = getURI(vm, "that_counter");
	const ObjectURI& pushedArgs = getURI(vm, "pushed_args");
	const ObjectURI& testCompleted = getURI(vm, "test_completed");

	getObject(root)->get_member(thisCounter, &tmp);
	check_equals(toNumber(tmp, vm), 0);
	getObject(root)->get_member(thatCounter, &tmp);
	check_equals(toNumber(tmp, vm), 0);

	tester.advanceClock(500); // "sleep" 500 milliseconds
	tester.advance(); // run expired timers

	getObject(root)->get_member(thisCounter, &tmp);
	check_equals(toNumber(tmp, vm), 1);
	getObject(root)->get_member(thatCounter, &tmp);
	check_equals(toNumber(tmp, vm), 0);

	tester.advanceClock(600); // "sleep" 500 milliseconds
	tester.advance(); // run expired timers

	getObject(root)->get_member(thisCounter, &tmp);
	check_equals(toNumber(tmp, vm), 2);
	getObject(root)->get_member(thatCounter, &tmp);
	check_equals(toNumber(tmp, vm), 1);

	tester.advanceClock(500); // "sleep" 500 milliseconds
	tester.advance(); // run expired timers

	getObject(root)->get_member(thisCounter, &tmp);
	check_equals(toNumber(tmp, vm), 3);
	getObject(root)->get_member(thatCounter, &tmp);
	check_equals(toNumber(tmp, vm), 1);

	tester.advanceClock(520); // "sleep" 520 milliseconds
	tester.advance(); // run expired timers

	getObject(root)->get_member(thisCounter, &tmp);
	check_equals(toNumber(tmp, vm), 4);
	getObject(root)->get_member(thatCounter, &tmp);
	check_equals(toNumber(tmp, vm), 2);

	tester.advanceClock(1020); // "sleep" 1020 milliseconds
	tester.advance(); // run expired timers

	getObject(root)->get_member(thisCounter, &tmp);
	check_equals(toNumber(tmp, vm), 4);
	getObject(root)->get_member(thatCounter, &tmp);
	check_equals(toNumber(tmp, vm), 3);

	tester.advanceClock(1020); // "sleep" 1020 milliseconds
	tester.advance(); // run expired timers

	getObject(root)->get_member(thisCounter, &tmp);
	check_equals(toNumber(tmp, vm), 4);
	getObject(root)->get_member(thatCounter, &tmp);
	check_equals(toNumber(tmp, vm), 4);

	tester.advanceClock(520); // "sleep" 520 milliseconds
	tester.advance(); // run expired timers

	getObject(root)->get_member(thisCounter, &tmp);
	check_equals(toNumber(tmp, vm), 5);
	getObject(root)->get_member(thatCounter, &tmp);
	check_equals(toNumber(tmp, vm), 4);

	getObject(root)->get_member(pushedArgs, &tmp);
	as_environment env(vm); // needed for proper to_string()
	check_equals(tmp.to_string(), std::string("8,9,10"));

	tester.advanceClock(100); // "sleep" another 100 milliseconds
	tester.advance(); // run expired timers

	getObject(root)->get_member(testCompleted, &tmp);
	check_equals(toNumber(tmp, vm), 1);

}
コード例 #18
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = INPUT_FILENAME;
	MovieTester tester(filename);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 14);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 0);

	const DisplayObject* mc1 = tester.findDisplayItemByName(*root, "mc1");
	check(mc1);

	const DisplayObject* mc2 = tester.findDisplayItemByName(*root, "mc2");
	check(mc2);

	const DisplayObject* mc3 = tester.findDisplayItemByName(*root, "mc3");
	check(mc3);

	check_equals(root->get_current_frame(), 0);
	for (unsigned f=root->get_current_frame(); f<root->get_frame_count()-1; ++f)
	{
		check_equals(root->get_current_frame(), f);
		check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
		tester.advance();
	}

	// does stop() on last frame
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
	check_equals(root->get_current_frame(), root->get_frame_count()-1);

}
コード例 #19
0
ファイル: button_test1runner.cpp プロジェクト: aopui/gnash
int
trymain(int /*argc*/, char** /*argv*/)
{
	string filename = string(BUILDDIR) + string("/") + string(INPUT_FILENAME);
	unique_ptr<MovieTester> t;

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	try
	{
		t.reset(new MovieTester(filename));
	}
	catch (const GnashException& e)
	{
		std::cerr << "Error initializing MovieTester: " << e.what() << std::endl;
		exit(EXIT_FAILURE);
	}
	
	MovieTester& tester = *t;

	// TODO: check why we need this !!
	//       I wouldn't want the first advance to be needed
	tester.advance();

	MovieClip* root = tester.getRootMovie();
	VM& vm = getVM(*getObject(root));

	check_equals(root->get_frame_count(), 1);

	rgba white(255, 255, 255, 255);
	rgba yellow(255, 255, 0, 255);
	rgba green(0,255,0,255);
	rgba red(255,0,0,255);

	// A point on the visible green button
	point visibleGreen(100, 260);

	// A point on the BIG green button, but not on the small one
	point bigGreen(100, 352);

	// A point on the yellow box, overlapping the green button
	point yellowOnGreen(127, 256);

	// A point on the yellow box, not overlapping the green button
	point yellowOffGreen(136, 231);

	// A point on the BIG yellow box, not overlapping the green button,
	// would be on the small red box...
	point bigYellowOffGreen(294,365);

	// A point on the red box, but out of the red button hit area
	point redNoHit(241, 351);

	// A point on the BIG red button, but not on the small one
	point bigRedNoHit(330, 397);

	//----------------------------------------
	// Test starts
	//----------------------------------------

	// check some pixel colors
	check_pixel(visibleGreen.x, visibleGreen.y, 2, green, 1);
	check_pixel(redNoHit.x, redNoHit.y, 2, red, 1);
	check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, red, 1); // still red, till we move over it
	check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, red, 1); // still red, till we move over it
	check_pixel(bigGreen.x, bigGreen.y, 2, white, 1); // nothing here, as long as the green is small

	// now move over the red button hit area, so it becomes yellow
	tester.movePointerTo(yellowOnGreen.x, yellowOnGreen.y);
	check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, yellow, 1); 
	check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, yellow, 1); 
	tester.movePointerTo(yellowOffGreen.x, yellowOffGreen.y);
	check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, yellow, 1); 
	check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, yellow, 1); 

	// 1. Click on the visible part of the green box.
	tester.movePointerTo(visibleGreen.x, visibleGreen.y);
	tester.click();
	tester.advance();

	// check new pixel colors
	check_pixel(visibleGreen.x, visibleGreen.y, 2, green, 1);
	check_pixel(bigGreen.x, bigGreen.y, 2, green, 1); // now green is big
	check_pixel(redNoHit.x, redNoHit.y, 2, red, 1);
	check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, red, 1); // still red, till we move over it
	check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, red, 1); // still red, till we move over it

	// 2. Now move your mouse on the top-left area of the red box (the box will become yellow),
	//    and click where it overlaps with the green one.
	tester.movePointerTo(yellowOnGreen.x, yellowOnGreen.y);

	check_pixel(visibleGreen.x, visibleGreen.y, 2, green, 1);
	check_pixel(bigGreen.x, bigGreen.y, 2, green, 1); // now green is big
	check_pixel(redNoHit.x, redNoHit.y, 2, green, 1); // the red button shrinked, showing green underneath
	check_pixel(bigRedNoHit.x, bigRedNoHit.y, 2, green, 1); // the red button is still small, but green is big
	check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, yellow, 1); // still red, till we move over it
	check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, yellow, 1); // still red, till we move over it

	tester.click(); 
	tester.advance();

	check_pixel(visibleGreen.x, visibleGreen.y, 2, green, 1);
	check_pixel(bigGreen.x, bigGreen.y, 2, white, 1); // green is small again
	check_pixel(bigRedNoHit.x, bigRedNoHit.y, 2, white, 1); // the red button grew, but pointer is in the hit area...
	check_pixel(bigYellowOffGreen.x, bigYellowOffGreen.y, 2, yellow, 1); // yellow grew
	check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, yellow, 1); // still red, till we move over it
	check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, yellow, 1); // still red, till we move over it

	tester.movePointerTo(bigRedNoHit.x, bigRedNoHit.y);
	check_pixel(bigRedNoHit.x, bigRedNoHit.y, 2, red, 1); // the red button grew, but pointer is in the hit area...
	check_pixel(bigYellowOffGreen.x, bigYellowOffGreen.y, 2, red, 1); // yellow grew, but we're not in the hit area

	//----------------------------------------
	// Check test ended completely
	//----------------------------------------

	as_value eot;
        
    getObject(root)->get_member(getURI(vm, "testcompleted"), &eot);
        
	//cerr << "EOT is " << eot.to_debug_string() << endl;
	check(eot.to_bool(8));
	return 0;
}
コード例 #20
0
ファイル: movie_clip.hpp プロジェクト: drunkenme/openswf
 inline void MovieNode::execute_named_frame_actions(const char* name)
 {
     auto frame = m_sprite->get_frame(name);
     if( frame != 0 ) execute_frame_actions(frame);
 }
コード例 #21
0
bool MovieClipTest::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
	MovieClip* mc = (MovieClip*) this->getChildByTag(this->curTag);
	if (mc) mc->stop();
	return true;
}
コード例 #22
0
ファイル: loadMovieTestRunner.cpp プロジェクト: diocles/gnash
int
main(int /*argc*/, char** /*argv*/)
{
	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	tester.reset(new MovieTester(filename));

	URL baseURL(filename);
	URL mediaURL(MEDIADIR"/");
	URL lynchURL("lynch.swf", mediaURL);
	URL greenURL("green.jpg", mediaURL);
	URL offspringURL("offspring.swf", mediaURL);
	std::string url;

	gnash::RcInitFile& rc = gnash::RcInitFile::getDefaultInstance();
	rc.addLocalSandboxPath(MEDIADIR);



	root = tester->getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 2);
	check_equals(root->get_current_frame(), 0);

	tester->advance();
	check_equals(root->get_current_frame(), 1);

	// Verify that 'coverart' exists and is empty
	DisplayObject* coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart"));
	MovieClip* coverart = coverartch->to_movie();
	check(coverart);
	url = coverart->get_root()->url();
	check_equals(coverart->get_root()->url(), baseURL.str());

	// Check scribbling on the empty canvas
	checkScribbling();

	// Click on the first (lynch)
	tester->movePointerTo(80, 80);
	check(tester->isMouseOverMouseEntity());
	tester->pressMouseButton();

    // Wait for the movie to load
    // TODO: drop this test and use a self-containment instead
    do {
	    usleep(500); // give it some time...
	    tester->advance(); // loads (should) happen on next advance
	    coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart"));
    } while (coverartch->to_movie() == coverart);

	coverart = coverartch->to_movie();
	check_equals(coverart->get_root()->url(), lynchURL.str());

	tester->depressMouseButton();

	// Check scribbling on the lynch
	checkScribbling();

	// Run 'coverart' tests..
	tester->movePointerTo(640,180);
	tester->click(); tester->advance();

	// Click on the second (green)
	tester->movePointerTo(280, 80);
	check(tester->isMouseOverMouseEntity());
	tester->click();

    // Wait for the movie to load
    // TODO: drop this test and use a self-containment instead
    do {
	    usleep(500); // give it some time... 
	    tester->advance(); // loads (should) happen on next advance
	    coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart"));
    } while (coverartch->to_movie() == coverart);

	coverart = coverartch->to_movie();
	check_equals(coverart->get_root()->url(), greenURL.str());
	// TODO: find a way to test if the jpeg is really displayed
	//       (like turn it into a mouse-event-handling char and use isMouseOverActiveEntity ?)

	// Check scribbling on the jpeg
	checkScribbling();

	// Run 'coverart' tests..
	tester->movePointerTo(640,180);
	tester->click(); tester->advance();

	// Click on the third (offspring)
	tester->movePointerTo(480, 80);
	check(tester->isMouseOverMouseEntity());
	tester->click();

    // Wait for the movie to load
    // TODO: drop this test and use a self-containment instead
    do {
	    usleep(500); // give it some time... 
	    tester->advance(); // loads (should) happen on next advance
	    coverartch = const_cast<DisplayObject*>(tester->findDisplayItemByName(*root, "coverart"));
    } while (coverartch->to_movie() == coverart);

	coverart = coverartch->to_movie();
	check_equals(coverart->get_root()->url(), offspringURL.str());

	// Check scribbling on the offspring
	checkScribbling();

	// Run 'coverart' tests..
	tester->movePointerTo(640,180);
	tester->click(); tester->advance();

	// Get summary ...
	tester->pressKey(key::SHIFT);
	tester->click(); tester->advance();
	tester->releaseKey(key::SHIFT);

	// Consistency checking
	VM& vm = getVM(*getObject(root));
	as_value eot;
	// It's an swf6, so lowercase 'END_OF_TEST'
	bool endOfTestFound = getObject(root)->get_member(getURI(vm, "end_of_test"), &eot);
	check(endOfTestFound);
	if ( endOfTestFound )
	{
		check_equals(eot.to_bool(8), true);
	}

}
コード例 #23
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 4);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 0);

	tester.advance();  // advance to the second frame.

	const DisplayObject* mc1 = tester.findDisplayItemByName(*root, "square1");
	check(mc1);
	const DisplayObject* mc2 = tester.findDisplayItemByName(*root, "square2");
	check(mc2);

	check_equals(mc1->visible(), true);
	check_equals(mc2->visible(), false);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
	check_equals(root->get_current_frame(), 1);

	// we're in stop mode, so advance should not advance anything
	tester.advance();
	check_equals(root->get_current_frame(), 1);
	tester.advance();
	check_equals(root->get_current_frame(), 1);

	// roll over the middle of the square, this should trigger
	// the addition of a goto_frame(3) action, which is executed
	// at advance() time.
	tester.movePointerTo(60, 60);
	tester.advance();
	check_equals(root->get_current_frame(), 2);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
	tester.advance();
	check_equals(root->get_current_frame(), 2);

	// keep the pointer inside
	tester.movePointerTo(41, 60);
	tester.advance();
	check_equals(root->get_current_frame(), 2);

	// pointer on the border (corner case)
	tester.movePointerTo(40, 60);
	tester.advance();
	check_equals(root->get_current_frame(), 2);
	
	// pointer out of the square.
	tester.movePointerTo(300, 60);
	//tester.advance();  // mouse event handler should drive the movie
	check_equals(root->get_current_frame(), 1);
	
	// pointer back to the square again.
	tester.movePointerTo(60, 60);
	tester.click();
	//tester.advance(); // mouse event handler should drive the movie
	check_equals(root->get_current_frame(), 3);
}
コード例 #24
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 6);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 0);

	check(! tester.findDisplayItemByDepth(*root, 71) );
	check(! tester.findDisplayItemByDepth(*root, 72) );

	tester.movePointerTo(30, 30);
	check(!tester.isMouseOverMouseEntity());

	tester.advance();
	check_equals(root->get_current_frame(), 1);

	check( tester.findDisplayItemByDepth(*root, 71) );
	check(! tester.findDisplayItemByDepth(*root, 72) );

	tester.movePointerTo(30, 30);
	check(tester.isMouseOverMouseEntity());
	tester.movePointerTo(100, 30);
	check(!tester.isMouseOverMouseEntity());

	tester.advance();
	check_equals(root->get_current_frame(), 2);

	check(tester.findDisplayItemByDepth(*root, 71) );
	check(tester.findDisplayItemByDepth(*root, 72) );

	tester.movePointerTo(30, 30);
	check(tester.isMouseOverMouseEntity());
	tester.movePointerTo(100, 30);
	check(tester.isMouseOverMouseEntity());

	tester.advance();
	check_equals(root->get_current_frame(), 3);

	check(tester.findDisplayItemByDepth(*root, 71) );
	check(tester.findDisplayItemByDepth(*root, 72) );
	check(tester.findDisplayItemByDepth(*root, 73) );

	tester.movePointerTo(30, 30);
	check(tester.isMouseOverMouseEntity());
	tester.movePointerTo(100, 30);
	check(tester.isMouseOverMouseEntity());
	tester.movePointerTo(170, 30);
	check(tester.isMouseOverMouseEntity());

	tester.advance();
	check_equals(root->get_current_frame(), 4);

	tester.movePointerTo(30, 30);
	check(tester.isMouseOverMouseEntity());
	tester.movePointerTo(100, 30);
	check(tester.isMouseOverMouseEntity());
	tester.movePointerTo(170, 30);
	check(tester.isMouseOverMouseEntity());
	tester.movePointerTo(240, 30);
	check(tester.isMouseOverMouseEntity());

	tester.advance();
	check_equals(root->get_current_frame(), 5);

	tester.advance();
	check_equals(root->get_current_frame(), 5); // we should be in stop mode
}
コード例 #25
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	if ( ! tester.canTestRendering() )
	{
		cout << "UNTESTED: rendering of embedded video (testing not possible with this build)." << endl;
		return EXIT_SUCCESS; // so testing doesn't abort
	} 

	rgba red(255,0,0,255);
	rgba yellow(255,255,0,255);

	// TODO: change the scaling of the window/canvas
	int scale_x = 1;
	int scale_y = 1;

	size_t framecount = root->get_frame_count();
	check_equals(framecount, 12);
	
	// Just loop twice, so to catch crashes...
	for (int j = 0; j < 2; ++j) {

		if ( ! tester.canTestVideo() )
		{
			// no pixel checking, but we'd still be interested in crashes...
			tester.advance();
			continue;
		}
		
		// Frame 1

		check_equals(root->get_current_frame(), 0); // 0-based

		// Check the color in (5,5) - should be red
		check_pixel(5, 5, 2, red, 5);

		// Check the color in (35,5) - should be yellow
		check_pixel(35*scale_x, 5, 2, yellow, 5);

		// Check the color in (5,35) - should be yellow
		check_pixel(5, 35*scale_y, 2, yellow, 5);

		while (true)
		{
			// Frame X
			tester.advance();
			size_t framenum = root->get_current_frame();
            assert(framenum > 0);

			cout << "---- Pixel checking in frame " << framenum+1 << " play state " << root->getPlayState() << endl;
			
			size_t i = (framenum-1)*10;

			// Check the color in (5+i,5) - should be yellow
			check_pixel((5 + i)*scale_x, 5, 2, yellow, 5);

			// Check the color in (25+i,5) - should be red
			check_pixel((25 + i)*scale_x, 5, 2, red, 5);

			// Check the color in (25+i,35) - should be yellow
			check_pixel((25 + i)*scale_x, 35*scale_y, 1, yellow, 5);

			// The video is 128x96 so we don't want to check beyond that
			if (45+i <= 128) {
				// Check the color in (45+i,5) - should be yellow
				check_pixel((45 + i)*scale_x, 5, 2, yellow, 5);
			}

			if (framenum + 2 == framecount) {
				// check we're playing, or we'll never get to next loop...
				check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
				break;
			}

			tester.click();
		}

		tester.advance();

		// Check the color in (5,5) - should be yellow. Well, anything
		// but white or transparent.
		check_pixel(5, 5, 2, yellow, 5);
		check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
		tester.click();

		// Sanity check
		check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);

		tester.advance();

	}

}
コード例 #26
0
int
main(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	MovieClip* root = tester.getRootMovie();
	assert(root);

	as_value tmp;

	check_equals(root->get_frame_count(), 6);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 0);

	check(! tester.findDisplayItemByDepth(*root, 70) );
	check(! tester.findDisplayItemByDepth(*root, 71) );
	check(! tester.findDisplayItemByDepth(*root, 72) );
	check(! tester.findDisplayItemByDepth(*root, 73) );

	tester.movePointerTo(30, 30);
	check(!tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is white
	check_pixel(30, 30, 2, rgba(255,255,255,255), 2);

	tester.advance();

	check(tester.findDisplayItemByDepth(*root, 70) );
	check(! tester.findDisplayItemByDepth(*root, 71) );
	check(! tester.findDisplayItemByDepth(*root, 72) );
	check(! tester.findDisplayItemByDepth(*root, 73) );

	tester.movePointerTo(30, 30);
	check(tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is red
	check_pixel(30, 30, 2, rgba(255,0,0,255), 2);

	tester.movePointerTo(100, 30);
	check(!tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is white
	check_pixel(100, 30, 2, rgba(255,255,255,255), 2);

	VM& vm = tester.vm();
	const ObjectURI& mousedown = getURI(vm, "mousedown");
	const ObjectURI& mouseup = getURI(vm, "mouseup");

	getObject(root)->get_member(mousedown, &tmp);
	check(tmp.is_undefined());
	getObject(root)->get_member(mouseup, &tmp);
	check(tmp.is_undefined());

	// Note that we are *not* on an active entity !
	tester.pressMouseButton();

	getObject(root)->get_member(mousedown, &tmp);
	check_equals(toNumber(tmp, vm), 1);
	check ( ! getObject(root)->get_member(mouseup, &tmp) );

	tester.depressMouseButton();

	getObject(root)->get_member(mousedown, &tmp);
	check_equals(toNumber(tmp, vm), 1);
	getObject(root)->get_member(mouseup, &tmp);
	check_equals(toNumber(tmp, vm), 1);

	tester.advance();

	check( tester.findDisplayItemByDepth(*root, 70) );
	check( tester.findDisplayItemByDepth(*root, 71) );
	check(! tester.findDisplayItemByDepth(*root, 72) );
	check(! tester.findDisplayItemByDepth(*root, 73) );

	tester.movePointerTo(100, 30);
	check(tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is red
	check_pixel(100, 30, 2, rgba(255,0,0,255), 2);

	tester.movePointerTo(170, 30);
	check(!tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is white
	check_pixel(170, 30, 2, rgba(255,255,255,255), 2);

	tester.advance();

	check( tester.findDisplayItemByDepth(*root, 70) );
	check( tester.findDisplayItemByDepth(*root, 71) );
	check( tester.findDisplayItemByDepth(*root, 72) );
	check(! tester.findDisplayItemByDepth(*root, 73) );

	tester.movePointerTo(170, 30);
	check(tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is red
	check_pixel(170, 30, 2, rgba(255,0,0,255), 2);

	tester.movePointerTo(240, 30);
	check(!tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is white
	check_pixel(240, 30, 2, rgba(255,255,255,255), 2);

	tester.advance();

	check( tester.findDisplayItemByDepth(*root, 70) );
	check( tester.findDisplayItemByDepth(*root, 71) );
	check( tester.findDisplayItemByDepth(*root, 72) );
	check( tester.findDisplayItemByDepth(*root, 73) );

	tester.movePointerTo(240, 30);
	check(tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is red
	check_pixel(240, 30, 2, rgba(255,0,0,255), 2);

	tester.movePointerTo(340, 30);
	check(! tester.isMouseOverMouseEntity());
	// check that the pixel under the mouse is white
	check_pixel(340, 30, 2, rgba(255,255,255,255), 2);

	// Note that we are *not* on an active entity !
	tester.pressMouseButton();

	getObject(root)->get_member(mousedown, &tmp);
	check_equals(toNumber(tmp, vm), 5);

}
コード例 #27
0
int
main(int /*argc*/, char** /*argv*/)
{
	typedef gnash::geometry::SnappingRanges2d<int> Ranges;
	typedef gnash::geometry::Range2d<int> Bounds;

	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
	dbglogfile.setVerbosity(1);

	// Colors we'll use during the test
	rgba red(255,0,0,255);
	rgba white(255,255,255,255);
	rgba black(0,0,0,255);

	// Ranges we'll use during the test
	Range2d<int> redRange(300,300,360,360);
	Range2d<int> blackRange(330,270,450,390);

	// Coordinates we'll use during testing
	int x_left = 270; // on the left of any DisplayObject
	int x_red = 310; // on the red square
	int x_int = 340; // on the intersection between the red and black squares
	int x_black = 370; // on black square
	int x_right = 460; // on the right of any DisplayObject
	int y = 330;

	Ranges invalidated;
	MovieClip* root = tester.getRootMovie();
	assert(root);

	// FRAME 1 (start)

	check_equals(root->get_frame_count(), 4);
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 0);
	check_equals(root->getDisplayList().size(), 1);  // dejagnu clip
	invalidated = tester.getInvalidatedRanges();
	check( invalidated.contains(76, 4) ); // the "-xtrace enabled-" label...

	tester.advance(); // FRAME 2, place DisplayObjects (black on top)
	invalidated = tester.getInvalidatedRanges();
	
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 1);
	check_equals(root->getDisplayList().size(), 3); // dejagnu + red square + black square

	// check invalidated bounds contain both the red and black square
	check( invalidated.contains(redRange) );
	check( invalidated.contains(blackRange) );
	
	// Check that the black square is over the red square
	check_pixel(x_left, y, 2, white, 2); 
	check_pixel(x_red, y, 2, red, 2); 
	check_pixel(x_int, y, 2, black, 2);  // black is *over* red square
	check_pixel(x_black, y, 2, black, 2);  
	check_pixel(x_right, y, 2, white, 2);  

	tester.advance(); // FRAME 3, depth-swap the two DisplayObjects
	invalidated = tester.getInvalidatedRanges();
	
	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
	check_equals(root->get_current_frame(), 2);
	check_equals(root->getDisplayList().size(), 3); // dejagnu + red square + black square

	// check invalidated bounds to contain the intersection
	// between the two DisplayObjects.
	//
	check( invalidated.contains(Intersection(redRange,blackRange)) );
	
	// Check that the black square is now behind the red square
	check_pixel(x_left, y, 2, white, 2); 
	check_pixel(x_red, y, 2, red, 2); 
	check_pixel(x_int, y, 2, red, 2);  // black is *behind* red square
	check_pixel(x_black, y, 2, black, 2);  
	check_pixel(x_right, y, 2, white, 2);  

	tester.advance(); // FRAME 4, jump to frame 2 and stop
	invalidated = tester.getInvalidatedRanges();

	check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
	check_equals(root->get_current_frame(), 1);
	check_equals(root->getDisplayList().size(), 3); // dejagnu + red square + black square

	// Invalidated bounds can't be Null because something is printed 
	// in the XTRACE window... Anyway, the squares should be far enoguh
	// to assume the invalidated bounds won't contain their intersection
	//
	// Gnash has an huge invalidated bounds for the whole movie lifetime, btw....
	// 
	xcheck( ! invalidated.intersects(Intersection(redRange,blackRange)) );

	// Check that the black square is still behind the red square
	check_pixel(x_left, y, 2, white, 2); 
	check_pixel(x_red, y, 2, red, 2); 
	check_pixel(x_int, y, 2, red, 2);  // black is *behind* red square
	check_pixel(x_black, y, 2, black, 2);  
	check_pixel(x_right, y, 2, white, 2);  
}
コード例 #28
0
int
main(int /*argc*/, char** /*argv*/)
{
  string filename =  string(INPUT_FILENAME);
  MovieTester tester(filename);

  gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
  dbglogfile.setVerbosity(1);

  MovieClip* root = tester.getRootMovie();
  assert(root);

  check_equals(root->get_frame_count(), 24);
  check_equals(root->get_current_frame(), 0);

  tester.advance();
  tester.advance();
  // check we are stopped at frame2
  check_equals(root->get_current_frame(), 1);
  
  // provide a key press to continue the test
  tester.pressKey(key::A);
  tester.releaseKey(key::A);
  
  tester.advance();
  check_equals(root->get_current_frame(), 2);
  
  tester.advance();
  tester.advance();
  // check we are stopped at frame4
  check_equals(root->get_current_frame(), 3);
  
  // provide a key press to continue the test
  tester.pressKey(key::B);
  tester.releaseKey(key::B);
    
  tester.advance();
  check_equals(root->get_current_frame(), 4);
  
  tester.advance();
  tester.advance();
  // check we are stopped at frame6
  check_equals(root->get_current_frame(), 5);
 
  // provide a key press to continue the test
  tester.pressKey(key::C);
  tester.releaseKey(key::C);
    
  tester.advance();
  check_equals(root->get_current_frame(), 6);
  
  tester.advance();
  check_equals(root->get_current_frame(), 7);
  
  tester.advance();
  tester.advance();
  // check we are stopped at frame9
  check_equals(root->get_current_frame(), 8);
  
  // provide a key press to continue the test
  tester.pressKey(key::D);
  tester.releaseKey(key::D);
  
  // we have jumped back to frame8
  check_equals(root->get_current_frame(), 7);
  
  tester.advance();
  // and we are in frame9 again
  check_equals(root->get_current_frame(), 8);
  
  // provide a key press to continue the test
  tester.pressKey(key::E);
  tester.releaseKey(key::E);
  	
  // we have jumped forward to frame10
  check_equals(root->get_current_frame(), 9);
  
  tester.advance();
  check_equals(root->get_current_frame(), 10);
  
  tester.advance();
  tester.advance();
  // check we are stopped at frame12
  check_equals(root->get_current_frame(), 11);
  
  // provide a key press to continue the test
  tester.pressKey(key::F);
  tester.releaseKey(key::F);
  
  // we have jumped backward to frame11
  check_equals(root->get_current_frame(), 10);
  
  tester.advance();
  // and we are in frame12 again
  check_equals(root->get_current_frame(), 11);
  
  // provide a key press to continue the test
  tester.pressKey(key::G);
  tester.releaseKey(key::G);
  // we have jumped forward to frame13
  check_equals(root->get_current_frame(), 12);
  
  tester.advance();
  tester.advance();
  // check we are stopped at frame14
  check_equals(root->get_current_frame(), 13);
  
  // provide a key press to continue the test
  tester.pressKey(key::H);
  tester.releaseKey(key::H);
    
  tester.advance();
  tester.advance();
  // check we are stopped at frame15
  check_equals(root->get_current_frame(), 14);
  
  // provide a key press to continue the test
  tester.pressKey(key::I);
  tester.releaseKey(key::I);
  
  // check we have jumped to frame16
  check_equals(root->get_current_frame(), 15);
  
  for(int i=0; i<10; i++)
  {
 	 tester.advance();
  }
  // check we are stopped at frame20
  check_equals(root->get_current_frame(), 19);
  
  // provide a key press to continue the test
  tester.pressKey(key::J);
  tester.releaseKey(key::J);
  // check have jumped to frame21
  check_equals(root->get_current_frame(), 20);
  
  tester.advance();
  tester.advance();
  // check we are stopped at frame22
  check_equals(root->get_current_frame(), 21);
  
  // provide a key press to continue the test
  tester.pressKey(key::K);
  tester.releaseKey(key::K);
  tester.advance();

  // Select the text field
  tester.movePointerTo(310, 25);
  tester.click();

  // Enter 'i'
  tester.pressKey(key::i);
  tester.advance();

  // reached frame23, test finished
  check_equals(root->get_current_frame(), 23);
}
コード例 #29
0
int
main(int /*argc*/, char** /*argv*/)
{
	//string filename = INPUT_FILENAME;
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	MovieTester tester(filename);

	std::string idleString = "Idle";

	MovieClip* root = tester.getRootMovie();
	assert(root);

	check_equals(root->get_frame_count(), 7);

	check_equals(root->get_current_frame(), 0);

	const TextField* text = dynamic_cast<const TextField*>(
		tester.findDisplayItemByName(*root, "textfield"));
	check(text);

	const TextField* text2 = dynamic_cast<const TextField*>(
		tester.findDisplayItemByName(*root, "textfield2"));
	check(text2);

	const TextField* text3 = dynamic_cast<const TextField*>(
		tester.findDisplayItemByName(*root, "textfield3"));
	check(text3);

	check_equals(string(text->get_text_value()), idleString);
	check_equals(string(text2->get_text_value()), idleString);
	check_equals(string(text3->get_text_value()), idleString);

	tester.advance();
	check_equals(root->get_current_frame(), 1);

	const DisplayObject* mc1 = tester.findDisplayItemByName(*root, "square1");
	check(mc1);
	check_equals(mc1->get_depth(), 2+DisplayObject::staticDepthOffset);

	check(!tester.isMouseOverMouseEntity());
	check(!tester.usingHandCursor());

	// check that pixel @ 60,60 is red !
	rgba red(255,0,0,255);
	check_pixel(60, 60, 2, red, 2);

	tester.advance();
	check_equals(root->get_current_frame(), 2);
	tester.advance();
	check_equals(root->get_current_frame(), 2); // need to roll out

	tester.movePointerTo(60, 60); // roll over the square
	check(tester.isMouseOverMouseEntity());
	check(tester.usingHandCursor());
	check_equals(root->get_current_frame(), 2); // need to roll out

	tester.movePointerTo(0, 0); // roll out, should go to next frame
	check(!tester.isMouseOverMouseEntity());
	check(!tester.usingHandCursor());
	check_equals(root->get_current_frame(), 3); 

	for (size_t fno=root->get_current_frame(); fno<root->get_frame_count(); fno++)
	{
		const DisplayObject* square_back = tester.findDisplayItemByDepth(*root, 1+DisplayObject::staticDepthOffset);
		const DisplayObject* square_front = tester.findDisplayItemByDepth(*root, 3+DisplayObject::staticDepthOffset);

		switch (fno)
		{
			case 3:
				check(!square_back);
				check(!square_front);
				break;
			case 4:
				check(square_back);
				check(!square_front);
				break;
			case 5:
				check(square_back);
				check(square_front);
				break;
		}

		check_equals(root->get_current_frame(), fno);

		info (("testing mouse activity in frame %d", root->get_current_frame()));
		test_mouse_activity(tester, text, text2, square_front!=NULL, fno != root->get_frame_count()-1);

		// TODO: test key presses !
		//       They seem NOT to trigger immediate redraw

		tester.advance();

	}

	// last advance should not restart the loop (it's in STOP mode)
        check_equals(root->getPlayState(), MovieClip::PLAYSTATE_STOP);
	check_equals(root->get_current_frame(), 6);

}
コード例 #30
0
int
trymain(int /*argc*/, char** /*argv*/)
{
	string filename = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
	unique_ptr<MovieTester> t;

	try
	{
		t.reset(new MovieTester(filename));
	}
	catch (const GnashException& e)
	{
		std::cerr << "Error initializing MovieTester: " << e.what() << std::endl;
		exit(EXIT_FAILURE);
	}

	MovieTester& tester = *t;

	tester.advance();

	MovieClip* root = tester.getRootMovie();
	assert(root);

	VM& vm = getVM(*getObject(root));

	if ( ! tester.canTestSound() )
	{
		cout << "UNTESTED: sounds can't be tested with this build." << endl;
		return EXIT_SUCCESS; // so testing doesn't abort
	} 

	const int totalFrames = root->get_frame_count();

	// Make sure you adjust this with the test!
	cerr << "Total frames: " <<  totalFrames << endl;
	assert (totalFrames == 26);

	int numSoundsStarted[] = {
		0, 
		4, // Multiple   (+4 sounds started)
		6, // NoMultiple (+2 sounds started)
        9, // Trimmed    (+3 sounds started)
        14 // Attached   (+5 sounds started)
	};

	/// Expected success for each test
	bool testPasses[] = {
		true,
		true,
		true,
		true,
		true
	};

	// Advance and check...
	int frame = root->get_current_frame();
	int test = 0;
	while (frame <= totalFrames) {
		as_value testReady;
		if (getObject(root)->get_member(getURI(vm, "testReady"), &testReady)) {

			getObject(root)->delProperty(getURI(vm, "testReady"));
			
			// When a test is ready, check the result of the previous test.
			if (testPasses[test]) {
				check_equals(tester.soundsStarted(), numSoundsStarted[test]);
			}
			else {
				xcheck_equals(tester.soundsStarted(), numSoundsStarted[test]);
			}

			check_equals(tester.soundsStopped(), tester.soundsStarted());
            check_equals(tester.streamingSound(), false);
			++test;
			tester.click();

		}
		tester.advance();
		frame++;
	}

    if (testPasses[test]) {
        check_equals(tester.soundsStarted(), numSoundsStarted[test]);
    }
    else {
        xcheck_equals(tester.soundsStarted(), numSoundsStarted[test]);
    }

    // Consistency checking
    as_value eot;
    bool endOfTestFound =
        getObject(root)->get_member(getURI(vm, "endoftest"), &eot);
    check(endOfTestFound);

    return EXIT_SUCCESS;
}