~ps-jenkins/bamf/latestsnapshot-0.4.0daily13.05.3113.04-0ubuntu1

« back to all changes in this revision

Viewing changes to tests/bamfdaemon/test-view.c

  • Committer: Tarmac
  • Author(s): Marco Trevisan (Treviño)
  • Date: 2013-02-06 01:20:53 UTC
  • mfrom: (507.1.41 bamf)
  • Revision ID: tarmac-20130206012053-kkllr2nqlbwcdiz1
BamfView: use an idle to emit the active-changed signal to avoid to send the same event to a view. Fixes: https://bugs.launchpad.net/bugs/1115827.

Approved by Brandon Schaefer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
static void test_active              (void);
26
26
static void test_active_event        (void);
 
27
static void test_active_event_count  (void);
27
28
static void test_allocation          (void);
28
29
static void test_child_added_event   (void);
29
30
static void test_child_removed_event (void);
54
55
  g_test_add_func (DOMAIN"/Path/Collision", test_path_collision);
55
56
  g_test_add_func (DOMAIN"/Events/Close", test_closed_event);
56
57
  g_test_add_func (DOMAIN"/Events/Active", test_active_event);
 
58
  g_test_add_func (DOMAIN"/Events/Active/Count", test_active_event_count);
57
59
  g_test_add_func (DOMAIN"/Events/Running", test_running_event);
58
60
  g_test_add_func (DOMAIN"/Events/ChildAdded", test_child_added_event);
59
61
  g_test_add_func (DOMAIN"/Events/ChildRemoved", test_child_removed_event);
317
319
  active_event_fired = FALSE;
318
320
  bamf_view_set_active (view, TRUE);
319
321
  g_assert (bamf_view_is_active (view));
 
322
  g_assert (!active_event_fired);
320
323
 
 
324
  while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE);
321
325
  g_assert (active_event_fired);
322
326
  g_assert (active_event_result);
323
327
 
324
328
  active_event_fired = FALSE;
325
329
  bamf_view_set_active (view, FALSE);
326
330
  g_assert (!bamf_view_is_active (view));
 
331
  g_assert (!active_event_fired);
327
332
 
 
333
  while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE);
328
334
  g_assert (active_event_fired);
329
335
  g_assert (!active_event_result);
330
336
 
332
338
  g_assert (!BAMF_IS_VIEW (view));
333
339
}
334
340
 
 
341
guint active_event_calls;
 
342
 
 
343
static void
 
344
on_active_event_count (BamfView *view, gboolean active, gpointer pointer)
 
345
{
 
346
  active_event_calls++;;
 
347
  active_event_result = active;
 
348
}
 
349
 
 
350
static void
 
351
test_active_event_count (void)
 
352
{
 
353
  BamfView *view;
 
354
 
 
355
  view = g_object_new (BAMF_TYPE_VIEW, NULL);
 
356
  g_assert (!bamf_view_is_active (view));
 
357
 
 
358
  g_signal_connect (G_OBJECT (view), "active-changed",
 
359
        (GCallback) on_active_event_count, NULL);
 
360
 
 
361
  active_event_calls = 0;
 
362
  bamf_view_set_active (view, TRUE);
 
363
  g_assert (bamf_view_is_active (view));
 
364
  g_assert_cmpuint (active_event_calls, ==, 0);
 
365
 
 
366
  while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE);
 
367
  g_assert_cmpuint (active_event_calls, ==, 1);
 
368
  g_assert (active_event_result);
 
369
 
 
370
  active_event_calls = 0;
 
371
  bamf_view_set_active (view, FALSE);
 
372
  bamf_view_set_active (view, TRUE);
 
373
  bamf_view_set_active (view, FALSE);
 
374
 
 
375
  while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE);
 
376
  g_assert_cmpuint (active_event_calls, ==, 1);
 
377
  g_assert (!active_event_result);
 
378
}
 
379
 
335
380
static gboolean running_event_fired;
336
381
static gboolean running_event_result;
337
382