tracker r1676 - in branches/xesam-support: . tests/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1676 - in branches/xesam-support: . tests/trackerd
- Date: Fri, 13 Jun 2008 11:50:33 +0000 (UTC)
Author: pvanhoof
Date: Fri Jun 13 11:50:33 2008
New Revision: 1676
URL: http://svn.gnome.org/viewvc/tracker?rev=1676&view=rev
Log:
2008-06-13 Philip Van Hoof <pvanhoof gnome org>
* tests/trackerd/tracker-xesam-test.c:
* tests/trackerd/tracker-xesam-session-test.c:
* tests/trackerd/tracker-xesam-hit-test.c:
* tests/trackerd/tracker-xesam-hits-test.c:
* tests/trackerd/tracker-xesam-test.h:
Making the Xesam unit tests work
Added:
branches/xesam-support/tests/trackerd/tracker-xesam-test.h
Modified:
branches/xesam-support/ChangeLog
branches/xesam-support/tests/trackerd/tracker-xesam-hit-test.c
branches/xesam-support/tests/trackerd/tracker-xesam-hits-test.c
branches/xesam-support/tests/trackerd/tracker-xesam-session-test.c
branches/xesam-support/tests/trackerd/tracker-xesam-test.c
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-hit-test.c
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-hit-test.c (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-hit-test.c Fri Jun 13 11:50:33 2008
@@ -29,11 +29,11 @@
#include "xesam/xesam-g-testsearcher.h"
#include "xesam/gtestextensions.h"
+#include "tracker-xesam-test.h"
+
/* Shortcut to defining a test */
#define TEST(func) g_test_add ("/tracker/xesam/hit/"#func, Fixture, NULL, (void (*) (Fixture*, gconstpointer))setup, test_##func, teardown);
-#define TIMEOUT 1500
-#define TEST_XML "<request><query><contains><field name=\"xesam:album\" /><string>li</string></contains></query></request>"
#define NUM_FIELDS _get_num_fields()
/* Fields set in the session's hit-fields property */
@@ -203,13 +203,13 @@
{
XesamGHit *hit;
guint i;
+ guint count = xesam_g_hits_get_count (fix->hits);
- for (i = 0; i < xesam_g_hits_get_count (fix->hits); i++) {
+ for (i = 0; i < count; i++) {
hit = xesam_g_hits_get (fix->hits, i);
/* This assumes that hit is the first XesamGHit to be delievered */
g_assert_cmpint (i, ==, xesam_g_hit_get_id (hit));
- g_print ("id: %d\n", xesam_g_hit_get_id(hit));
}
}
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-hits-test.c
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-hits-test.c (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-hits-test.c Fri Jun 13 11:50:33 2008
@@ -29,11 +29,11 @@
#include "xesam/xesam-g-testsearcher.h"
#include "xesam/gtestextensions.h"
+#include "tracker-xesam-test.h"
+
/* Shortcut to defining a test */
#define TEST(func) g_test_add ("/tracker/xesam/hits/"#func, Fixture, NULL, (void (*) (Fixture*, gconstpointer))setup, test_##func, teardown);
-#define TIMEOUT 1500
-#define TEST_XML "<request><query><contains><field name=\"xesam:album\" /><string>li</string></contains></query></request>"
/* Test fixture passed to all tests */
typedef struct {
@@ -46,6 +46,17 @@
GList *hit_list;
} Fixture;
+/* Fields set in the session's hit-fields property */
+const gchar *HITS_TEST_FIELDS[2] =
+{
+// "xesam:url",
+// "xesam:title",
+// "xesam:subject",
+ "xesam:album",
+ NULL
+};
+
+
/* HELPER METHODS BEGIN */
@@ -59,9 +70,10 @@
fix->mainloop = g_main_loop_new (NULL, FALSE);
fix->searcher = XESAM_G_SEARCHER(xesam_g_dbus_searcher_new_default ());
fix->session = xesam_g_session_new (fix->searcher);
-
+
+ g_object_set (fix->session, "hit-fields", HITS_TEST_FIELDS, NULL);
+
fix->search = xesam_g_session_new_search (fix->session, xesam_g_query_new_from_xml(TEST_XML));
- fix->hit_list = NULL;
g_assert (XESAM_IS_G_SEARCHER (fix->searcher));
g_assert (XESAM_IS_G_SESSION (fix->session));
@@ -74,20 +86,24 @@
TEST_XML);
g_assert (XESAM_IS_G_HITS (fix->hits));
+ g_assert_cmpint (xesam_g_hits_get_count (fix->hits), >, 0);
}
static void
teardown (Fixture *fix,
gconstpointer test_data)
{
+ if (fix->hit_list)
+ g_list_foreach (fix->hit_list, (GFunc) g_object_unref, NULL);
+
/* Make sure we did not screw up the searcher and session in the test */
g_assert (XESAM_IS_G_SEARCHER(fix->searcher));
g_assert (XESAM_IS_G_SESSION(fix->session));
g_assert (XESAM_IS_G_SEARCH(fix->search));
g_assert (XESAM_IS_G_HITS(fix->hits));
- /* Allow to process any dangling async calls. This is needed to make
- * the leak detection below work */
+ /* Allow to process any dangling async calls. This is needed
+ * to make the leak detecction below work. */
gtx_yield_main_loop (TIMEOUT);
g_main_loop_unref (fix->mainloop);
@@ -95,32 +111,14 @@
gtx_assert_last_unref (fix->search);
gtx_assert_last_unref (fix->session);
- /* Allow to process any dangling async calls. This is needed to make
- * the leak detection below work. Yes we need it again! */
+ /* Allow to process any dangling async calls. This is needed
+ * to make the leak detecction below work. Yes, we need it two times */
gtx_yield_main_loop (TIMEOUT);
gtx_assert_last_unref (fix->searcher);
if (fix->error)
g_error_free (fix->error);
-
-
- /* Assert that all hits in the list are freed */
- if (fix->hit_list) {
- GList *iter;
- XesamGHit *hit;
-
- xesam_g_debug ("Testing that XesamGHit objects are cleaned up");
-
- for (iter = fix->hit_list; iter; iter = iter->next) {
- hit = XESAM_G_HIT (iter->data);
- gtx_assert_last_unref (hit);
- }
-
- g_list_free (fix->hit_list);
- }
-
- gtx_yield_main_loop (TIMEOUT);
}
static void
@@ -145,8 +143,8 @@
g_assert_cmpint (hit_count, >, 0);
for (i = 0; i < hit_count; i++) {
- //hit = xesam_g_hits_get (fix->hits, i);
-// g_assert (XESAM_IS_G_HIT (hit));
+ hit = xesam_g_hits_get (fix->hits, i);
+ g_assert (XESAM_IS_G_HIT (hit));
/* Build a list of hit objects with refs. We use this
* to assert that they are properly freed later */
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-session-test.c
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-session-test.c (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-session-test.c Fri Jun 13 11:50:33 2008
@@ -27,10 +27,11 @@
#include "xesam/xesam-g-testsearcher.h"
#include "xesam/gtestextensions.h"
+#include "tracker-xesam-test.h"
+
/* Shortcut to defining a test */
#define TEST(func) g_test_add ("/tracker/xesam/session/"#func, Fixture, NULL, (void (*) (Fixture*, gconstpointer))setup, test_##func, teardown);
-#define TIMEOUT 500
/* Test fixture passed to all tests */
typedef struct {
Modified: branches/xesam-support/tests/trackerd/tracker-xesam-test.c
==============================================================================
--- branches/xesam-support/tests/trackerd/tracker-xesam-test.c (original)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-test.c Fri Jun 13 11:50:33 2008
@@ -7,6 +7,8 @@
#include "tracker-xesam-hits-test.h"
#include "tracker-xesam-hit-test.h"
+#include "tracker-xesam-test.h"
+
/*
* This is a hack to initialize the dbus glib specialized types.
* See bug https://bugs.freedesktop.org/show_bug.cgi?id=13908
Added: branches/xesam-support/tests/trackerd/tracker-xesam-test.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-test.h Fri Jun 13 11:50:33 2008
@@ -0,0 +1,7 @@
+#ifndef _TRACKER_XESAM_TEST_H_
+#define _TRACKER_XESAM_TEST_H_
+
+#define TEST_XML "<request><query><contains><field name=\"xesam:album\" /><string>li</string></contains></query></request>"
+#define TIMEOUT 1500
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]