[Swfdec-commits] Branch 'test' - 7 commits - test/custom test/image test/swfdec_test.c test/swfdec_test_image.c test/swfdec_test_plugin.c test/swfdec_test_plugin.h test/swfdec_test_test.c test/swfdec_test_test.h test/trace
Benjamin Otte
company at kemper.freedesktop.org
Fri Feb 1 07:23:00 PST 2008
test/custom/Makefile.am | 2
test/image/Makefile.am | 2
test/swfdec_test.c | 2
test/swfdec_test_image.c | 8 +
test/swfdec_test_plugin.c | 69 ++++++++++++++
test/swfdec_test_plugin.h | 22 ++++
test/swfdec_test_test.c | 215 +++++++++++++++++++++++++++-------------------
test/swfdec_test_test.h | 11 +-
test/trace/Makefile.am | 2
9 files changed, 239 insertions(+), 94 deletions(-)
New commits:
commit c7a4757dbd3d155e6a9eeb7db91e49c300967130
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Feb 1 16:22:13 2008 +0100
add screenshot support
diff --git a/test/swfdec_test_plugin.c b/test/swfdec_test_plugin.c
index 9129ae0..bea718d 100644
--- a/test/swfdec_test_plugin.c
+++ b/test/swfdec_test_plugin.c
@@ -43,6 +43,22 @@ swfdec_test_plugin_swfdec_advance (SwfdecTestPlugin *plugin, unsigned int msecs)
}
static void
+swfdec_test_plugin_swfdec_screenshot (SwfdecTestPlugin *plugin, unsigned char *data,
+ guint x, guint y, guint width, guint height)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32,
+ width, height, width * 4);
+ cr = cairo_create (surface);
+ cairo_translate (cr, -x, -y);
+ swfdec_player_render (plugin->data, cr, x, y, width, height);
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+}
+
+static void
swfdec_test_plugin_swfdec_mouse_move (SwfdecTestPlugin *plugin, double x, double y)
{
swfdec_player_mouse_move (plugin->data, x, y);
@@ -104,10 +120,11 @@ swfdec_test_plugin_swfdec_new (SwfdecTestPlugin *plugin)
SwfdecURL *url;
plugin->advance = swfdec_test_plugin_swfdec_advance;
- plugin->finish = swfdec_test_plugin_swfdec_finish;
+ plugin->screenshot = swfdec_test_plugin_swfdec_screenshot;
plugin->mouse_move = swfdec_test_plugin_swfdec_mouse_move;
plugin->mouse_press = swfdec_test_plugin_swfdec_mouse_press;
plugin->mouse_release = swfdec_test_plugin_swfdec_mouse_release;
+ plugin->finish = swfdec_test_plugin_swfdec_finish;
plugin->data = player = swfdec_player_new (NULL);
g_signal_connect (player, "fscommand", G_CALLBACK (swfdec_test_plugin_swfdec_fscommand), plugin);
diff --git a/test/swfdec_test_plugin.h b/test/swfdec_test_plugin.h
index 83bd3cb..e7a68e9 100644
--- a/test/swfdec_test_plugin.h
+++ b/test/swfdec_test_plugin.h
@@ -54,6 +54,14 @@ struct _SwfdecTestPlugin {
unsigned int rate; /* in 256th of a second */
void (* advance) (SwfdecTestPlugin * plugin,
unsigned int msecs);
+ /* data nulled is ARGB for (provided) width * height with rowstride = width * 4 */
+ /* size is guaranteed to fit into 0,0 x width,height */
+ void (* screenshot) (SwfdecTestPlugin * plugin,
+ unsigned char * data,
+ unsigned int x,
+ unsigned int y,
+ unsigned int width,
+ unsigned int height);
void (* mouse_move) (SwfdecTestPlugin * plugin,
double x,
double y);
diff --git a/test/swfdec_test_test.c b/test/swfdec_test_test.c
index 322ef8a..0d6bd56 100644
--- a/test/swfdec_test_test.c
+++ b/test/swfdec_test_test.c
@@ -266,31 +266,31 @@ void
swfdec_test_test_render (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
SwfdecAsValue *argv, SwfdecAsValue *retval)
{
-#if 0
SwfdecTestTest *test;
SwfdecAsObject *image;
+ int x, y, w, h;
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "|iiii", &x, &y, &w, &h);
- if (!swfdec_test_test_ensure_player (test))
+ if (!test->plugin_loaded || test->plugin_error || test->plugin_quit)
return;
if (argc == 0) {
- swfdec_player_get_size (test->player, &w, &h);
- if (w < 0 || h < 0)
- swfdec_player_get_default_size (test->player, (guint *) &w, (guint *) &h);
+ w = test->plugin.width;
+ h = test->plugin.height;
}
image = swfdec_test_image_new (cx, w, h);
if (image == NULL)
return;
- cr = cairo_create (SWFDEC_TEST_IMAGE (image)->surface);
- cairo_translate (cr, -x, -y);
- swfdec_player_render (test->player, cr, x, y, w, h);
- cairo_destroy (cr);
- SWFDEC_AS_VALUE_SET_OBJECT (retval, image);
-#else
- swfdec_test_throw (cx, "implement");
-#endif
+
+ if (test->plugin.screenshot) {
+ test->plugin.screenshot (&test->plugin,
+ cairo_image_surface_get_data (SWFDEC_TEST_IMAGE (image)->surface),
+ x, y, w, h);
+ SWFDEC_AS_VALUE_SET_OBJECT (retval, image);
+ } else {
+ swfdec_test_throw (cx, "plugin doesn't implement mouse_press");
+ }
}
SWFDEC_TEST_FUNCTION ("Test", swfdec_test_test_new, swfdec_test_test_get_type)
commit e36ac8c072d9fb2f8379ceb74f7cf188dbc0147f
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Feb 1 16:22:06 2008 +0100
throw if saving fails
diff --git a/test/swfdec_test_image.c b/test/swfdec_test_image.c
index 26282ba..3d3a60e 100644
--- a/test/swfdec_test_image.c
+++ b/test/swfdec_test_image.c
@@ -23,6 +23,7 @@
#include "swfdec_test_image.h"
#include "swfdec_test_function.h"
+#include "swfdec_test_utils.h"
#define SWFDEC_TEST_IMAGE_IS_VALID(image) ((image)->surface && \
cairo_surface_status ((image)->surface) == CAIRO_STATUS_SUCCESS)
@@ -190,6 +191,7 @@ swfdec_test_image_save (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
{
SwfdecTestImage *image;
const char *filename;
+ cairo_status_t status;
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_IMAGE, &image, "s", &filename);
@@ -197,8 +199,10 @@ swfdec_test_image_save (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
if (!SWFDEC_TEST_IMAGE_IS_VALID (image))
return;
- if (cairo_surface_write_to_png (image->surface, filename) != CAIRO_STATUS_SUCCESS)
- return;
+ status = cairo_surface_write_to_png (image->surface, filename);
+ if (status != CAIRO_STATUS_SUCCESS) {
+ swfdec_test_throw (cx, "Couldn't save to %s: %s", filename, cairo_status_to_string (status));
+ }
SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
}
commit 1bffe8a4ac6cbe18f8b5af7e82dfa4a52c992058
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Feb 1 15:54:18 2008 +0100
implement mouse events again
diff --git a/test/swfdec_test_plugin.c b/test/swfdec_test_plugin.c
index abbd653..9129ae0 100644
--- a/test/swfdec_test_plugin.c
+++ b/test/swfdec_test_plugin.c
@@ -43,6 +43,24 @@ swfdec_test_plugin_swfdec_advance (SwfdecTestPlugin *plugin, unsigned int msecs)
}
static void
+swfdec_test_plugin_swfdec_mouse_move (SwfdecTestPlugin *plugin, double x, double y)
+{
+ swfdec_player_mouse_move (plugin->data, x, y);
+}
+
+static void
+swfdec_test_plugin_swfdec_mouse_press (SwfdecTestPlugin *plugin, double x, double y, guint button)
+{
+ swfdec_player_mouse_press (plugin->data, x, y, button);
+}
+
+static void
+swfdec_test_plugin_swfdec_mouse_release (SwfdecTestPlugin *plugin, double x, double y, guint button)
+{
+ swfdec_player_mouse_release (plugin->data, x, y, button);
+}
+
+static void
swfdec_test_plugin_swfdec_finish (SwfdecTestPlugin *plugin)
{
if (plugin->data) {
@@ -87,6 +105,9 @@ swfdec_test_plugin_swfdec_new (SwfdecTestPlugin *plugin)
plugin->advance = swfdec_test_plugin_swfdec_advance;
plugin->finish = swfdec_test_plugin_swfdec_finish;
+ plugin->mouse_move = swfdec_test_plugin_swfdec_mouse_move;
+ plugin->mouse_press = swfdec_test_plugin_swfdec_mouse_press;
+ plugin->mouse_release = swfdec_test_plugin_swfdec_mouse_release;
plugin->data = player = swfdec_player_new (NULL);
g_signal_connect (player, "fscommand", G_CALLBACK (swfdec_test_plugin_swfdec_fscommand), plugin);
diff --git a/test/swfdec_test_plugin.h b/test/swfdec_test_plugin.h
index d7861f9..83bd3cb 100644
--- a/test/swfdec_test_plugin.h
+++ b/test/swfdec_test_plugin.h
@@ -54,6 +54,17 @@ struct _SwfdecTestPlugin {
unsigned int rate; /* in 256th of a second */
void (* advance) (SwfdecTestPlugin * plugin,
unsigned int msecs);
+ void (* mouse_move) (SwfdecTestPlugin * plugin,
+ double x,
+ double y);
+ void (* mouse_press) (SwfdecTestPlugin * plugin,
+ double x,
+ double y,
+ unsigned int button); /* 1 - 32 */
+ void (* mouse_release) (SwfdecTestPlugin * plugin,
+ double x,
+ double y,
+ unsigned int button); /* 1 - 32 */
void (* finish) (SwfdecTestPlugin * plugin);
void * data;
};
diff --git a/test/swfdec_test_test.c b/test/swfdec_test_test.c
index bee1e7a..322ef8a 100644
--- a/test/swfdec_test_test.c
+++ b/test/swfdec_test_test.c
@@ -177,7 +177,11 @@ swfdec_test_test_advance (SwfdecAsContext *cx, SwfdecAsObject *object, guint arg
if (msecs < 0 || !test->plugin_loaded || test->plugin_error || test->plugin_quit)
return;
- test->plugin.advance (&test->plugin, msecs);
+ if (test->plugin.advance) {
+ test->plugin.advance (&test->plugin, msecs);
+ } else {
+ swfdec_test_throw (cx, "plugin doesn't implement advance");
+ }
}
SWFDEC_TEST_FUNCTION ("Test_reset", swfdec_test_test_reset, 0)
@@ -203,14 +207,14 @@ swfdec_test_test_mouse_move (SwfdecAsContext *cx, SwfdecAsObject *object, guint
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "nn", &x, &y);
-#if 0
- if (!swfdec_test_test_ensure_player (test))
+ if (!test->plugin_loaded || test->plugin_error || test->plugin_quit)
return;
- swfdec_player_mouse_move (test->player, x, y);
-#else
- swfdec_test_throw (cx, "implement");
-#endif
+ if (test->plugin.advance) {
+ test->plugin.mouse_move (&test->plugin, x, y);
+ } else {
+ swfdec_test_throw (cx, "plugin doesn't implement mouse_move");
+ }
}
SWFDEC_TEST_FUNCTION ("Test_mouse_press", swfdec_test_test_mouse_press, 0)
@@ -224,15 +228,15 @@ swfdec_test_test_mouse_press (SwfdecAsContext *cx, SwfdecAsObject *object, guint
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "nn|i", &x, &y, &button);
-#if 0
- if (!swfdec_test_test_ensure_player (test))
+ if (!test->plugin_loaded || test->plugin_error || test->plugin_quit)
return;
button = CLAMP (button, 1, 32);
- swfdec_player_mouse_press (test->player, x, y, button);
-#else
- swfdec_test_throw (cx, "implement");
-#endif
+ if (test->plugin.advance) {
+ test->plugin.mouse_press (&test->plugin, x, y, button);
+ } else {
+ swfdec_test_throw (cx, "plugin doesn't implement mouse_press");
+ }
}
SWFDEC_TEST_FUNCTION ("Test_mouse_release", swfdec_test_test_mouse_release, 0)
@@ -246,15 +250,15 @@ swfdec_test_test_mouse_release (SwfdecAsContext *cx, SwfdecAsObject *object, gui
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "nn|i", &x, &y, &button);
-#if 0
- if (!swfdec_test_test_ensure_player (test))
+ if (!test->plugin_loaded || test->plugin_error || test->plugin_quit)
return;
button = CLAMP (button, 1, 32);
- swfdec_player_mouse_release (test->player, x, y, button);
-#else
- swfdec_test_throw (cx, "implement");
-#endif
+ if (test->plugin.advance) {
+ test->plugin.mouse_release (&test->plugin, x, y, button);
+ } else {
+ swfdec_test_throw (cx, "plugin doesn't implement mouse_press");
+ }
}
SWFDEC_TEST_FUNCTION ("Test_render", swfdec_test_test_render, 0)
commit 6b0a346c5bba0b26944e5860f1a156599906c14d
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Feb 1 15:39:35 2008 +0100
switch to plugin usage
trace directory already works, the rest is broken.
diff --git a/test/swfdec_test.c b/test/swfdec_test.c
index 35e99d1..0559c75 100644
--- a/test/swfdec_test.c
+++ b/test/swfdec_test.c
@@ -31,6 +31,7 @@
#include "swfdec_test_function.h"
#include "swfdec_test_initialize.h"
+#include "swfdec_test_test.h"
/* Start of script file */
@@ -81,6 +82,7 @@ main (int argc, char **argv)
GOptionEntry options[] = {
{ "dump", 'd', 0, G_OPTION_ARG_NONE, &dump, "dump images on failure", FALSE },
+ { "player", 'p', 0, G_OPTION_ARG_STRING, &swfdec_test_plugin_name, "player to test", "NAME" },
{ "script", 's', 0, G_OPTION_ARG_STRING, &script_filename, "script to execute if not ./default.sts", "FILENAME" },
{ NULL }
};
diff --git a/test/swfdec_test_test.c b/test/swfdec_test_test.c
index c263bed..bee1e7a 100644
--- a/test/swfdec_test_test.c
+++ b/test/swfdec_test_test.c
@@ -30,6 +30,94 @@
#include "swfdec_test_image.h"
#include "swfdec_test_utils.h"
+/*** PLUGIN HANDLING ***/
+
+#define SWFDEC_TEST_TEST_FROM_PLUGIN(x) \
+ SWFDEC_TEST_TEST ((gpointer) ((guint8 *) (x) - G_STRUCT_OFFSET (SwfdecTestTest, plugin)))
+
+char *swfdec_test_plugin_name = NULL;
+
+static void
+swfdec_test_test_quit (SwfdecTestPlugin *plugin)
+{
+ SwfdecTestTest *test = SWFDEC_TEST_TEST_FROM_PLUGIN (plugin);
+
+ test->plugin_quit = TRUE;
+}
+
+static void
+swfdec_test_test_error (SwfdecTestPlugin *plugin, const char *description)
+{
+ SwfdecTestTest *test = SWFDEC_TEST_TEST_FROM_PLUGIN (plugin);
+
+ if (test->plugin_error)
+ return;
+ test->plugin_error = TRUE;
+ swfdec_test_throw (SWFDEC_AS_OBJECT (test)->context, description);
+}
+
+static void
+swfdec_test_test_trace (SwfdecTestPlugin *plugin, const char *message)
+{
+ SwfdecTestTest *test = SWFDEC_TEST_TEST_FROM_PLUGIN (plugin);
+ gsize len = strlen (message);
+ SwfdecBuffer *buffer;
+
+ buffer = swfdec_buffer_new_and_alloc (len + 1);
+ memcpy (buffer->data, message, len);
+ buffer->data[len] = '\n';
+ swfdec_buffer_queue_push (test->trace, buffer);
+}
+
+static void
+swfdec_test_test_load_plugin (SwfdecTestTest *test, const char *filename)
+{
+ memset (&test->plugin, 0, sizeof (SwfdecTestPlugin));
+ /* initialize test->plugin */
+ test->plugin.filename = g_strdup (filename);
+ test->plugin.trace = swfdec_test_test_trace;
+ test->plugin.quit = swfdec_test_test_quit;
+ test->plugin.error = swfdec_test_test_error;
+
+ /* load the right values */
+ if (swfdec_test_plugin_name) {
+ void (*init) (SwfdecTestPlugin *plugin);
+ char *dir = g_build_filename (g_get_home_dir (), ".swfdec-test", NULL);
+ char *name = g_module_build_path (dir, swfdec_test_plugin_name);
+ g_free (dir);
+ test->module = g_module_open (name, G_MODULE_BIND_LOCAL);
+ if (test->module == NULL) {
+ swfdec_test_throw (SWFDEC_AS_OBJECT (test)->context, "could not find player \"%s\"",
+ swfdec_test_plugin_name);
+ return;
+ }
+ if (!g_module_symbol (test->module, "swfdec_test_plugin_init", (gpointer) &init)) {
+ g_module_close (test->module);
+ test->module = NULL;
+ }
+ init (&test->plugin);
+ } else {
+ swfdec_test_plugin_swfdec_new (&test->plugin);
+ }
+ test->plugin_loaded = TRUE;
+}
+
+static void
+swfdec_test_test_unload_plugin (SwfdecTestTest *test)
+{
+ if (!test->plugin_loaded)
+ return;
+ test->plugin.finish (&test->plugin);
+ g_free (test->plugin.filename);
+ if (test->module) {
+ g_module_close (test->module);
+ test->module = NULL;
+ }
+ test->plugin_quit = FALSE;
+ test->plugin_error = FALSE;
+ test->plugin_loaded = FALSE;
+}
+
/*** SWFDEC_TEST_TEST ***/
G_DEFINE_TYPE (SwfdecTestTest, swfdec_test_test, SWFDEC_TYPE_AS_OBJECT)
@@ -46,11 +134,7 @@ swfdec_test_test_dispose (GObject *object)
g_free (test->filename);
test->filename = NULL;
- if (test->player) {
- g_signal_handlers_disconnect_matched (test, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, test);
- g_object_unref (test->player);
- test->player = NULL;
- }
+ swfdec_test_test_unload_plugin (test);
G_OBJECT_CLASS (swfdec_test_test_parent_class)->dispose (object);
}
@@ -70,61 +154,14 @@ swfdec_test_test_init (SwfdecTestTest *test)
}
static void
-swfdec_test_test_fscommand (SwfdecPlayer *player, const char *command,
- const char *para, SwfdecTestTest *test)
-{
- if (g_ascii_strcasecmp (command, "quit") == 0) {
- test->player_quit = TRUE;
- }
-}
-
-static void
-swfdec_test_test_trace_cb (SwfdecPlayer *player, const char *message, SwfdecTestTest *test)
-{
- gsize len = strlen (message);
- SwfdecBuffer *buffer;
-
- buffer = swfdec_buffer_new_and_alloc (len + 1);
- memcpy (buffer->data, message, len);
- buffer->data[len] = '\n';
- swfdec_buffer_queue_push (test->trace, buffer);
-}
-
-static gboolean
-swfdec_test_test_ensure_player (SwfdecTestTest *test)
-{
- SwfdecURL *url;
-
- if (test->filename == NULL)
- return FALSE;
- if (test->player)
- return TRUE;
-
- g_assert (test->player_quit == FALSE);
- test->player = swfdec_player_new (NULL);
- url = swfdec_url_new_from_input (test->filename);
- swfdec_player_set_url (test->player, url);
- swfdec_url_free (url);
- g_signal_connect (test->player, "fscommand", G_CALLBACK (swfdec_test_test_fscommand), test);
- g_signal_connect (test->player, "trace", G_CALLBACK (swfdec_test_test_trace_cb), test);
- return TRUE;
-}
-
-static void
swfdec_test_do_reset (SwfdecTestTest *test, const char *filename)
{
- if (test->player) {
- g_signal_handlers_disconnect_matched (test, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, test);
- g_object_unref (test->player);
- test->player = NULL;
- }
+ swfdec_test_test_unload_plugin (test);
swfdec_buffer_queue_clear (test->trace);
if (filename == NULL)
return;
- g_free (test->filename);
- test->filename = g_strdup (filename);
- test->player_quit = FALSE;
+ swfdec_test_test_load_plugin (test, filename);
}
SWFDEC_TEST_FUNCTION ("Test_advance", swfdec_test_test_advance, 0)
@@ -137,23 +174,10 @@ swfdec_test_test_advance (SwfdecAsContext *cx, SwfdecAsObject *object, guint arg
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "i", &msecs);
- if (msecs < 0 || test->player_quit)
- return;
- if (!swfdec_test_test_ensure_player (test))
+ if (msecs < 0 || !test->plugin_loaded || test->plugin_error || test->plugin_quit)
return;
- if (msecs == 0) {
- if (!test->player_quit)
- swfdec_player_advance (test->player, 0);
- } else {
- while (msecs > 0 && !test->player_quit) {
- int next_event = swfdec_player_get_next_event (test->player);
- if (next_event < 0)
- break;
- next_event = MIN (next_event, msecs);
- swfdec_player_advance (test->player, next_event);
- msecs -= next_event;
- }
- }
+
+ test->plugin.advance (&test->plugin, msecs);
}
SWFDEC_TEST_FUNCTION ("Test_reset", swfdec_test_test_reset, 0)
@@ -179,10 +203,14 @@ swfdec_test_test_mouse_move (SwfdecAsContext *cx, SwfdecAsObject *object, guint
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "nn", &x, &y);
+#if 0
if (!swfdec_test_test_ensure_player (test))
return;
swfdec_player_mouse_move (test->player, x, y);
+#else
+ swfdec_test_throw (cx, "implement");
+#endif
}
SWFDEC_TEST_FUNCTION ("Test_mouse_press", swfdec_test_test_mouse_press, 0)
@@ -196,11 +224,15 @@ swfdec_test_test_mouse_press (SwfdecAsContext *cx, SwfdecAsObject *object, guint
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "nn|i", &x, &y, &button);
+#if 0
if (!swfdec_test_test_ensure_player (test))
return;
button = CLAMP (button, 1, 32);
swfdec_player_mouse_press (test->player, x, y, button);
+#else
+ swfdec_test_throw (cx, "implement");
+#endif
}
SWFDEC_TEST_FUNCTION ("Test_mouse_release", swfdec_test_test_mouse_release, 0)
@@ -214,11 +246,15 @@ swfdec_test_test_mouse_release (SwfdecAsContext *cx, SwfdecAsObject *object, gui
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "nn|i", &x, &y, &button);
+#if 0
if (!swfdec_test_test_ensure_player (test))
return;
button = CLAMP (button, 1, 32);
swfdec_player_mouse_release (test->player, x, y, button);
+#else
+ swfdec_test_throw (cx, "implement");
+#endif
}
SWFDEC_TEST_FUNCTION ("Test_render", swfdec_test_test_render, 0)
@@ -226,10 +262,9 @@ void
swfdec_test_test_render (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
SwfdecAsValue *argv, SwfdecAsValue *retval)
{
+#if 0
SwfdecTestTest *test;
SwfdecAsObject *image;
- int x, y, w, h;
- cairo_t *cr;
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "|iiii", &x, &y, &w, &h);
@@ -249,6 +284,9 @@ swfdec_test_test_render (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc
swfdec_player_render (test->player, cr, x, y, w, h);
cairo_destroy (cr);
SWFDEC_AS_VALUE_SET_OBJECT (retval, image);
+#else
+ swfdec_test_throw (cx, "implement");
+#endif
}
SWFDEC_TEST_FUNCTION ("Test", swfdec_test_test_new, swfdec_test_test_get_type)
@@ -293,6 +331,9 @@ swfdec_test_test_get_rate (SwfdecAsContext *cx, SwfdecAsObject *object, guint ar
SWFDEC_AS_CHECK (SWFDEC_TYPE_TEST_TEST, &test, "");
- SWFDEC_AS_VALUE_SET_NUMBER (retval, test->player ? swfdec_player_get_rate (test->player) : 0);
+ if (!test->plugin_loaded)
+ return;
+
+ SWFDEC_AS_VALUE_SET_NUMBER (retval, test->plugin.rate / 256.0);
}
diff --git a/test/swfdec_test_test.h b/test/swfdec_test_test.h
index 110aecc..f074108 100644
--- a/test/swfdec_test_test.h
+++ b/test/swfdec_test_test.h
@@ -21,6 +21,7 @@
#define _SWFDEC_TEST_TEST_H_
#include "swfdec_test_plugin.h"
+#include <gmodule.h>
#include <swfdec/swfdec.h>
G_BEGIN_DECLS
@@ -40,9 +41,13 @@ struct _SwfdecTestTest
{
SwfdecAsObject as_object;
+ SwfdecTestPlugin plugin; /* the plugin we use */
+ GModule * module; /* module we loaded the plugin from or NULL */
+ gboolean plugin_loaded; /* the plugin is loaded and ready to rumble */
+ gboolean plugin_quit; /* the plugin has called quit */
+ gboolean plugin_error; /* the plugin has called error */
+
char * filename; /* file the player should be loaded from */
- SwfdecPlayer * player; /* the player or %NULL if none */
- gboolean player_quit; /* the player has called fscommand:quit */
SwfdecBufferQueue * trace; /* all captured trace output */
};
@@ -51,6 +56,8 @@ struct _SwfdecTestTestClass
SwfdecAsObjectClass as_object_class;
};
+extern char *swfdec_test_plugin_name;
+
GType swfdec_test_test_get_type (void);
void swfdec_test_plugin_swfdec_new (SwfdecTestPlugin * plugin);
commit cd93f6d47db6d5ae0a7a28a44b86cc74ec523a70
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Feb 1 15:39:08 2008 +0100
provide width/height/rate
diff --git a/test/swfdec_test_plugin.c b/test/swfdec_test_plugin.c
index 6a641fb..abbd653 100644
--- a/test/swfdec_test_plugin.c
+++ b/test/swfdec_test_plugin.c
@@ -28,13 +28,27 @@
static void
swfdec_test_plugin_swfdec_advance (SwfdecTestPlugin *plugin, unsigned int msecs)
{
- swfdec_player_advance (plugin->data, msecs);
+ if (msecs == 0) {
+ swfdec_player_advance (plugin->data, 0);
+ } else {
+ while (msecs > 0 && plugin->data) {
+ long next_event = swfdec_player_get_next_event (plugin->data);
+ if (next_event < 0)
+ break;
+ next_event = MIN (next_event, (long) msecs);
+ swfdec_player_advance (plugin->data, next_event);
+ msecs -= next_event;
+ }
+ }
}
static void
swfdec_test_plugin_swfdec_finish (SwfdecTestPlugin *plugin)
{
- g_object_unref (plugin->data);
+ if (plugin->data) {
+ g_object_unref (plugin->data);
+ plugin->data = NULL;
+ }
}
static void
@@ -50,6 +64,18 @@ swfdec_test_plugin_swfdec_fscommand (SwfdecPlayer *player, const char *command,
{
if (g_ascii_strcasecmp (command, "quit") == 0) {
plugin->quit (plugin);
+ swfdec_test_plugin_swfdec_finish (plugin);
+ }
+}
+
+static void
+swfdec_test_plugin_swfdec_notify (SwfdecPlayer *player, GParamSpec *pspec, SwfdecTestPlugin *plugin)
+{
+ if (g_str_equal (pspec->name, "default-width") ||
+ g_str_equal (pspec->name, "default-height")) {
+ swfdec_player_get_default_size (player, &plugin->width, &plugin->height);
+ } else if (g_str_equal (pspec->name, "rate")) {
+ plugin->rate = swfdec_player_get_rate (player) * 256;
}
}
@@ -65,6 +91,7 @@ swfdec_test_plugin_swfdec_new (SwfdecTestPlugin *plugin)
g_signal_connect (player, "fscommand", G_CALLBACK (swfdec_test_plugin_swfdec_fscommand), plugin);
g_signal_connect (player, "trace", G_CALLBACK (swfdec_test_plugin_swfdec_trace), plugin);
+ g_signal_connect (player, "notify", G_CALLBACK (swfdec_test_plugin_swfdec_notify), plugin);
url = swfdec_url_new_from_input (plugin->filename);
swfdec_player_set_url (player, url);
swfdec_url_free (url);
commit bb149cc0becbb9f6338169d8acc69c7175d9bf01
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Feb 1 15:38:57 2008 +0100
let the plugin provide width/height/rate
diff --git a/test/swfdec_test_plugin.h b/test/swfdec_test_plugin.h
index 86b7f91..d7861f9 100644
--- a/test/swfdec_test_plugin.h
+++ b/test/swfdec_test_plugin.h
@@ -49,6 +49,9 @@ struct _SwfdecTestPlugin {
void (* error) (SwfdecTestPlugin * plugin,
const char * description);
/* initialized by the plugin during swfdec_test_plugin_new() */
+ unsigned int width;
+ unsigned int height;
+ unsigned int rate; /* in 256th of a second */
void (* advance) (SwfdecTestPlugin * plugin,
unsigned int msecs);
void (* finish) (SwfdecTestPlugin * plugin);
commit b2715c1971b8e06cc7f2a501bccc71a194e6ec53
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Feb 1 15:38:03 2008 +0100
s/test/swfdec-test/
diff --git a/test/custom/Makefile.am b/test/custom/Makefile.am
index f596de7..11b2d82 100644
--- a/test/custom/Makefile.am
+++ b/test/custom/Makefile.am
@@ -1,6 +1,6 @@
check-local:
for file in $(srcdir)/*.sts; do \
- ../test --script $$file $(srcdir)/`basename $$file .sts`*.swf; \
+ ../swfdec-test --script $$file $(srcdir)/`basename $$file .sts`*.swf; \
done
EXTRA_DIST = \
diff --git a/test/image/Makefile.am b/test/image/Makefile.am
index 7fef43b..59e8119 100644
--- a/test/image/Makefile.am
+++ b/test/image/Makefile.am
@@ -1,5 +1,5 @@
check-local:
- ../test --script $(srcdir)/default.sts $(srcdir)/*.swf
+ ../swfdec-test --script $(srcdir)/default.sts $(srcdir)/*.swf
EXTRA_DIST = \
README \
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index d2173df..df407cd 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1,5 +1,5 @@
check-local:
- ../test --script $(srcdir)/default.sts $(srcdir)/*.swf
+ ../swfdec-test --script $(srcdir)/default.sts $(srcdir)/*.swf
EXTRA_DIST = \
README \
More information about the Swfdec-commits
mailing list