From 12715ce7e03fec9544d7261c87aa9ddaa39b75ad Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Fri, 29 Jan 2016 12:16:34 +0100 Subject: added integration tests for adding/removing players and playback controls --- tests/integration/indicator-sound-test-base.cpp | 43 +++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'tests/integration/indicator-sound-test-base.cpp') 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; -- cgit v1.2.3