From cc77ef3dd05a0e52a74b1ac073b95bd041a2f0d1 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Fri, 16 Oct 2015 16:49:28 +0200 Subject: Fixed race condition connection to the Notifications interface --- tests/integration/indicator-sound-test-base.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/integration/indicator-sound-test-base.cpp') diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp index c261fcf..3c6e52a 100644 --- a/tests/integration/indicator-sound-test-base.cpp +++ b/tests/integration/indicator-sound-test-base.cpp @@ -26,6 +26,8 @@ #include "dbus-types.h" #include +#include +#include #include #include "utils/dbus-pulse-volume.h" @@ -36,6 +38,11 @@ using namespace std; using namespace testing; namespace mh = unity::gmenuharness; +namespace +{ + const int MAX_TIME_WAITING_FOR_NOTIFICATIONS = 2000; +} + IndicatorSoundTestBase::IndicatorSoundTestBase() : dbusMock(dbusTestRunner) { @@ -61,6 +68,13 @@ void IndicatorSoundTestBase::SetUp() "as", "ret = ['actions', 'body', 'body-markup', 'icon-static', 'image/svg+xml', 'x-canonical-private-synchronous', 'x-canonical-append', 'x-canonical-private-icon-only', 'x-canonical-truncation', 'private-synchronous', 'append', 'private-icon-only', 'truncation']" ).waitForFinished(); + + int waitedTime = 0; + while (!dbusTestRunner.sessionConnection().interface()->isServiceRegistered("org.freedesktop.Notifications") && waitedTime < MAX_TIME_WAITING_FOR_NOTIFICATIONS) + { + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + waitedTime += 10; + } } void IndicatorSoundTestBase::TearDown() -- cgit v1.2.3