Пример #1
0
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);
}
Пример #2
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);  
}
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

}
Пример #4
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);

	// 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;
}