tracker r1669 - in branches/xesam-support: . tests/trackerd tests/trackerd/xesam



Author: pvanhoof
Date: Fri Jun 13 08:59:46 2008
New Revision: 1669
URL: http://svn.gnome.org/viewvc/tracker?rev=1669&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/Makefile.am:
	* tests/trackerd/tracker-xesam-session-test.h:
	* tests/trackerd/xesam:
	* tests/trackerd/xesam/xesam-g-testsearcher.h:
	* tests/trackerd/xesam/xesam-g-debug-private.h:
	* tests/trackerd/xesam/xesam-g-utils.h:
	* tests/trackerd/xesam/xesam-g-test-query-builder.c:
	* tests/trackerd/xesam/gtestextensions.c:
	* tests/trackerd/xesam/Makefile.am:
	* tests/trackerd/xesam/xesam-g-test-query-builder.h:
	* tests/trackerd/xesam/gtestextensions.h:
	* tests/trackerd/xesam/xesam-g-testsearcher.c:
	* configure.ac:

	Added infrastructure and first test example (ported from xesam-glib's 
	tests repository) for testing Xesam



Added:
   branches/xesam-support/tests/trackerd/tracker-xesam-session-test.c
   branches/xesam-support/tests/trackerd/tracker-xesam-session-test.h
   branches/xesam-support/tests/trackerd/xesam/
   branches/xesam-support/tests/trackerd/xesam/Makefile.am
   branches/xesam-support/tests/trackerd/xesam/gtestextensions.c
   branches/xesam-support/tests/trackerd/xesam/gtestextensions.h
   branches/xesam-support/tests/trackerd/xesam/xesam-g-debug-private.h
   branches/xesam-support/tests/trackerd/xesam/xesam-g-test-query-builder.c
   branches/xesam-support/tests/trackerd/xesam/xesam-g-test-query-builder.h
   branches/xesam-support/tests/trackerd/xesam/xesam-g-testsearcher.c
   branches/xesam-support/tests/trackerd/xesam/xesam-g-testsearcher.h
   branches/xesam-support/tests/trackerd/xesam/xesam-g-utils.h
Modified:
   branches/xesam-support/ChangeLog
   branches/xesam-support/configure.ac
   branches/xesam-support/tests/trackerd/Makefile.am
   branches/xesam-support/tests/trackerd/tracker-xesam-test.c

Modified: branches/xesam-support/configure.ac
==============================================================================
--- branches/xesam-support/configure.ac	(original)
+++ branches/xesam-support/configure.ac	Fri Jun 13 08:59:46 2008
@@ -216,6 +216,8 @@
 ####################################################################
 GLIB_WITH_UNIT_TESTING=2.15.0
 
