From 01a3509e25233d109365704bb6767dda753312d1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 13 Oct 2015 22:32:20 -0500 Subject: in test-snap, wait a moment after creating the Snap to allow its async dbus internals to finish bootstrapping --- tests/test-snap.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/test-snap.cpp b/tests/test-snap.cpp index 5041645..e606cc7 100644 --- a/tests/test-snap.cpp +++ b/tests/test-snap.cpp @@ -34,6 +34,8 @@ using namespace ayatana::indicator::datetime; +namespace uin = ayatana::indicator::notifications; + #include "glib-fixture.h" /*** @@ -371,6 +373,15 @@ protected: &error); g_assert_no_error (error); } + + std::shared_ptr create_snap(const std::shared_ptr& ne, + const std::shared_ptr& sb, + const std::shared_ptr& settings) + { + auto snap = std::make_shared(ne, sb, settings); + wait_msec(100); // wait a moment for the Snap to finish its async dbus bootstrapping + return snap; + } }; /*** @@ -392,13 +403,14 @@ TEST_F(SnapFixture, InteractiveDuration) auto settings = std::make_shared(); settings->alarm_duration.set(duration_minutes); auto ne = std::make_shared(APP_NAME); - Snap snap (ne, settings); + auto sb = std::make_shared(); + auto snap = create_snap(ne, sb, settings); make_interactive(); // call the Snap Decision auto func = [this](const Appointment&, const Alarm&){g_idle_add(quit_idle, loop);}; - snap(appt, appt.alarms.front(), func, func); + (*snap)(appt, appt.alarms.front(), func, func); // confirm that Notify got called once guint len = 0; @@ -442,7 +454,8 @@ TEST_F(SnapFixture, InhibitSleep) { auto settings = std::make_shared(); auto ne = std::make_shared(APP_NAME); - auto snap = new Snap (ne, settings); + auto sb = std::make_shared(); + auto snap = create_snap(ne, sb, settings); make_interactive(); @@ -469,7 +482,7 @@ TEST_F(SnapFixture, InhibitSleep) // force-close the snap wait_msec(100); - delete snap; + snap.reset(); wait_msec(100); // confirm that sleep got uninhibted @@ -497,7 +510,8 @@ TEST_F(SnapFixture, ForceScreen) { auto settings = std::make_shared(); auto ne = std::make_shared(APP_NAME); - auto snap = new Snap (ne, settings); + auto sb = std::make_shared(); + auto snap = create_snap(ne, sb, settings); make_interactive(); @@ -518,7 +532,7 @@ TEST_F(SnapFixture, ForceScreen) // force-close the snap wait_msec(100); - delete snap; + snap.reset(); wait_msec(100); // confirm that sleep got uninhibted @@ -552,7 +566,7 @@ TEST_F(SnapFixture,DISABLED_Vibrate) { true, "pulse", true } }; - auto snap = std::make_shared(ne, settings); + auto snap = create_snap(ne, sb, settings); for(const auto& test_case : test_cases) { -- cgit v1.2.3