aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-01-21 17:34:44 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-01-21 17:34:44 +0100
commitd84d6f7cce3715ec88a67418c4d4298237618463 (patch)
tree9df8e7f13176748b6270e4060af476d109869561 /tests
parent36e0fea77699a71d03245900b9c0ae5a7cf2bcf5 (diff)
downloadlibayatana-indicator-d84d6f7cce3715ec88a67418c4d4298237618463.tar.gz
libayatana-indicator-d84d6f7cce3715ec88a67418c4d4298237618463.tar.bz2
libayatana-indicator-d84d6f7cce3715ec88a67418c4d4298237618463.zip
Add basic tests for indicator-ng
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am25
-rw-r--r--tests/com.canonical.test.indicator4
-rw-r--r--tests/test-indicator-ng.c62
3 files changed, 91 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c98bdbf..97741b0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -466,3 +466,28 @@ DISTCLEANFILES += loader-tester
DISTCLEANFILES += $(XML_REPORT) $(HTML_REPORT)
+#############################
+# Indicator-ng
+#############################
+
+if USE_GTK3
+
+check_PROGRAMS += test-indicator-ng
+
+test_indicator_ng_SOURCES = test-indicator-ng.c
+
+test_indicator_ng_CFLAGS = \
+ $(LIBINDICATOR_CFLAGS) \
+ -I$(top_srcdir) \
+ -DSRCDIR="\"$(srcdir)\"" \
+ -Wall
+
+test_indicator_ng_LDADD = \
+ $(LIBINDICATOR_LIBS) \
+ -L$(top_builddir)/libindicator/.libs \
+ $(INDICATOR_LIB)
+
+TESTS += test-indicator-ng
+DISTCLEANFILES = test-indicator-ng
+
+endif
diff --git a/tests/com.canonical.test.indicator b/tests/com.canonical.test.indicator
new file mode 100644
index 0000000..dad4c94
--- /dev/null
+++ b/tests/com.canonical.test.indicator
@@ -0,0 +1,4 @@
+[Indicator Service]
+Name=indicator-test
+BusName=com.canonical.indicator.test
+ObjectPath=/com/canonical/indicator/test
diff --git a/tests/test-indicator-ng.c b/tests/test-indicator-ng.c
new file mode 100644
index 0000000..65a1e72
--- /dev/null
+++ b/tests/test-indicator-ng.c
@@ -0,0 +1,62 @@
+
+#include <libindicator/indicator-ng.h>
+
+static void
+test_non_existing (void)
+{
+ IndicatorNg *indicator;
+ GError *error = NULL;
+
+ indicator = indicator_ng_new (SRCDIR "/com.canonical.does.not.exist.indicator", &error);
+ g_assert (indicator == NULL);
+ g_assert_error (error, G_FILE_ERROR, G_FILE_ERROR_NOENT);
+
+ g_clear_error (&error);
+}
+
+static void
+test_instantiation (void)
+{
+ IndicatorNg *indicator;
+ GError *error = NULL;
+
+ indicator = indicator_ng_new (SRCDIR "/com.canonical.test.indicator", &error);
+ g_assert (indicator);
+ g_assert (error == NULL);
+
+ g_assert_cmpstr (indicator_ng_get_service_file (indicator), ==, SRCDIR "/com.canonical.test.indicator");
+ g_assert_cmpstr (indicator_ng_get_profile (indicator), ==, "desktop");
+
+ /* no service running, so there shouldn't be any indicators */
+ g_assert (indicator_object_get_entries (INDICATOR_OBJECT (indicator)) == NULL);
+
+ g_object_unref (indicator);
+}
+
+static void
+test_instantiation_with_profile (void)
+{
+ IndicatorNg *indicator;
+ GError *error = NULL;
+
+ indicator = indicator_ng_new_for_profile (SRCDIR "/com.canonical.test.indicator", "greeter", &error);
+ g_assert (indicator);
+ g_assert (error == NULL);
+
+ g_assert_cmpstr (indicator_ng_get_profile (indicator), ==, "greeter");
+
+ g_object_unref (indicator);
+}
+
+int
+main (int argc, char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+ gtk_init (&argc, &argv);
+
+ g_test_add_func ("/indicator-ng/non-existing", test_non_existing);
+ g_test_add_func ("/indicator-ng/instantiation", test_instantiation);
+ g_test_add_func ("/indicator-ng/instantiation-with-profile", test_instantiation_with_profile);
+
+ return g_test_run ();
+}