aboutsummaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/indicator-sound-test-base.cpp32
-rw-r--r--tests/integration/indicator-sound-test-base.h4
-rw-r--r--tests/integration/test-indicator.cpp65
3 files changed, 93 insertions, 8 deletions
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp
index f61857e..cf60868 100644
--- a/tests/integration/indicator-sound-test-base.cpp
+++ b/tests/integration/indicator-sound-test-base.cpp
@@ -448,13 +448,37 @@ bool IndicatorSoundTestBase::initializeMenuChangedSignal()
return true;
}
-bool IndicatorSoundTestBase::waitVolumeChangedInIndicator()
+QVariant IndicatorSoundTestBase::waitPropertyChanged(QSignalSpy *signalSpy, QString property)
{
- if (signal_spy_volume_changed_)
+ QVariant ret_val;
+ if (signalSpy)
{
- return signal_spy_volume_changed_->wait();
+ signalSpy->wait();
+ if (signalSpy->count())
+ {
+ QList<QVariant> arguments = signalSpy->takeLast();
+ if (arguments.size() == 3 && static_cast<QMetaType::Type>(arguments.at(1).type()) == QMetaType::QVariantMap)
+ {
+ QMap<QString, QVariant> map = arguments.at(1).toMap();
+ QMap<QString, QVariant>::iterator iter = map.find(property);
+ if (iter != map.end())
+ {
+ return iter.value();
+ }
+ }
+ }
}
- return false;
+ return ret_val;
+}
+bool IndicatorSoundTestBase::waitVolumeChangedInIndicator()
+{
+ QVariant val = waitPropertyChanged(signal_spy_volume_changed_.get(), "Volume");
+ return !val.isNull();
+}
+
+QVariant IndicatorSoundTestBase::waitLastRunningPlayerChanged()
+{
+ return waitPropertyChanged(signal_spy_volume_changed_.get(), "LastRunningPlayer");
}
void IndicatorSoundTestBase::initializeAccountsInterface()
diff --git a/tests/integration/indicator-sound-test-base.h b/tests/integration/indicator-sound-test-base.h
index 969fd69..5c36031 100644
--- a/tests/integration/indicator-sound-test-base.h
+++ b/tests/integration/indicator-sound-test-base.h
@@ -144,6 +144,10 @@ protected:
float getVolumeValue(bool *isValid = nullptr);
+ static QVariant waitPropertyChanged(QSignalSpy * signalSpy, QString property);
+
+ QVariant waitLastRunningPlayerChanged();
+
QtDBusTest::DBusTestRunner dbusTestRunner;
QtDBusMock::DBusMock dbusMock;
diff --git a/tests/integration/test-indicator.cpp b/tests/integration/test-indicator.cpp
index 33a27af..bc426aa 100644
--- a/tests/integration/test-indicator.cpp
+++ b/tests/integration/test-indicator.cpp
@@ -394,9 +394,7 @@ TEST_F(TestIndicator, DesktopAddMprisPlayer)
.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")
)
)
@@ -925,9 +923,7 @@ TEST_F(TestIndicator, DesktopMprisPlayersPlaybackControls)
.string_attribute("x-canonical-type", "com.canonical.unity.media-player")
)
.item(mh::MenuItemMatcher()
- .string_attribute("x-canonical-previous-action","indicator.previous.testplayer3.desktop")
.string_attribute("x-canonical-play-action","indicator.play.testplayer3.desktop")
- .string_attribute("x-canonical-next-action","indicator.next.testplayer3.desktop")
.string_attribute("x-canonical-type","com.canonical.unity.playback-item")
)
)
@@ -935,6 +931,67 @@ TEST_F(TestIndicator, DesktopMprisPlayersPlaybackControls)
.label("Sound Settingsā€¦")
)
).match());
+
+ // check that the last running player is the one we expect
+ QVariant lastPlayerRunning = waitLastRunningPlayerChanged();
+ EXPECT_TRUE(lastPlayerRunning.type() == QVariant::String);
+ EXPECT_EQ(lastPlayerRunning.toString(), "testplayer3.desktop");
+
+ // restart the indicator to simulate a new user session
+ ASSERT_NO_THROW(startIndicator());
+
+ // check that player 3 is the only one with playback controls
+ // as it was the last one being stopped
+ EXPECT_MATCHRESULT(mh::MenuMatcher(desktopParameters())
+ .item(mh::MenuItemMatcher()
+ .action("indicator.root")
+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
+ .mode(mh::MenuItemMatcher::Mode::all)
+ .submenu()
+ .item(mh::MenuItemMatcher()
+ .section()
+ .item(mh::MenuItemMatcher().checkbox()
+ .label("Mute")
+ )
+ .item(volumeSlider(INITIAL_VOLUME, "Volume"))
+ )
+ .item(mh::MenuItemMatcher()
+ .section()
+ .item(mh::MenuItemMatcher()
+ .action("indicator.testplayer3.desktop")
+ .label("TestPlayer3")
+ .themed_icon("icon", {"testplayer"})
+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
+ )
+ .item(mh::MenuItemMatcher()
+ .string_attribute("x-canonical-play-action","indicator.play.testplayer3.desktop")
+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
+ )
+ )
+ .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()
+ .section()
+ .item(mh::MenuItemMatcher()
+ .action("indicator.testplayer2.desktop")
+ .label("TestPlayer2")
+ .themed_icon("icon", {"testplayer"})
+ .string_attribute("x-canonical-type", "com.canonical.unity.media-player")
+ )
+ )
+ .item(mh::MenuItemMatcher()
+ .label("Sound Settingsā€¦")
+ )
+ ).match());
+
}
TEST_F(TestIndicator, DesktopMprisPlayerButtonsState)