diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dbus-types/org.freedesktop.Accounts.xml | 5 | ||||
-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 | ||||
-rw-r--r-- | tests/service-mocks/accounts-mock/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml | 2 |
6 files changed, 31 insertions, 8 deletions
diff --git a/tests/dbus-types/org.freedesktop.Accounts.xml b/tests/dbus-types/org.freedesktop.Accounts.xml index d9c6b2a..f284d54 100644 --- a/tests/dbus-types/org.freedesktop.Accounts.xml +++ b/tests/dbus-types/org.freedesktop.Accounts.xml @@ -1,8 +1,13 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.freedesktop.Accounts"> <method name="FindUserByName"> <arg direction="in" type="s" name="user" /> <arg direction="out" type="o" name="path" /> </method> + <method name="FindUserById"> + <arg direction="in" type="x" name="uid" /> + <arg direction="out" type="o" name="path" /> + </method> </interface> </node> 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); diff --git a/tests/service-mocks/accounts-mock/CMakeLists.txt b/tests/service-mocks/accounts-mock/CMakeLists.txt index bc71a8b..ad858bd 100644 --- a/tests/service-mocks/accounts-mock/CMakeLists.txt +++ b/tests/service-mocks/accounts-mock/CMakeLists.txt @@ -20,7 +20,7 @@ qt5_add_dbus_adaptor(adaptor_files AccountsServiceSoundMockAdaptor) qt5_add_dbus_adaptor(adaptor_files - org.freedesktop.Accounts.Mock.xml + ${CMAKE_SOURCE_DIR}/tests/dbus-types/org.freedesktop.Accounts.xml AccountsMock.h ubuntu::indicators::testing::AccountsMock AccountsMockAdaptor) diff --git a/tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml b/tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml index f284d54..f977e7c 100644 --- a/tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml +++ b/tests/service-mocks/accounts-mock/org.freedesktop.Accounts.Mock.xml @@ -9,5 +9,7 @@ <arg direction="in" type="x" name="uid" /> <arg direction="out" type="o" name="path" /> </method> + <signal name="FindUserByIdInvoked"> + </signal> </interface> </node> |