[tracker/libtracker-bus: 32/52] tests/functional-tests: Refactored the tests a bit more
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-bus: 32/52] tests/functional-tests: Refactored the tests a bit more
- Date: Fri, 13 Aug 2010 08:24:57 +0000 (UTC)
commit 9890f6cac99d0496740c386115594861b77e072a
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Jul 22 12:42:11 2010 +0200
tests/functional-tests: Refactored the tests a bit more
tests/functional-tests/.gitignore | 1 +
tests/functional-tests/Makefile.am | 8 +---
tests/functional-tests/bus-query-test.vala | 45 +-------------------
tests/functional-tests/bus-update-test.vala | 4 +-
tests/functional-tests/shared-query-test.vala | 54 ++++++++++++++++++++++++
tests/functional-tests/shared-update-test.vala | 9 ++++-
6 files changed, 67 insertions(+), 54 deletions(-)
---
diff --git a/tests/functional-tests/.gitignore b/tests/functional-tests/.gitignore
index 7ee8336..7eb76a3 100644
--- a/tests/functional-tests/.gitignore
+++ b/tests/functional-tests/.gitignore
@@ -1,3 +1,4 @@
+shared-query-test.c
shared-update-test.c
bus-query-test
bus-query-test.c
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index 9df606c..7864efd 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -73,13 +73,7 @@ MAINTAINERCLEANFILES = \
$(BUILT_SOURCES) \
$(busy_handling_test_VALASOURCES:.vala=.c)
-default_update_test_VALASOURCES = shared-update-test.vala default-update-test.vala
-
-default_update_test_SOURCES = \
- default_update_test.vala.stamp \
- $(default_update_test_VALASOURCES:.vala=.c)
-
-bus_query_test_VALASOURCES = bus-query-test.vala
+bus_query_test_VALASOURCES = shared-query-test.vala bus-query-test.vala
bus_query_test_SOURCES = \
bus_query_test.vala.stamp \
diff --git a/tests/functional-tests/bus-query-test.vala b/tests/functional-tests/bus-query-test.vala
index df88a0d..1867fed 100644
--- a/tests/functional-tests/bus-query-test.vala
+++ b/tests/functional-tests/bus-query-test.vala
@@ -1,51 +1,10 @@
using Tracker;
using Tracker.Sparql;
-private int iter_cursor (Cursor cursor)
-{
- try {
- while (cursor.next()) {
- int i;
-
- for (i = 0; i < cursor.n_columns; i++) {
- print ("%s%s", i != 0 ? ",":"", cursor.get_string (i));
- }
-
- print ("\n");
- }
- } catch (GLib.Error e) {
- warning ("Couldn't iterate query results: %s", e.message);
- return -1;
- }
-
- 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);
-
- if (a == -1)
- return a;
-
- print ("\nRewinding\n");
- cursor.rewind ();
-
- print ("\nSecond run\n");
- a = iter_cursor (cursor);
-
+ TestApp app = new TestApp (new Tracker.Bus.Connection ());
- return a;
+ return app.run ();
}
diff --git a/tests/functional-tests/bus-update-test.vala b/tests/functional-tests/bus-update-test.vala
index e48b5d4..1867fed 100644
--- a/tests/functional-tests/bus-update-test.vala
+++ b/tests/functional-tests/bus-update-test.vala
@@ -6,7 +6,5 @@ main( string[] args )
{
TestApp app = new TestApp (new Tracker.Bus.Connection ());
- app.run ();
-
- return 0;
+ return app.run ();
}
diff --git a/tests/functional-tests/shared-query-test.vala b/tests/functional-tests/shared-query-test.vala
new file mode 100644
index 0000000..b11cdce
--- /dev/null
+++ b/tests/functional-tests/shared-query-test.vala
@@ -0,0 +1,54 @@
+using Tracker;
+using Tracker.Sparql;
+
+public class TestApp : GLib.Object {
+ Sparql.Connection con;
+
+ public TestApp (Sparql.Connection connection) {
+ con = connection;
+ }
+
+ int iter_cursor (Cursor cursor) {
+ try {
+ while (cursor.next()) {
+ int i;
+
+ for (i = 0; i < cursor.n_columns; i++) {
+ print ("%s%s", i != 0 ? ",":"", cursor.get_string (i));
+ }
+
+ print ("\n");
+ }
+ } catch (GLib.Error e) {
+ warning ("Couldn't iterate query results: %s", e.message);
+ return -1;
+ }
+
+ return (0);
+ }
+
+ public int run () {
+ 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 a;
+ }
+}
diff --git a/tests/functional-tests/shared-update-test.vala b/tests/functional-tests/shared-update-test.vala
index 22c966c..3d6c57f 100644
--- a/tests/functional-tests/shared-update-test.vala
+++ b/tests/functional-tests/shared-update-test.vala
@@ -5,6 +5,7 @@ using Tracker.Sparql;
public class TestApp : GLib.Object {
MainLoop loop;
Sparql.Connection con;
+ private int res = 0;
public TestApp (Sparql.Connection connection) {
con = connection;
@@ -37,6 +38,7 @@ public class TestApp : GLib.Object {
con.update ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }");
} catch (Tracker.Sparql.Error ea) {
warning ("Couldn't update: %s", ea.message);
+ res = -1;
}
try {
@@ -44,6 +46,7 @@ public class TestApp : GLib.Object {
a = iter_cursor (cursor);
} catch (Tracker.Sparql.Error eb) {
warning ("Couldn't query: %s", eb.message);
+ res = -1;
}
}
@@ -56,6 +59,7 @@ public class TestApp : GLib.Object {
yield con.update_async ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }");
} catch (Tracker.Sparql.Error ea) {
warning ("Couldn't update: %s", ea.message);
+ res = -1;
}
try {
@@ -63,6 +67,7 @@ public class TestApp : GLib.Object {
a = iter_cursor (cursor);
} catch (Tracker.Sparql.Error eb) {
warning ("Couldn't query: %s", eb.message);
+ res = -1;
}
}
@@ -86,11 +91,13 @@ public class TestApp : GLib.Object {
return false;
}
- public void run () {
+ public int run () {
loop = new MainLoop (null, false);
Idle.add (in_mainloop);
loop.run ();
+
+ return res;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]