CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/05/24 12:08:04
Modified files: . : ChangeLog testsuite/misc-ming.all: Makefile.am replace_sprites1test.c Added files: testsuite/misc-ming.all: replace_buttons1test.c replace_buttons1test_runner.cpp Log message: * testsuite/misc-ming.all/: Makefile.am, replace_buttons1test.c, replace_buttons1test_runner.cpp: New test for buttons replacement. * testsuite/misc-ming.all/replace_sprites1test.c: Add new test checking for _x. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3337&r2=1.3338 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.129&r2=1.130 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/replace_sprites1test.c?cvsroot=gnash&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/replace_buttons1test.c?cvsroot=gnash&rev=1.1 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/replace_buttons1test_runner.cpp?cvsroot=gnash&rev=1.1 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.3337 retrieving revision 1.3338 diff -u -b -r1.3337 -r1.3338 --- ChangeLog 24 May 2007 11:57:54 -0000 1.3337 +++ ChangeLog 24 May 2007 12:08:03 -0000 1.3338 @@ -1,5 +1,13 @@ 2007-05-24 Sandro Santilli <[EMAIL PROTECTED]> + * testsuite/misc-ming.all/: Makefile.am, + replace_buttons1test.c, replace_buttons1test_runner.cpp: + New test for buttons replacement. + * testsuite/misc-ming.all/replace_sprites1test.c: + Add new test checking for _x. + +2007-05-24 Sandro Santilli <[EMAIL PROTECTED]> + * server/dlist.cpp (replace_character): always call ::construct on the new character. * backend/sound_handler_sdl.h: fix const-correctness Index: testsuite/misc-ming.all/Makefile.am =================================================================== RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v retrieving revision 1.129 retrieving revision 1.130 diff -u -b -r1.129 -r1.130 --- testsuite/misc-ming.all/Makefile.am 24 May 2007 07:31:45 -0000 1.129 +++ testsuite/misc-ming.all/Makefile.am 24 May 2007 12:08:03 -0000 1.130 @@ -163,6 +163,7 @@ check_PROGRAMS += \ replace_shapes1test \ replace_sprites1test \ + replace_buttons1test \ $(NULL) endif @@ -237,6 +238,7 @@ check_PROGRAMS += \ replace_shapes1test_runner \ replace_sprites1test_runner \ + replace_buttons1test_runner \ $(NULL) endif @@ -685,6 +687,27 @@ replace_sprites1test.swf \ $(NULL) +replace_buttons1test_SOURCES = replace_buttons1test.c +replace_buttons1test_LDADD = libgnashmingutils.la + +replace_buttons1test.swf: replace_buttons1test + ./replace_buttons1test $(top_srcdir)/testsuite/media + +replace_buttons1test_runner_SOURCES = \ + replace_buttons1test_runner.cpp \ + $(NULL) +replace_buttons1test_runner_CXXFLAGS = \ + -DTGTDIR='"$(abs_builddir)"' \ + $(NULL) +replace_buttons1test_runner_LDADD = \ + $(top_builddir)/testsuite/libtestsuite.la \ + $(NULL) +replace_buttons1test_runner_DEPENDENCIES = \ + $(top_builddir)/testsuite/libtestsuite.la \ + replace_buttons1test.swf \ + $(NULL) + + masks_test_SOURCES = \ masks_test.c \ $(NULL) @@ -1464,6 +1487,7 @@ TEST_CASES += \ replace_shapes1test_runner \ replace_sprites1test_runner \ + replace_buttons1test_runner \ $(NULL) endif Index: testsuite/misc-ming.all/replace_sprites1test.c =================================================================== RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/replace_sprites1test.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- testsuite/misc-ming.all/replace_sprites1test.c 24 May 2007 06:45:29 -0000 1.5 +++ testsuite/misc-ming.all/replace_sprites1test.c 24 May 2007 12:08:04 -0000 1.6 @@ -42,9 +42,9 @@ * * Expected behaviour: * - * A single "movieclip" instances have been constructed in total. - * The instance contains a red shape at (100,300) initially, still a red shape - * at (130,330) after the replace, a red shape at (100,300) again on loop-back. + * In frame 2 we have a red square at (100,300), in frame 3 we have a red square at (130,330), + * after the jump-back we have a red square at (100,300) again. + * The name specified in the PlaceObject2 tag in frame 2 always point to the same instance */ #include "ming_utils.h" @@ -180,6 +180,7 @@ xcheck_equals(mo, "typeof(static1)", "'movieclip'"); xcheck_equals(mo, "static1.name", "'static1'"); xcheck_equals(mo, "static1._target", "'/static1'"); + xcheck_equals(mo, "static1._x", "130"); // While the new name results undefined... xcheck_equals(mo, "typeof(static2)", "'undefined'"); Index: testsuite/misc-ming.all/replace_buttons1test.c =================================================================== RCS file: testsuite/misc-ming.all/replace_buttons1test.c diff -N testsuite/misc-ming.all/replace_buttons1test.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/misc-ming.all/replace_buttons1test.c 24 May 2007 12:08:04 -0000 1.1 @@ -0,0 +1,242 @@ +/* + * Copyright (C) 2007 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +/* + * Sandro Santilli, [EMAIL PROTECTED] + * + * Test "Jump backward to start of lifetime after replacement with different button" + * + * run as ./replace_buttons1test + * + * Timeline: + * + * Frame | 1 | 2 | 3 | 4 | 5 | 6 | 7 | + * --------+---+---+---+---+---+---+---+ + * Event | |P* | X | J | | | | + * + * P = place (by PlaceObject2) + * X = replace (by PlaceObject2) + * J = jump + * * = jump target + * + * Description: + * + * frame2: button 1 placed at depth -16381 and position 100,300 + * frame3: instance at depth -16381 replaced by button 2 at position 130,330 + * frame4: jump back to frame 2 and stop + * + * Expected behaviour: + * + * In frame 2 we have a red square at (100,300), in frame 3 we have a red square at (130,330), + * after the jump-back we have a red square at (100,300) again. + * The name specified in the PlaceObject2 tag in frame 2 always point to the same instance + */ + +#include "ming_utils.h" + +#include <stdlib.h> +#include <stdio.h> +#include <ming.h> + +#define OUTPUT_VERSION 6 +#define OUTPUT_FILENAME "replace_buttons1test.swf" + +SWFDisplayItem add_static_mc(SWFMovie mo, const char* name, int depth, int x, int y, int width, int height); +SWFMovieClip get_static_mc(int width, int height, int r, int g, int b); +SWFShape get_shape(int width, int height, int r, int g, int b); +SWFButton get_button(int width, int height, int r, int g, int b); + +SWFShape +get_shape(int width, int height, int r, int g, int b) +{ + SWFShape sh; + + /*sh = make_fill_square (-(width/2), -(height/2), width, height, r, g, b, r, g, b);*/ + sh = make_fill_square (0, 0, width, height, r, g, b, r, g, b); + + return sh; +} + +SWFButton +get_button(int width, int height, int r, int g, int b) +{ + SWFButton bu = newSWFButton(); + SWFShape sh; + + sh = make_fill_square (0, 0, width, height, r, g, b, r, g, b); + + SWFButton_addShape(bu, (SWFCharacter)sh, SWFBUTTON_UP ); + + return bu; +} + +SWFMovieClip +get_static_mc(int width, int height, int r, int g, int b) +{ + SWFShape sh = get_shape(width, height, r, g, b); + SWFMovieClip mc = newSWFMovieClip(); + + SWFMovieClip_add(mc, (SWFBlock)sh); + + SWFMovieClip_nextFrame(mc); + + return mc; + +} + +SWFDisplayItem +add_static_mc(SWFMovie mo, const char* name, int depth, int x, int y, int width, int height) +{ + SWFMovieClip mc; + SWFDisplayItem it; + + mc = get_static_mc(width, height, 255, 0, 0); + + it = SWFMovie_add(mo, (SWFBlock)mc); + SWFDisplayItem_setDepth(it, depth); + SWFDisplayItem_moveTo(it, x, y); + SWFDisplayItem_setName(it, name); + + return it; +} + + +int +main(int argc, char** argv) +{ + SWFMovie mo; + SWFMovieClip dejagnuclip; + SWFButton static1, static2; + SWFDisplayItem it1; + + + const char *srcdir="."; + if ( argc>1 ) + srcdir=argv[1]; + else + { + //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]); + //return 1; + } + + Ming_init(); + mo = newSWFMovieWithVersion(OUTPUT_VERSION); + SWFMovie_setDimension(mo, 800, 600); + SWFMovie_setRate (mo, 2); + + static1 = get_button(60, 60, 255, 0, 0); + static2 = get_button(60, 60, 0, 255, 0); + + dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600); + SWFMovie_add(mo, (SWFBlock)dejagnuclip); + SWFMovie_nextFrame(mo); + + // Frame 2: place character at depth 3 (-16381) + it1 = SWFMovie_add(mo, (SWFBlock)static1); + SWFDisplayItem_setDepth(it1, 3); + SWFDisplayItem_moveTo(it1, 100, 300); + SWFDisplayItem_setName(it1, "static1"); + SWFDisplayItem_addAction(it1, newSWFAction( + "_root.note(this+' onClipConstruct');" + " _root.check_equals(typeof(_root), 'movieclip');" + " if ( isNaN(_root.depth3Constructed) ) {" + " _root.depth3Constructed=1; " + " } else {" + " _root.depth3Constructed++;" + " }" + " _root.note('_root.depth3Constructed set to '+_root.depth3Constructed);" + ), SWFACTION_CONSTRUCT); + add_actions(mo, "static1.name='static1';"); + + check_equals(mo, "typeof(static1)", "'object'"); + check_equals(mo, "static1._target", "'/static1'"); + check_equals(mo, "static1.name", "'static1'"); + + SWFMovie_nextFrame(mo); + + // Frame 3: replace instance at depth -16381 with character 2 + if ( SWFMovie_replace(mo, it1, (SWFBlock)static2) ) + { + abort(); // grace and beauty... + } + SWFDisplayItem_moveTo(it1, 130, 330); + SWFDisplayItem_setName(it1, "static2"); + SWFDisplayItem_addAction(it1, newSWFAction( + "_root.note(this+' onClipConstruct');" + " _root.check_equals(typeof(_root), 'movieclip');" + " if ( isNaN(_root.depth3Constructed) ) {" + " _root.depth3Constructed=1; " + " } else {" + " _root.depth3Constructed++;" + " }" + " _root.note('_root.depth3Constructed set to '+_root.depth3Constructed);" + ), SWFACTION_CONSTRUCT); + + + // Can still reference the old character and it's variables, after replace + xcheck_equals(mo, "typeof(static2)", "'undefined'"); + xcheck_equals(mo, "typeof(static1)", "'object'"); + xcheck_equals(mo, "static1._target", "'/static1'"); + xcheck_equals(mo, "static1.name", "'static1'"); + xcheck_equals(mo, "static1._x", "130"); + + // While the new name results undefined... + xcheck_equals(mo, "typeof(static2)", "'undefined'"); // the name wasn't changed + + // Everything suggests that a new instance is NOT created on replace !!! + // Gnash here fails because it creates a NEW instance + + // We can't check the color or the _x in a self-contained testcase unfortunately, + // we'll need a MovieTester-based runner for this. + // It is expected the color of the current instane is GREEN, and the boundaries + // are from 130 to 190 for X and 330 to 390 for Y. + // TODO: implement a MovieTester based runner !! + + SWFMovie_nextFrame(mo); + + // Frame 4: jump to frame 2, stop and check + + add_actions(mo, + + "gotoAndStop(2); " + + // Shapes don't get their onConstruct event invoked ! + "check_equals(typeof(_root.depth3Constructed), 'undefined');" + + // Original character name is still referenceable + "check_equals(typeof(static1), 'object');" + + // It's a new instance ! + "check_equals(typeof(static1.name), 'undefined');" + + // We can't check the color or the _x in a self-contained testcase unfortunately, + // we'll need a MovieTester-based runner for this. + // It is expected the color of the current instance is RED, and the boundaries + // are from 100 to 120 for both X and Y. + // TODO: implement a MovieTester based runner !! + + "totals();" + ); + SWFMovie_nextFrame(mo); + + //Output movie + puts("Saving " OUTPUT_FILENAME ); + SWFMovie_save(mo, OUTPUT_FILENAME); + + return 0; +} Index: testsuite/misc-ming.all/replace_buttons1test_runner.cpp =================================================================== RCS file: testsuite/misc-ming.all/replace_buttons1test_runner.cpp diff -N testsuite/misc-ming.all/replace_buttons1test_runner.cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/misc-ming.all/replace_buttons1test_runner.cpp 24 May 2007 12:08:04 -0000 1.1 @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2007 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * + */ + +#define INPUT_FILENAME "replace_buttons1test.swf" + +#include "MovieTester.h" +#include "sprite_instance.h" +#include "character.h" +#include "dlist.h" +#include "container.h" +#include "log.h" + +#include "check.h" +#include <string> +#include <cassert> + +using namespace gnash; +using namespace std; +using namespace gnash::geometry; + +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); + + // Ranges we'll use during the test + Range2d<int> redRange1(100,300,160,360); + Range2d<int> redRange2(130,330,190,390); + + Ranges invalidated; + sprite_instance* root = tester.getRootMovie(); + assert(root); + + // FRAME 1 (start) + + check_equals(root->get_frame_count(), 4); + check_equals(root->get_play_state(), sprite_instance::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 character + invalidated = tester.getInvalidatedRanges(); + + check_equals(root->get_play_state(), sprite_instance::PLAY); + check_equals(root->get_current_frame(), 1); + check_equals(root->getDisplayList().size(), 2); // dejagnu + red square + + // check invalidated bounds contain the red square at (100,300 - 160,360) + check( invalidated.contains(redRange1) ); + + // 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 character + invalidated = tester.getInvalidatedRanges(); + + check_equals(root->get_play_state(), sprite_instance::PLAY); + check_equals(root->get_current_frame(), 2); + check_equals(root->getDisplayList().size(), 2); // dejagnu + red square + + // check invalidated bounds to contain: + // - the red square (moved) + // - the red square (original) + // + check( invalidated.contains(redRange1) ); + check( invalidated.contains(redRange2) ); + + // check that we have a red square at (130,330 - 190,390) + // Gnash fails here becase it does a *real* replace, while it + // seems we're not supposed to replace, just to move (who knows why?!) + xcheck_pixel(134, 334, 2, red, 2); // UL + xcheck_pixel(186, 334, 2, red, 2); // UR + xcheck_pixel(186, 386, 2, red, 2); // LL + xcheck_pixel(134, 386, 2, red, 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->get_play_state(), sprite_instance::STOP); + check_equals(root->get_current_frame(), 1); + check_equals(root->getDisplayList().size(), 2); // dejagnu + red square + + // check invalidated bounds to contain: + // - the red square (moved) + // - the red square (original) + // + check( invalidated.contains(redRange1) ); + check( invalidated.contains(redRange2) ); + + // 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 + +} + _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit