[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog testsuite/FuzzyPixel.h testsuit...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog testsuite/FuzzyPixel.h testsuit... |
Date: |
Fri, 20 Apr 2007 14:01:27 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/04/20 14:01:27
Modified files:
. : ChangeLog
testsuite : FuzzyPixel.h MovieTester.cpp MovieTester.h
testsuite/misc-ming.all: ButtonEventsTest-Runner.cpp
Log message:
* testsuite/FuzzyPixel.h: const-correctness
* testsuite/MovieTester.{cpp,h}: prepared for working
with all render handlers, implemented support for
a single one (AGG only for now); provided
check_pixel and xcheck_pixel macros.
* testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp:
Test pixel checker (doesn't work).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2955&r2=1.2956
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/FuzzyPixel.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.h?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp?cvsroot=gnash&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2955
retrieving revision 1.2956
diff -u -b -r1.2955 -r1.2956
--- ChangeLog 20 Apr 2007 13:46:20 -0000 1.2955
+++ ChangeLog 20 Apr 2007 14:01:26 -0000 1.2956
@@ -1,5 +1,15 @@
2007-04-20 Sandro Santilli <address@hidden>
+ * testsuite/FuzzyPixel.h: const-correctness
+ * testsuite/MovieTester.{cpp,h}: prepared for working
+ with all render handlers, implemented support for
+ a single one (AGG only for now); provided
+ check_pixel and xcheck_pixel macros.
+ * testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp:
+ Test pixel checker (doesn't work).
+
+2007-04-20 Sandro Santilli <address@hidden>
+
* server/types.{cpp,h}: add toShortString, for neater output.
* libgeometry/snappingrange.h: add output operator.
* server/debugger.cpp, server/parser/action_buffer.cpp,
Index: testsuite/FuzzyPixel.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/FuzzyPixel.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- testsuite/FuzzyPixel.h 20 Apr 2007 09:18:48 -0000 1.2
+++ testsuite/FuzzyPixel.h 20 Apr 2007 14:01:27 -0000 1.3
@@ -70,7 +70,7 @@
/// @param tolerance
/// The tolerance to use in comparisons.
///
- FuzzyPixel(rgba& color, short unsigned tolerance=0)
+ FuzzyPixel(const rgba& color, short unsigned tolerance=0)
:
_col(color),
// From short unsigned to signed we hopefully never swap sign.
Index: testsuite/MovieTester.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- testsuite/MovieTester.cpp 20 Apr 2007 09:03:42 -0000 1.26
+++ testsuite/MovieTester.cpp 20 Apr 2007 14:01:27 -0000 1.27
@@ -32,6 +32,8 @@
#include "render.h" // for get_render_handler
#include "types.h" // for rgba class
#include "FuzzyPixel.h"
+#include "render.h"
+#include "render_handler.h"
#include "render_handler_agg.h"
#include <cstdio>
@@ -101,8 +103,13 @@
}
void
-MovieTester::advance()
+MovieTester::render(render_handler& h, InvalidatedRanges& invalidated_regions)
{
+ set_render_handler(&h);
+
+ invalidated_regions.setWorld(); // testing
+ h.set_invalidated_regions(invalidated_regions);
+
// We call display here to simulate effect of a real run.
//
// What we're particularly interested about is
@@ -119,6 +126,27 @@
// real runs as close as possible, by calling display().
//
_movie_root->display();
+}
+
+void
+MovieTester::render()
+{
+ InvalidatedRanges ranges;
+ _movie_root->add_invalidated_bounds(ranges, false);
+ cout << "Invalidated ranges before any advance: " << ranges << endl;
+
+ for (TRenderers::const_iterator it=_testingRenderers.begin(),
itE=_testingRenderers.end();
+ it != itE; ++it)
+ {
+ TestingRenderer& rend = *(*it);
+ render(rend.getRenderer(), ranges);
+ }
+}
+
+void
+MovieTester::advance()
+{
+ render();
_movie_root->advance(1.0);
#ifdef SHOW_INVALIDATED_BOUNDS_ON_ADVANCE
@@ -156,9 +184,55 @@
}
void
-MovieTester::checkPixel(unsigned radius, const rgba& color, int tolerance)
const
+MovieTester::checkPixel(unsigned radius, const rgba& color,
+ short unsigned tolerance, const std::string& label, bool
expectFailure) const
{
- log_msg("XFAILED: pixel checking not implemented yet.");
+ FuzzyPixel exp(color, tolerance);
+ const char* X="";
+ if ( expectFailure ) X="X";
+
+ //cout <<"BINGO: X is '"<< X<<"'"<<endl;
+
+ for (TRenderers::const_iterator it=_testingRenderers.begin(),
itE=_testingRenderers.end();
+ it != itE; ++it)
+ {
+ const TestingRenderer& rend = *(*it);
+
+ std::stringstream ss;
+ ss << rend.getName() <<" ";
+ ss << "pix:" << _x << "," << _y <<" ";
+
+ rgba obt_col;
+
+ if ( ! rend.getRenderer().getAveragePixel(obt_col, _x, _y,
radius) )
+ {
+ ss << " is out of rendering buffer";
+ log_msg("%sFAILED: %s (%s)", X,
+ ss.str().c_str(),
+ label.c_str()
+ );
+ }
+
+ ss << "exp:" << color.toShortString() << " ";
+ ss << "obt:" << obt_col.toShortString() << " ";
+ ss << "tol:" << tolerance;
+
+ FuzzyPixel obt(obt_col, tolerance);
+ if (exp == obt)
+ {
+ log_msg("%sPASSED: %s %s", X,
+ ss.str().c_str(),
+ label.c_str()
+ );
+ }
+ else
+ {
+ log_msg("%sFAILED: %s %s", X,
+ ss.str().c_str(),
+ label.c_str()
+ );
+ }
+ }
}
void
@@ -233,40 +307,49 @@
{
std::auto_ptr<render_handler> handler;
+ // TODO: add support for testing multiple renderers
+ // This is tricky as requires changes in the core lib
+
+#ifdef RENDERER_AGG
// Initialize AGG
handler.reset( create_render_handler_agg("RGB24") );
assert(handler.get());
addTestingRenderer(handler, "AGG_RGB24");
+#endif
+
+#ifdef RENDERER_CAIRO
+ // Initialize Cairo
+#endif
+
+#ifdef RENDERER_OPENGL
+ // Initialize opengl renderer
+#endif
}
void
MovieTester::addTestingRenderer(std::auto_ptr<render_handler> h, const
std::string& name)
{
- // TODO: init the buffer before pushing, and do not add to the table
- // if the renderer is not capable of doing so !!
-
+ if ( ! h->initTestBuffer(_width, _height) )
+ {
cout << "UNTESTED: render handler " << name
<< " doesn't support in-memory rendering "
- << "(not true, but we need to add interfaces "
- << "for this in the base render_handler class)"
<< endl;
+ return;
+ }
- // h->initTestBuffer(_width, _height);
- //_testingRenderers.push_back(TestingRendererPtr(new TestingRenderer(h,
name)));
-}
-
-FuzzyPixel
-TestingRenderer::getAveragePixel(int x, int y, unsigned radius, unsigned
tolerance) const
-{
- render_handler* rend = get_render_handler();
- assert(rend);
- rgba color;
- if ( ! rend->getAveragePixel(color, x, y, radius) )
+ // TODO: make the core lib support this
+ if ( ! _testingRenderers.empty() )
{
- return FuzzyPixel();
+ cout << "UNTESTED: can't test render handler " << name
+ << " because gnash core lib is unable to support
testing of "
+ << "multiple renderers from a single process "
+ << "and we're already testing render handler "
+ << _testingRenderers.front()->getName()
+ << endl;
+ return;
}
- return FuzzyPixel(color, tolerance);
-}
+ _testingRenderers.push_back(TestingRendererPtr(new TestingRenderer(h,
name)));
+}
} // namespace gnash
Index: testsuite/MovieTester.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- testsuite/MovieTester.h 20 Apr 2007 09:03:42 -0000 1.14
+++ testsuite/MovieTester.h 20 Apr 2007 14:01:27 -0000 1.15
@@ -24,11 +24,26 @@
#include "gnash.h" // for namespace key
#include "sound_handler_test.h" // for creating the "test" sound handler
#include "types.h" // for rgba class
+#include "render_handler.h" // for dtor visibility by auto_ptr
#include <memory> // for auto_ptr
#include <string>
#include <boost/shared_ptr.hpp>
+#define check_pixel(radius, color, tolerance) \
+ {\
+ std::stringstream ss; \
+ ss << "[" << __FILE__ << ":" << __LINE__ << "]"; \
+ tester.checkPixel(2, rgba(0,0,0,255), 1, ss.str(), false); \
+ }
+
+#define xcheck_pixel(radius, color, tolerance) \
+ {\
+ std::stringstream ss; \
+ ss << "[" << __FILE__ << ":" << __LINE__ << "]"; \
+ tester.checkPixel(2, rgba(0,0,0,255), 1, ss.str(), true); \
+ }
+
// Forward declarations
namespace gnash {
class movie_definition;
@@ -56,26 +71,8 @@
const std::string& getName() const { return _name; }
- /// Get the average pixel under the mouse pointer
- //
- /// @param x
- /// X coordinate, in pixels
- ///
- /// @param x
- /// Y coordinate, in pixels
- ///
- /// @param radius
- /// Radius defining the average zone used.
- /// 1 means a single pixel.
- /// Behaviour of passing 0 is undefined.
- ///
- /// @param tolerance
- /// The tolerance value to use for the returned FuzzyPixel.
- ///
- /// Note that if current pointer is outside of the rendered region
- /// an intollerant FuzzyPixel is returned.
- ///
- FuzzyPixel getAveragePixel(int x, int y, unsigned radius, unsigned
tolerance) const;
+ /// Return the underlying render handler
+ render_handler& getRenderer() const { return *_renderer; }
private:
@@ -157,7 +154,13 @@
/// @param tolerance
/// The tolerated difference of any r,g,b,a values
///
- void checkPixel(unsigned radius, const rgba& color, int tolerance)
const;
+ /// @param label
+ /// A label to use in test results.
+ ///
+ /// @param expectFailure
+ /// Set to true if a failure is expected. Defaults to false.
+ ///
+ void checkPixel(unsigned radius, const rgba& color, short unsigned
tolerance, const std::string& label, bool expectFailure=false) const;
/// Notify mouse button was pressed
void pressMouseButton();
@@ -200,6 +203,23 @@
/// Initialize testing renderers
void initTestingRenderers();
+ /// Render the current movie to all testing renderers
+ //
+ /// This function calls movie_root::display internally
+ ///
+ void render();
+
+ /// Render the current movie to a specific testing renderer
+ //
+ /// @param renderer
+ /// The renderer to draw to. It will be temporarly set as
+ /// the global renderer in the gnash core lib.
+ ///
+ /// @param invalidated
+ /// The invalidated ranges as computed by the core lib.
+ ///
+ void render(render_handler& renderer, InvalidatedRanges& invalidated);
+
/// Add a testing renderer to the list, initializing it with current
viewport size
void addTestingRenderer(std::auto_ptr<render_handler> h, const
std::string& name);
@@ -227,6 +247,8 @@
/// boost 1.33 requirement for the moment.
/// Still, I'd like to simplify things...
/// is shared_ptr fine ?
+ typedef std::vector< TestingRendererPtr > TRenderers;
+
std::vector< TestingRendererPtr > _testingRenderers;
};
Index: testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp
===================================================================
RCS file:
/sources/gnash/gnash/testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp 20 Apr 2007 07:21:26
-0000 1.12
+++ testsuite/misc-ming.all/ButtonEventsTest-Runner.cpp 20 Apr 2007 14:01:27
-0000 1.13
@@ -43,7 +43,7 @@
check_equals(string(text2->get_text_value()), string("RollOver"));
check(tester.isMouseOverMouseEntity());
// TODO: check that pixel @ 60,60 is yellow !
- //tester.checkPixel(2, rgba(0,0,0,255), 1);
+ xcheck_pixel(2, rgba(255,255,0,255), 2);
// press the mouse button, this should change
// the textfield value.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog testsuite/FuzzyPixel.h testsuit...,
Sandro Santilli <=