[tracker/libtracker-bus: 6/44] libtracker-bus: Implement rewind for fd-passing, added functional test



commit 42eee48e209cd348f70b021f9818ed39f5104e6d
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Jul 19 14:04:19 2010 +0200

    libtracker-bus: Implement rewind for fd-passing, added functional test

 src/libtracker-bus/tracker-bus-fd-cursor.c         |    3 +-
 tests/functional-tests/Makefile.am                 |   14 +++---
 .../{bus-test.vala => bus-query-test.vala}         |   46 ++++++++++++--------
 3 files changed, 37 insertions(+), 26 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus-fd-cursor.c b/src/libtracker-bus/tracker-bus-fd-cursor.c
index d63adf8..cbd0f0c 100644
--- a/src/libtracker-bus/tracker-bus-fd-cursor.c
+++ b/src/libtracker-bus/tracker-bus-fd-cursor.c
@@ -68,7 +68,8 @@ G_DEFINE_TYPE (TrackerBusFDCursor, tracker_bus_fd_cursor, TRACKER_SPARQL_TYPE_CU
 static void
 tracker_bus_fd_cursor_rewind (TrackerBusFDCursor *cursor)
 {
-	/* FIXME: Implement */
+	cursor->buffer_index = 0;
+	cursor->data = cursor->buffer;
 }
 
 static inline int
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index bf622fb..81f59b0 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -73,21 +73,21 @@ MAINTAINERCLEANFILES =					\
 	$(BUILT_SOURCES)				\
 	$(busy_handling_test_VALASOURCES:.vala=.c)
 
-bus_test_VALASOURCES = bus-test.vala
+bus_query_test_VALASOURCES = bus-query-test.vala
 
-bus_test_SOURCES = \
-	bus_test.vala.stamp \
-	$(bus_test_VALASOURCES:.vala=.c)
+bus_query_test_SOURCES = \
+	bus_query_test.vala.stamp \
+	$(bus_query_test_VALASOURCES:.vala=.c)
 
 bus_vapi_sources = \
 	$(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi \
 	$(top_srcdir)/src/libtracker-bus/tracker-bus-$(TRACKER_API_VERSION).vapi
 
-bus-test.vala.stamp: $(bus_test_VALASOURCES) $(bus_vapi_sources)
+bus-query-test.vala.stamp: $(bus_query_test_VALASOURCES) $(bus_vapi_sources)
 	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 --pkg dbus-glib-1 $^
 	$(AM_V_GEN)touch $@
 
-bus_test_LDADD = \
+bus_query_test_LDADD = \
 	$(top_builddir)/src/libtracker-bus/libtracker-bus-$(TRACKER_API_VERSION).la \
 	$(top_builddir)/src/libtracker-sparql/libtracker-sparql-$(TRACKER_API_VERSION).la \
 	$(top_builddir)/src/libtracker-common/libtracker-common.la \
@@ -97,7 +97,7 @@ bus_test_LDADD = \
 
 BUILT_SOURCES = \
 	busy-handling-test.vala.stamp \
-	bus-test.vala.stamp
+	bus-query-test.vala.stamp
 
 EXTRA_DIST = 					\
 	$(config_SCRIPTS) 			\
diff --git a/tests/functional-tests/bus-test.vala b/tests/functional-tests/bus-query-test.vala
similarity index 72%
rename from tests/functional-tests/bus-test.vala
rename to tests/functional-tests/bus-query-test.vala
index 68ad63a..df88a0d 100644
--- a/tests/functional-tests/bus-test.vala
+++ b/tests/functional-tests/bus-query-test.vala
@@ -1,19 +1,8 @@
 using Tracker;
 using Tracker.Sparql;
 
-int
-main( string[] args )
+private int iter_cursor (Cursor cursor)
 {
-	Sparql.Connection con = new Tracker.Bus.Connection ();
-	Cursor cursor;
-
-	try {
-		cursor = con.query ("SELECT ?u WHERE { ?u a rdfs:Class }");
-	} catch (GLib.Error e) {
-		warning ("Couldn't perform query: %s", e.message);
-		return -1;
-	}
-
 	try {
 		while (cursor.next()) {
 			int i;
@@ -29,13 +18,34 @@ main( string[] args )
 		return -1;
 	}
 
-	// Testing new API with GModule
-	
-//	print ("\n\n");
+	return (0);
+}
+
+int
+main( string[] args )
+{
+	Sparql.Connection con = new Tracker.Bus.Connection ();
+	Cursor cursor;
+	int a;
+
+	try {
+		cursor = con.query ("SELECT ?u WHERE { ?u a rdfs:Class }");
+	} catch (GLib.Error e) {
+		warning ("Couldn't perform query: %s", e.message);
+		return -1;
+	}
+
+	a = iter_cursor (cursor);
 
-//	Lookup foo = new Lookup ();
+	if (a == -1)
+		return a;
 
+	print ("\nRewinding\n");
+	cursor.rewind ();
+
+	print ("\nSecond run\n");
+	a = iter_cursor (cursor);
 
-	return( 0 );
-}
 
+	return a;
+}



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