[tracker/tracker-1.0] libtracker-sparql: Add a test case
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-1.0] libtracker-sparql: Add a test case
- Date: Mon, 22 Sep 2014 14:32:37 +0000 (UTC)
commit 4babc63eb93c8c7f20f0784bb1f5e1c3440cee32
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Sep 22 15:21:27 2014 +0200
libtracker-sparql: Add a test case
https://bugzilla.gnome.org/show_bug.cgi?id=737023
tests/libtracker-sparql/Makefile.am | 6 +-
tests/libtracker-sparql/tracker-gb-737023.c | 106 +++++++++++++++++++++++++++
2 files changed, 111 insertions(+), 1 deletions(-)
---
diff --git a/tests/libtracker-sparql/Makefile.am b/tests/libtracker-sparql/Makefile.am
index 52705b1..fa12d2d 100644
--- a/tests/libtracker-sparql/Makefile.am
+++ b/tests/libtracker-sparql/Makefile.am
@@ -2,7 +2,9 @@ include $(top_srcdir)/Makefile.decl
noinst_PROGRAMS += $(test_programs)
-test_programs = tracker-test
+test_programs = \
+ tracker-test \
+ tracker-gb-737023
AM_CPPFLAGS = \
$(BUILD_CFLAGS) \
@@ -17,3 +19,5 @@ LDADD = \
$(LIBTRACKER_SPARQL_LIBS)
tracker_test_SOURCES = tracker-test.c
+
+tracker_gb_737023_test_SOURCES = tracker-gb-737023.c
diff --git a/tests/libtracker-sparql/tracker-gb-737023.c b/tests/libtracker-sparql/tracker-gb-737023.c
new file mode 100644
index 0000000..ae212d6
--- /dev/null
+++ b/tests/libtracker-sparql/tracker-gb-737023.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2014, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gio/gio.h>
+
+#include <libtracker-sparql/tracker-sparql.h>
+
+static void
+query_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+ GCancellable *cancellable;
+ GError *error = NULL;
+ TrackerSparqlConnection *conn = TRACKER_SPARQL_CONNECTION (source_object);
+ TrackerSparqlCursor *cursor = NULL;
+
+ cursor = tracker_sparql_connection_query_finish (conn, res, &error);
+ if (error != NULL) {
+ g_error_free (error);
+ }
+
+ cancellable = g_cancellable_new ();
+ tracker_sparql_connection_query_async (conn,
+ "SELECT ?urn WHERE {?urn a rdfs:Resource}",
+ cancellable,
+ query_cb,
+ NULL);
+ g_cancellable_cancel (cancellable);
+
+ g_object_unref (cancellable);
+ g_clear_object (&cursor);
+}
+
+static gboolean
+quit_cb (gpointer user_data)
+{
+ g_main_loop_quit ((GMainLoop *) user_data);
+ return G_SOURCE_REMOVE;
+}
+
+static void
+test_tracker_sparql_gb737023 (void)
+{
+ GCancellable *cancellable;
+ GError *error = NULL;
+ GMainLoop *loop;
+ TrackerSparqlConnection *conn;
+
+ g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=");
+ g_test_bug ("737023");
+
+ g_setenv ("TRACKER_SPARQL_BACKEND", "bus", TRUE);
+ conn = tracker_sparql_connection_get (NULL, &error);
+ g_assert_no_error (error);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ /* This should be enough. */
+ g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
+ 2,
+ quit_cb,
+ loop,
+ (GDestroyNotify) g_main_loop_unref);
+
+ cancellable = g_cancellable_new ();
+ tracker_sparql_connection_query_async (conn,
+ "SELECT ?urn WHERE {?urn a rdfs:Resource}",
+ cancellable,
+ query_cb,
+ NULL);
+ g_cancellable_cancel (cancellable);
+ g_main_loop_run (loop);
+
+ g_object_unref (cancellable);
+ g_object_unref (conn);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ gint result;
+
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/libtracker-sparql/tracker/gb737023",
+ test_tracker_sparql_gb737023);
+
+ result = g_test_run ();
+
+ return result;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]