aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-10-16 16:49:28 +0200
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-10-16 16:49:28 +0200
commitcc77ef3dd05a0e52a74b1ac073b95bd041a2f0d1 (patch)
tree4ba60cd4ef84b3b5b890dd94e5575a09b4254dd8
parent6d4dec654f47a3628d7d79f8fae494950518d236 (diff)
downloadayatana-indicator-sound-cc77ef3dd05a0e52a74b1ac073b95bd041a2f0d1.tar.gz
ayatana-indicator-sound-cc77ef3dd05a0e52a74b1ac073b95bd041a2f0d1.tar.bz2
ayatana-indicator-sound-cc77ef3dd05a0e52a74b1ac073b95bd041a2f0d1.zip
Fixed race condition connection to the Notifications interface
-rw-r--r--src/service.vala2
-rw-r--r--tests/integration/indicator-sound-test-base.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/service.vala b/src/service.vala
index 8b08dc0..65d5943 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -43,7 +43,7 @@ public class IndicatorSound.Service: Object {
warn_notification.closed.connect((n) => { n.clear_actions(); });
BusWatcher.watch_namespace (GLib.BusType.SESSION,
"org.freedesktop.Notifications",
- () => { debug("Notifications name appeared"); notify_server_caps_checked = false; },
+ () => { debug("Notifications name appeared"); },
() => { debug("Notifications name vanshed"); notify_server_caps_checked = false; });
this.settings = new Settings ("com.canonical.indicator.sound");
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 <gio/gio.h>
+#include <chrono>
+#include <thread>
#include <QSignalSpy>
#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()