[tracker/tracker-sparql-qt: 2/3] Add tests for libtracker-sparql-qt



commit f3edda7384611a1de69bee48d7397fb8f759306f
Author: Adrien Bustany <abustany gnome org>
Date:   Sun Jan 16 12:36:28 2011 +0200

    Add tests for libtracker-sparql-qt

 configure.ac                                       |    1 +
 tests/Makefile.am                                  |    4 +
 tests/libtracker-sparql-qt/Makefile.am             |   21 +++++++
 .../tracker-sparql-qt-test.cpp                     |   59 ++++++++++++++++++++
 .../libtracker-sparql-qt/tracker-sparql-qt-test.h  |   20 +++++++
 tests/libtracker-sparql-qt/tracker-test.c          |   44 +++++++++++++++
 6 files changed, 149 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5b9c8a9..1f7557c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2148,6 +2148,7 @@ AC_CONFIG_FILES([
 	tests/libtracker-fts/limits/Makefile
 	tests/libtracker-fts/prefix/Makefile
 	tests/libtracker-sparql/Makefile
+	tests/libtracker-sparql-qt/Makefile
 	tests/functional-tests/Makefile
 	tests/functional-tests/ipc/Makefile
 	tests/functional-tests/common/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9785b5e..78938d4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -18,3 +18,7 @@ endif
 if HAVE_TRACKER_FTS
 SUBDIRS += libtracker-fts
 endif
+
+if HAVE_LIBTRACKER_SPARQL_QT
+SUBDIRS += libtracker-sparql-qt
+endif
diff --git a/tests/libtracker-sparql-qt/Makefile.am b/tests/libtracker-sparql-qt/Makefile.am
new file mode 100644
index 0000000..358374c
--- /dev/null
+++ b/tests/libtracker-sparql-qt/Makefile.am
@@ -0,0 +1,21 @@
+include $(top_srcdir)/Makefile.decl
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+TEST_PROGS +=                                          \
+	tracker-test
+
+AM_CPPFLAGS =                                          \
+	$(BUILD_CFLAGS)                                \
+	-I$(top_srcdir)/src                            \
+	-I$(top_srcdir)/src/libtracker-sparql-qt       \
+	-I$(top_builddir)/src                          \
+	-I$(top_srcdir)/tests/common                   \
+	$(LIBTRACKER_SPARQL_QT_CFLAGS)
+
+LDADD =                                                \
+	$(top_builddir)/src/libtracker-sparql-qt/libtracker-sparql-qt- TRACKER_API_VERSION@.la \
+	$(BUILD_LIBS)                                  \
+	$(LIBTRACKER_SPARQL_QT_LIBS)
+
+tracker_test_SOURCES = tracker-test.c tracker-sparql-qt-test.cpp
diff --git a/tests/libtracker-sparql-qt/tracker-sparql-qt-test.cpp b/tests/libtracker-sparql-qt/tracker-sparql-qt-test.cpp
new file mode 100644
index 0000000..17d45e8
--- /dev/null
+++ b/tests/libtracker-sparql-qt/tracker-sparql-qt-test.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011, Adrien Bustany <abustany gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 "tracker-sparql-qt-test.h"
+
+#include <tracker-sparql-qt.h>
+
+#define VERIFY(assertion) \
+	if (not assertion) { \
+		qFatal("Assertion %s failed", #assertion); \
+	}
+
+#define COMPARE(a, b) \
+	if (a != b) { \
+		qFatal("Expected %s == %s, got %s", #a, #b, qPrintable(QVariant(a).toString())); \
+	}
+
+using namespace TrackerSparql;
+
+void
+test_tracker_sparql_qt_error()
+{
+	Error e;
+
+	VERIFY(not e.valid());
+	COMPARE(e.code(), -1);
+	COMPARE(e.message(), QString());
+
+	GError dummyError;
+	dummyError.code = 42;
+	dummyError.message = g_strdup("Dummy error");
+
+	e = Error(&dummyError);
+
+	COMPARE(e.code(), 42);
+	COMPARE(e.message(), QString::fromLatin1("Dummy error"));
+
+	Error ee = e;
+	COMPARE(e.code(), ee.code());
+	COMPARE(e.message(), ee.message());
+}
diff --git a/tests/libtracker-sparql-qt/tracker-sparql-qt-test.h b/tests/libtracker-sparql-qt/tracker-sparql-qt-test.h
new file mode 100644
index 0000000..b25a5b1
--- /dev/null
+++ b/tests/libtracker-sparql-qt/tracker-sparql-qt-test.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2011, Adrien Bustany <abustany gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ */
+
+extern "C" void test_tracker_sparql_qt_error();
diff --git a/tests/libtracker-sparql-qt/tracker-test.c b/tests/libtracker-sparql-qt/tracker-test.c
new file mode 100644
index 0000000..7382bb6
--- /dev/null
+++ b/tests/libtracker-sparql-qt/tracker-test.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011, Adrien Bustany <abustany gnome org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 "config.h"
+
+#include <glib.h>
+
+extern void test_tracker_sparql_qt_error();
+
+gint
+main (gint argc, gchar **argv)
+{
+	int result;
+
+	g_thread_init (NULL);
+	g_type_init ();
+	g_test_init (&argc, &argv, NULL);
+
+	/* do not require prior installation */
+	g_setenv ("TRACKER_SPARQL_MODULE_PATH", "../../src/libtracker-bus/.libs", TRUE);
+
+	g_test_add_func ("/libtracker-sparql-qt/tracker/Error",
+	                 test_tracker_sparql_qt_error);
+
+	result = g_test_run ();
+
+	return result;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]