[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog testsuite/misc-ming.all/Makefil...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog testsuite/misc-ming.all/Makefil... |
Date: |
Mon, 16 Oct 2006 12:01:39 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/10/16 12:01:39
Modified files:
. : ChangeLog
testsuite/misc-ming.all: Makefile.am
Added files:
testsuite/misc-ming.all: RollOverOutTest-Runner.cpp
RollOverOutTest.c
Log message:
new test for RollOver and RollOut events
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1231&r2=1.1232
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/RollOverOutTest-Runner.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/RollOverOutTest.c?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1231
retrieving revision 1.1232
diff -u -b -r1.1231 -r1.1232
--- ChangeLog 16 Oct 2006 11:57:41 -0000 1.1231
+++ ChangeLog 16 Oct 2006 12:01:39 -0000 1.1232
@@ -1,5 +1,7 @@
2006-10-16 Sandro Santilli <address@hidden>
+ * testsuite/misc-ming.all/: Makefile.am, RollOverOutTest-Runner.cpp,
+ RollOverOutTest.c: new test for RollOver and RollOut events
* testsuite/misc-ming.all/ming_utils.{c,h}: added make_fill_square()
function.
* testsuite/MovieTester.{cpp,h}: added movePointerTo() method
Index: testsuite/misc-ming.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- testsuite/misc-ming.all/Makefile.am 15 Oct 2006 15:57:42 -0000 1.23
+++ testsuite/misc-ming.all/Makefile.am 16 Oct 2006 12:01:39 -0000 1.24
@@ -65,7 +65,9 @@
DefineEditTextTest \
DefineEditTextVariableNameTest \
DefineEditTextVariableNameTest-Runner \
+ RollOverOutTest-Runner \
spritehier \
+ RollOverOutTest \
PlaceObject2Test \
RemoveObject2Test
@@ -138,6 +140,24 @@
RemoveObject2Test.swf: RemoveObject2Test
./RemoveObject2Test
+RollOverOutTest_SOURCES = \
+ RollOverOutTest.c \
+ ming_utils.h \
+ ming_utils.c \
+ $(NULL)
+RollOverOutTest_LDADD = $(MING_LIBS)
+RollOverOutTest.swf: RollOverOutTest
+ ./RollOverOutTest $(top_srcdir)/testsuite/media
+RollOverOutTest_Runner_SOURCES = \
+ RollOverOutTest-Runner.cpp \
+ $(NULL)
+RollOverOutTest_Runner_LDADD = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ $(NULL)
+RollOverOutTest_Runner_DEPENDENCIES = \
+ RollOverOutTest.swf \
+ $(NULL)
+
clean-local:
-rm *.swf media
Index: testsuite/misc-ming.all/RollOverOutTest-Runner.cpp
===================================================================
RCS file: testsuite/misc-ming.all/RollOverOutTest-Runner.cpp
diff -N testsuite/misc-ming.all/RollOverOutTest-Runner.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/RollOverOutTest-Runner.cpp 16 Oct 2006 12:01:39
-0000 1.1
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2005, 2006 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
+ *
+ * Linking Gnash statically or dynamically with other modules is making a
+ * combined work based on Gnash. Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of Gnash give you
+ * permission to combine Gnash with free software programs or libraries
+ * that are released under the GNU LGPL and with code included in any
+ * release of Talkback distributed by the Mozilla Foundation. You may
+ * copy and distribute such a system following the terms of the GNU GPL
+ * for all but the LGPL-covered parts and Talkback, and following the
+ * LGPL for the LGPL-covered parts.
+ *
+ * Note that people who make modified versions of Gnash are not obligated
+ * to grant this special exception for their modified versions; it is their
+ * choice whether to do so. The GNU General Public License gives permission
+ * to release a modified version without this exception; this exception
+ * also makes it possible to release a modified version which carries
+ * forward this exception.
+ *
+ */
+
+#define INPUT_FILENAME "RollOverOutTest.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;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+ string filename = INPUT_FILENAME;
+ MovieTester tester(filename);
+
+ // TODO: check why we need this !!
+ // I wouldn't want the first advance to be needed
+ tester.advance();
+
+ dbglogfile.setVerbosity(1);
+
+ sprite_instance* root = tester.getRootMovie();
+ assert(root);
+
+ check_equals(root->get_frame_count(), 3);
+ check_equals(root->get_play_state(), movie_interface::PLAY);
+ check_equals(root->get_current_frame(), 0);
+
+ const character* mc1 = tester.findDisplayItemByName(*root, "square1");
+ check(mc1);
+ const character* mc2 = tester.findDisplayItemByName(*root, "square2");
+ check(mc2);
+ check_equals(mc1->get_visible(), false);
+ check_equals(mc2->get_visible(), false);
+
+ tester.advance();
+
+ check_equals(mc1->get_visible(), true);
+ check_equals(mc2->get_visible(), false);
+
+ //check_equals(mc1->get_height(), 40*20);
+ //check_equals(mc1->get_width(), 40*20);
+ check_equals(root->get_play_state(), movie_interface::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);
+ 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(2) action, which is executed
+ // at advance() time.
+ tester.movePointerTo(60, 60);
+ tester.advance();
+ check_equals(root->get_current_frame(), 2);
+ check_equals(root->get_play_state(), movie_interface::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);
+
+}
+
Index: testsuite/misc-ming.all/RollOverOutTest.c
===================================================================
RCS file: testsuite/misc-ming.all/RollOverOutTest.c
diff -N testsuite/misc-ming.all/RollOverOutTest.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/RollOverOutTest.c 16 Oct 2006 12:01:39 -0000
1.1
@@ -0,0 +1,250 @@
+/***********************************************************************
+ *
+ * Copyright (C) 2005, 2006 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
+ *
+ * Linking Gnash statically or dynamically with other modules is making a
+ * combined work based on Gnash. Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of Gnash give you
+ * permission to combine Gnash with free software programs or libraries
+ * that are released under the GNU LGPL and with code included in any
+ * release of Talkback distributed by the Mozilla Foundation. You may
+ * copy and distribute such a system following the terms of the GNU GPL
+ * for all but the LGPL-covered parts and Talkback, and following the
+ * LGPL for the LGPL-covered parts.
+ *
+ * Note that people who make modified versions of Gnash are not obligated
+ * to grant this special exception for their modified versions; it is their
+ * choice whether to do so. The GNU General Public License gives permission
+ * to release a modified version without this exception; this exception
+ * also makes it possible to release a modified version which carries
+ * forward this exception.
+ *
+ ***********************************************************************
+ *
+ * Test case for mouse events.
+ *
+ * In a movie of 120x120 pixels, it places a movieclip containing a squared
+ * shape in the middle of the stage.
+ *
+ * The movie has 3 frames.
+ *
+ * - frame1: initialization
+ * - frame2: the square is red
+ * - frame3: the square is green
+ *
+ * In frame2, rollOver event moves the playhead to frame3.
+ * In frame3, rollOut event moves the playhead to frame2.
+ *
+ ***********************************************************************/
+
+#include "ming_utils.h"
+
+#include <ming.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define OUTPUT_VERSION 6
+#define OUTPUT_FILENAME "RollOverOutTest.swf"
+
+SWFFont font;
+
+void add_event(SWFMovie mo, const char* name, const char* event, const char*
action);
+void add_code(SWFMovie mo, const char* code);
+void add_text_field(SWFMovie mo, const char* name, int depth);
+void set_text(SWFMovie mo, const char* text);
+SWFDisplayItem add_square(SWFMovie mo, byte r, byte g, byte b, int depth);
+
+void
+add_event(SWFMovie mo, const char* name, const char* event, const char* action)
+{
+ SWFAction ac;
+ char buf[1024];
+
+ sprintf(buf,
+ "event=undefined;"
+ "%s.on%s=function() { %s; };"
+ , name, event, action
+ );
+ ac = compileSWFActionCode(buf);
+
+ SWFMovie_add(mo, (SWFBlock)ac);
+}
+
+void
+add_code(SWFMovie mo, const char* code)
+{
+ SWFAction ac;
+
+ ac = compileSWFActionCode(code);
+
+ SWFMovie_add(mo, (SWFBlock)ac);
+}
+
+SWFDisplayItem add_square(SWFMovie mo, byte r, byte g, byte b, int depth)
+{
+ SWFDisplayItem it;
+ SWFMovieClip mc;
+ SWFShape sh;
+ mc = newSWFMovieClip();
+ sh = make_fill_square(0, 0, 40, 40, r, g, b, r, g, b);
+ SWFMovieClip_add(mc, (SWFBlock)sh);
+ SWFMovieClip_nextFrame(mc); /* showFrame */
+ it = SWFMovie_add(mo, (SWFBlock)mc);
+ SWFDisplayItem_setDepth(it, depth);
+ return it;
+}
+
+void
+add_text_field(SWFMovie mo, const char* name, int depth)
+{
+ SWFDisplayItem it;
+ SWFTextField tf = newSWFTextField();
+ SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX);
+
+ SWFTextField_setFont(tf, (void*)font);
+ SWFTextField_addChars(tf, "
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345689:.,/address@hidden");
+ SWFTextField_addString(tf, "
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345689:.,/address@hidden");
+ SWFTextField_setVariableName(tf, name);
+
+ it = SWFMovie_add(mo, (SWFBlock)tf);
+ SWFDisplayItem_scale(it, 0.3, 0.3);
+ SWFDisplayItem_moveTo(it, 0, 10);
+ SWFTextField_setBounds(tf, 120*(1/0.3), 10*(1/0.3));
+ SWFDisplayItem_setDepth(it, depth);
+}
+
+void
+set_text(SWFMovie mo, const char* text)
+{
+ char buf[1024];
+ sprintf(buf, "_root.msg=\"%s\";", text);
+ add_code(mo, buf);
+}
+
+int
+main(int argc, char **argv)
+{
+ SWFMovie mo;
+ SWFDisplayItem it;
+ const char *srcdir=".";
+ char fdbfont[256];
+
+ /*********************************************
+ *
+ * Initialization
+ *
+ *********************************************/
+
+ puts("Setting things up");
+
+ Ming_init();
+ Ming_useSWFVersion (OUTPUT_VERSION);
+ Ming_setScale(20.0);
+
+ mo = newSWFMovie();
+ SWFMovie_setDimension(mo, 120, 120);
+
+ if ( argc>1 ) srcdir=argv[1];
+ else
+ {
+ fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+ return 1;
+ }
+
+ sprintf(fdbfont, "%s/Bitstream Vera Sans.fdb", srcdir);
+ FILE *font_file = fopen(fdbfont, "r");
+ if ( font_file == NULL )
+ {
+ perror(fdbfont);
+ exit(1);
+ }
+ /*SWFBrowserFont bfont = newSWFBrowserFont("_sans");*/
+ font = loadSWFFontFromFile(font_file);
+
+ add_text_field(mo, "_root.msg", 1);
+
+ /*****************************************************
+ *
+ * Add squares
+ *
+ *****************************************************/
+
+ it = add_square(mo, 255, 0, 0, 2);
+ SWFDisplayItem_moveTo(it, 40, 40);
+ SWFDisplayItem_setName(it, "square1");
+
+ it = add_square(mo, 0, 255, 0, 3);
+ SWFDisplayItem_moveTo(it, 40, 40);
+ SWFDisplayItem_setName(it, "square2");
+
+ add_code(mo, "square1._visible = false; square2._visible=false;");
+
+ SWFMovie_nextFrame(mo); /* showFrame */
+
+
+ /*****************************************************
+ *
+ * Frame 1: display a red square.
+ * onRollOver: goto frame2
+ *
+ *****************************************************/
+
+ set_text(mo, "Frame1: move the mouse on the square");
+ add_code(mo, "square1._visible = true; square2._visible=false;");
+
+ add_event(mo, "square1", "RollOver", "gotoFrame(2)");
+ //add_event(mo, "square", "RollOver", "");
+ //add_event(mo, "square", "RollOut", "");
+ //add_event(mo, "square", "MouseDown", "");
+ //add_event(mo, "square", "MouseUp", "");
+
+ add_code(mo, "stop();");
+ SWFMovie_nextFrame(mo); /* showFrame */
+
+ /*****************************************************
+ *
+ * Frame 2: display a green square.
+ * onRollOut: goto frame1
+ *
+ *****************************************************/
+
+ set_text(mo, "Frame2: move the mouse off the square");
+ add_code(mo, "square2._visible = true; square1._visible=false;");
+
+ //add_event(mo, "square", "RollOver", "gotoFrame(2)");
+ //add_event(mo, "square", "RollOver", "");
+ add_event(mo, "square2", "RollOut", "gotoFrame(1)");
+ //add_event(mo, "square", "MouseDown", "");
+ //add_event(mo, "square", "MouseUp", "");
+
+ add_code(mo, "stop();");
+ SWFMovie_nextFrame(mo); /* showFrame */
+
+ /*****************************************************
+ *
+ * Save it...
+ *
+ *****************************************************/
+
+ puts("Saving " OUTPUT_FILENAME );
+
+ SWFMovie_save(mo, OUTPUT_FILENAME);
+
+ return 0;
+}