[dia] [unit test] implement trivial DiaObject::draw() test
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [unit test] implement trivial DiaObject::draw() test
- Date: Sun, 14 Oct 2012 13:27:40 +0000 (UTC)
commit adc125e6f6ad2633a510b995f297ab5e8c08c8f7
Author: Hans Breuer <hans breuer org>
Date: Sun Oct 14 15:26:01 2012 +0200
[unit test] implement trivial DiaObject::draw() test
This is testing the new path renderer as well as the object's
draw method. Currently it is a just-doesn't-crash test, but with
a more reliable path renderer we might introduce checks e.g.
against the bounding box calculation of the object.
Also added dia_object_set_string() call to
_test_connectionpoint_consistency() to have some more realistic
object state to test.
tests/test-objects.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-objects.c b/tests/test-objects.c
index 2a60a39..76220a6 100644
--- a/tests/test-objects.c
+++ b/tests/test-objects.c
@@ -33,6 +33,7 @@
#include "dialib.h"
#include "create.h"
#include "properties.h"
+#include "diapathrenderer.h"
/* allows to select specific objects for testing */
static gchar *_type_name = NULL;
@@ -361,8 +362,12 @@ _test_connectionpoint_consistency (const DiaObjectType *type)
Point pos = {0, 0};
Point center;
DiaObject *o = type->ops->create (&pos, type->default_user_data, &h1, &h2);
+ ObjectChange *change;
int i;
+ change = dia_object_set_string (o, NULL, "Test me!");
+ _object_change_free (change);
+
pos = o->position;
center.x = (o->bounding_box.right + o->bounding_box.left) / 2;
center.y = (o->bounding_box.bottom + o->bounding_box.top) / 2;
@@ -486,6 +491,22 @@ _test_object_menu (const DiaObjectType *type)
g_free (o);
}
+static void
+_test_draw (const DiaObjectType *type)
+{
+ Handle *h1 = NULL, *h2 = NULL;
+ Point from = {0, 0};
+ DiaObject *o = type->ops->create (&from, type->default_user_data, &h1, &h2);
+
+ DiaRenderer *renderer = g_object_new (DIA_TYPE_PATH_RENDERER, 0);
+
+ o->ops->draw (o, renderer);
+ /* finally */
+ o->ops->destroy (o);
+ g_free (o);
+ g_object_unref (renderer);
+}
+
/*
* A dictionary interface to all registered object(-types)
*/
@@ -528,6 +549,10 @@ _ot_item (gpointer key,
g_test_add_data_func (testpath, type, _test_object_menu);
g_free (testpath);
+ testpath = g_strdup_printf ("%s/%s/%s", base, name, "Draw");
+ g_test_add_data_func (testpath, type, _test_draw);
+ g_free (testpath);
+
++num_objects;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]