[tracker/direct-access-update-fd-passing: 5/5] tests/functional-tests: Refactored the update tests
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/direct-access-update-fd-passing: 5/5] tests/functional-tests: Refactored the update tests
- Date: Thu, 22 Jul 2010 09:33:56 +0000 (UTC)
commit f1dd1ec0ec245adcdfedf25683be5718010a9bb6
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Jul 22 11:23:49 2010 +0200
tests/functional-tests: Refactored the update tests
tests/functional-tests/.gitignore | 5 +-
tests/functional-tests/Makefile.am | 18 ++--
tests/functional-tests/bus-update-test.vala | 42 +---------
tests/functional-tests/default-update-test.vala | 9 ++
tests/functional-tests/direct-update-test.vala | 41 ----------
tests/functional-tests/shared-update-test.vala | 96 +++++++++++++++++++++++
6 files changed, 120 insertions(+), 91 deletions(-)
---
diff --git a/tests/functional-tests/.gitignore b/tests/functional-tests/.gitignore
index 6d07005..30f6375 100644
--- a/tests/functional-tests/.gitignore
+++ b/tests/functional-tests/.gitignore
@@ -1,11 +1,12 @@
+shared-update-test.c
bus-query-test
bus-query-test.c
direct-query-test
direct-query-test.c
bus-update-test
bus-update-test.c
-direct-update-test
-direct-update-test.c
+default-update-test
+default-update-test.c
ttl
force-sqlite-misused-batch.sh
force-sqlite-misused.sh
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index 1afdec7..34d6d1a 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -49,7 +49,7 @@ bashscripts_SCRIPTS = \
@sed -e "s|@topsrcdir[ ]|${top_srcdir}|" \
-e "s|@libexecdir[ ]|${libexecdir}|" $< > $@
-noinst_PROGRAMS = direct-query-test bus-query-test direct-update-test bus-update-test
+noinst_PROGRAMS = direct-query-test bus-query-test default-update-test bus-update-test
direct_query_test_VALASOURCES = direct-query-test.vala
@@ -57,11 +57,11 @@ direct_query_test_SOURCES = \
direct_query_test.vala.stamp \
$(direct_query_test_VALASOURCES:.vala=.c)
-direct_update_test_VALASOURCES = direct-update-test.vala
+default_update_test_VALASOURCES = shared-update-test.vala default-update-test.vala
-direct_update_test_SOURCES = \
- direct_update_test.vala.stamp \
- $(direct_update_test_VALASOURCES:.vala=.c)
+default_update_test_SOURCES = \
+ default_update_test.vala.stamp \
+ $(default_update_test_VALASOURCES:.vala=.c)
bus_query_test_VALASOURCES = bus-query-test.vala
@@ -69,7 +69,7 @@ bus_query_test_SOURCES = \
bus_query_test.vala.stamp \
$(bus_query_test_VALASOURCES:.vala=.c)
-bus_update_test_VALASOURCES = bus-update-test.vala
+bus_update_test_VALASOURCES = shared-update-test.vala bus-update-test.vala
bus_update_test_SOURCES = \
bus_update_test.vala.stamp \
@@ -89,11 +89,11 @@ direct_query_test_LDADD = \
$(GIO_LIBS) \
$(GLIB2_LIBS)
-direct-update-test.vala.stamp: $(direct_update_test_VALASOURCES) $(direct_vapi_sources)
+default-update-test.vala.stamp: $(default_update_test_VALASOURCES) $(direct_vapi_sources)
$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 $^
$(AM_V_GEN)touch $@
-direct_update_test_LDADD = $(direct_query_test_LDADD)
+default_update_test_LDADD = $(direct_query_test_LDADD)
bus_vapi_sources = \
$(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi \
@@ -119,7 +119,7 @@ bus_update_test_LDADD = $(bus_query_test_LDADD)
BUILT_SOURCES = direct-query-test.vala.stamp \
bus-query-test.vala.stamp \
- direct-update-test.vala.stamp \
+ default-update-test.vala.stamp \
bus-update-test.vala.stamp
EXTRA_DIST = \
diff --git a/tests/functional-tests/bus-update-test.vala b/tests/functional-tests/bus-update-test.vala
index 6514fdb..e48b5d4 100644
--- a/tests/functional-tests/bus-update-test.vala
+++ b/tests/functional-tests/bus-update-test.vala
@@ -1,48 +1,12 @@
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 {
- con.update ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }");
- } catch (GLib.Error e) {
- warning ("Couldn't perform query: %s", e.message);
- return -1;
- }
-
- try {
- cursor = con.query ("SELECT ?title WHERE { <test01> nie:title ?title }");
- } catch (GLib.Error e) {
- warning ("Couldn't perform query: %s", e.message);
- return -1;
- }
+ TestApp app = new TestApp (new Tracker.Bus.Connection ());
- a = iter_cursor (cursor);
+ app.run ();
- return a;
+ return 0;
}
diff --git a/tests/functional-tests/default-update-test.vala b/tests/functional-tests/default-update-test.vala
new file mode 100644
index 0000000..4dacd6e
--- /dev/null
+++ b/tests/functional-tests/default-update-test.vala
@@ -0,0 +1,9 @@
+int
+main( string[] args )
+{
+ TestApp app = new TestApp (Tracker.Sparql.Connection.get());
+
+ app.run ();
+
+ return 0;
+}
diff --git a/tests/functional-tests/shared-update-test.vala b/tests/functional-tests/shared-update-test.vala
new file mode 100644
index 0000000..22c966c
--- /dev/null
+++ b/tests/functional-tests/shared-update-test.vala
@@ -0,0 +1,96 @@
+using Tracker;
+using Tracker.Sparql;
+
+
+public class TestApp : GLib.Object {
+ MainLoop loop;
+ 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);
+ }
+
+ void update_query () {
+ Cursor cursor;
+ int a;
+
+ try {
+ con.update ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }");
+ } catch (Tracker.Sparql.Error ea) {
+ warning ("Couldn't update: %s", ea.message);
+ }
+
+ try {
+ cursor = con.query ("SELECT ?title WHERE { <test01> nie:title ?title }");
+ a = iter_cursor (cursor);
+ } catch (Tracker.Sparql.Error eb) {
+ warning ("Couldn't query: %s", eb.message);
+ }
+
+ }
+
+ async void update_query_async () {
+ Cursor cursor;
+ int a;
+
+ try {
+ yield con.update_async ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }");
+ } catch (Tracker.Sparql.Error ea) {
+ warning ("Couldn't update: %s", ea.message);
+ }
+
+ try {
+ cursor = con.query ("SELECT ?title WHERE { <test01> nie:title ?title }");
+ a = iter_cursor (cursor);
+ } catch (Tracker.Sparql.Error eb) {
+ warning ("Couldn't query: %s", eb.message);
+ }
+
+ }
+
+ void do_sync_tests () {
+ update_query ();
+ }
+
+ async void do_async_tests () {
+ yield update_query_async ();
+
+ print ("Async tests done, now I can quit the mainloop\n");
+ loop.quit ();
+ }
+
+ bool in_mainloop () {
+
+ do_sync_tests ();
+ do_async_tests ();
+
+ return false;
+ }
+
+ public void run () {
+ loop = new MainLoop (null, false);
+
+ Idle.add (in_mainloop);
+
+ loop.run ();
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]