+have_xesam_glib=no
+
 AC_ARG_ENABLE(unit_tests, 
 	AS_HELP_STRING([--enable-unit-tests=@<:@no/yes/auto@:>@],
 			[Enable unit tests (if available)]), , 
@@ -231,6 +233,8 @@
       AC_PATH_PROG(GTESTER, [gtester], [no] )
       if test "x$GTESTER" = "xno" ; then
 	 AC_MSG_ERROR([*** Gtester is not in the path])
+      else
+	PKG_CHECK_MODULES(XESAM_GLIB, xesam-glib, [have_xesam_glib=yes], [have_xesam_glib=no])
       fi
    fi
 else
@@ -238,12 +242,9 @@
    glib_pkgconfig=
 fi
 
-have_xesam_glib=no
 if test "x$enable_unit_tests" = "xyes"; then
    if test "x$have_unit_tests" != "xyes"; then
       AC_MSG_ERROR([Couldn't find unit test compatible glib.])
-   else
-	PKG_CHECK_MODULES(XESAM_GLIB, xesam-glib, [have_xesam_glib=yes], [have_xesam_glib=no])
    fi
 fi
 
@@ -736,6 +737,7 @@
 	tests/Makefile
 	tests/libtracker-common/Makefile
 	tests/trackerd/Makefile
+	tests/trackerd/xesam/Makefile
 	src/xdgmime/Makefile
 	po/Makefile.in
 	python/Makefile

Modified: branches/xesam-support/tests/trackerd/Makefile.am
==============================================================================
--- branches/xesam-support/tests/trackerd/Makefile.am	(original)
+++ branches/xesam-support/tests/trackerd/Makefile.am	Fri Jun 13 08:59:46 2008
@@ -1,32 +1,36 @@
+SUBDIRS = xesam .
+
 include $(top_srcdir)/Makefile.decl
 
 noinst_PROGRAMS = $(TEST_PROGS)
 
+INCLUDES = \
+	-g \
+	-DG_LOG_DOMAIN=\"Tracker\" \
+	-I$(top_srcdir)/src \
+	$(GMODULE_CFLAGS) \
+	$(GTHREAD_CFLAGS) \
+	$(GLIB2_CFLAGS) \
+	$(DBUS_CFLAGS)
+
 if HAVE_XESAM_GLIB
-TEST_PROGS += tracker-xesam
-else
-TEST_PROGS =
-endif
 
-INCLUDES = 			\
-	-g 			\
-	-DG_LOG_DOMAIN=\"Tracker\"					\
-	-I$(top_srcdir)/src						\
-	$(GMODULE_CFLAGS)						\
-	$(GTHREAD_CFLAGS)						\
-	$(GLIB2_CFLAGS)
+TEST_PROGS += tracker-xesam
 
-if HAVE_XESAM_GLIB
 INCLUDES += $(XESAM_GLIB_CFLAGS)
 
 tracker_xesam_SOURCES = \
-	tracker-xesam-test.c
+	tracker-xesam-test.c \
+	tracker-xesam-session-test.c \
+	tracker-xesam-session-test.h
+
+tracker_xesam_LDADD = \
+	$(top_builddir)/tests/trackerd/xesam/libxesamhelper.la \
+	$(XESAM_GLIB_LIBS) \
+	$(GMODULE_LIBS) \
+	$(GTHREAD_LIBS) \
+	$(GLIB2_LIBS) \
+	$(DBUS_LIBS)
 
-tracker_xesam_LDADD =							\
-	$(XESAM_GLIB_LIBS)						\
-	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
-	$(GMODULE_LIBS)							\
-	$(GTHREAD_LIBS)							\
-	$(GLIB2_LIBS)							
 endif
 

Added: branches/xesam-support/tests/trackerd/tracker-xesam-session-test.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-session-test.c	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,314 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with main.c; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+ 
+#include <glib.h>
+#include <glib/gtestutils.h>
+#include <glib-object.h>
+
+#include <xesam-glib/xesam-glib.h>
+#include <xesam-glib/xesam-g-searcher.h>
+#include <xesam-glib/xesam-g-dbussearcher.h>
+#include <xesam-glib/xesam-g-session.h>
+
+#include "xesam/xesam-g-utils.h"
+#include "xesam/xesam-g-testsearcher.h"
+#include "xesam/gtestextensions.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 {
+	GMainLoop			*mainloop;
+	GError				*error;
+	XesamGSearcher		*searcher;
+	XesamGSession		*session;
+} Fixture;
+
+/* HELPER METHODS BEGIN */
+
+/**
+ * check_property
+ * @session:
+ * @property:
+ *
+ * Returns: %TRUE iff the property is available after atmost %TIMEOUT.
+ */
+static gboolean
+check_property (XesamGSession *session, gchar *property)
+{
+	gchar *notify_signal;
+	GParamSpec	  *tmp_pspec;
+	
+	notify_signal = g_strconcat ("notify::", property, NULL);
+	
+	if (xesam_g_session_test_property (session, property)) {
+		g_free (notify_signal);
+		return TRUE;
+	}
+	
+	if (gtx_wait_for_signal (G_OBJECT(session), TIMEOUT,
+							 notify_signal, &tmp_pspec)) {
+		g_param_spec_unref (tmp_pspec);
+		if (xesam_g_session_test_property (session, property)) {
+			g_free (notify_signal);
+			return TRUE;
+		}
+		g_free (notify_signal);
+		return FALSE;
+		
+	}
+	
+	if (xesam_g_session_test_property (session, property)) {
+		g_free (notify_signal);
+		return TRUE;
+	}
+	
+	g_critical ("'%s' emitted, but test_property() returns FALSE", notify_signal);
+	g_free (notify_signal);
+	return FALSE;
+}
+
+/* HELPER METHODS END */
+
+static void
+setup (Fixture		 *fix,
+	   GType *searcher_type)
+{
+	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_assert (XESAM_IS_G_SEARCHER(fix->searcher));
+	g_assert (XESAM_IS_G_SESSION(fix->session));
+}
+
+static void
+teardown (Fixture		*fix,
+		  gconstpointer test_data)
+{
+	/* 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_main_loop_unref (fix->mainloop);
+	g_object_unref (fix->searcher);
+	g_object_unref (fix->session);
+	
+	if (fix->error)
+		g_error_free (fix->error);
+}
+
+/* Test that a session becomes ready within a reasonable timeframe */
+static void
+test_ready (Fixture *fix,
+			  gconstpointer	test_data)
+{
+	if (gtx_wait_for_signal (G_OBJECT(fix->session), TIMEOUT, "ready"))
+		g_critical ("'ready' signal never emitted");
+	
+	if (!gtx_wait_for_signal (G_OBJECT(fix->session), TIMEOUT, "ready"))
+		g_critical ("'ready' signal emitted twice");
+	
+	g_assert (xesam_g_session_is_ready (fix->session));
+}
+
+/* Test that we can call close immediately on a session */
+static void
+test_immediate_close (Fixture		*fix,
+					  gconstpointer	test_data)
+{
+	xesam_g_session_close (fix->session);
+	
+	if (gtx_wait_for_signal (G_OBJECT(fix->session), TIMEOUT, "closed"))
+		g_critical ("'closed' signal never emitted");
+	
+	g_assert (xesam_g_session_is_closed (fix->session));
+}
+
+/* Test that we can call close multiple times without problems */
+static void
+test_multiple_close (Fixture		*fix,
+					 gconstpointer	test_data)
+{
+	/* The first close() should go well */
+	xesam_g_session_close (fix->session);
+	if (gtx_wait_for_signal (G_OBJECT(fix->session), TIMEOUT, "closed"))
+		g_critical ("'closed' signal never emitted");
+	g_assert (xesam_g_session_is_closed (fix->session));
+	
+	/* Next close should not emit 'closed' */
+	xesam_g_session_close (fix->session);
+	if (!gtx_wait_for_signal (G_OBJECT(fix->session), TIMEOUT, "closed"))
+		g_critical ("'closed' signal emitted, but session already closed");
+	g_assert (xesam_g_session_is_closed (fix->session));
+	
+	/* Even more closing should not emit 'closed' */
+	xesam_g_session_close (fix->session);
+	if (!gtx_wait_for_signal (G_OBJECT(fix->session), TIMEOUT, "closed"))
+		g_critical ("'closed' signal emitted, but session already closed");
+	g_assert (xesam_g_session_is_closed (fix->session));
+}
+
+/* Test that we can call sync on all props */
+static void
+test_sync_properties (Fixture *fix,
+					 gconstpointer test_data)
+{
+	XesamGSession *session;
+	
+	session = fix->session;
+	
+	xesam_g_session_sync_property (session, "search-live");
+	if (!check_property (session, "search-live"))
+		g_critical ("search-live not synced");
+	
+	xesam_g_session_sync_property (session, "hit-fields");
+	if (!check_property(session, "hit-fields"))
+		g_critical ("hit-fields not synced");
+	
+	xesam_g_session_sync_property (session, "hit-fields-extended");
+	if (!check_property(session, "hit-fields-extended"))
+		g_critical ("hit-fields-extended not synced");
+	
+	xesam_g_session_sync_property (session, "hit-snippet-length");
+	if (!check_property(session, "hit-snippet-length"))
+		g_critical ("hit-snippet-length not synced");
+	
+	xesam_g_session_sync_property (session, "sort-primary");
+	if (!check_property(session, "sort-primary"))
+		g_critical ("sort-primary not synced");
+	
+	xesam_g_session_sync_property (session, "sort-secondary");
+	if (!check_property(session, "sort-secondary"))
+		g_critical ("sort-secondary not synced");
+	
+	xesam_g_session_sync_property (session, "sort-order");
+	if (!check_property(session, "sort-order"))
+		g_critical ("sort-order not synced");
+	
+	xesam_g_session_sync_property (session, "vendor-id");
+	if (!check_property(session, "vendor-id"))
+		g_critical ("vendor-id not synced");
+	
+	xesam_g_session_sync_property (session, "vendor-version");
+	if (!check_property(session, "vendor-version"))
+		g_critical ("vendor-version not synced");
+	
+	xesam_g_session_sync_property (session, "vendor-display");
+	if (!check_property(session, "vendor-display"))
+		g_critical ("vendor-display not synced");
+	
+	xesam_g_session_sync_property (session, "vendor-xesam");
+	if (!check_property(session, "vendor-xesam"))
+		g_critical ("vendor-xesam not synced");
+	
+	xesam_g_session_sync_property (session, "vendor-ontology-fields");
+	if (!check_property(session, "vendor-ontology-fields"))
+		g_critical ("vendor-ontology-fields not synced");
+	
+	xesam_g_session_sync_property (session, "vendor-ontology-contents");
+	if (!check_property(session, "vendor-ontology-contents"))
+		g_critical ("vendor-ontology-ceontents not synced");
+	
+	xesam_g_session_sync_property (session, "vendor-ontology-sources");
+	if (!check_property(session, "vendor-ontology-sources"))
+		g_critical ("vendor-ontology-sources not synced");
+
+	xesam_g_session_sync_property (session, "vendor-extensions");
+	if (!check_property(session, "vendor-extensions"))
+		g_critical ("vendor-extensions not synced");
+
+	xesam_g_session_sync_property (session, "vendor-ontologies");
+	if (!check_property(session, "vendor-ontologies"))
+		g_critical ("vendor-ontologies not synced");
+	
+	xesam_g_session_sync_property (session, "vendor-maxhits");
+	if (!check_property(session, "vendor-maxhits"))
+		g_critical ("vendor-maxhits not synced");
+
+}
+
+/* Test that we can create a new Search object. Testing the functionality
+ * of the spawned search is done in the test-search.c test suite. */
+static void
+test_immediate_new_search (Fixture *fix,
+						   gconstpointer test_data)
+{
+	XesamGSearch	*search;
+	
+	/* Don't bother to wait for 'ready'. This should work regardless. */
+	search = xesam_g_session_new_search_from_text (fix->session,
+												   "hello world");
+	
+	g_assert (XESAM_IS_G_SEARCH (search));
+	g_assert (xesam_g_search_get_session (search) == fix->session);
+	
+	g_object_unref (search);
+	
+	/* search will not be finalized before it has received a handle */
+	gtx_yield_main_loop (TIMEOUT);
+}
+
+
+static void
+test_field_map (Fixture	*fix,
+		gconstpointer	test_data)
+{
+	GHashTable  *map;
+	GParamSpec  *pspec;
+	
+	if (gtx_wait_for_signal (G_OBJECT(fix->session),TIMEOUT, "ready"))
+		g_critical ("'ready' never emitted on session");
+	
+	map = xesam_g_session_get_field_map (fix->session);
+	g_assert (map != NULL);
+	g_assert_cmpint (g_hash_table_size (map), == , 1);
+	g_assert_cmpint (*((int*)g_hash_table_lookup (map, "xesam:url")), ==, 0);
+	
+	/* Update hit-fields */
+	gchar *hit_fields[4] = {"xesam:url", "xesam:title", "xesam:subject", NULL};
+	g_object_set (fix->session, "hit-fields", hit_fields, NULL);
+	
+	/* Wait for propoerty change to be registered remotely */
+	if (gtx_wait_for_signal (G_OBJECT(fix->session),TIMEOUT,
+				 "notify::hit-fields", &pspec))
+		g_critical ("'notify::hit-fields' never emitted on session");
+	
+	g_param_spec_unref (pspec);
+	
+	map = xesam_g_session_get_field_map (fix->session);
+	g_assert_cmpint (g_hash_table_size (map), == , 3);
+	g_assert_cmpint (*((int*)g_hash_table_lookup (map, "xesam:url")), ==, 0);
+	g_assert_cmpint (*((int*)g_hash_table_lookup (map, "xesam:title")), ==, 1);
+	g_assert_cmpint (*((int*)g_hash_table_lookup (map, "xesam:subject")), ==, 2);
+}
+
+
+void
+g_test_add_session_tests (void)
+{
+	TEST (ready);
+	TEST (immediate_close);
+	TEST (multiple_close);
+	TEST (sync_properties);
+	TEST (immediate_new_search);
+	TEST (field_map);
+
+	return;
+}

Added: branches/xesam-support/tests/trackerd/tracker-xesam-session-test.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/tracker-xesam-session-test.h	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,6 @@
+#ifndef _TRACKER_XESAM_SESSION_TEST_H_
+#define _TRACKER_XESAM_SESSION_TEST_H_
+
+void g_test_add_session_tests (void);
+
+#endif

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 08:59:46 2008
@@ -1,19 +1,39 @@
 #include <glib.h>
 #include <glib/gtestutils.h>
 
+#include <dbus/dbus-glib-bindings.h>
+
+#include "tracker-xesam-session-test.h"
+
+/*
+ * This is a hack to initialize the dbus glib specialized types.
+ * See bug https://bugs.freedesktop.org/show_bug.cgi?id=13908
+ */
+static void
+init_dbus_glib_types (void)
+{
+	DBusGConnection *connection;
+	GError 			*error;
+	error = NULL;
+	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+	dbus_g_connection_unref (connection);
+}
 
 int
 main (int argc, char **argv) {
 
-        int result;
+	int result;
 
 	g_type_init ();
 	g_test_init (&argc, &argv, NULL);
 
-//	g_test_add_func ("/trackerd/tracker-services/get_id_for_service",  
-//                       test_get_id_for_service);
+	init_dbus_glib_types();
+
+	g_test_bug_base ("http://bugzilla.gnome.org/";);
+
+	g_test_add_session_tests ();
+
+	result = g_test_run ();
 
-        result = g_test_run ();
-        
-        return result;
+	return result;
 }

Added: branches/xesam-support/tests/trackerd/xesam/Makefile.am
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/Makefile.am	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,24 @@
+if HAVE_XESAM_GLIB
+
+noinst_LTLIBRARIES = libxesamhelper.la
+
+INCLUDES = \
+        -g \
+        -DG_LOG_DOMAIN=\"Tracker\" \
+        -I$(top_srcdir)/src \
+        $(GMODULE_CFLAGS) \
+        $(GTHREAD_CFLAGS) \
+        $(GLIB2_CFLAGS) \
+	$(XESAM_GLIB_CFLAGS)
+
+libxesamhelper_la_SOURCES = \
+	xesam-g-debug-private.h \
+	xesam-g-utils.h \
+	gtestextensions.c \
+	gtestextensions.h \
+	xesam-g-test-query-builder.c \
+	xesam-g-test-query-builder.h \
+	xesam-g-testsearcher.c \
+	xesam-g-testsearcher.h
+
+endif

Added: branches/xesam-support/tests/trackerd/xesam/gtestextensions.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/gtestextensions.c	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,382 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * gtestextensions
+ * Copyright (C) Mikkel Kamstrup Erlandsen 2008 <mikkel kamstrup gmail com>
+ *               Scott Asofyet 2008 (wait_for_signal code)
+ * 
+ * gtestextensions is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * gtestextensions 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with xesam-glib.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#include <gobject/gvaluecollector.h>
+#include <string.h> /* memset(), from G_VALUE_COLLECT() */
+#include "gtestextensions.h"
+
+typedef struct {
+    GClosure closure;
+    GValue * return_value;
+    GValueArray * param_values;
+    GMainLoop * loop;
+} WaitForSignalClosure;
+
+
+gboolean
+gtx_dispatch_test_case (GtxTestContext *ctx)
+{
+	g_assert (ctx != NULL);
+	ctx->test_func (ctx->fixture, ctx->test_data);
+	return FALSE;
+}
+
+void
+gtx_flush_sources (gboolean may_block)
+{
+	GMainContext *ctx;
+	
+	ctx = g_main_context_default ();
+	
+	while (g_main_context_pending (ctx))
+		g_main_context_iteration (ctx, may_block);
+}
+
+/**
+ * gtx_quit_main_loop
+ * @loop: The main loop to quit
+ *
+ * This is a convenience to close a #GMainLoop via a #GSourceFunc.
+ *
+ * Returns: Always %FALSE
+ */
+gboolean
+gtx_quit_main_loop (GMainLoop *loop)
+{
+	g_assert (loop != NULL);
+	
+	if (g_main_loop_is_running (loop))
+		g_main_loop_quit (loop);
+	else
+		g_warning ("Tried to quit non-running GMainLoop %p", loop);
+	
+	return FALSE;
+}
+
+/**
+ * gtx_yield_main_loop
+ * @millis: Number of milli seconds to return control to the main loop
+ *
+ * Return control to the main loop for a specified amount of time. This
+ * is to allow async test to process events in a blocking fashion.
+ */
+void
+gtx_yield_main_loop (guint millis)
+{
+	GMainLoop *recursive_main;
+	
+	recursive_main = g_main_loop_new (NULL, FALSE);
+	
+	g_timeout_add (millis, (GSourceFunc)gtx_quit_main_loop, recursive_main);
+	g_main_loop_run (recursive_main);
+	
+	gtx_flush_sources (FALSE);
+	
+	g_main_loop_unref (recursive_main);
+}
+
+static void
+wait_for_signal_closure_marshal (GClosure *closure,
+                                 GValue *return_value,
+                                 guint n_param_values,
+                                 const GValue *param_values,
+                                 gpointer invocation_hint,
+                                 gpointer marshal_data)
+{	
+    WaitForSignalClosure * wfsclosure = (WaitForSignalClosure *) closure;
+    guint i;
+	
+    wfsclosure->param_values = g_value_array_new (n_param_values);
+    for (i = 0 ; i < n_param_values ; i++)
+        g_value_array_append (wfsclosure->param_values, param_values + i);
+
+    if (return_value)
+        g_value_copy (wfsclosure->return_value, return_value);
+
+    gtx_quit_main_loop (wfsclosure->loop);
+
+    (void) invocation_hint;
+    (void) marshal_data;
+}
+
+static gboolean
+wait_for_signal_values (GObject * object,
+                        gint max_wait_ms,
+                        guint signal_id,
+                        GQuark detail,
+                        GValue * return_value,
+                        GValueArray ** param_values)
+{
+    WaitForSignalClosure * wfs;
+    guint handler_id;
+    guint max_timeout_id;
+    gboolean timed_out = FALSE;
+
+    wfs = (WaitForSignalClosure *)
+        g_closure_new_simple (sizeof (WaitForSignalClosure), NULL);
+    wfs->loop = g_main_loop_new (NULL, FALSE);
+    wfs->return_value = return_value;
+    wfs->param_values = NULL;
+
+    g_closure_set_marshal (&wfs->closure, wait_for_signal_closure_marshal);
+
+    handler_id = g_signal_connect_closure_by_id (object, signal_id, detail,
+                                                 &wfs->closure, FALSE);
+
+    max_timeout_id = g_timeout_add (max_wait_ms, (GSourceFunc)gtx_quit_main_loop,
+									wfs->loop);
+
+    g_main_loop_run (wfs->loop);
+	
+    g_closure_invalidate (&wfs->closure);
+
+    if (wfs->param_values) {
+        if (param_values)
+            *param_values = wfs->param_values;
+        else
+            g_value_array_free (wfs->param_values);
+
+        wfs->param_values = NULL;
+
+    } else {
+        timed_out = TRUE;
+    }
+	
+    g_main_loop_unref (wfs->loop);
+    wfs->loop = NULL;
+	
+    /* Closure will be destroyed here */
+    g_signal_handler_disconnect (object, handler_id);
+	g_source_remove (max_timeout_id);
+	
+    return timed_out;
+}
+
+
+/**
+ * gtx_wait_for_signal
+ * @object:  The object
+ * @max_wait_ms:  Maximum number of milliseconds to wait before giving up
+ *                and failing; passed directly to g_timeout_add().
+ * @detailed_signal:  Detailed signal name for which to wait.
+ * @...:  If @detailed_signal has a return value, the first vararg should
+ *        be the value to return from the signal handler.  The rest of the
+ *        varargs should be pointers to variables in which to store the
+ *        parameters passed to the signal.  Pass NULL for any param in
+ *        which you are not interested.  The caller is responsible for
+ *        freeing or unreffing any strings or objects returned here.
+ *
+ * returns: True if the signal was received, false if the timeout was
+ *          reached without the signal firing.
+ */
+gboolean
+gtx_wait_for_signal (GObject * object,
+                 gint max_wait_ms,
+                 const gchar * detailed_signal,
+                 ...)
+{
+    GSignalQuery query;
+    GValue * return_value = NULL, the_return_value = { 0, };
+    GValueArray * param_values = NULL;
+    guint signal_id;
+    GQuark detail;
+    gboolean ret;
+    va_list ap;
+
+    if (! g_signal_parse_name (detailed_signal, G_OBJECT_TYPE (object),
+                               &signal_id, &detail, FALSE))
+        g_error ("Signal %s is invalid for object type %s",
+                 detailed_signal, g_type_name (G_OBJECT_TYPE (object)));
+
+    g_signal_query (signal_id, &query);
+
+    va_start (ap, detailed_signal);
+
+    if (query.return_type != G_TYPE_NONE) {
+        GType t = query.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE;
+        gboolean static_scope = t & G_SIGNAL_TYPE_STATIC_SCOPE;
+        gchar * error;
+        g_value_init (&the_return_value, t);
+        return_value = &the_return_value;
+        G_VALUE_COLLECT (return_value, ap,
+                         static_scope ? G_VALUE_NOCOPY_CONTENTS : 0,
+                         &error);
+        if (error)
+            g_error ("%s: %s", G_STRLOC, error);
+    }
+
+    ret = wait_for_signal_values (object,
+                                  max_wait_ms,
+                                  signal_id,
+                                  detail,
+                                  return_value,
+                                  &param_values);
+
+    if (param_values) {
+        guint i;
+
+        /* Skip the instance */
+        for (i = 1 ; i < param_values->n_values ; i++) {
+            GValue * v = g_value_array_get_nth (param_values, i);
+            switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (v))) {
+                case G_TYPE_INVALID:
+                case G_TYPE_NONE:
+                case G_TYPE_INTERFACE:
+                    break;
+
+                case G_TYPE_CHAR:
+                    {
+                        gchar * p = va_arg (ap, gchar *);
+                        if (p)
+                            *p = g_value_get_char (v);
+                    }
+                    break;
+                case G_TYPE_UCHAR:
+                    {
+                        guchar * p = va_arg (ap, guchar *);
+                        if (p)
+                            *p = g_value_get_uchar (v);
+                    }
+                    break;
+                case G_TYPE_BOOLEAN:
+                    {
+                        gboolean * p = va_arg (ap, gboolean *);
+                        if (p)
+                            *p = g_value_get_boolean (v);
+                    }
+                    break;
+                case G_TYPE_INT:
+                    {
+                        gint * p = va_arg (ap, gint *);
+                        if (p)
+                            *p = g_value_get_int (v);
+                    }
+                    break;
+                case G_TYPE_UINT:
+                    {
+                        guint * p = va_arg (ap, guint *);
+                        if (p)
+                            *p = g_value_get_uint (v);
+                    }
+                    break;
+                case G_TYPE_LONG:
+                    {
+                        glong * p = va_arg (ap, glong *);
+                        if (p)
+                            *p = g_value_get_long (v);
+                    }
+                    break;
+                case G_TYPE_ULONG:
+                    {
+                        gulong * p = va_arg (ap, gulong *);
+                        if (p)
+                            *p = g_value_get_ulong (v);
+                    }
+                    break;
+                case G_TYPE_INT64:
+                    {
+                        gint64 * p = va_arg (ap, gint64 *);
+                        if (p)
+                            *p = g_value_get_int64 (v);
+                    }
+                    break;
+                case G_TYPE_UINT64:
+                    {
+                        guint64 * p = va_arg (ap, guint64 *);
+                        if (p)
+                            *p = g_value_get_uint64 (v);
+                    }
+                    break;
+                case G_TYPE_ENUM:
+                    {
+                        gint * p = va_arg (ap, gint *);
+                        if (p)
+                            *p = g_value_get_int (v);
+                    }
+                    break;
+                case G_TYPE_FLAGS:
+                    {
+                        guint * p = va_arg (ap, guint *);
+                        if (p)
+                            *p = g_value_get_uint (v);
+                    }
+                    break;
+                case G_TYPE_FLOAT:
+                    {
+                        gfloat * p = va_arg (ap, gfloat *);
+                        if (p)
+                            *p = g_value_get_float (v);
+                    }
+                    break;
+                case G_TYPE_DOUBLE:
+                    {
+                        gdouble * p = va_arg (ap, gdouble *);
+                        if (p)
+                            *p = g_value_get_double (v);
+                    }
+                    break;
+                case G_TYPE_STRING:
+                    {
+                        gchar ** p = va_arg (ap, gchar **);
+                        if (p)
+                            *p = g_value_dup_string (v);
+                    }
+                    break;
+                case G_TYPE_POINTER:
+                    {
+                        gpointer * p = va_arg (ap, gpointer *);
+                        if (p)
+                            *p = g_value_get_pointer (v);
+                    }
+                    break;
+                case G_TYPE_BOXED:
+                    {
+                        gpointer * p = va_arg (ap, gpointer *);
+                        if (p)
+                            *p = g_value_dup_boxed (v);
+                    }
+                    break;
+                case G_TYPE_PARAM:
+                    {
+                        GParamSpec ** p = va_arg (ap, GParamSpec **);
+                        if (p)
+                            *p = g_value_dup_param (v);
+                    }
+                    break;
+                case G_TYPE_OBJECT:
+                    {
+                        GObject ** p = va_arg (ap, GObject **);
+                        if (p)
+                            *p = g_value_dup_object (v);
+                    }
+                    break;
+            }
+        }
+
+        g_value_array_free (param_values);
+    }
+
+    va_end (ap);
+
+    return ret;
+}

Added: branches/xesam-support/tests/trackerd/xesam/gtestextensions.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/gtestextensions.h	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,115 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * gtestextensions
+ * Copyright (C) Mikkel Kamstrup Erlandsen 2008 <mikkel kamstrup gmail com>
+ * 
+ * gtestextensions is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * gtestextensions 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with xesam-glib.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __G_TEST_EXTENSIONS_H__
+#define __G_TEST_EXTENSIONS_H__
+
+#include <glib.h>
+#include <glib/gtestutils.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef void (*GtxTestFunc) (gpointer fixture, gconstpointer test_data);
+
+typedef struct {
+	gpointer		fixture;
+	gconstpointer	test_data;
+	GtxTestFunc 	test_func;
+	GMainLoop		*loop;
+} GtxTestContext;
+
+gboolean	gtx_wait_for_signal				(GObject 		*object,
+											 gint			max_wait_ms,
+											 const gchar	*detailed_signal,
+											 ...);
+
+gboolean	gtx_dispatch_test_case			(GtxTestContext	*ctx);
+
+gboolean	gtx_quit_main_loop				(GMainLoop		*loop);
+
+void		gtx_yield_main_loop				(guint			millis);
+
+void		gtx_flush_sources				(gboolean may_block);
+
+/**
+ * GTX_DEFINE_LOOPED
+ * @func: A function to be called as an idle handler in a #GMainLoop
+ *
+ * Declare that a test function is runnable in a #GMainLoop idle handler.
+ * Use GTX_LOOPED() to get a reference to a version of @func being run
+ * in a main loop.
+ */
+#define GTX_DEFINE_LOOPED(func) \
+							void \
+							func##__gtx_looped (gpointer fixture,\
+												gconstpointer test_data)\
+							{\
+								GMainLoop   *loop;\
+								GtxTestContext *ctx;\
+								\
+								loop = g_main_loop_new (NULL, FALSE);\
+								ctx = g_new0 (GtxTestContext, 1);\
+								\
+								ctx->fixture = fixture;\
+								ctx->test_data = test_data;\
+								ctx->test_func = func;\
+								ctx->loop = loop;\
+								\
+								g_idle_add ((GSourceFunc)gtx_dispatch_test_case,\
+											ctx);\
+								g_idle_add ((GSourceFunc)gtx_quit_main_loop,\
+											loop);\
+								\
+								g_main_loop_run (loop);\
+								\
+								g_free (ctx);\
+							}
+
+/**
+ * GTX_LOOPED
+ * @func: A function on which GTX_DEFINE_LOOPED has been set
+ *
+ * Get a reference to the version of @func being run inside a main loop.
+ */
+#define GTX_LOOPED(func) func##__gtx_looped
+
+/**
+ * gtx_assert_last_unref
+ * @o: A #GObject
+ *
+ * Calls g_object_unref on @o and raises a critical error if the 
+ * #GObject is not finalized after this call.
+ */
+/* This macro is based on code by Benjamin Otte, April, 2008 */
+#define gtx_assert_last_unref(o) G_STMT_START { \
+	gpointer _tmp = o; \
+	g_object_add_weak_pointer (G_OBJECT(o), &_tmp); \
+	g_object_unref (G_OBJECT(o)); \
+	if (_tmp != NULL) \
+		g_critical ("Leak detected. Object %s %p is not unreferenced",\
+					g_type_name(G_OBJECT_TYPE(o)), o);\
+} G_STMT_END 
+
+G_END_DECLS
+
+#endif /* __G_TEST_EXTENSIONS_H__ */

