aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-02-23 10:07:50 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-02-23 10:07:50 +0100
commit957c495207b8c53ffa9d3622c24fdff4f31cebfa (patch)
treebdac05be2556ffc26c7a4fa8e1c86fa47b80a59f
parentba4e4b3973a00902ff0f3d9eb4650f5f61e76c78 (diff)
downloadayatana-indicator-sound-957c495207b8c53ffa9d3622c24fdff4f31cebfa.tar.gz
ayatana-indicator-sound-957c495207b8c53ffa9d3622c24fdff4f31cebfa.tar.bz2
ayatana-indicator-sound-957c495207b8c53ffa9d3622c24fdff4f31cebfa.zip
added integration test to check last running player
-rw-r--r--src/service.vala1
-rw-r--r--tests/integration/indicator-sound-test-base.cpp15
-rw-r--r--tests/integration/test-indicator.cpp63
-rw-r--r--tests/service-mocks/accounts-mock/AccountsServiceSoundMock.cpp15
-rw-r--r--tests/service-mocks/accounts-mock/AccountsServiceSoundMock.h4
-rw-r--r--tests/service-mocks/accounts-mock/com.ubuntu.AccountsService.Sound.Mock.xml1
6 files changed, 87 insertions, 12 deletions
diff --git a/src/service.vala b/src/service.vala
index d55a3c8..d72f16e 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -91,7 +91,6 @@ public class IndicatorSound.Service: Object {
this.actions.add_action (this.create_high_volume_action ());
this.actions.add_action (this.create_volume_sync_action ());
- // OLD string last_player = this.settings.get_string ("last-running-player");
this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal);
this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp
index 8242fb6..1cea780 100644
--- a/tests/integration/indicator-sound-test-base.cpp
+++ b/tests/integration/indicator-sound-test-base.cpp
@@ -456,17 +456,14 @@ QVariant IndicatorSoundTestBase::waitPropertyChanged(QString property)
signal_spy_volume_changed_->wait();
if (signal_spy_volume_changed_->count())
{
- QList<QVariant> arguments = signal_spy_volume_changed_->takeFirst();
+ QList<QVariant> arguments = signal_spy_volume_changed_->takeLast();
if (arguments.size() == 3 && static_cast<QMetaType::Type>(arguments.at(1).type()) == QMetaType::QVariantMap)
{
- QVariantMap map = arguments.at(1).toMap();
- QMapIterator<QString, QVariant> iter(map);
- while (iter.hasNext()) {
- iter.next();
- if (iter.key() == property)
- {
- return iter.value();
- }
+ QMap<QString, QVariant> map = arguments.at(1).toMap();
+ QMap<QString, QVariant>::iterator iter = map.find(property);
+ if (iter != map.end())
+ {
+ return iter.value();
}
}
}
diff --git a/tests/integration/test-indicator.cpp b/tests/integration/test-indicator.cpp
index 33a27af..6dbc73d 100644
--- a/tests/integration/test-indicator.cpp
+++ b/tests/integration/test-indicator.cpp
@@ -925,9 +925,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 +933,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)
diff --git a/tests/service-mocks/accounts-mock/AccountsServiceSoundMock.cpp b/tests/service-mocks/accounts-mock/AccountsServiceSoundMock.cpp
index 37de377..b0e4862 100644
--- a/tests/service-mocks/accounts-mock/AccountsServiceSoundMock.cpp
+++ b/tests/service-mocks/accounts-mock/AccountsServiceSoundMock.cpp
@@ -46,3 +46,18 @@ void AccountsServiceSoundMock::setVolume(double volume)
"Volume",
property("Volume"));
}
+
+QString AccountsServiceSoundMock::lastRunningPlayer() const
+{
+ return lastRunningPlayer_;
+}
+
+void AccountsServiceSoundMock::setLastRunningPlayer(QString const & lastRunningPlayer)
+{
+ lastRunningPlayer_ = lastRunningPlayer;
+ notifier_.notifyPropertyChanged(QDBusConnection::systemBus(),
+ ACCOUNTS_SOUND_INTERFACE,
+ USER_PATH,
+ "LastRunningPlayer",
+ property("LastRunningPlayer"));
+}
diff --git a/tests/service-mocks/accounts-mock/AccountsServiceSoundMock.h b/tests/service-mocks/accounts-mock/AccountsServiceSoundMock.h
index bb3dbe8..fd5104e 100644
--- a/tests/service-mocks/accounts-mock/AccountsServiceSoundMock.h
+++ b/tests/service-mocks/accounts-mock/AccountsServiceSoundMock.h
@@ -37,10 +37,13 @@ class AccountsServiceSoundMock : public QObject, protected QDBusContext
{
Q_OBJECT
Q_PROPERTY(double Volume READ volume WRITE setVolume)
+ Q_PROPERTY(QString LastRunningPlayer READ lastRunningPlayer WRITE setLastRunningPlayer)
public Q_SLOTS:
double volume() const;
void setVolume(double volume);
+ QString lastRunningPlayer() const;
+ void setLastRunningPlayer(QString const & lastRunningPlayer);
public:
AccountsServiceSoundMock(QObject* parent = 0);
@@ -48,6 +51,7 @@ public:
private:
double volume_;
+ QString lastRunningPlayer_;
DBusPropertiesNotifier notifier_;
};
diff --git a/tests/service-mocks/accounts-mock/com.ubuntu.AccountsService.Sound.Mock.xml b/tests/service-mocks/accounts-mock/com.ubuntu.AccountsService.Sound.Mock.xml
index 859cd46..daf82e5 100644
--- a/tests/service-mocks/accounts-mock/com.ubuntu.AccountsService.Sound.Mock.xml
+++ b/tests/service-mocks/accounts-mock/com.ubuntu.AccountsService.Sound.Mock.xml
@@ -2,5 +2,6 @@
<node>
<interface name="com.ubuntu.AccountsService.Sound">
<property name="Volume" type="d" access="readwrite"/>
+ <property name="LastRunningPlayer" type="s" access="readwrite"/>
</interface>
</node> \ No newline at end of file