~azzar1/unity/scale-left-padding

« back to all changes in this revision

Viewing changes to tests/test_utils.h

  • Committer: Andrea Azzarone
  • Date: 2011-12-19 22:18:53 UTC
  • mfrom: (1792 unity)
  • mto: This revision was merged to the branch mainline in revision 1833.
  • Revision ID: azzaronea@gmail.com-20111219221853-wyy8fqwxk78s85ct
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    if (model.count == n_rows)
32
32
      g_source_remove(timeout_id);
33
33
  }
 
34
 
 
35
  static void WaitUntil(bool& success, unsigned int max_wait = 10)
 
36
  {
 
37
    bool timeout_reached = false;
 
38
    guint32 timeout_id = ScheduleTimeout(&timeout_reached, max_wait);
 
39
 
 
40
    while (!success && !timeout_reached)
 
41
      g_main_context_iteration(g_main_context_get_thread_default(), TRUE);
 
42
 
 
43
    if (success)
 
44
      g_source_remove(timeout_id);
 
45
 
 
46
    EXPECT_TRUE(success);
 
47
  }
 
48
 
 
49
  static guint32 ScheduleTimeout(bool* timeout_reached, unsigned int timeout_duration = 10)
 
50
  {
 
51
    return g_timeout_add_seconds(timeout_duration, TimeoutCallback, timeout_reached);
 
52
  }
 
53
 
 
54
private:
 
55
  static gboolean TimeoutCallback(gpointer data)
 
56
  {
 
57
    *(bool*)data = true;
 
58
    return FALSE;
 
59
  };
34
60
};
35
61
 
36
62
}