~ted/ubuntu-app-launch/reformat-all-the-things-doit

« back to all changes in this revision

Viewing changes to tests/eventually-fixture.h

  • Committer: Ted Gould
  • Date: 2017-02-03 15:37:09 UTC
  • mfrom: (280.1.5 ubuntu-app-launch)
  • Revision ID: ted@gould.cx-20170203153709-fq3hovzzt6xv5cyz
MergeĀ futureĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
{
28
28
protected:
29
29
    std::chrono::milliseconds _eventuallyTime = std::chrono::minutes{1};
 
30
    std::once_flag checkEventuallyEnv_;
30
31
 
31
32
    static gboolean timeout_cb(gpointer user_data)
32
33
    {
45
46
 
46
47
    testing::AssertionResult eventuallyLoop(std::function<testing::AssertionResult(void)> &testfunc)
47
48
    {
 
49
        std::call_once(checkEventuallyEnv_, [this]() {
 
50
            auto eventuallyenv = getenv("EVENTUALLY_TIMEOUT");
 
51
            if (eventuallyenv != nullptr)
 
52
            {
 
53
                _eventuallyTime = std::chrono::seconds{std::atoi(eventuallyenv)};
 
54
            }
 
55
        });
 
56
 
48
57
        auto loop = std::shared_ptr<GMainLoop>(g_main_loop_new(nullptr, FALSE),
49
58
                                               [](GMainLoop *loop) { g_clear_pointer(&loop, g_main_loop_unref); });
50
59