diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2010-08-12 16:32:18 -0400 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2010-08-12 16:32:18 -0400 |
commit | 2840a6f037bb7e5b366090519603f6706a26b704 (patch) | |
tree | 72f1888f6b4f198ba20c1267b07cdf594a7fcd90 /tests | |
parent | 77beabaa23a8ff37b5c0060647ba3988dc27e13e (diff) | |
parent | 2368f530f2ada528bdfee8922088e7f836441d77 (diff) | |
download | libayatana-appindicator-2840a6f037bb7e5b366090519603f6706a26b704.tar.gz libayatana-appindicator-2840a6f037bb7e5b366090519603f6706a26b704.tar.bz2 libayatana-appindicator-2840a6f037bb7e5b366090519603f6706a26b704.zip |
releasing version 0.2.4-0ubuntu10.2.4-0ubuntu1
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.in | 2 | ||||
-rw-r--r-- | tests/test-libappindicator.c | 133 |
2 files changed, 135 insertions, 0 deletions
diff --git a/tests/Makefile.in b/tests/Makefile.in index dc4be9b..10be609 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -277,6 +277,8 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PYGTK_CODEGEN = @PYGTK_CODEGEN@ PYGTK_DEFSDIR = @PYGTK_DEFSDIR@ PYTHON = @PYTHON@ diff --git a/tests/test-libappindicator.c b/tests/test-libappindicator.c index 86879b3..8d12ac5 100644 --- a/tests/test-libappindicator.c +++ b/tests/test-libappindicator.c @@ -163,12 +163,145 @@ test_libappindicator_init (void) } void +test_libappindicator_set_label (void) +{ + AppIndicator * ci = app_indicator_new ("my-id", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_assert(ci != NULL); + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + /* First check all the clearing modes, this is important as + we're going to use them later, we need them to work. */ + app_indicator_set_label(ci, NULL, NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "", NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, NULL, ""); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "", ""); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "label", ""); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, NULL, NULL); + + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + app_indicator_set_label(ci, "label", "guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0); + + app_indicator_set_label(ci, "label2", "guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "label2") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0); + + app_indicator_set_label(ci, "trick-label", "trick-guide"); + + g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label") == 0); + g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide") == 0); + + g_object_unref(G_OBJECT(ci)); + return; +} + +void +label_signals_cb (AppIndicator * appindicator, gchar * label, gchar * guide, gpointer user_data) +{ + gint * label_signals_count = (gint *)user_data; + (*label_signals_count)++; + return; +} + +void +label_signals_check (void) +{ + while (g_main_context_pending(NULL)) { + g_main_context_iteration(NULL, TRUE); + } + + return; +} + +void +test_libappindicator_label_signals (void) +{ + gint label_signals_count = 0; + AppIndicator * ci = app_indicator_new ("my-id", + "my-name", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS); + + g_assert(ci != NULL); + g_assert(app_indicator_get_label(ci) == NULL); + g_assert(app_indicator_get_label_guide(ci) == NULL); + + g_signal_connect(G_OBJECT(ci), APP_INDICATOR_SIGNAL_NEW_LABEL, G_CALLBACK(label_signals_cb), &label_signals_count); + + /* Shouldn't be a signal as it should be stuck in idle */ + app_indicator_set_label(ci, "label", "guide"); + g_assert(label_signals_count == 0); + + /* Should show up after idle processing */ + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Shouldn't signal with no change */ + label_signals_count = 0; + app_indicator_set_label(ci, "label", "guide"); + label_signals_check(); + g_assert(label_signals_count == 0); + + /* Change one, we should get one signal */ + app_indicator_set_label(ci, "label2", "guide"); + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Change several times, one signal */ + label_signals_count = 0; + app_indicator_set_label(ci, "label1", "guide0"); + app_indicator_set_label(ci, "label1", "guide1"); + app_indicator_set_label(ci, "label2", "guide2"); + app_indicator_set_label(ci, "label3", "guide3"); + label_signals_check(); + g_assert(label_signals_count == 1); + + /* Clear should signal too */ + label_signals_count = 0; + app_indicator_set_label(ci, NULL, NULL); + label_signals_check(); + g_assert(label_signals_count == 1); + + 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); + g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label); + g_test_add_func ("/indicator-application/libappindicator/label_signals", test_libappindicator_label_signals); return; } |