[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog testsuite/MovieTester.cpp tests...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog testsuite/MovieTester.cpp tests... |
Date: |
Thu, 08 Feb 2007 00:38:51 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/02/08 00:38:51
Modified files:
. : ChangeLog
testsuite : MovieTester.cpp MovieTester.h
testsuite/misc-ming.all: Makefile.am
Added files:
testsuite/misc-ming.all: KeyTest-Runner.cpp KeyTest.as
Log message:
* testsuite/MovieTester.{cpp,h}: add pressKey() and releaseKey()
methods.
* testsuite/misc-ming.all/: KeyTest-Runner.cpp, KeyTest.as,
Makefile.am: test for Key events.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2269&r2=1.2270
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/Makefile.am?cvsroot=gnash&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/KeyTest-Runner.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/KeyTest.as?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2269
retrieving revision 1.2270
diff -u -b -r1.2269 -r1.2270
--- ChangeLog 7 Feb 2007 21:51:56 -0000 1.2269
+++ ChangeLog 8 Feb 2007 00:38:50 -0000 1.2270
@@ -1,5 +1,10 @@
2007-02-07 Sandro Santilli <address@hidden>
+
+ * testsuite/MovieTester.{cpp,h}: add pressKey() and releaseKey()
+ methods.
+ * testsuite/misc-ming.all/: KeyTest-Runner.cpp, KeyTest.as,
+ Makefile.am: test for Key events.
* testsuite/actionscript.all/Object.as: add test for overriding
addProperty() member of an object.
Index: testsuite/MovieTester.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- testsuite/MovieTester.cpp 26 Jan 2007 10:51:52 -0000 1.18
+++ testsuite/MovieTester.cpp 8 Feb 2007 00:38:51 -0000 1.19
@@ -26,7 +26,7 @@
#include "movie_root.h"
#include "sprite_instance.h"
#include "as_environment.h"
-#include "gnash.h" // for create_movie and create_library_movie
+#include "gnash.h" // for create_movie and create_library_movie and for
gnash::key namespace
#include "VM.h" // for initialization
#include <cstdio>
@@ -149,6 +149,18 @@
_movie_root->notify_mouse_clicked(false, 1);
}
+void
+MovieTester::pressKey(key::code code)
+{
+ notify_key_event(code, true);
+}
+
+void
+MovieTester::releaseKey(key::code code)
+{
+ notify_key_event(code, false);
+}
+
bool
MovieTester::isMouseOverMouseEntity()
{
Index: testsuite/MovieTester.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- testsuite/MovieTester.h 8 Dec 2006 11:54:11 -0000 1.8
+++ testsuite/MovieTester.h 8 Feb 2007 00:38:51 -0000 1.9
@@ -21,6 +21,7 @@
#define _GNASH_MOVIETESTER_H
#include "Range2d.h"
+#include "gnash.h" // for namespace key
#include <memory> // for auto_ptr
#include <string> // for auto_ptr
@@ -92,6 +93,18 @@
/// Notify mouse button was depressed
void depressMouseButton();
+ /// Notify key press
+ //
+ /// See key codes in namespace gnash::key (gnash.h)
+ ///
+ void pressKey(key::code k);
+
+ /// Notify key release
+ //
+ /// See key codes in namespace gnash::key (gnash.h)
+ ///
+ void releaseKey(key::code k);
+
/// Return true if the currently active
/// character is over a character that
/// handles mouse events
Index: testsuite/misc-ming.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/Makefile.am,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- testsuite/misc-ming.all/Makefile.am 25 Jan 2007 10:55:29 -0000 1.58
+++ testsuite/misc-ming.all/Makefile.am 8 Feb 2007 00:38:51 -0000 1.59
@@ -31,7 +31,8 @@
testrun.sum \
testrun.log
-EXTRA_DIST = VarAndCharClashTest.as
+EXTRA_DIST = VarAndCharClashTest.as \
+ KeyTest.as
AM_CPPFLAGS = -I.. \
@@ -78,6 +79,7 @@
simple_loop_test \
simple_loop_testrunner \
action_execution_order_test \
+ KeyTest-Runner \
$(NULL)
check_SCRIPTS = \
@@ -439,6 +441,26 @@
sh $< $(top_builddir) VarAndCharClashTest.swf > $@
chmod 755 $@
+# This will only work with Ming-0.4.0beta2 (support for prebuilt clips
inclusion)
+# Uses a low frame rate to test immediate redraw on key event
+KeyTest.swf: $(srcdir)/../media/green.swf ../Dejagnu.swf $(srcdir)/KeyTest.as
+ $(MAKESWF) -o $@ ../Dejagnu.swf $(srcdir)/../media/green.swf
$(srcdir)/KeyTest.as
+
+KeyTest_Runner_SOURCES = \
+ KeyTest-Runner.cpp \
+ $(NULL)
+KeyTest_Runner_CXXFLAGS = \
+ -DSRCDIR='"$(srcdir)"' \
+ -DTGTDIR='"$(abs_builddir)"' \
+ $(NULL)
+KeyTest_Runner_LDADD = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ $(NULL)
+KeyTest_Runner_DEPENDENCIES = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ KeyTest.swf \
+ $(NULL)
+
Dejagnu_SOURCES = \
Dejagnu.c \
ming_utils.h \
@@ -470,6 +492,7 @@
registerClassTestRunner \
action_execution_order_testrunner \
simple_loop_testrunner \
+ KeyTest-Runner \
$(NULL)
Index: testsuite/misc-ming.all/KeyTest-Runner.cpp
===================================================================
RCS file: testsuite/misc-ming.all/KeyTest-Runner.cpp
diff -N testsuite/misc-ming.all/KeyTest-Runner.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/KeyTest-Runner.cpp 8 Feb 2007 00:38:51 -0000
1.1
@@ -0,0 +1,93 @@
+/*
+ * 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
+ *
+ *
+ */
+
+#define INPUT_FILENAME "KeyTest.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 = string(TGTDIR) + string("/") + string(INPUT_FILENAME);
+ MovieTester tester(filename);
+
+ gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+ dbglogfile.setVerbosity(1);
+
+ sprite_instance* root = tester.getRootMovie();
+ assert(root);
+
+ check_equals(root->get_frame_count(), 3);
+ check_equals(root->get_current_frame(), 0);
+
+ tester.advance();
+ check_equals(root->get_current_frame(), 1);
+
+ // need non-const for calling get_member below
+ character* mc1 =
const_cast<character*>(tester.findDisplayItemByName(*root, "green"));
+ check(mc1);
+
+ as_value tmp;
+
+ check(mc1->get_member("_x", &tmp));
+ check_equals(tmp.to_number(), 0);
+
+ tester.advance();
+ check_equals(root->get_current_frame(), 2);
+
+ check(mc1->get_member("_x", &tmp));
+ check_equals(tmp.to_number(), 200);
+
+ tester.pressKey(key::J);
+
+ check(mc1->get_member("_x", &tmp));
+ check_equals(tmp.to_number(), 250);
+
+ tester.pressKey(key::K);
+
+ check(mc1->get_member("_x", &tmp));
+ check_equals(tmp.to_number(), 300);
+
+ tester.releaseKey(key::A);
+
+ check(mc1->get_member("_x", &tmp));
+ check_equals(tmp.to_number(), 250);
+
+ tester.releaseKey(key::B);
+
+ check(mc1->get_member("_x", &tmp));
+ check_equals(tmp.to_number(), 200);
+
+ // TODO: test pressing and releases keys
+
+
+}
+
Index: testsuite/misc-ming.all/KeyTest.as
===================================================================
RCS file: testsuite/misc-ming.all/KeyTest.as
diff -N testsuite/misc-ming.all/KeyTest.as
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/KeyTest.as 8 Feb 2007 00:38:51 -0000 1.1
@@ -0,0 +1,37 @@
+//
+// This ActionScript code is intended to be compiled in the third frame
+// of a movie so composed:
+// frame1) Dejagnu.swf
+// frame2) A bitmap character named 'green'
+//
+// The aim is testing use of Key.addListener
+// It is expected that any keypress in the movie makes the 'green' character
move
+// on the right, and any keyrelease will move it back on the left.
+// Pressing multiple keys down will result in a longer right-shift, but
+// when releasing all keys, the bitmap returns to its original position.
+//
+
+
+check_equals(typeof(green), 'movieclip');
+
+// Move the 'green' character on the right
+// so that Dejagnu.swf xtrace window is visible
+green._x = 200;
+
+l = new Object;
+l.onKeyDown = function ()
+{
+ green._x += 50;
+};
+l.onKeyUp = function ()
+{
+ green._x -= 50;
+};
+
+check_equals(typeof(Key), 'object');
+Key.addListener(l);
+Key = 4;
+check_equals(typeof(Key), 'number');
+
+totals();
+stop();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog testsuite/MovieTester.cpp tests...,
Sandro Santilli <=