[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog testsuite/Makefile.am testsuite...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog testsuite/Makefile.am testsuite... |
Date: |
Fri, 20 Apr 2007 09:03:42 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/04/20 09:03:42
Modified files:
. : ChangeLog
testsuite : Makefile.am MovieTester.cpp MovieTester.h
Added files:
testsuite : FuzzyPixel.cpp FuzzyPixel.h
Log message:
* testsuite/: Makefile.am, FuzzyPixel.{cpp,h},
MovieTester.{cpp,h}: framework for renderers
testing, needs changes in render_handler to complete.
See task #6785.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2945&r2=1.2946
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/Makefile.am?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.cpp?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/MovieTester.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/FuzzyPixel.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/FuzzyPixel.h?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2945
retrieving revision 1.2946
diff -u -b -r1.2945 -r1.2946
--- ChangeLog 20 Apr 2007 08:57:34 -0000 1.2945
+++ ChangeLog 20 Apr 2007 09:03:42 -0000 1.2946
@@ -1,5 +1,12 @@
2007-04-20 Sandro Santilli <address@hidden>
+ * testsuite/: Makefile.am, FuzzyPixel.{cpp,h},
+ MovieTester.{cpp,h}: framework for renderers
+ testing, needs changes in render_handler to complete.
+ See task #6785.
+
+2007-04-20 Sandro Santilli <address@hidden>
+
* testsuite/misc-ming.all/masks_test.c: draft masks test.
* doc/C/asspec/movieclip.xml:
Dumped a bit of info about _name. Hopefully Ann will give it some
Index: testsuite/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/Makefile.am,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- testsuite/Makefile.am 16 Mar 2007 15:00:49 -0000 1.33
+++ testsuite/Makefile.am 20 Apr 2007 09:03:42 -0000 1.34
@@ -25,6 +25,8 @@
libtestsuite_la_SOURCES = \
MovieTester.h \
MovieTester.cpp \
+ FuzzyPixel.cpp \
+ FuzzyPixel.h \
sound_handler_test.h \
sound_handler_test.cpp \
$(NULL)
Index: testsuite/MovieTester.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- testsuite/MovieTester.cpp 18 Apr 2007 17:28:13 -0000 1.25
+++ testsuite/MovieTester.cpp 20 Apr 2007 09:03:42 -0000 1.26
@@ -31,6 +31,8 @@
#include "sound_handler_test.h" // for creating the "test" sound handler
#include "render.h" // for get_render_handler
#include "types.h" // for rgba class
+#include "FuzzyPixel.h"
+#include "render_handler_agg.h"
#include <cstdio>
#include <string>
@@ -74,6 +76,13 @@
_movie_root = &(VM::init(*_movie_def).getRoot());
+ // Initialize viewport size with the one advertised in the header
+ _width = unsigned(_movie_def->get_width_pixels());
+ _height = unsigned(_movie_def->get_height_pixels());
+
+ // Initialize the testing renderers
+ initTestingRenderers();
+
// Now complete load of the movie
_movie_def->completeLoad();
_movie_def->ensure_frame_loaded(_movie_def->get_frame_count());
@@ -146,17 +155,10 @@
_movie_root->notify_mouse_moved(x, y);
}
-FuzzyPixel
-MovieTester::getAveragePixel(unsigned radius, int tolerance) const
+void
+MovieTester::checkPixel(unsigned radius, const rgba& color, int tolerance)
const
{
- render_handler* rend = get_render_handler();
- assert(rend);
- rgba color;
- if ( ! rend->getAveragePixel(color, _x, _y, radius) )
- {
- return FuzzyPixel();
- }
- return FuzzyPixel(color, tolerance);
+ log_msg("XFAILED: pixel checking not implemented yet.");
}
void
@@ -226,24 +228,45 @@
return _sound_handler.get()->test_times_stopped_all();
}
-bool
-FuzzyPixel::operator==(const FuzzyPixel& o) const
+void
+MovieTester::initTestingRenderers()
+{
+ std::auto_ptr<render_handler> handler;
+
+ // Initialize AGG
+ handler.reset( create_render_handler_agg("RGB24") );
+ assert(handler.get());
+ addTestingRenderer(handler, "AGG_RGB24");
+}
+
+void
+MovieTester::addTestingRenderer(std::auto_ptr<render_handler> h, const
std::string& name)
{
- // Intolerant FuzzyPixels never succeed in comparison
- if ( _tol < 0 || o._tol < 0 ) return false;
+ // TODO: init the buffer before pushing, and do not add to the table
+ // if the renderer is not capable of doing so !!
- int tol=std::max(_tol, o._tol);
- if ( ! fuzzyEqual(_col.m_r, o._col.m_r, tol) ) return false;
- if ( ! fuzzyEqual(_col.m_g, o._col.m_g, tol) ) return false;
- if ( ! fuzzyEqual(_col.m_b, o._col.m_b, tol) ) return false;
- if ( ! fuzzyEqual(_col.m_a, o._col.m_a, tol) ) return false;
- return true;
+ 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;
+
+ // h->initTestBuffer(_width, _height);
+ //_testingRenderers.push_back(TestingRendererPtr(new TestingRenderer(h,
name)));
}
-std::ostream&
-operator<< (std::ostream& o, const FuzzyPixel& p)
+FuzzyPixel
+TestingRenderer::getAveragePixel(int x, int y, unsigned radius, unsigned
tolerance) const
{
- return o << "FuzzyPixel(" << p._col.toString() << ") [tol:" << p._tol
<< "]";
+ render_handler* rend = get_render_handler();
+ assert(rend);
+ rgba color;
+ if ( ! rend->getAveragePixel(color, x, y, radius) )
+ {
+ return FuzzyPixel();
+ }
+ return FuzzyPixel(color, tolerance);
}
+
} // namespace gnash
Index: testsuite/MovieTester.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/MovieTester.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- testsuite/MovieTester.h 18 Apr 2007 17:28:13 -0000 1.13
+++ testsuite/MovieTester.h 20 Apr 2007 09:03:42 -0000 1.14
@@ -26,7 +26,8 @@
#include "types.h" // for rgba class
#include <memory> // for auto_ptr
-#include <string> // for auto_ptr
+#include <string>
+#include <boost/shared_ptr.hpp>
// Forward declarations
namespace gnash {
@@ -34,97 +35,56 @@
class movie_root;
class sprite_instance;
class character;
+ class FuzzyPixel;
}
namespace gnash {
-/// An utility class used to compare rgba values with a given tolerance
-class FuzzyPixel
+/// A table of built renderers
+//
+///
+class TestingRenderer
{
public:
- friend std::ostream& operator<< (std::ostream& o, const FuzzyPixel& p);
-
- /// Construct a black, alpha 0 FuzzyPixel with NO tolerance.
- //
- /// No tolerance means that any comparison will fail
- ///
- FuzzyPixel()
+ TestingRenderer(std::auto_ptr<render_handler> renderer, const
std::string& name)
:
- _col(0,0,0,0),
- _tol(0)
- {
- }
+ _name(name),
+ _renderer(renderer)
+ {}
- /// Construct a FuzzyPixel with given color and tolerance
- //
- /// @param color
- /// The color value
- ///
- /// @param tolerance
- /// The tolerance to use in comparisons
- ///
- FuzzyPixel(rgba& color, int tolerance=0)
- :
- _col(color),
- _tol(tolerance)
- {
- }
+ const std::string& getName() const { return _name; }
- /// Construct a FuzzyPixel with given values
+ /// Get the average pixel under the mouse pointer
//
- /// @param r
- /// The red value.
+ /// @param x
+ /// X coordinate, in pixels
///
- /// @param g
- /// The green value.
+ /// @param x
+ /// Y coordinate, in pixels
///
- /// @param b
- /// The blue value.
- ///
- /// @param a
- /// The alpha value.
+ /// @param radius
+ /// Radius defining the average zone used.
+ /// 1 means a single pixel.
+ /// Behaviour of passing 0 is undefined.
///
- FuzzyPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
- :
- _col(r, g, b, a),
- _tol(0)
- {
- }
-
- /// Set the tolerance to use in comparisons
- //
- /// @param tol
- /// The tolerance to use in comparisons
+ /// @param tolerance
+ /// The tolerance value to use for the returned FuzzyPixel.
///
- void setTolerance(int tol)
- {
- _tol = tol;
- }
-
- /// Compare two FuzzyPixel using the tolerance of the most tolerant of
the two
- //
- /// Note that if any of the two operands has 0 tolerance, any equality
- /// comparison will fail.
+ /// Note that if current pointer is outside of the rendered region
+ /// an intollerant FuzzyPixel is returned.
///
- bool operator==(const FuzzyPixel& other) const;
-
- // Return true if a and b are below a given tolerance
- static bool fuzzyEqual(int a, int b, int tol)
- {
- return abs(a-b) <= tol;
- }
+ FuzzyPixel getAveragePixel(int x, int y, unsigned radius, unsigned
tolerance) const;
private:
- rgba _col;
-
- // tolerance value
- int _tol;
-
+ std::string _name;
+ std::auto_ptr<render_handler> _renderer;
};
+typedef boost::shared_ptr<TestingRenderer> TestingRendererPtr;
+
/// An utility class for testing movie playback
//
/// This is a just born implementation and doesn't
@@ -138,6 +98,11 @@
public:
/// Fully load the movie at the specified location
/// and create an instance of it.
+ /// Also, initialize any built renderer capable of in-memory
+ /// rendering to allow testing of it.
+ /// The renderer(s) will be initialized with a memory
+ /// buffer with the size found in the SWF header
+ ///
MovieTester(const std::string& filespec);
/// Advance the movie by one frame
@@ -176,20 +141,23 @@
///
void movePointerTo(int x, int y);
- /// Get the average pixel under the mouse pointer
+ /// Check color of the average pixel under the mouse pointer
//
+ ///
+ /// This method will test any built renderer.
+ ///
/// @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.
+ /// @param color
+ /// The color we expect to find under the pointer.
///
- /// Note that if current pointer is outside of the rendered region
- /// an intollerant FuzzyPixel is returned.
+ /// @param tolerance
+ /// The tolerated difference of any r,g,b,a values
///
- FuzzyPixel getAveragePixel(unsigned radius, int tolerance) const;
+ void checkPixel(unsigned radius, const rgba& color, int tolerance)
const;
/// Notify mouse button was pressed
void pressMouseButton();
@@ -229,6 +197,12 @@
private:
+ /// Initialize testing renderers
+ void initTestingRenderers();
+
+ /// 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);
+
gnash::movie_root* _movie_root;
gnash::movie_definition* _movie_def;
@@ -237,9 +211,23 @@
std::auto_ptr<TEST_sound_handler> _sound_handler;
+ /// Current pointer position - X ordinate
int _x;
+ /// Current pointer position - Y ordinate
int _y;
+
+ /// Current viewport width
+ unsigned _width;
+
+ /// Current viewport height
+ unsigned _height;
+
+ /// I'd use ptr_list here, but trying not to spread
+ /// boost 1.33 requirement for the moment.
+ /// Still, I'd like to simplify things...
+ /// is shared_ptr fine ?
+ std::vector< TestingRendererPtr > _testingRenderers;
};
} // namespace gnash
Index: testsuite/FuzzyPixel.cpp
===================================================================
RCS file: testsuite/FuzzyPixel.cpp
diff -N testsuite/FuzzyPixel.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/FuzzyPixel.cpp 20 Apr 2007 09:03:42 -0000 1.1
@@ -0,0 +1,45 @@
+/*
+ * 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 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
+ *
+ *
+ */
+
+#include "FuzzyPixel.h"
+#include "types.h" // for rgba class
+
+namespace gnash {
+
+bool
+FuzzyPixel::operator==(const FuzzyPixel& o) const
+{
+ // Intolerant FuzzyPixels never succeed in comparison
+ if ( _tol < 0 || o._tol < 0 ) return false;
+
+ int tol=std::max(_tol, o._tol);
+ if ( ! fuzzyEqual(_col.m_r, o._col.m_r, tol) ) return false;
+ if ( ! fuzzyEqual(_col.m_g, o._col.m_g, tol) ) return false;
+ if ( ! fuzzyEqual(_col.m_b, o._col.m_b, tol) ) return false;
+ if ( ! fuzzyEqual(_col.m_a, o._col.m_a, tol) ) return false;
+ return true;
+}
+
+std::ostream&
+operator<< (std::ostream& o, const FuzzyPixel& p)
+{
+ return o << "FuzzyPixel(" << p._col.toString() << ") [tol:" << p._tol
<< "]";
+}
+
+} // namespace gnash
Index: testsuite/FuzzyPixel.h
===================================================================
RCS file: testsuite/FuzzyPixel.h
diff -N testsuite/FuzzyPixel.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/FuzzyPixel.h 20 Apr 2007 09:03:42 -0000 1.1
@@ -0,0 +1,121 @@
+/*
+ * 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 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
+ *
+ *
+ */
+
+#ifndef _GNASH_FUZZYPIXEL_H
+#define _GNASH_FUZZYPIXEL_H
+
+#include "Range2d.h"
+#include "gnash.h" // for namespace key
+#include "sound_handler_test.h" // for creating the "test" sound handler
+#include "types.h" // for rgba class
+
+#include <iostream>
+
+namespace gnash {
+
+/// An utility class used to compare rgba values with a given tolerance
+class FuzzyPixel
+{
+
+public:
+
+ friend std::ostream& operator<< (std::ostream& o, const FuzzyPixel& p);
+
+ /// Construct a black, alpha 0 FuzzyPixel with NO tolerance.
+ //
+ /// No tolerance means that any comparison will fail
+ ///
+ FuzzyPixel()
+ :
+ _col(0,0,0,0),
+ _tol(0)
+ {
+ }
+
+ /// Construct a FuzzyPixel with given color and tolerance
+ //
+ /// @param color
+ /// The color value
+ ///
+ /// @param tolerance
+ /// The tolerance to use in comparisons
+ ///
+ FuzzyPixel(rgba& color, int tolerance=0)
+ :
+ _col(color),
+ _tol(tolerance)
+ {
+ }
+
+ /// Construct a FuzzyPixel with given values
+ //
+ /// @param r
+ /// The red value.
+ ///
+ /// @param g
+ /// The green value.
+ ///
+ /// @param b
+ /// The blue value.
+ ///
+ /// @param a
+ /// The alpha value.
+ ///
+ FuzzyPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
+ :
+ _col(r, g, b, a),
+ _tol(0)
+ {
+ }
+
+ /// Set the tolerance to use in comparisons
+ //
+ /// @param tol
+ /// The tolerance to use in comparisons
+ ///
+ void setTolerance(int tol)
+ {
+ _tol = tol;
+ }
+
+ /// Compare two FuzzyPixel using the tolerance of the most tolerant of
the two
+ //
+ /// Note that if any of the two operands has 0 tolerance, any equality
+ /// comparison will fail.
+ ///
+ bool operator==(const FuzzyPixel& other) const;
+
+ // Return true if a and b are below a given tolerance
+ static bool fuzzyEqual(int a, int b, int tol)
+ {
+ return abs(a-b) <= tol;
+ }
+
+private:
+
+ rgba _col;
+
+ // tolerance value
+ int _tol;
+
+};
+
+} // namespace gnash
+
+#endif // _GNASH_FUZZYPIXEL_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog testsuite/Makefile.am testsuite...,
Sandro Santilli <=