Added: branches/xesam-support/tests/trackerd/xesam/xesam-g-debug-private.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/xesam-g-debug-private.h	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,90 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with main.c; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+/*
+ * This file contains special tools for debugging, used in xesam-glib
+ */
+ 
+#ifndef _XESAM_G_DEBUG_PRIVATE_H_
+#define _XESAM_G_DEBUG_PRIVATE_H_
+
+#include "config.h"
+
+G_BEGIN_DECLS
+
+#ifndef XESAM_G_LOG_DOMAIN
+#define XESAM_G_LOG_DOMAIN    "XesamGLib"
+#endif  /* XESAM_G_LOG_DOMAIN */
+
+/*
+ * Make xesam_g_debug a noop if ENABLE_DEBUG is not defined
+ */
+#ifdef ENABLE_DEBUG
+
+#   ifdef G_HAVE_ISO_VARARGS
+#	   define xesam_g_debug(...)    g_log (XESAM_G_LOG_DOMAIN, \
+										   G_LOG_LEVEL_DEBUG,  \
+										   __VA_ARGS__)
+#	   define xesam_g_debug_object(object, ...)    xesam_g_debug_object_real (object, __VA_ARGS__)
+
+#   elif defined(G_HAVE_GNUC_VARARGS)
+#	   define xesam_g_debug(format...)  g_log (XESAM_G_LOG_DOMAIN,   \
+											   G_LOG_LEVEL_DEBUG,	\
+											   format)
+#	   define xesam_g_debug_object(object, format...)    xesam_g_debug_object_real (object, format)
+#   else   /* no varargs macros */
+static void
+xesam_g_debug (const gchar *format,
+			   ...)
+{
+	va_list args;
+	va_start (args, format);
+	g_logv (XESAM_G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
+	va_end (args);
+}
+
+static void
+xesam_g_debug_object (GObject *obj,
+					  const gchar *format,
+					  ...)
+{
+	va_list args;
+	va_start (args, format);
+	xesam_g_debug_object_va (obj, format, args);
+	va_end (args);
+}
+#   endif  /* !__GNUC__ */
+
+#else /* NO DEBUGGING OUTPUT */
+
+#   ifdef G_HAVE_ISO_VARARGS
+#	   define xesam_g_debug(...)    G_STMT_START{ (void)0; }G_STMT_END
+#	   define xesam_g_debug_object(object, ...)    G_STMT_START{ (void)0; }G_STMT_END
+#   elif defined(G_HAVE_GNUC_VARARGS)
+#	   define xesam_g_debug(format...)     G_STMT_START{ (void)0; }G_STMT_END
+#	   define xesam_g_debug_object(object, format...)     G_STMT_START{ (void)0; }G_STMT_END
+#   else   /* no varargs macros */
+
+static void xesam_g_debug (const gchar *format, ...) { ; }
+static void xesam_g_debug_object (GObject *obj, const gchar *format, ...) { ; }
+
+#   endif /* !__GNUC__ */
+
+#endif /* ENABLE_DEBUG */
+
+G_END_DECLS
+
+#endif /* _XESAM_G_DEBUG_PRIVATE_H_ */

Added: branches/xesam-support/tests/trackerd/xesam/xesam-g-test-query-builder.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/xesam-g-test-query-builder.c	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,415 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * xesam-glib
+ * Copyright (C) Mikkel Kamstrup Erlandsen 2008 <mikkel kamstrup gmail com>
+ * 
+ * xesam-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * xesam-glib 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with xesam-glib.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#include "xesam-g-test-query-builder.h"
+#include <xesam-glib/xesam-g-query-builder.h>
+#include <xesam-glib/xesam-glib-globals.h>
+#include "xesam-g-utils.h"
+#include "xesam-g-debug-private.h"
+
+enum  {
+	XESAM_G_TEST_QUERY_BUILDER_DUMMY_PROPERTY
+};
+
+typedef struct {
+	gchar		*attr1;
+	gchar		*attr2;
+	gboolean	*bool_attr;
+	gchar		*text;
+	guint		element_detail;
+} ExpectedElementData;
+
+struct _XesamGTestQueryBuilderPrivate {
+	GSList	*expected_data;
+};
+
+static void xesam_g_test_query_builder_real_add_query (XesamGQueryBuilder		*self,
+													   XesamGQueryElementType	query_type,
+													   const gchar				*content_cat,
+													   const gchar				*source_cat,
+													   GError					**error);
+
+static void xesam_g_test_query_builder_real_add_clause (XesamGQueryBuilder		*self,
+														XesamGClauseElementType	clause_type,
+														const gchar				*boost,
+														const gboolean			*negate,
+														const gchar				**attr_names,
+														const gchar				**attr_vals,
+														GError					**error);
+
+static void xesam_g_test_query_builder_real_add_field (XesamGQueryBuilder		*self,
+													   XesamGFieldElementType	field_type,
+													   const char				*name,
+													   GError					**error);
+
+static void xesam_g_test_query_builder_real_add_value (XesamGQueryBuilder		*self,
+													   XesamGValueElementType	value_type,
+													   const gchar				*value,
+													   const gchar				**attr_names,
+													   const gchar				**attr_vals,
+													   GError					**error);
+
+static void xesam_g_test_query_builder_real_close_current_child
+													  (XesamGQueryBuilder		*self,
+													   GError					**error);
+
+static ExpectedElementData*
+			expected_element_data_new 					(guint					element_detail,
+														 const gchar			*attr1,
+														 const gchar			*attr2,
+														 const gboolean			*bool_attr,
+														 const gchar			*text);
+
+static void expected_element_data_destroy				(ExpectedElementData	*exp_data);
+
+static void check_expected_data							(XesamGTestQueryBuilder	*self,
+														 guint					element_detail,
+														 const gchar			*attr1,
+														 const gchar			*attr2,
+														 const gboolean			*bool_attr,
+														 const gchar			*text);
+
+static gpointer xesam_g_test_query_builder_parent_class = NULL;
+static XesamGQueryBuilderIface* xesam_g_test_query_builder_parent_iface = NULL;
+
+
+static void
+xesam_g_test_query_builder_real_add_query (XesamGQueryBuilder		*base,
+										   XesamGQueryElementType	query_type,
+										   const gchar				*content_cat,
+										   const gchar				*source_cat,
+										   GError					**error)
+{
+	XesamGTestQueryBuilder	*self;
+	GEnumValue 				*enum_val;
+	static 		GEnumClass	*enum_class = NULL;
+	
+	g_return_if_fail (XESAM_IS_G_TEST_QUERY_BUILDER (base));
+	
+	self = XESAM_G_TEST_QUERY_BUILDER (base);
+	
+	if (!enum_class)
+		enum_class = (GEnumClass*) g_type_class_ref (XESAM_TYPE_G_QUERY_ELEMENT);
+	
+	enum_val = g_enum_get_value (enum_class, query_type);
+	g_return_if_fail (enum_val != NULL);
+	
+	check_expected_data (self, query_type, content_cat, source_cat, NULL, NULL);
+	
+	xesam_g_debug_object (self, "add_query (%s, content='%s', source='%s')",
+						  enum_val->value_nick, content_cat, source_cat);
+}
+
+static void
+xesam_g_test_query_builder_real_add_clause (XesamGQueryBuilder		*base,
+											XesamGClauseElementType	clause_type,
+											const gchar				*boost,
+											const gboolean			*negate,
+											const gchar				**attr_names,
+											const gchar				**attr_vals,
+											GError					**error)
+{
+	XesamGTestQueryBuilder	*self;
+	GEnumValue 				*enum_val;
+	static 		GEnumClass	*enum_class = NULL;
+	
+	g_return_if_fail (XESAM_IS_G_TEST_QUERY_BUILDER (base));
+	
+	self = XESAM_G_TEST_QUERY_BUILDER (base);
+	
+	if (!enum_class)
+		enum_class = (GEnumClass*) g_type_class_ref (XESAM_TYPE_G_CLAUSE_ELEMENT);
+	
+	enum_val = g_enum_get_value (enum_class, clause_type);
+	g_return_if_fail (enum_val != NULL);
+	
+	check_expected_data (self, clause_type, boost, NULL, negate, NULL);
+	
+	xesam_g_debug_object (self, "add_clause (%s, negate='%s' boost='%s')",
+						  enum_val->value_nick,
+						  negate ? (*negate ? "True" : "False") : "NULL",
+						  boost);
+}
+
+static void
+xesam_g_test_query_builder_real_add_field (XesamGQueryBuilder		*base,
+										   XesamGFieldElementType	field_type,
+										   const char				*name,
+										   GError					**error)
+{
+	XesamGTestQueryBuilder	*self;
+	GEnumValue 				*enum_val;
+	static 		GEnumClass	*enum_class = NULL;
+	
+	g_return_if_fail (XESAM_IS_G_TEST_QUERY_BUILDER (base));
+	
+	self = XESAM_G_TEST_QUERY_BUILDER (base);
+	
+	if (!enum_class)
+		enum_class = (GEnumClass*) g_type_class_ref (XESAM_TYPE_G_FIELD_ELEMENT);
+	
+	enum_val = g_enum_get_value (enum_class, field_type);
+	g_return_if_fail (enum_val != NULL);
+	
+	check_expected_data (self, field_type, name, NULL, NULL, NULL);
+	
+	xesam_g_debug_object (self, "add_field (%s, name='%s')",
+						  enum_val->value_nick, name);
+}
+
+static void
+xesam_g_test_query_builder_real_add_value (XesamGQueryBuilder		*base,
+										   XesamGValueElementType	value_type,
+										   const gchar				*value,
+										   const gchar				**attr_names,
+										   const gchar				**attr_vals,
+										   GError					**error)
+{
+	XesamGTestQueryBuilder	*self;
+	GEnumValue 				*enum_val;
+	static 		GEnumClass	*enum_class = NULL;
+	
+	g_return_if_fail (XESAM_IS_G_TEST_QUERY_BUILDER (base));
+	
+	self = XESAM_G_TEST_QUERY_BUILDER (base);
+	
+	if (!enum_class)
+		enum_class = (GEnumClass*) g_type_class_ref (XESAM_TYPE_G_VALUE_ELEMENT);
+	
+	enum_val = g_enum_get_value (enum_class, value_type);
+	g_return_if_fail (enum_val != NULL);
+	
+	check_expected_data (self, value_type, NULL, NULL, NULL, value);
+	
+	xesam_g_debug_object (self, "add_value (%s='%s')",
+						  enum_val->value_nick,
+						  value);
+}
+
+static void
+xesam_g_test_query_builder_real_close_current_child (XesamGQueryBuilder	*base,
+													 GError				**error)
+{
+	XesamGTestQueryBuilder	*self;
+	
+	g_return_if_fail (XESAM_IS_G_TEST_QUERY_BUILDER (base));
+	
+	self = XESAM_G_TEST_QUERY_BUILDER (base);
+	
+	check_expected_data (self, XESAM_G_ELEMENT_TYPE_NONE, NULL, NULL, NULL, NULL);
+	
+	xesam_g_debug_object (self, "close_child ()");
+}
+
+
+static void
+xesam_g_test_query_builder_finalize (GObject *obj)
+{
+	GSList							*iter;
+	XesamGTestQueryBuilderPrivate	*priv;
+	ExpectedElementData				*exp_data;
+	
+	xesam_g_debug_object (obj, "Finalizing");
+	
+	priv = XESAM_G_TEST_QUERY_BUILDER(obj)->priv;
+	
+	for (iter = priv->expected_data; iter; iter = iter->next) {
+		exp_data = (ExpectedElementData*)iter->data;
+		expected_element_data_destroy (exp_data);
+	}
+	
+	if (priv->expected_data) {
+		g_slist_free (priv->expected_data);
+		g_critical ("TestQueryBuilder still contains expected data");
+	}
+	
+}
+
+static void
+xesam_g_test_query_builder_class_init (XesamGTestQueryBuilderClass * klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	
+	xesam_g_test_query_builder_parent_class = g_type_class_peek_parent (klass);
+	
+	object_class->finalize = xesam_g_test_query_builder_finalize;
+}
+
+
+static void
+xesam_g_test_query_builder_interface_init (XesamGQueryBuilderIface * iface)
+{
+	xesam_g_test_query_builder_parent_iface = g_type_interface_peek_parent (iface);
+	
+	iface->add_query = xesam_g_test_query_builder_real_add_query;
+	iface->add_clause = xesam_g_test_query_builder_real_add_clause;
+	iface->add_field = xesam_g_test_query_builder_real_add_field;
+	iface->add_value = xesam_g_test_query_builder_real_add_value;
+	iface->close_current_child = xesam_g_test_query_builder_real_close_current_child;
+}
+
+
+static void
+xesam_g_test_query_builder_init (XesamGTestQueryBuilder *self)
+{	
+	self->priv = g_new0 (XesamGTestQueryBuilderPrivate, 1);
+	
+}
+
+
+GType
+xesam_g_test_query_builder_get_type (void)
+{
+	static GType xesam_g_test_query_builder_type_id = 0;
+	
+	if (G_UNLIKELY (xesam_g_test_query_builder_type_id == 0)) {
+		
+		static const GTypeInfo g_define_type_info = {
+			sizeof (XesamGTestQueryBuilderClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) xesam_g_test_query_builder_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,
+			sizeof (XesamGTestQueryBuilder),
+			0,
+			(GInstanceInitFunc) xesam_g_test_query_builder_init
+		};
+		
+		static const GInterfaceInfo xesam_g_query_builder_info = {
+			(GInterfaceInitFunc) xesam_g_test_query_builder_interface_init,
+			(GInterfaceFinalizeFunc) NULL,
+			NULL
+		};
+		
+		xesam_g_test_query_builder_type_id = g_type_register_static (G_TYPE_OBJECT,
+																	 "XesamGTestQueryBuilder",
+																	 &g_define_type_info,
+																	 0);
+		
+		g_type_add_interface_static (xesam_g_test_query_builder_type_id,
+									 XESAM_TYPE_G_QUERY_BUILDER,
+									 &xesam_g_query_builder_info);
+	}
+	
+	return xesam_g_test_query_builder_type_id;
+}
+
+XesamGTestQueryBuilder*
+xesam_g_test_query_builder_new (void)
+{
+	XesamGTestQueryBuilder	*self;
+	
+	self = g_object_new (XESAM_TYPE_G_TEST_QUERY_BUILDER, NULL);
+	
+	return self;
+}
+
+void
+xesam_g_test_query_builder_expect_data (XesamGTestQueryBuilder	*self,
+										guint					element_detail,
+										const gchar				*attr1,
+										const gchar				*attr2,
+										const gboolean			*bool_attr,
+										const gchar				*text)
+{
+	ExpectedElementData	*exp_data;
+	
+	g_return_if_fail (XESAM_IS_G_TEST_QUERY_BUILDER(self));
+	
+	exp_data = expected_element_data_new (element_detail,
+										  attr1, attr2, bool_attr, text);
+	
+	self->priv->expected_data = g_slist_prepend (self->priv->expected_data, exp_data);
+										   
+}
+
+static ExpectedElementData*
+expected_element_data_new (guint					element_detail,
+						   const gchar				*attr1,
+						   const gchar				*attr2,
+						   const gboolean			*bool_attr,
+						   const gchar				*text)
+{
+	ExpectedElementData	*exp_data;
+	
+	exp_data = g_slice_new (ExpectedElementData);
+	exp_data->element_detail = element_detail;
+	exp_data->attr1 = g_strdup (attr1);
+	exp_data->attr2 = g_strdup (attr2);
+	exp_data->bool_attr = g_memdup (bool_attr, sizeof(gboolean));
+	exp_data->text = g_strdup (text);
+	
+	return exp_data;
+}
+
+static void
+expected_element_data_destroy (ExpectedElementData *exp_data)
+{
+	if (exp_data->attr1) g_free (exp_data->attr1);
+	if (exp_data->attr2) g_free (exp_data->attr2);
+	if (exp_data->bool_attr != NULL) g_free (exp_data->bool_attr);
+	if (exp_data->text) g_free (exp_data->text);
+	
+	g_slice_free (ExpectedElementData, exp_data);
+}
+
+static void
+check_expected_data (XesamGTestQueryBuilder *self,
+					 guint					element_detail,
+					 const gchar			*attr1,
+					 const gchar			*attr2,
+					 const gboolean			*bool_attr,
+					 const gchar			*text)
+{
+	ExpectedElementData	*exp_data;
+	
+	g_return_if_fail (XESAM_IS_G_TEST_QUERY_BUILDER(self));
+	
+	if (!self->priv->expected_data) {
+		/* No data to check */
+		return;
+	}
+	
+	exp_data = (ExpectedElementData*) self->priv->expected_data->data;
+	
+	g_assert_cmpuint (element_detail, ==, exp_data->element_detail);
+	
+	g_assert_cmpstr (attr1, ==, exp_data->attr1);
+	g_assert_cmpstr (attr2, ==, exp_data->attr2);
+	g_assert_cmpstr (text, ==, exp_data->text);
+	
+	if (bool_attr != NULL && exp_data->bool_attr != NULL)
+		g_assert_cmpuint (*bool_attr, ==, *exp_data->bool_attr);
+	else if (bool_attr != NULL && !*bool_attr && exp_data->bool_attr == NULL)
+		/* bool_attr is False and we expect it to be unset. This is ok. */;
+	else if (!(bool_attr == NULL && exp_data->bool_attr == NULL))
+		g_critical ("bool_attr and exp_data->bool_attr differ. %p != %p",
+					bool_attr, exp_data->bool_attr);
+	/* else : both bool_attr are NULL */
+	
+		
+	self->priv->expected_data = g_slist_delete_link (self->priv->expected_data,
+													 self->priv->expected_data);
+	
+	expected_element_data_destroy (exp_data);
+}

Added: branches/xesam-support/tests/trackerd/xesam/xesam-g-test-query-builder.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/xesam-g-test-query-builder.h	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,65 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * xesam-glib
+ * Copyright (C) Mikkel Kamstrup Erlandsen 2008 <mikkel kamstrup gmail com>
+ * 
+ * xesam-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * xesam-glib 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with xesam-glib.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __XESAM_G_TEST_QUERY_BUILDER_H__
+#define __XESAM_G_TEST_QUERY_BUILDER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "xesam-glib/xesam-g-query-builder.h"
+
+G_BEGIN_DECLS
+
+
+#define XESAM_TYPE_G_TEST_QUERY_BUILDER (xesam_g_test_query_builder_get_type ())
+#define XESAM_G_TEST_QUERY_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XESAM_TYPE_G_TEST_QUERY_BUILDER, XesamGTestQueryBuilder))
+#define XESAM_G_TEST_QUERY_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XESAM_TYPE_G_TEST_QUERY_BUILDER, XesamGTestQueryBuilderClass))
+#define XESAM_IS_G_TEST_QUERY_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XESAM_TYPE_G_TEST_QUERY_BUILDER))
+#define XESAM_IS_G_TEST_QUERY_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XESAM_TYPE_G_TEST_QUERY_BUILDER))
+#define XESAM_G_TEST_QUERY_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XESAM_TYPE_G_TEST_QUERY_BUILDER, XesamGTestQueryBuilderClass))
+
+typedef struct _XesamGTestQueryBuilder XesamGTestQueryBuilder;
+typedef struct _XesamGTestQueryBuilderClass XesamGTestQueryBuilderClass;
+typedef struct _XesamGTestQueryBuilderPrivate XesamGTestQueryBuilderPrivate;
+
+struct _XesamGTestQueryBuilder {
+	GObject parent;
+	XesamGTestQueryBuilderPrivate *priv;
+};
+struct _XesamGTestQueryBuilderClass {
+	GObjectClass parent;
+};
+
+XesamGTestQueryBuilder* 	xesam_g_test_query_builder_new			(void);
+
+GType 						xesam_g_test_query_builder_get_type		(void);
+
+void						xesam_g_test_query_builder_expect_data	(XesamGTestQueryBuilder	*self,
+																	 guint 					element_detail,
+																	 const gchar			*attr1,
+																	 const gchar			*attr2,
+																	 const gboolean			*bool_attr,
+																	 const gchar			*value);
+
+G_END_DECLS
+
+#endif

Added: branches/xesam-support/tests/trackerd/xesam/xesam-g-testsearcher.c
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/xesam-g-testsearcher.c	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,449 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * xesam-glib
+ * Copyright (C) Mikkel Kamstrup Erlandsen 2007 <mikkel kamstrup gmail com>
+ * 
+ * xesam-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * xesam-glib 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with xesam-glib.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#include "xesam-g-testsearcher.h"
+#include <xesam-glib/xesam-g-searcher.h>
+#include <xesam-glib/xesam-glib-globals.h>
+#include "xesam-g-utils.h"
+
+enum  {
+	XESAM_G_TEST_SEARCHER_DUMMY_PROPERTY
+};
+
+typedef struct {
+	GValue	live;					// Boolean
+	GValue	hit_fields;			// GStrv
+	GValue	hit_fields_extended;	// GStrv
+	GValue	hit_snippet_length;	// UInt
+	GValue	sort_primary;			// String
+	GValue	sort_secondary;		// String
+	GValue	sort_order;			// String
+	GValue	vendor_id;				// String
+	GValue	vendor_version;		// UInt
+	GValue	vendor_display;		// String
+	GValue	vendor_xesam;			// UInt
+	GValue	vendor_ontology_fields;  // GStrv
+	GValue	vendor_ontology_contents;// GStrv
+	GValue	vendor_ontology_sources; // GStrv
+	GValue	vendor_extensions;		// GStrv
+	GValue	vendor_ontologies;		// GPtrArray(GStrv)
+	GValue	vendor_maxhits;		// UInt
+} Properties;
+
+struct _XesamGTestSearcherPrivate {
+	Properties		*props;
+};
+
+static void xesam_g_test_searcher_real_new_session 		(XesamGSearcher		*base,
+														 XesamGSearcherGotHandle callback,
+														 gpointer			user_data);
+
+static void xesam_g_test_searcher_real_close_session	(XesamGSearcher		*base,
+														 const gchar			*session_handle,
+														 XesamGSearcherVoidResponse callback,
+														 gpointer			user_data);
+
+static void xesam_g_test_searcher_real_get_property 	(XesamGSearcher		*base,
+														 const gchar			*session_handle,
+														 const gchar			*prop_name,
+														 XesamGSearcherGotProperty callback,
+														 gpointer			user_data);
+
+static void xesam_g_test_searcher_real_set_property 	(XesamGSearcher		*base,
+														 const gchar		*session_handle,
+														 const gchar		*prop_name,
+														 const GValue		*value,
+														 XesamGSearcherGotProperty callback,
+														 gpointer			user_data);
+
+static void xesam_g_test_searcher_real_new_search 		(XesamGSearcher		*base,
+														 const gchar			*session_handle,
+														 const gchar			*query,
+														 XesamGSearcherGotHandle callback,
+														 gpointer			user_data);
+
+static void xesam_g_test_searcher_real_start_search 	(XesamGSearcher		*base,
+														 const gchar			*search_handle,
+														 XesamGSearcherVoidResponse callback,
+														 gpointer			user_data);
+
+static void xesam_g_test_searcher_real_close_search 	(XesamGSearcher		*base,
+														 const gchar			*search_handle,
+														 XesamGSearcherVoidResponse callback,
+														 gpointer			user_data);
+
+static void xesam_g_test_searcher_real_get_hits			(XesamGSearcher		*base,
+														 const gchar			*search_handle,
+														 guint 				count,
+														 XesamGSearcherGotHits callback,
+														 gpointer			user_data);
+
+static void xesam_g_test_searcher_real_get_hit_data		(XesamGSearcher		*base,
+														 const gchar		*search_handle,
+														 GArray				*hit_ids,
+														 GStrv				field_names,														 
+														 XesamGSearcherGotHits callback,
+														 gpointer user_data);
+
+static void xesam_g_test_searcher_real_get_hit_count	(XesamGSearcher		*base,
+														 const gchar			*search_handle,
+														 XesamGSearcherGotHitCount callback,
+														 gpointer user_data);
+
+static void xesam_g_test_searcher_real_get_state		(XesamGSearcher		*base,
+														 XesamGSearcherGotState callback,
+														 gpointer			user_data);
+
+
+static gpointer xesam_g_test_searcher_parent_class = NULL;
+static XesamGSearcherIface* xesam_g_test_searcher_xesam_g_searcher_parent_iface = NULL;
+
+
+static void
+xesam_g_test_searcher_real_new_session (XesamGSearcher	*base,
+										XesamGSearcherGotHandle callback,
+										gpointer 		user_data)
+{	
+	static int session_num = 0;
+	
+	XesamGTestSearcher * self;
+	GString *session_handle_s;
+	
+	self = XESAM_G_TEST_SEARCHER (base);
+	session_handle_s = g_string_new (NULL);
+	g_string_printf (session_handle_s, "dummy-session-%d", session_num);
+	
+	callback (base, g_string_free (session_handle_s, FALSE), user_data, NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_close_session (XesamGSearcher	*base,
+										  const gchar		*session_handle,
+										  XesamGSearcherVoidResponse callback,
+										  gpointer			user_data)
+{
+	XesamGTestSearcher * self;
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (session_handle != NULL);
+	
+	callback (base, user_data, NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_get_property (XesamGSearcher		*base,
+										 const gchar		*session_handle,
+										 const gchar		*prop_name,
+										 XesamGSearcherGotProperty callback,
+										 gpointer			user_data)
+{
+	XesamGTestSearcher  *self;
+	GValue				*target_val;
+	
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (session_handle != NULL);
+	g_return_if_fail (prop_name != NULL);
+	
+	if (g_str_equal (prop_name, "search.live"))
+		target_val = &self->priv->props->live;
+	else if (g_str_equal (prop_name, "hit.fields"))
+		target_val = &self->priv->props->hit_fields;
+	else if (g_str_equal (prop_name, "hit.fields.extended"))
+		target_val = &self->priv->props->hit_fields_extended;
+	else
+		g_critical ("GetProperty '%s' not supported by test searcher", prop_name);
+	
+	callback (base, g_strdup (prop_name),
+			  xesam_g_clone_value(target_val), user_data, NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_set_property (XesamGSearcher	*base,
+										 const gchar	*session_handle,
+										 const gchar	*prop_name,
+										 const GValue	*value,
+										 XesamGSearcherGotProperty callback,
+										 gpointer		user_data)
+{
+	XesamGTestSearcher  *self;
+	GValue				*target_val;
+	
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (session_handle != NULL);
+	g_return_if_fail (prop_name != NULL);
+	g_return_if_fail (G_IS_VALUE(value));
+	
+	if (g_str_equal (prop_name, "search.live")) {
+		target_val = &self->priv->props->live;
+	} else if (g_str_equal (prop_name, "hit.fields")) {
+		target_val =  &self->priv->props->hit_fields;
+	} else if (g_str_equal (prop_name, "hit.fields.extended")) {
+		target_val =  &self->priv->props->hit_fields_extended;
+	} else 
+		g_critical ("SetProperty '%s' not supported by test searcher", prop_name);
+	
+	callback (base, g_strdup(prop_name),
+			  xesam_g_clone_value(target_val), user_data, NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_new_search (XesamGSearcher	*base,
+									   const gchar		*session_handle,
+									   const gchar		*query,
+									   XesamGSearcherGotHandle callback,
+									   gpointer user_data)
+{
+	XesamGTestSearcher * self;
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (session_handle != NULL);
+	g_return_if_fail (query != NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_start_search (XesamGSearcher	*base,
+										 const gchar		*search_handle,
+										 XesamGSearcherVoidResponse callback,
+										 gpointer		user_data)
+{
+	XesamGTestSearcher * self;
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (search_handle != NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_close_search (XesamGSearcher	*base,
+										 const gchar		*search_handle,
+										 XesamGSearcherVoidResponse callback,
+										 gpointer user_data)
+{
+	XesamGTestSearcher * self;
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (search_handle != NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_get_hits (XesamGSearcher	*base,
+									 const gchar		*search_handle,
+									 guint			count,
+									 XesamGSearcherGotHits callback,
+									 gpointer user_data)
+{
+	XesamGTestSearcher * self;
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (search_handle != NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_get_hit_data (XesamGSearcher	*base,
+										 const gchar	*search_handle,
+										 GArray			*hit_ids,
+										 GStrv			field_names,										 
+										 XesamGSearcherGotHits callback,
+										 gpointer user_data)
+{
+	XesamGTestSearcher * self;
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (search_handle != NULL);
+	g_return_if_fail (field_names != NULL);
+	g_return_if_fail (hit_ids != NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_get_hit_count (XesamGSearcher	*base,
+										  const gchar		*search_handle,
+										  XesamGSearcherGotHitCount callback,
+										  gpointer			user_data)
+{
+	XesamGTestSearcher * self;
+	self = XESAM_G_TEST_SEARCHER (base);
+	g_return_if_fail (search_handle != NULL);
+}
+
+
+static void
+xesam_g_test_searcher_real_get_state (XesamGSearcher	*base,
+									  XesamGSearcherGotState callback,
+									  gpointer			user_data)
+{
+	XesamGTestSearcher * self;
+	self = XESAM_G_TEST_SEARCHER (base);
+}
+
+
+XesamGTestSearcher*
+xesam_g_test_searcher_new (void)
+{
+	XesamGTestSearcher * self;
+	self = g_object_newv (XESAM_TYPE_G_TEST_SEARCHER, 0, NULL);
+	return self;
+}
+
+
+static void
+xesam_g_test_searcher_finalize (GObject *obj)
+{
+	Properties 					*props;
+	XesamGTestSearcher			*self;
+	XesamGTestSearcherPrivate	*priv;
+	
+	self = XESAM_G_TEST_SEARCHER (obj);
+	priv = self->priv;
+	props = priv->props;
+	
+	/* FIXME: Free prop GValue contents */
+	
+	g_free (props);
+	g_free (priv);
+	
+	g_debug ("Finalized test searcher\n");
+}
+
+static void
+xesam_g_test_searcher_class_init (XesamGTestSearcherClass * klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	
+	xesam_g_test_searcher_parent_class = g_type_class_peek_parent (klass);
+	
+	object_class->finalize = xesam_g_test_searcher_finalize;
+}
+
+
+static void
+xesam_g_test_searcher_xesam_g_searcher_interface_init (XesamGSearcherIface * iface)
+{
+	xesam_g_test_searcher_xesam_g_searcher_parent_iface = g_type_interface_peek_parent (iface);
+	iface->new_session = xesam_g_test_searcher_real_new_session;
+	iface->close_session = xesam_g_test_searcher_real_close_session;
+	iface->get_property = xesam_g_test_searcher_real_get_property;
+	iface->set_property = xesam_g_test_searcher_real_set_property;
+	iface->new_search = xesam_g_test_searcher_real_new_search;
+	iface->start_search = xesam_g_test_searcher_real_start_search;
+	iface->close_search = xesam_g_test_searcher_real_close_search;
+	iface->get_hits = xesam_g_test_searcher_real_get_hits;
+	iface->get_hit_data = xesam_g_test_searcher_real_get_hit_data;
+	iface->get_hit_count = xesam_g_test_searcher_real_get_hit_count;
+	iface->get_state = xesam_g_test_searcher_real_get_state;
+}
+
+
+static void
+xesam_g_test_searcher_init (XesamGTestSearcher *self)
+{
+	Properties *props;
+	
+	self->priv = g_new0 (XesamGTestSearcherPrivate, 1);
+	props = g_new0 (Properties, 1);
+	self->priv->props = props;
+	
+	g_value_init(&props->live, G_TYPE_BOOLEAN);
+	g_value_init(&props->hit_fields, G_TYPE_STRV);
+	g_value_init(&props->hit_fields_extended, G_TYPE_STRV);
+	g_value_init(&props->hit_snippet_length, G_TYPE_UINT);
+	g_value_init(&props->sort_primary, G_TYPE_STRING);
+	g_value_init(&props->sort_secondary, G_TYPE_STRING);
+	g_value_init(&props->sort_order, G_TYPE_STRING);
+	g_value_init(&props->vendor_id, G_TYPE_STRING);
+	g_value_init(&props->vendor_version, G_TYPE_UINT);
+	g_value_init(&props->vendor_display, G_TYPE_STRING);
+	g_value_init(&props->vendor_xesam, G_TYPE_UINT);
+	g_value_init(&props->vendor_ontology_fields, G_TYPE_STRV);
+	g_value_init(&props->vendor_ontology_contents, G_TYPE_STRV);
+	g_value_init(&props->vendor_ontology_sources, G_TYPE_STRV);
+	g_value_init(&props->vendor_extensions, G_TYPE_STRV);
+	g_value_init(&props->vendor_ontologies, XESAM_TYPE_STRV_ARRAY);
+	g_value_init(&props->vendor_maxhits, G_TYPE_UINT);
+	
+	const gchar *hit_fields[2] = {"xesam:url", NULL};
+	const gchar *hit_fields_extended[1] = {NULL};
+	const gchar *fields[3] = {"xesam:url", "xesam:relevancyRating", NULL};
+	const gchar *contents[2] = {"xesam:Content", NULL};
+	const gchar *sources[2] = {"xesam:Source", NULL};
+	const gchar *exts[1] = {NULL};
+	const gchar *dummy_onto[4] = {"dummy-onto","0.1","/usr/share/xesam/ontologies/dummy-onto-0.1", NULL};
+	GPtrArray *ontos = g_ptr_array_new ();
+	g_ptr_array_add (ontos, dummy_onto);
+	
+	g_value_set_boolean (&props->live, FALSE);
+	g_value_set_boxed (&props->hit_fields, hit_fields);
+	g_value_set_boxed (&props->hit_fields_extended, hit_fields_extended);
+	g_value_set_uint (&props->hit_snippet_length, 200);
+	g_value_set_string (&props->sort_primary, "xesam:relevancyRating");
+	g_value_set_string (&props->sort_secondary, "");
+	g_value_set_string (&props->sort_order, "descending");
+	g_value_set_string (&props->vendor_id, "XesamGLibTestSearcher");
+	g_value_set_uint (&props->vendor_version, 90);
+	g_value_set_string (&props->vendor_display, "Test Searcher for Xesam-GLib");
+	g_value_set_uint (&props->vendor_xesam, 90);
+	g_value_set_boxed (&props->vendor_ontology_fields, fields);
+	g_value_set_boxed (&props->vendor_ontology_contents, contents);
+	g_value_set_boxed (&props->vendor_ontology_sources, sources);
+	g_value_set_boxed (&props->vendor_extensions, exts);
+	g_value_set_boxed(&props->vendor_ontologies, ontos);
+	g_value_set_uint (&props->vendor_maxhits, 50);
+}
+
+
+GType
+xesam_g_test_searcher_get_type (void)
+{
+	static GType xesam_g_test_searcher_type_id = 0;
+	
+	if (G_UNLIKELY (xesam_g_test_searcher_type_id == 0)) {
+		
+		static const GTypeInfo g_define_type_info = {
+			sizeof (XesamGTestSearcherClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) xesam_g_test_searcher_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,
+			sizeof (XesamGTestSearcher),
+			0,
+			(GInstanceInitFunc) xesam_g_test_searcher_init
+		};
+		
+		static const GInterfaceInfo xesam_g_searcher_info = {
+			(GInterfaceInitFunc) xesam_g_test_searcher_xesam_g_searcher_interface_init,
+			(GInterfaceFinalizeFunc) NULL,
+			NULL};
+		
+		xesam_g_test_searcher_type_id = g_type_register_static (G_TYPE_OBJECT,
+																"XesamGTestSearcher",
+																&g_define_type_info,
+																0);
+		
+		g_type_add_interface_static (xesam_g_test_searcher_type_id,
+									 XESAM_TYPE_G_SEARCHER,
+									 &xesam_g_searcher_info);
+	}
+	
+	return xesam_g_test_searcher_type_id;
+}

Added: branches/xesam-support/tests/trackerd/xesam/xesam-g-testsearcher.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/xesam-g-testsearcher.h	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,59 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * xesam-glib
+ * Copyright (C) Mikkel Kamstrup Erlandsen 2007 <mikkel kamstrup gmail com>
+ * 
+ * xesam-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * xesam-glib 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with xesam-glib.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __XESAM_G_TESTSEARCHER_H__
+#define __XESAM_G_TESTSEARCHER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xesam-glib/xesam-g-searcher.h"
+
+G_BEGIN_DECLS
+
+
+#define XESAM_TYPE_G_TEST_SEARCHER (xesam_g_test_searcher_get_type ())
+#define XESAM_G_TEST_SEARCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XESAM_TYPE_G_TEST_SEARCHER, XesamGTestSearcher))
+#define XESAM_G_TEST_SEARCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XESAM_TYPE_G_TEST_SEARCHER, XesamGTestSearcherClass))
+#define XESAM_IS_G_TEST_SEARCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XESAM_TYPE_G_TEST_SEARCHER))
+#define XESAM_IS_G_TEST_SEARCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XESAM_TYPE_G_TEST_SEARCHER))
+#define XESAM_G_TEST_SEARCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XESAM_TYPE_G_TEST_SEARCHER, XesamGTestSearcherClass))
+
+typedef struct _XesamGTestSearcher XesamGTestSearcher;
+typedef struct _XesamGTestSearcherClass XesamGTestSearcherClass;
+typedef struct _XesamGTestSearcherPrivate XesamGTestSearcherPrivate;
+
+struct _XesamGTestSearcher {
+	GObject parent;
+	XesamGTestSearcherPrivate *priv;
+};
+struct _XesamGTestSearcherClass {
+	GObjectClass parent;
+};
+
+XesamGTestSearcher* xesam_g_test_searcher_new (void);
+GType xesam_g_test_searcher_get_type (void);
+
+G_END_DECLS
+
+#endif

Added: branches/xesam-support/tests/trackerd/xesam/xesam-g-utils.h
==============================================================================
--- (empty file)
+++ branches/xesam-support/tests/trackerd/xesam/xesam-g-utils.h	Fri Jun 13 08:59:46 2008
@@ -0,0 +1,46 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * xesam-glib
+ * Copyright (C) Mikkel Kamstrup Erlandsen 2007 <mikkel kamstrup gmail com>
+ * 
+ * xesam-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * xesam-glib 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with xesam-glib.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+/*
+ * xesam-g-utils.h defines commonly used *private* functionality
+ * of the xesam-glib.
+ */
+
+#ifndef _XESAM_G_UTILS_H_
+#define _XESAM_G_UTILS_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+GValue* init_value_if_null 				(GValue **value,
+										 GType value_type);
+
+gchar*	g_property_to_xesam_property 	(gchar 	*g_prop_name);
+
+void	free_ptr_array_of_values		(GPtrArray *array);
+
+GValue* xesam_g_clone_value				(const GValue *orig);
+
+G_END_DECLS
+
+#endif /* _XESAM_G_UTILS_H_ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]