[tracker/direct-access: 24/40] libtracker-data: Fix rewind for direct-access, added functional test



commit ffbdbe3e6215081becabbecbbc7e5b3c9006033c
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Jul 19 14:00:33 2010 +0200

    libtracker-data: Fix rewind for direct-access, added functional test

 src/libtracker-data/tracker-db-interface-sqlite.c |    1 +
 tests/functional-tests/direct-test.vala           |   47 +++++++++++++--------
 2 files changed, 30 insertions(+), 18 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 180f9dd..0134f49 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1202,6 +1202,7 @@ tracker_db_cursor_rewind (TrackerDBCursor *cursor)
 	g_return_if_fail (TRACKER_IS_DB_CURSOR (cursor));
 
 	sqlite3_reset (cursor->stmt);
+	cursor->finished = FALSE;
 }
 
 gboolean
diff --git a/tests/functional-tests/direct-test.vala b/tests/functional-tests/direct-test.vala
index b73581a..f1ec29e 100644
--- a/tests/functional-tests/direct-test.vala
+++ b/tests/functional-tests/direct-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.Direct.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;
@@ -28,14 +17,36 @@ main( string[] args )
 		warning ("Couldn't iterate query results: %s", e.message);
 		return -1;
 	}
-		
-	// Testing new API with GModule
-	
-//	print ("\n\n");
 
-//	Lookup foo = new Lookup ();
+	return (0);
+}
+
+int
+main( string[] args )
+{
+	Sparql.Connection con = new Tracker.Direct.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);
+
+	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]