[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/button_character_instanc...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/button_character_instanc... |
Date: |
Thu, 17 Jan 2008 12:42:18 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/01/17 12:42:17
Modified files:
. : ChangeLog
server : button_character_instance.cpp
testsuite/misc-swfc.all: Makefile.am button_test1.sc
Added files:
testsuite/misc-swfc.all: button_test1runner.cpp
Log message:
button_character_instance::get_topmost_mouse_entity:
topmost entity is a child, if it's a mouse entity, not necessarely us.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5423&r2=1.5424
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-swfc.all/Makefile.am?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-swfc.all/button_test1.sc?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-swfc.all/button_test1runner.cpp?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5423
retrieving revision 1.5424
diff -u -b -r1.5423 -r1.5424
--- ChangeLog 17 Jan 2008 11:09:57 -0000 1.5423
+++ ChangeLog 17 Jan 2008 12:42:16 -0000 1.5424
@@ -1,5 +1,14 @@
2008-01-17 Sandro Santilli <address@hidden>
+ * server/button_character_instance.cpp (get_topmost_mouse_entity):
+ topmost entity is a child, if it's a mouse entity, not necessarely
+ us.
+ * testsuite/misc-swfc.all/: Makefile.am, button_test1.sc,
+ button_test1runner.cpp: turn button_test1.swf into a self-contained
+ interactive test.
+
+2008-01-17 Sandro Santilli <address@hidden>
+
* server/button_character_instance.{cpp,h}: drop the :advance()
method, no more needed; reduce ::display() to a few lines.
Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- server/button_character_instance.cpp 17 Jan 2008 11:09:57 -0000
1.74
+++ server/button_character_instance.cpp 17 Jan 2008 12:42:17 -0000
1.75
@@ -398,8 +398,37 @@
return 0;
}
+ //-------------------------------------------------
+ // Check our active and visible childrens first
+ //-------------------------------------------------
+
+ typedef std::vector<character*> Chars;
+ Chars actChars;
+ get_active_characters(actChars);
+
+ if ( ! actChars.empty() )
+ {
+ std::sort(actChars.begin(), actChars.end(), charDepthLessThen);
+
+ matrix m = get_matrix();
+ point p;
+ m.transform_by_inverse(&p, point(x, y));
+
+ for (Chars::reverse_iterator it=actChars.rbegin(),
itE=actChars.rend(); it!=itE; ++it)
+ {
+ character* ch = *it;
+ if ( ! ch->get_visible() ) continue;
+ character *hit = ch->get_topmost_mouse_entity(p.x, p.y);
+ if ( hit ) return hit;
+ }
+ }
+
+ //-------------------------------------------------
+ // If that failed, check our hit area
+ //-------------------------------------------------
+
// Find hit characters
- std::vector<character*> hitChars;
+ Chars hitChars;
get_active_characters(hitChars, HIT);
if ( hitChars.empty() ) return 0;
Index: testsuite/misc-swfc.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-swfc.all/Makefile.am,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- testsuite/misc-swfc.all/Makefile.am 16 Jan 2008 11:31:08 -0000 1.27
+++ testsuite/misc-swfc.all/Makefile.am 17 Jan 2008 12:42:17 -0000 1.28
@@ -37,20 +37,48 @@
gotoFrameFromInterval.sc \
gotoFrameFromInterval2.sc \
gotoFrameLabelAsFunction.sc \
- button_test1.sc \
$(NULL)
# These ones are the ones for which consistency check fail
BOGO_SCTESTS = \
$(NULL)
+# These ones are the ones for which a MovieTester-based runner exists
+INTERACTIVE_SCTESTS = \
+ button_test1.sc \
+ $(NULL)
+
+check_PROGRAMS = \
+ button_test1runner \
+ $(NULL)
+
+AM_CPPFLAGS = -I.. \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/libbase \
+ -I$(top_srcdir)/libmedia \
+ -I$(top_srcdir)/backend \
+ -I$(top_srcdir)/server \
+ -I$(top_srcdir)/server/vm \
+ -I$(top_srcdir)/server/parser \
+ -I$(top_srcdir)/libgeometry \
+ -I$(top_srcdir)/testsuite \
+ $(BOOST_CFLAGS) \
+ $(NULL)
+
+GNASH_LIBS = \
+ $(top_builddir)/testsuite/libtestsuite.la \
+ $(top_builddir)/server/libgnashserver.la \
+ $(top_builddir)/libbase/libgnashbase.la \
+ $(top_builddir)/libamf/libgnashamf.la \
+ $(NULL)
+
# These will get compiled to SWFs just as above, but will not be executed as a
test
# They are for secondary movies to be loaded by the above tests.
AUXMOVIES = \
$(NULL)
-EXTRA_DIST = $(SCTESTS) $(AUXMOVIES) check.sc Dejagnu.sc hello.sc
+EXTRA_DIST = $(SCTESTS) $(AUXMOVIES) $(INTERACTIVE_SCTESTS) check.sc
Dejagnu.sc hello.sc
if ENABLE_SWFC
@@ -69,7 +97,8 @@
TEST_DRIVERS = ../simple.exp
TEST_CASES = \
sanetests-runner \
- bogustests-runner
+ bogustests-runner \
+ $(check_PROGRAMS)
sanetests-runner: $(srcdir)/../generic-testrunner.sh $(SANE_SCTESTS_OUT)
$(AUXMOVIES_OUT) Makefile
sh $< -c __END_OF_TEST__ -f 50 -r 50 $(top_builddir)
$(SANE_SCTESTS_OUT) > $@
@@ -86,6 +115,20 @@
$(SWFC_CPP) $< > $(@:%.swf=pp_%.sc)
$(SWFC) $(SWFC_FLAGS) -o $@ $(@:%.swf=pp_%.sc)
+button_test1runner_SOURCES = \
+ button_test1runner.cpp \
+ $(NULL)
+button_test1runner_LDADD = \
+ $(GNASH_LIBS) \
+ $(NULL)
+button_test1runner_CXXFLAGS = \
+ -DBUILDDIR='"$(top_builddir)/testsuite/misc-swfc.all"' \
+ $(NULL)
+button_test1runner_DEPENDENCIES = \
+ button_test1.swf \
+ $(GNASH_LIBS) \
+ $(NULL)
+
CLEANFILES = \
$(TEST_CASES) \
gnash-dbg.log \
Index: testsuite/misc-swfc.all/button_test1.sc
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-swfc.all/button_test1.sc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- testsuite/misc-swfc.all/button_test1.sc 16 Jan 2008 11:55:27 -0000
1.2
+++ testsuite/misc-swfc.all/button_test1.sc 17 Jan 2008 12:42:17 -0000
1.3
@@ -25,12 +25,13 @@
.end
.box rbox width=200 height=300 fill=#FF0000 color=#000000
+.box ybox_small width=100 height=150 fill=#FFFF00 color=#000000
.box gbox width=200 height=200 fill=#00FF00 color=#000000
.button button1
.show rbox as=idle
- .show rbox as=area
- .show rbox as=hover
+ .show ybox_small as=area
+ .show ybox_small as=hover
.show rbox as=pressed
.on_press:
trace("red box");
@@ -55,7 +56,7 @@
.sprite buttonContainer
.put button2 pin=center x=0 y=0 scalex=100% scaley=100%
- .put button1 pin=center x=20 y=20 scalex=100% scaley=100% alpha=50
+ .put button1 pin=center x=20 y=20 scalex=100% scaley=100% alpha=100%
.end
.button button3
@@ -70,7 +71,7 @@
.end
//.put buttonContainer pin=center x=200 y=200 scalex=100% scaley=100%
-.put button3 pin=center x=200 y=300 scalex=100% scaley=50% alpha=50%
+.put button3 pin=center x=200 y=300 scalex=100% scaley=50% alpha=100%
.frame 1
.action:
@@ -97,18 +98,22 @@
check_equals(button3.instance1.button2['_target'],
"/button3/instance1/button2");
check_equals(button3.instance1.button2['_parent'],
_level0.button3.instance1);
- endOfTest(); // comment out this line and uncomment the
following ones
- // when MovieTester-based runners are available,
or you
- // intend to run the test manually
- //note("1. Press on the green box.");
- //nexttest = test2;
+// Define this when MovieTester-based runners are available, or you
+// intend to run the test manually
+#define MOVIETESTER_BASED
+#ifndef MOVIETESTER_BASED
+ endOfTest();
+#else
+ note("1. Click on the visible part of the green box.");
+ nexttest = test2;
+#endif
};
test2 = function()
{
check_equals(button3.instance1.button1._height, 300);
check_equals(button3.instance1.button2._height, 400);
- note("2. Press on the red box, where it overlaps with the green
one.");
+ note("2. Now move your mouse on the top-left area of the red
box (the box will become yellow), and click where it overlaps with the green
one.");
nexttest = test3;
};
@@ -123,7 +128,8 @@
endOfTest = function()
{
- totals(18);
+ _root.testcompleted = true;
+ totals(22);
};
_global.runNextTest = function()
Index: testsuite/misc-swfc.all/button_test1runner.cpp
===================================================================
RCS file: testsuite/misc-swfc.all/button_test1runner.cpp
diff -N testsuite/misc-swfc.all/button_test1runner.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-swfc.all/button_test1runner.cpp 17 Jan 2008 12:42:17
-0000 1.1
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2005, 2006, 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 3 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 "button_test1.swf"
+
+#include "MovieTester.h"
+#include "GnashException.h"
+#include "sprite_instance.h"
+#include "character.h"
+#include "dlist.h"
+#include "log.h"
+#include "Point2d.h"
+#include "VM.h"
+#include "string_table.h"
+#include "as_value.h"
+
+#include "check.h"
+#include <string>
+#include <cassert>
+
+using namespace gnash;
+using namespace std;
+
+int
+main(int /*argc*/, char** /*argv*/)
+{
+ string filename = string(BUILDDIR) + string("/") +
string(INPUT_FILENAME);
+ auto_ptr<MovieTester> t;
+
+ gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+ dbglogfile.setVerbosity(1);
+
+ try
+ {
+ t.reset(new MovieTester(filename));
+ }
+ catch (const GnashException& e)
+ {
+ std::cerr << "Error initializing MovieTester: " << e.what() <<
std::endl;
+ exit(EXIT_FAILURE);
+ }
+
+ MovieTester& tester = *t;
+
+ // TODO: check why we need this !!
+ // I wouldn't want the first advance to be needed
+ tester.advance();
+
+ sprite_instance* root = tester.getRootMovie();
+ VM& vm = root->getVM();
+ string_table& st = vm.getStringTable();
+
+ check_equals(root->get_frame_count(), 1);
+
+ rgba white(255, 255, 255, 255);
+ rgba yellow(255, 255, 0, 255);
+ rgba green(0,255,0,255);
+ rgba red(255,0,0,255);
+
+ typedef geometry::Point2d<int> intpoint;
+
+ // A point on the visible green button
+ intpoint visibleGreen(100, 260);
+
+ // A point on the BIG green button, but not on the small one
+ intpoint bigGreen(100, 352);
+
+ // A point on the yellow box, overlapping the green button
+ intpoint yellowOnGreen(127, 256);
+
+ // A point on the yellow box, not overlapping the green button
+ intpoint yellowOffGreen(136, 231);
+
+ // A point on the BIG yellow box, not overlapping the green button,
+ // would be on the small red box...
+ intpoint bigYellowOffGreen(294,365);
+
+ // A point on the red box, but out of the red button hit area
+ intpoint redNoHit(241, 351);
+
+ // A point on the BIG red button, but not on the small one
+ intpoint bigRedNoHit(330, 397);
+
+ //----------------------------------------
+ // Test starts
+ //----------------------------------------
+
+ // check some pixel colors
+ check_pixel(visibleGreen.x, visibleGreen.y, 2, green, 1);
+ check_pixel(redNoHit.x, redNoHit.y, 2, red, 1);
+ check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, red, 1); // still
red, till we move over it
+ check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, red, 1); // still red,
till we move over it
+ check_pixel(bigGreen.x, bigGreen.y, 2, white, 1); // nothing here, as
long as the green is small
+
+ // now move over the red button hit area, so it becomes yellow
+ tester.movePointerTo(yellowOnGreen.x, yellowOnGreen.y);
+ check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, yellow, 1);
+ check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, yellow, 1);
+ tester.movePointerTo(yellowOffGreen.x, yellowOffGreen.y);
+ check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, yellow, 1);
+ check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, yellow, 1);
+
+ // 1. Click on the visible part of the green box.
+ tester.movePointerTo(visibleGreen.x, visibleGreen.y);
+ tester.click();
+ tester.advance();
+
+ // check new pixel colors
+ check_pixel(visibleGreen.x, visibleGreen.y, 2, green, 1);
+ check_pixel(bigGreen.x, bigGreen.y, 2, green, 1); // now green is big
+ check_pixel(redNoHit.x, redNoHit.y, 2, red, 1);
+ check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, red, 1); // still
red, till we move over it
+ check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, red, 1); // still red,
till we move over it
+
+ // 2. Now move your mouse on the top-left area of the red box (the box
will become yellow),
+ // and click where it overlaps with the green one.
+ tester.movePointerTo(yellowOnGreen.x, yellowOnGreen.y);
+
+ check_pixel(visibleGreen.x, visibleGreen.y, 2, green, 1);
+ check_pixel(bigGreen.x, bigGreen.y, 2, green, 1); // now green is big
+ check_pixel(redNoHit.x, redNoHit.y, 2, green, 1); // the red button
shrinked, showing green underneath
+ check_pixel(bigRedNoHit.x, bigRedNoHit.y, 2, green, 1); // the red
button is still small, but green is big
+ check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, yellow, 1); // still
red, till we move over it
+ check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, yellow, 1); // still
red, till we move over it
+
+ tester.click();
+ tester.advance();
+
+ check_pixel(visibleGreen.x, visibleGreen.y, 2, green, 1);
+ check_pixel(bigGreen.x, bigGreen.y, 2, white, 1); // green is small
again
+ check_pixel(bigRedNoHit.x, bigRedNoHit.y, 2, white, 1); // the red
button grew, but pointer is in the hit area...
+ check_pixel(bigYellowOffGreen.x, bigYellowOffGreen.y, 2, yellow, 1); //
yellow grew
+ check_pixel(yellowOffGreen.x, yellowOffGreen.y, 2, yellow, 1); // still
red, till we move over it
+ check_pixel(yellowOnGreen.x, yellowOnGreen.y, 2, yellow, 1); // still
red, till we move over it
+
+ tester.movePointerTo(bigRedNoHit.x, bigRedNoHit.y);
+ check_pixel(bigRedNoHit.x, bigRedNoHit.y, 2, red, 1); // the red button
grew, but pointer is in the hit area...
+ check_pixel(bigYellowOffGreen.x, bigYellowOffGreen.y, 2, red, 1); //
yellow grew, but we're not in the hit area
+
+ //----------------------------------------
+ // Check test ended completely
+ //----------------------------------------
+
+ as_value eot;
+ bool endOfTestFound = root->get_member(st.find("testcompleted"), &eot);
+ //cerr << "EOT is " << eot.to_debug_string() << endl;
+ check(eot.to_bool());
+}
+