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



commit 7a448d5122c69cb32c3da7e501e2b02e76eb5c3f
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/bus-test.vala       |   46 +++++++++++++++++-----------
 2 files changed, 30 insertions(+), 19 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/bus-test.vala b/tests/functional-tests/bus-test.vala
index 68ad63a..df88a0d 100644
--- a/tests/functional-tests/bus-test.vala
+++ b/tests/functional-tests/bus-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]