aboutsummaryrefslogtreecommitdiff
path: root/tests/test-libappindicator.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-12-02 12:05:28 -0600
committerTed Gould <ted@gould.cx>2009-12-02 12:05:28 -0600
commit5317413c8321c19e844664721aae963b5fa00d9a (patch)
treee716e959353ef0ea12c0f186b97b0f26dd156832 /tests/test-libappindicator.c
parentf897644bc0a7908665718495d8991310cc11b170 (diff)
parent5c4e31a5c9310845ca8e5260545e1bff78e0b5ea (diff)
downloadayatana-indicator-application-5317413c8321c19e844664721aae963b5fa00d9a.tar.gz
ayatana-indicator-application-5317413c8321c19e844664721aae963b5fa00d9a.tar.bz2
ayatana-indicator-application-5317413c8321c19e844664721aae963b5fa00d9a.zip
* Massive name change.
* debian/* changing packaging to not be "custom" anymore and now everything is "application" * debian/control: Splitting out libappindicator * Adding debian/libappindicator0.install, debian/libappindicator-dev.install, debian/indicator-application.install
Diffstat (limited to 'tests/test-libappindicator.c')
-rw-r--r--tests/test-libappindicator.c163
1 files changed, 163 insertions, 0 deletions
diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c
new file mode 100644
index 0000000..1d7c920
--- /dev/null
+++ b/tests/test-libappindicator.c
@@ -0,0 +1,163 @@
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libappindicator/app-indicator.h>
+
+void
+test_libappindicator_prop_signals_status_helper (AppIndicator * ci, gchar * status, gboolean * signalactivated)
+{
+ *signalactivated = TRUE;
+ return;
+}
+
+void
+test_libappindicator_prop_signals_helper (AppIndicator * ci, gboolean * signalactivated)
+{
+ *signalactivated = TRUE;
+ return;
+}
+
+void
+test_libappindicator_prop_signals (void)
+{
+ AppIndicator * ci = APP_INDICATOR(g_object_new(APP_INDICATOR_TYPE, NULL));
+ g_assert(ci != NULL);
+
+ gboolean signaled = FALSE;
+ gulong handlerid;
+
+ handlerid = 0;
+ handlerid = g_signal_connect(G_OBJECT(ci), "new-icon", G_CALLBACK(test_libappindicator_prop_signals_helper), &signaled);
+ g_assert(handlerid != 0);
+
+ handlerid = 0;
+ handlerid = g_signal_connect(G_OBJECT(ci), "new-attention-icon", G_CALLBACK(test_libappindicator_prop_signals_helper), &signaled);
+ g_assert(handlerid != 0);
+
+ handlerid = 0;
+ handlerid = g_signal_connect(G_OBJECT(ci), "new-status", G_CALLBACK(test_libappindicator_prop_signals_status_helper), &signaled);
+ g_assert(handlerid != 0);
+
+
+ signaled = FALSE;
+ app_indicator_set_icon(ci, "bob");
+ g_assert(signaled);
+
+ signaled = FALSE;
+ app_indicator_set_icon(ci, "bob");
+ g_assert(!signaled);
+
+ signaled = FALSE;
+ app_indicator_set_icon(ci, "al");
+ g_assert(signaled);
+
+
+ signaled = FALSE;
+ app_indicator_set_attention_icon(ci, "bob");
+ g_assert(signaled);
+
+ signaled = FALSE;
+ app_indicator_set_attention_icon(ci, "bob");
+ g_assert(!signaled);
+
+ signaled = FALSE;
+ app_indicator_set_attention_icon(ci, "al");
+ g_assert(signaled);
+
+
+ signaled = FALSE;
+ app_indicator_set_status(ci, APP_INDICATOR_STATUS_PASSIVE);
+ g_assert(!signaled);
+
+ signaled = FALSE;
+ app_indicator_set_status(ci, APP_INDICATOR_STATUS_ACTIVE);
+ g_assert(signaled);
+
+ signaled = FALSE;
+ app_indicator_set_status(ci, APP_INDICATOR_STATUS_ACTIVE);
+ g_assert(!signaled);
+
+ signaled = FALSE;
+ app_indicator_set_status(ci, APP_INDICATOR_STATUS_ATTENTION);
+ g_assert(signaled);
+
+ return;
+}
+
+void
+test_libappindicator_init_set_props (void)
+{
+ AppIndicator * ci = APP_INDICATOR(g_object_new(APP_INDICATOR_TYPE, NULL));
+ g_assert(ci != NULL);
+
+ app_indicator_set_id(ci, "my-id");
+ app_indicator_set_category(ci, APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
+ app_indicator_set_status(ci, APP_INDICATOR_STATUS_ACTIVE);
+ app_indicator_set_icon(ci, "my-name");
+ app_indicator_set_attention_icon(ci, "my-attention-name");
+
+ g_assert(!g_strcmp0("my-id", app_indicator_get_id(ci)));
+ g_assert(!g_strcmp0("my-name", app_indicator_get_icon(ci)));
+ g_assert(!g_strcmp0("my-attention-name", app_indicator_get_attention_icon(ci)));
+ g_assert(app_indicator_get_status(ci) == APP_INDICATOR_STATUS_ACTIVE);
+ g_assert(app_indicator_get_category(ci) == APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
+
+ g_object_unref(G_OBJECT(ci));
+ return;
+}
+
+void
+test_libappindicator_init_with_props (void)
+{
+ AppIndicator * ci = APP_INDICATOR(g_object_new(APP_INDICATOR_TYPE,
+ "id", "my-id",
+ "category-enum", APP_INDICATOR_CATEGORY_APPLICATION_STATUS,
+ "status-enum", APP_INDICATOR_STATUS_ACTIVE,
+ "icon-name", "my-name",
+ "attention-icon-name", "my-attention-name",
+ NULL));
+ g_assert(ci != NULL);
+
+ g_assert(!g_strcmp0("my-id", app_indicator_get_id(ci)));
+ g_assert(!g_strcmp0("my-name", app_indicator_get_icon(ci)));
+ g_assert(!g_strcmp0("my-attention-name", app_indicator_get_attention_icon(ci)));
+ g_assert(app_indicator_get_status(ci) == APP_INDICATOR_STATUS_ACTIVE);
+ g_assert(app_indicator_get_category(ci) == APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
+
+ g_object_unref(G_OBJECT(ci));
+ return;
+}
+
+void
+test_libappindicator_init (void)
+{
+ AppIndicator * ci = APP_INDICATOR(g_object_new(APP_INDICATOR_TYPE, NULL));
+ g_assert(ci != NULL);
+ g_object_unref(G_OBJECT(ci));
+ return;
+}
+
+void
+test_libappindicator_props_suite (void)
+{
+ g_test_add_func ("/indicator-application/libappindicator/init", test_libappindicator_init);
+ g_test_add_func ("/indicator-application/libappindicator/init_props", test_libappindicator_init_with_props);
+ g_test_add_func ("/indicator-application/libappindicator/init_set_props", test_libappindicator_init_set_props);
+ g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals);
+
+ return;
+}
+
+gint
+main (gint argc, gchar * argv[])
+{
+ g_type_init();
+ g_test_init(&argc, &argv, NULL);
+
+ /* Test suites */
+ test_libappindicator_props_suite();
+
+
+ return g_test_run ();
+}