aboutsummaryrefslogtreecommitdiff
path: root/tests/integration/indicator-sound-test-base.cpp
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-01-29 12:16:34 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-01-29 12:16:34 +0100
commit12715ce7e03fec9544d7261c87aa9ddaa39b75ad (patch)
tree9704d6a09856ee745926ec36705738dda19d7cba /tests/integration/indicator-sound-test-base.cpp
parentee2ba9c677721724c8385ff2c9f32f7a9f090f0d (diff)
downloadayatana-indicator-sound-12715ce7e03fec9544d7261c87aa9ddaa39b75ad.tar.gz
ayatana-indicator-sound-12715ce7e03fec9544d7261c87aa9ddaa39b75ad.tar.bz2
ayatana-indicator-sound-12715ce7e03fec9544d7261c87aa9ddaa39b75ad.zip
added integration tests for adding/removing players and playback controls
Diffstat (limited to 'tests/integration/indicator-sound-test-base.cpp')
-rw-r--r--tests/integration/indicator-sound-test-base.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp
index 91abf42..f61857e 100644
--- a/tests/integration/indicator-sound-test-base.cpp
+++ b/tests/integration/indicator-sound-test-base.cpp
@@ -192,16 +192,53 @@ bool IndicatorSoundTestBase::runProcess(QProcess& proc)
bool IndicatorSoundTestBase::startTestMprisPlayer(QString const& playerName)
{
- testPlayer1.terminate();
- testPlayer1.start(MEDIA_PLAYER_MPRIS_BIN, QStringList()
+ if (!stopTestMprisPlayer(playerName))
+ {
+ return false;
+ }
+ TestPlayer player;
+ player.name = playerName;
+ player.process.reset(new QProcess());
+ player.process->start(MEDIA_PLAYER_MPRIS_BIN, QStringList()
<< playerName);
- if (!testPlayer1.waitForStarted())
+ if (!player.process->waitForStarted())
+ {
+ qWarning() << "ERROR STARTING PLAYER " << playerName;
return false;
+ }
+ testPlayers.push_back(player);
return true;
}
+bool IndicatorSoundTestBase::stopTestMprisPlayer(QString const& playerName)
+{
+ bool terminateOK = true;
+ int index = findRunningTestMprisPlayer(playerName);
+ if (index != -1)
+ {
+ testPlayers[index].process->terminate();
+ if (!testPlayers[index].process->waitForFinished())
+ terminateOK = false;
+ testPlayers.remove(index);
+ }
+
+ return terminateOK;
+}
+
+int IndicatorSoundTestBase::findRunningTestMprisPlayer(QString const& playerName)
+{
+ for (int i = 0; i < testPlayers.size(); i++)
+ {
+ if (testPlayers.at(i).name == playerName)
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
bool IndicatorSoundTestBase::setTestMprisPlayerProperty(QString const &testPlayer, QString const &property, bool value)
{
QProcess setProperty;