summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Frade <ivan.frade@nokia.com>2010-04-28 13:44:44 +0300
committerMartyn Russell <martyn@lanedo.com>2010-04-29 12:04:21 +0100
commit689a89a21a22ebdcfabd4e9515193248a8cba1cc (patch)
tree65b88292e29078d5cda84973ce533506e9f648b3
parent805e1f1b89a4861651050c426ab8dbb64c45c683 (diff)
downloadtracker-689a89a21a22ebdcfabd4e9515193248a8cba1cc.tar.gz
Tests: initial test to libtracker-client
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/libtracker-client/Makefile.am30
-rw-r--r--tests/libtracker-client/tracker-test.c80
4 files changed, 112 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index c9537be1c..d83ec05b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1703,6 +1703,7 @@ AC_CONFIG_FILES([
src/plugins/nautilus/Makefile
src/vapi/Makefile
tests/common/Makefile
+ tests/libtracker-client/Makefile
tests/libtracker-common/Makefile
tests/libtracker-extract/Makefile
tests/libtracker-data/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cbdf2518f..3b90efbf3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,6 +3,7 @@ include $(top_srcdir)/Makefile.decl
SUBDIRS = \
common \
libtracker-common \
+ libtracker-client \
libtracker-extract \
libtracker-miner \
libtracker-data \
diff --git a/tests/libtracker-client/Makefile.am b/tests/libtracker-client/Makefile.am
new file mode 100644
index 000000000..d437a6938
--- /dev/null
+++ b/tests/libtracker-client/Makefile.am
@@ -0,0 +1,30 @@
+include $(top_srcdir)/Makefile.decl
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+TEST_PROGS += \
+ tracker-test
+
+INCLUDES = \
+ -DG_LOG_DOMAIN=\"Tracker\" \
+ -DTRACKER_COMPILATION \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/tests/common \
+ $(WARN_CFLAGS) \
+ $(GLIB2_CFLAGS) \
+ $(GCOV_CFLAGS) \
+ $(GMODULE_CFLAGS) \
+ $(GTHREAD_CFLAGS) \
+ $(DBUS_CFLAGS)
+
+tracker_test_SOURCES = \
+ tracker-test.c
+
+tracker_test_LDADD = \
+ $(top_builddir)/src/libtracker-client/libtracker-client-@TRACKER_API_VERSION@.la \
+ $(DBUS_LIBS) \
+ $(GMODULE_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(GIO_LIBS) \
+ $(GLIB2_LIBS) \
+ $(GCOV_LIBS) \ No newline at end of file
diff --git a/tests/libtracker-client/tracker-test.c b/tests/libtracker-client/tracker-test.c
new file mode 100644
index 000000000..da6cef15f
--- /dev/null
+++ b/tests/libtracker-client/tracker-test.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2008, Nokia <ivan.frade@nokia.com>
+ *
+ * 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 <glib.h>
+#include <libtracker-client/tracker.h>
+
+static void
+test_tracker_client ()
+{
+ TrackerClient *client;
+
+ client = tracker_client_new (0, -1);
+ g_assert (client);
+
+ g_object_unref (client);
+}
+
+typedef struct {
+ const gchar *input ;
+ const gchar *output;
+} ESCAPE_TEST_DATA;
+
+ESCAPE_TEST_DATA test_data [] = {
+ {"SELECT \"a\"", "SELECT \\\"a\\\""},
+ {"SELECT ?u \t \n \r \b \f", "SELECT ?u \\t \\n \\r \\b \\f"},
+ {NULL, NULL }
+};
+
+static void
+test_tracker_sparql_escape ()
+{
+ gint i;
+ gchar *result;
+
+ for (i = 0; test_data[i].input != NULL; i++) {
+ result = tracker_sparql_escape (test_data[i].input);
+ g_assert_cmpstr (result, ==, test_data[i].output);
+ g_free (result);
+ }
+}
+
+static void
+test_tracker_uri_vprintf_escaped ()
+{
+ gchar *result;
+
+ result = tracker_uri_printf_escaped ("test:uri:contact-%d", 14, NULL);
+ g_assert_cmpstr (result, ==, "test:uri:contact-14");
+ g_free (result);
+
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/libtracker-client/tracker/tracker_client", test_tracker_client);
+ g_test_add_func ("/libtracker-client/tracker/tracker_sparql_escape", test_tracker_sparql_escape);
+ g_test_add_func ("/libtracker-client/tracker/tracker_uri_vprintf_escaped",
+ test_tracker_uri_vprintf_escaped);
+
+ return g_test_run ();
+}