diff options
author | Xavi Garcia Mena <xavi.garcia.mena@canonical.com> | 2015-10-01 15:15:16 +0200 |
---|---|---|
committer | Xavi Garcia Mena <xavi.garcia.mena@canonical.com> | 2015-10-01 15:15:16 +0200 |
commit | 2dba91ca24ce98f866498333c7a39e20d68813f7 (patch) | |
tree | a7ccbc1f9eaf06d9cb50d766d7476fe70ffef38f /tests/integration | |
parent | 5d88ce9836c1d32abfd369e650354ed855ec4654 (diff) | |
download | ayatana-indicator-sound-2dba91ca24ce98f866498333c7a39e20d68813f7.tar.gz ayatana-indicator-sound-2dba91ca24ce98f866498333c7a39e20d68813f7.tar.bz2 ayatana-indicator-sound-2dba91ca24ce98f866498333c7a39e20d68813f7.zip |
added mechanism to wait for the gmenu to change. Added player test for the phone profile
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/indicator-sound-test-base.cpp | 38 | ||||
-rw-r--r-- | tests/integration/indicator-sound-test-base.h | 4 | ||||
-rw-r--r-- | tests/integration/test-indicator.cpp | 47 |
3 files changed, 75 insertions, 14 deletions
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp index 16f0bd6..a8d41a0 100644 --- a/tests/integration/indicator-sound-test-base.cpp +++ b/tests/integration/indicator-sound-test-base.cpp @@ -140,7 +140,6 @@ bool IndicatorSoundTestBase::startTestSound(QString const &role) if (!testSoundProcess.waitForStarted()) return false; -// sleep(1); return true; } @@ -218,7 +217,7 @@ void IndicatorSoundTestBase::startAccountsService() new QProcessDBusService(DBusTypes::ACCOUNTS_SERVICE, QDBusConnection::SystemBus, ACCOUNTS_SERVICE_BIN, - QStringList() )); + QStringList())); accountsService->start(dbusTestRunner.systemConnection()); initializeAccountsInterface(); @@ -275,6 +274,7 @@ void IndicatorSoundTestBase::TearDown() { unsetenv("XDG_DATA_DIRS"); unsetenv("PULSE_SERVER"); + unsetenv("DBUS_SYSTEM_BUS_ADDRESS"); } void gvariant_deleter(GVariant* varptr) @@ -338,20 +338,31 @@ unity::gmenuharness::MenuItemMatcher IndicatorSoundTestBase::silentModeSwitch(bo bool IndicatorSoundTestBase::waitMenuChange() { + if (signal_spy_menu_changed_) + { + return signal_spy_menu_changed_->wait(); + } + return false; +} + +bool IndicatorSoundTestBase::initializeMenuChangedSignal() +{ if (!menu_interface_) { menu_interface_.reset(new MenusInterface("com.canonical.indicator.sound", - "/com/canonical/indicator/sound/desktop", - QDBusConnection::sessionBus(), 0)); + "/com/canonical/indicator/sound", + dbusTestRunner.sessionConnection(), 0)); } if (menu_interface_) { qDebug() << "Waiting for signal"; - QSignalSpy spy(menu_interface_.get(), &MenusInterface::Changed); - qDebug() << "Signal count " << spy.count(); - return spy.wait(); + signal_spy_menu_changed_.reset(new QSignalSpy(menu_interface_.get(), &MenusInterface::Changed)); } - return false; + if (!menu_interface_ || !signal_spy_menu_changed_) + { + return false; + } + return true; } bool IndicatorSoundTestBase::waitVolumeChangedInIndicator() @@ -368,27 +379,28 @@ void IndicatorSoundTestBase::initializeAccountsInterface() auto username = qgetenv("USER"); if (username != "") { - std::unique_ptr<AccountsInterface> setInterface(new AccountsInterface("org.freedesktop.Accounts", + std::unique_ptr<AccountsInterface> accountsInterface(new AccountsInterface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", - QDBusConnection::systemBus(), 0)); + dbusTestRunner.systemConnection(), 0)); - QDBusReply<QDBusObjectPath> userResp = setInterface->call(QLatin1String("FindUserByName"), + QDBusReply<QDBusObjectPath> userResp = accountsInterface->call(QLatin1String("FindUserByName"), QLatin1String(username)); if (!userResp.isValid()) { qWarning() << "SetVolume::initializeAccountsInterface(): D-Bus error: " << userResp.error().message(); } + auto userPath = userResp.value().path(); if (userPath != "") { std::unique_ptr<AccountsSoundInterface> soundInterface(new AccountsSoundInterface("org.freedesktop.Accounts", userPath, - QDBusConnection::systemBus(), 0)); + dbusTestRunner.systemConnection(), 0)); accounts_interface_.reset(new DBusPropertiesInterface("org.freedesktop.Accounts", userPath, - soundInterface->connection(), 0)); + dbusTestRunner.systemConnection(), 0)); if (!accounts_interface_->isValid()) { qWarning() << "SetVolume::initializeAccountsInterface(): D-Bus error: " << accounts_interface_->lastError().message(); diff --git a/tests/integration/indicator-sound-test-base.h b/tests/integration/indicator-sound-test-base.h index 00ccf1a..0dc0052 100644 --- a/tests/integration/indicator-sound-test-base.h +++ b/tests/integration/indicator-sound-test-base.h @@ -75,6 +75,8 @@ protected: bool waitMenuChange(); + bool initializeMenuChangedSignal(); + bool waitVolumeChangedInIndicator(); void initializeAccountsInterface(); @@ -98,4 +100,6 @@ protected: std::unique_ptr<DBusPropertiesInterface> 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 82f06a4..22c0041 100644 --- a/tests/integration/test-indicator.cpp +++ b/tests/integration/test-indicator.cpp @@ -206,6 +206,51 @@ TEST_F(TestIndicator, PhoneAddMprisPlayer) .action("indicator.phone-settings") ) ).match()); + + // initialize the signal spy + EXPECT_TRUE(initializeMenuChangedSignal()); + + // start the test player + EXPECT_TRUE(startTestMprisPlayer("testplayer1")); + + // wait fot the menu change + EXPECT_TRUE(waitMenuChange()); + + // finally verify that the player is added + EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters()) + .item(mh::MenuItemMatcher() + .action("indicator.root") + .string_attribute("x-canonical-type", "com.canonical.indicator.root") + .string_attribute("x-canonical-scroll-action", "indicator.scroll") + .string_attribute("x-canonical-secondary-action", "indicator.mute") + .string_attribute("submenu-action", "indicator.indicator-shown") + .mode(mh::MenuItemMatcher::Mode::all) + .submenu() + .item(mh::MenuItemMatcher() + .section() + .item(silentModeSwitch(false)) + .item(volumeSlider(INITIAL_VOLUME)) + ) + .item(mh::MenuItemMatcher() + .section() + .item(mh::MenuItemMatcher() + .action("indicator.testplayer1.desktop") + .label("TestPlayer1") + .themed_icon("icon", {"testplayer"}) + .string_attribute("x-canonical-type", "com.canonical.unity.media-player") + ) + .item(mh::MenuItemMatcher() + .string_attribute("x-canonical-previous-action","indicator.previous.testplayer1.desktop") + .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop") + .string_attribute("x-canonical-next-action","indicator.next.testplayer1.desktop") + .string_attribute("x-canonical-type","com.canonical.unity.playback-item") + ) + ) + .item(mh::MenuItemMatcher() + .label("Sound Settingsā¦") + .action("indicator.phone-settings") + ) + ).match()); } TEST_F(TestIndicator, DesktopBasicInitialVolume) @@ -516,7 +561,7 @@ TEST_F(TestIndicator, DesktopChangeRoleVolume) EXPECT_TRUE(setSinkVolume(randomVolume)); if (randomVolume != INITIAL_VOLUME) { - EXPECT_FALSE(waitVolumeChangedInIndicator()); + EXPECT_TRUE(waitVolumeChangedInIndicator()); } // check the indicator |