diff options
author | Xavi Garcia Mena <xavi.garcia.mena@canonical.com> | 2015-10-26 12:01:16 +0100 |
---|---|---|
committer | Xavi Garcia Mena <xavi.garcia.mena@canonical.com> | 2015-10-26 12:01:16 +0100 |
commit | 698baf72cd6a606d9c8101c31e0d40b38d48a8bb (patch) | |
tree | 93c3ffbc9bb122892981cd79e7ee875cb2a2e883 /tests/integration | |
parent | dc719904611197a1f01fc4034f4678ffae556491 (diff) | |
download | ayatana-indicator-sound-698baf72cd6a606d9c8101c31e0d40b38d48a8bb.tar.gz ayatana-indicator-sound-698baf72cd6a606d9c8101c31e0d40b38d48a8bb.tar.bz2 ayatana-indicator-sound-698baf72cd6a606d9c8101c31e0d40b38d48a8bb.zip |
Changed unit test to wait for the indicator to connect the user accounts
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/indicator-sound-test-base.cpp | 17 | ||||
-rw-r--r-- | tests/integration/indicator-sound-test-base.h | 5 | ||||
-rw-r--r-- | tests/integration/test-indicator.cpp | 8 |
3 files changed, 23 insertions, 7 deletions
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp index 2bd71b6..dd5d4b5 100644 --- a/tests/integration/indicator-sound-test-base.cpp +++ b/tests/integration/indicator-sound-test-base.cpp @@ -407,11 +407,11 @@ void IndicatorSoundTestBase::initializeAccountsInterface() auto username = qgetenv("USER"); if (username != "") { - std::unique_ptr<AccountsInterface> accountsInterface(new AccountsInterface("org.freedesktop.Accounts", + main_accounts_interface_.reset(new AccountsInterface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", dbusTestRunner.systemConnection(), 0)); - QDBusReply<QDBusObjectPath> userResp = accountsInterface->call(QLatin1String("FindUserByName"), + QDBusReply<QDBusObjectPath> userResp = main_accounts_interface_->call(QLatin1String("FindUserByName"), QLatin1String(username)); if (!userResp.isValid()) @@ -805,3 +805,16 @@ void IndicatorSoundTestBase::checkPortDevicesLabels(DevicePortType speakerPort, ) ).match()); } + +bool IndicatorSoundTestBase::setVolumeUntilAccountsIsConnected(double volume) +{ + int RETRY_TIME = 5000; + + setActionValue("volume", QVariant::fromValue(volume)); + while(!signal_spy_volume_changed_->wait(10) && RETRY_TIME) + { + RETRY_TIME -= 10; + setActionValue("volume", QVariant::fromValue(volume)); + } + return (signal_spy_volume_changed_->count() != 0); +} diff --git a/tests/integration/indicator-sound-test-base.h b/tests/integration/indicator-sound-test-base.h index f9df9bb..41dd1c7 100644 --- a/tests/integration/indicator-sound-test-base.h +++ b/tests/integration/indicator-sound-test-base.h @@ -31,6 +31,7 @@ class MenusInterface; class DBusPulseVolume; class DBusPropertiesInterface; +class AccountsInterface; class QSignalSpy; #define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\ @@ -131,6 +132,8 @@ protected: void checkPortDevicesLabels(DevicePortType speakerPort, DevicePortType headphonesPort); + bool setVolumeUntilAccountsIsConnected(double volume); + QtDBusTest::DBusTestRunner dbusTestRunner; QtDBusMock::DBusMock dbusMock; @@ -149,6 +152,8 @@ protected: std::unique_ptr<DBusPropertiesInterface> accounts_interface_; + std::unique_ptr<AccountsInterface> main_accounts_interface_; + std::unique_ptr<QSignalSpy> signal_spy_volume_changed_; std::unique_ptr<QSignalSpy> signal_spy_menu_changed_; diff --git a/tests/integration/test-indicator.cpp b/tests/integration/test-indicator.cpp index e79c9d4..d55222b 100644 --- a/tests/integration/test-indicator.cpp +++ b/tests/integration/test-indicator.cpp @@ -32,7 +32,7 @@ class TestIndicator: public IndicatorSoundTestBase { }; -TEST_F(TestIndicator, DISABLED_PhoneChangeRoleVolume) +TEST_F(TestIndicator, PhoneChangeRoleVolume) { double INITIAL_VOLUME = 0.0; @@ -55,9 +55,7 @@ TEST_F(TestIndicator, DISABLED_PhoneChangeRoleVolume) QSignalSpy &userAccountsSpy = *signal_spy_volume_changed_; // set an initial volume to the alert role userAccountsSpy.clear(); - setStreamRestoreVolume("alert", 1.0); - WAIT_AT_LEAST_SIGNALS(userAccountsSpy, 1); - + EXPECT_TRUE(setVolumeUntilAccountsIsConnected(1.0)); userAccountsSpy.clear(); // play a test sound, it should change the role in the indicator EXPECT_TRUE(startTestSound("multimedia")); @@ -69,7 +67,7 @@ TEST_F(TestIndicator, DISABLED_PhoneChangeRoleVolume) userAccountsSpy.clear(); // set the random volume to the multimedia role - EXPECT_TRUE(setStreamRestoreVolume("multimedia", randomVolume)); + setActionValue("volume", QVariant::fromValue(randomVolume)); if (randomVolume != INITIAL_VOLUME) { WAIT_FOR_SIGNALS(userAccountsSpy, 1); |