gnash-commit
[Top][All Lists]
Advanced

[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 14:27:43 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/10/16 14:27:43

Modified files:
        .              : ChangeLog 
        testsuite/misc-ming.all: Makefile.am 
Added files:
        testsuite/misc-ming.all: ButtonEventsTest-Runner.cpp 
                                 ButtonEventsTest.c 

Log message:
                * testsuite/misc-ming.all/: ButtonEventsTest-Runner.cpp,
                  ButtonEventsTest.c, Makefile.am: new test for button
                  events.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1236&r2=1.1237
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/ButtonEventsTest.c?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1236
retrieving revision 1.1237
diff -u -b -r1.1236 -r1.1237
--- ChangeLog   16 Oct 2006 14:21:53 -0000      1.1236
+++ ChangeLog   16 Oct 2006 14:27:43 -0000      1.1237
@@ -1,5 +1,8 @@
 2006-10-16 Sandro Santilli <address@hidden>
 
+       * testsuite/misc-ming.all/: ButtonEventsTest-Runner.cpp,
+         ButtonEventsTest.c, Makefile.am: new test for button
+         events.
        * testsuite/MovieTester.{cpp,h}: added call to set_current_root 
          (seems needed by notify_mouse_clicked) and new pressMouseButton()
          and depressMouseButton() methods.

Index: testsuite/misc-ming.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- testsuite/misc-ming.all/Makefile.am 16 Oct 2006 12:12:08 -0000      1.25
+++ testsuite/misc-ming.all/Makefile.am 16 Oct 2006 14:27:43 -0000      1.26
@@ -66,8 +66,10 @@
        DefineEditTextVariableNameTest \
        DefineEditTextVariableNameTest-Runner \
        RollOverOutTest-Runner \
+       ButtonEventsTest-Runner \
        spritehier \
        RollOverOutTest \
+       ButtonEventsTest \
        PlaceObject2Test \
        RemoveObject2Test
 
@@ -158,13 +160,32 @@
        RollOverOutTest.swf     \
        $(NULL)
 
+ButtonEventsTest_SOURCES =     \
+       ButtonEventsTest.c      \
+       ming_utils.h    \
+       ming_utils.c    \
+       $(NULL)
+ButtonEventsTest_LDADD = $(MING_LIBS)
+ButtonEventsTest.swf: ButtonEventsTest
+       ./ButtonEventsTest $(top_srcdir)/testsuite/media
+ButtonEventsTest_Runner_SOURCES = \
+       ButtonEventsTest-Runner.cpp \
+       $(NULL)
+ButtonEventsTest_Runner_LDADD = \
+       $(top_builddir)/testsuite/libtestsuite.la \
+       $(NULL)
+ButtonEventsTest_Runner_DEPENDENCIES = \
+       ButtonEventsTest.swf    \
+       $(NULL)
+
 clean-local: 
        -rm *.swf media
 
 TEST_DRIVERS = ming.exp
 TEST_CASES = \
        DefineEditTextVariableNameTest-Runner \
-       RollOverOutTest-Runner
+       RollOverOutTest-Runner \
+       ButtonEventsTest-Runner
 
 check-DEJAGNU: site-update $(check_PROGRAMS)
        @runtest=$(RUNTEST); \

Index: testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp
===================================================================
RCS file: testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp
diff -N testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp 16 Oct 2006 14:27:43 
-0000      1.1
@@ -0,0 +1,122 @@
+/* 
+ *   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 "ButtonEventsTest.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(), 1);
+
+       const character* mc1 = tester.findDisplayItemByName(*root, "square1");
+       check(mc1);
+
+       const character* text = tester.findDisplayItemByName(*root, 
"textfield");
+       check(text);
+
+       check_equals(string(text->get_text_value()), string("Play with the 
button"));
+       // TODO: check that pixel @ 60,60 is red !
+
+       // roll over the middle of the square, this should change
+       // the textfield value, but only after advance().
+       tester.movePointerTo(60, 60);
+       tester.advance();
+       check_equals(string(text->get_text_value()), string("MouseOver"));
+       // TODO: check that pixel @ 60,60 is yellow !
+
+       // press the mouse button, this should change
+       // the textfield value, but only after advance().
+       tester.pressMouseButton();
+       tester.advance();
+       check_equals(string(text->get_text_value()), string("MouseDown"));
+       // TODO: check that pixel @ 60,60 is green !
+
+       // depress the mouse button, this should change
+       // the textfield value, but only after advance().
+       tester.depressMouseButton();
+       tester.advance();
+       check_equals(string(text->get_text_value()), string("MouseUp"));
+       // TODO: check that pixel @ 60,60 is yellow !
+
+       // roll off the square, this should change
+       // the textfield value, but only after advance().
+       tester.movePointerTo(39, 60);
+       tester.advance();
+       check_equals(string(text->get_text_value()), string("MouseOut"));
+       // TODO: check that pixel @ 60,60 is red !
+
+       // press the mouse button, this should not change anything
+       // as we're outside of the button.
+       tester.pressMouseButton();
+       tester.advance();
+       check_equals(string(text->get_text_value()), string("MouseOut"));
+       // TODO: check that pixel @ 60,60 is red !
+
+       // depress the mouse button, this should not change anything
+       // as we're outside of the button.
+       tester.depressMouseButton();
+       tester.advance();
+       check_equals(string(text->get_text_value()), string("MouseOut"));
+       // TODO: check that pixel @ 60,60 is red !
+}
+

Index: testsuite/misc-ming.all/ButtonEventsTest.c
===================================================================
RCS file: testsuite/misc-ming.all/ButtonEventsTest.c
diff -N testsuite/misc-ming.all/ButtonEventsTest.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/ButtonEventsTest.c  16 Oct 2006 14:27:43 -0000      
1.1
@@ -0,0 +1,226 @@
+/***********************************************************************
+ *
+ *   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
+ * button in the middle of the stage, and a text area on top.
+ *
+ * The movie has 1 frame.
+ *
+ * The following events print the event name in the text area
+ * (called _root.textfield) and change the color of the button:
+ *
+ * MouseOut  : red button (initial state)
+ * MouseOver : yellow button
+ * MouseDown : green button
+ * MouseUp   : yellow button (same as MouseOver, but the label on top changes)
+ *
+ ***********************************************************************/
+
+#include "ming_utils.h"
+
+#include <ming.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define OUTPUT_VERSION 6
+#define OUTPUT_FILENAME "ButtonEventsTest.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_button(SWFMovie mo)
+{
+       SWFDisplayItem it, it2;
+       SWFMovieClip mc;
+       SWFShape sh1, sh2, sh3, sh4;
+       SWFButton bu = newSWFButton();
+       SWFAction ac, ac2;
+       mc = newSWFMovieClip();
+
+       sh1 = make_fill_square(0, 0, 40, 40, 0, 0, 0, 0, 0, 0);
+       sh2 = make_fill_square(0, 0, 40, 40, 255, 0, 0, 255, 0, 0);
+       sh3 = make_fill_square(0, 0, 40, 40, 0, 255, 0, 0, 255, 0);
+       sh4 = make_fill_square(0, 0, 40, 40, 255, 255, 0, 255, 255, 0);
+
+       SWFButton_addShape(bu, (SWFCharacter)sh1, SWFBUTTON_HIT);
+       SWFButton_addShape(bu, (SWFCharacter)sh2, SWFBUTTON_UP );
+       SWFButton_addShape(bu, (SWFCharacter)sh3, SWFBUTTON_DOWN );
+       SWFButton_addShape(bu, (SWFCharacter)sh4, SWFBUTTON_OVER );
+
+       SWFButton_addAction(bu, 
compileSWFActionCode("_root.msg=\"MouseOut\";"), SWFBUTTON_MOUSEOUT);
+       SWFButton_addAction(bu, 
compileSWFActionCode("_root.msg=\"MouseOver\";"), SWFBUTTON_MOUSEOVER);
+       SWFButton_addAction(bu, 
compileSWFActionCode("_root.msg=\"MouseDown\";"), SWFBUTTON_MOUSEDOWN);
+       SWFButton_addAction(bu, compileSWFActionCode("_root.msg=\"MouseUp\";"), 
SWFBUTTON_MOUSEUP);
+
+       SWFMovieClip_add(mc, (SWFBlock)bu);
+       SWFMovieClip_nextFrame(mc); /* showFrame */
+
+       it = SWFMovie_add(mo, (SWFBlock)mc);
+       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, "Play with the button");
+       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);
+       SWFDisplayItem_setName(it, "textfield");
+}
+
+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", 10);
+
+       /*****************************************************
+        *
+        * Add button
+        *
+        *****************************************************/
+
+       it = add_button(mo);
+       SWFDisplayItem_moveTo(it, 40, 40);
+       SWFDisplayItem_setName(it, "square1");
+
+       SWFMovie_nextFrame(mo); /* showFrame */
+
+
+       /*****************************************************
+        *
+        * Save it...
+        *
+        *****************************************************/
+
+       puts("Saving " OUTPUT_FILENAME );
+
+       SWFMovie_save(mo, OUTPUT_FILENAME);
+
+       return 0;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]