166
test_libappindicator_set_label (void)
168
AppIndicator * ci = app_indicator_new ("my-id",
170
APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
172
g_assert(ci != NULL);
173
g_assert(app_indicator_get_label(ci) == NULL);
174
g_assert(app_indicator_get_label_guide(ci) == NULL);
176
/* First check all the clearing modes, this is important as
177
we're going to use them later, we need them to work. */
178
app_indicator_set_label(ci, NULL, NULL);
180
g_assert(app_indicator_get_label(ci) == NULL);
181
g_assert(app_indicator_get_label_guide(ci) == NULL);
183
app_indicator_set_label(ci, "", NULL);
185
g_assert(app_indicator_get_label(ci) == NULL);
186
g_assert(app_indicator_get_label_guide(ci) == NULL);
188
app_indicator_set_label(ci, NULL, "");
190
g_assert(app_indicator_get_label(ci) == NULL);
191
g_assert(app_indicator_get_label_guide(ci) == NULL);
193
app_indicator_set_label(ci, "", "");
195
g_assert(app_indicator_get_label(ci) == NULL);
196
g_assert(app_indicator_get_label_guide(ci) == NULL);
198
app_indicator_set_label(ci, "label", "");
200
g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0);
201
g_assert(app_indicator_get_label_guide(ci) == NULL);
203
app_indicator_set_label(ci, NULL, NULL);
205
g_assert(app_indicator_get_label(ci) == NULL);
206
g_assert(app_indicator_get_label_guide(ci) == NULL);
208
app_indicator_set_label(ci, "label", "guide");
210
g_assert(g_strcmp0(app_indicator_get_label(ci), "label") == 0);
211
g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0);
213
app_indicator_set_label(ci, "label2", "guide");
215
g_assert(g_strcmp0(app_indicator_get_label(ci), "label2") == 0);
216
g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "guide") == 0);
218
app_indicator_set_label(ci, "trick-label", "trick-guide");
220
g_assert(g_strcmp0(app_indicator_get_label(ci), "trick-label") == 0);
221
g_assert(g_strcmp0(app_indicator_get_label_guide(ci), "trick-guide") == 0);
223
g_object_unref(G_OBJECT(ci));
228
label_signals_cb (AppIndicator * appindicator, gchar * label, gchar * guide, gpointer user_data)
230
gint * label_signals_count = (gint *)user_data;
231
(*label_signals_count)++;
236
label_signals_check (void)
238
while (g_main_context_pending(NULL)) {
239
g_main_context_iteration(NULL, TRUE);
246
test_libappindicator_label_signals (void)
248
gint label_signals_count = 0;
249
AppIndicator * ci = app_indicator_new ("my-id",
251
APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
253
g_assert(ci != NULL);
254
g_assert(app_indicator_get_label(ci) == NULL);
255
g_assert(app_indicator_get_label_guide(ci) == NULL);
257
g_signal_connect(G_OBJECT(ci), APP_INDICATOR_SIGNAL_NEW_LABEL, G_CALLBACK(label_signals_cb), &label_signals_count);
259
/* Shouldn't be a signal as it should be stuck in idle */
260
app_indicator_set_label(ci, "label", "guide");
261
g_assert(label_signals_count == 0);
263
/* Should show up after idle processing */
264
label_signals_check();
265
g_assert(label_signals_count == 1);
267
/* Shouldn't signal with no change */
268
label_signals_count = 0;
269
app_indicator_set_label(ci, "label", "guide");
270
label_signals_check();
271
g_assert(label_signals_count == 0);
273
/* Change one, we should get one signal */
274
app_indicator_set_label(ci, "label2", "guide");
275
label_signals_check();
276
g_assert(label_signals_count == 1);
278
/* Change several times, one signal */
279
label_signals_count = 0;
280
app_indicator_set_label(ci, "label1", "guide0");
281
app_indicator_set_label(ci, "label1", "guide1");
282
app_indicator_set_label(ci, "label2", "guide2");
283
app_indicator_set_label(ci, "label3", "guide3");
284
label_signals_check();
285
g_assert(label_signals_count == 1);
287
/* Clear should signal too */
288
label_signals_count = 0;
289
app_indicator_set_label(ci, NULL, NULL);
290
label_signals_check();
291
g_assert(label_signals_count == 1);
166
297
test_libappindicator_props_suite (void)
168
299
g_test_add_func ("/indicator-application/libappindicator/init", test_libappindicator_init);
169
300
g_test_add_func ("/indicator-application/libappindicator/init_props", test_libappindicator_init_with_props);
170
301
g_test_add_func ("/indicator-application/libappindicator/init_set_props", test_libappindicator_init_set_props);
171
302
g_test_add_func ("/indicator-application/libappindicator/prop_signals", test_libappindicator_prop_signals);
303
g_test_add_func ("/indicator-application/libappindicator/set_label", test_libappindicator_set_label);
304
g_test_add_func ("/indicator-application/libappindicator/label_signals", test_libappindicator_label_signals);