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 +- tests/integration/indicator-sound-test-base.h | 9 + tests/integration/test-indicator.cpp | 568 +++++++++++++++++++++ .../applications/testplayer2.desktop | 21 + .../applications/testplayer3.desktop | 21 + tests/sound-menu.cc | 16 - 6 files changed, 659 insertions(+), 19 deletions(-) create mode 100644 tests/service-mocks/media-player-mpris-mock/applications/testplayer2.desktop create mode 100644 tests/service-mocks/media-player-mpris-mock/applications/testplayer3.desktop (limited to 'tests') 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; diff --git a/tests/integration/indicator-sound-test-base.h b/tests/integration/indicator-sound-test-base.h index d9d3289..969fd69 100644 --- a/tests/integration/indicator-sound-test-base.h +++ b/tests/integration/indicator-sound-test-base.h @@ -81,6 +81,8 @@ protected: bool runProcess(QProcess&); bool startTestMprisPlayer(QString const& playerName); + bool stopTestMprisPlayer(QString const& playerName); + int findRunningTestMprisPlayer(QString const& playerName); bool setTestMprisPlayerProperty(QString const &testPlayer, QString const &property, bool value); @@ -156,6 +158,13 @@ protected: QProcess testPlayer1; + struct TestPlayer + { + std::shared_ptr process; + QString name; + }; + QVector testPlayers; + std::unique_ptr menu_interface_; std::unique_ptr accounts_interface_; diff --git a/tests/integration/test-indicator.cpp b/tests/integration/test-indicator.cpp index 9224b73..050c306 100644 --- a/tests/integration/test-indicator.cpp +++ b/tests/integration/test-indicator.cpp @@ -367,6 +367,574 @@ TEST_F(TestIndicator, DesktopAddMprisPlayer) .label("Sound Settings…") ) ).match()); + + // stop the test player + EXPECT_TRUE(stopTestMprisPlayer("testplayer1")); + + 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.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…") + ) + ).match()); +} + +TEST_F(TestIndicator, DesktopMprisPlayersPlaybackControls) +{ + double INITIAL_VOLUME = 0.0; + + ASSERT_NO_THROW(startAccountsService()); + EXPECT_TRUE(clearGSettingsPlayers()); + ASSERT_NO_THROW(startPulseDesktop()); + + // initialize volumes in pulseaudio + EXPECT_FALSE(setStreamRestoreVolume("alert", INITIAL_VOLUME)); + EXPECT_TRUE(setSinkVolume(INITIAL_VOLUME)); + + // start the test player + EXPECT_TRUE(startTestMprisPlayer("testplayer1")); + + // start now the indicator, so it picks the new volumes + ASSERT_NO_THROW(startIndicator()); + + // check that the player is added + 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.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…") + ) + ).match()); + + // start the second test player + EXPECT_TRUE(startTestMprisPlayer("testplayer2")); + + // check that the player is added + 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.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() + .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() + .string_attribute("x-canonical-previous-action","indicator.previous.testplayer2.desktop") + .string_attribute("x-canonical-play-action","indicator.play.testplayer2.desktop") + .string_attribute("x-canonical-next-action","indicator.next.testplayer2.desktop") + .string_attribute("x-canonical-type","com.canonical.unity.playback-item") + ) + ) + .item(mh::MenuItemMatcher() + .label("Sound Settings…") + ) + ).match()); + + // start the third test player + EXPECT_TRUE(startTestMprisPlayer("testplayer3")); + + // check that the player is added + 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.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() + .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() + .string_attribute("x-canonical-previous-action","indicator.previous.testplayer2.desktop") + .string_attribute("x-canonical-play-action","indicator.play.testplayer2.desktop") + .string_attribute("x-canonical-next-action","indicator.next.testplayer2.desktop") + .string_attribute("x-canonical-type","com.canonical.unity.playback-item") + ) + ) + .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-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") + ) + ) + .item(mh::MenuItemMatcher() + .label("Sound Settings…") + ) + ).match()); + + // stop the test player + EXPECT_TRUE(stopTestMprisPlayer("testplayer3")); + + // check that player 3 is present, but it has no playback controls + 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.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() + .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() + .string_attribute("x-canonical-previous-action","indicator.previous.testplayer2.desktop") + .string_attribute("x-canonical-play-action","indicator.play.testplayer2.desktop") + .string_attribute("x-canonical-next-action","indicator.next.testplayer2.desktop") + .string_attribute("x-canonical-type","com.canonical.unity.playback-item") + ) + ) + .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() + .label("Sound Settings…") + ) + ).match()); + + EXPECT_TRUE(stopTestMprisPlayer("testplayer2")); + + // check that player 2 is present, but it has no playback controls + 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.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() + .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() + .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() + .label("Sound Settings…") + ) + ).match()); + + EXPECT_TRUE(stopTestMprisPlayer("testplayer1")); + + // check that player 1 is present, and it still has the playback controls + // as it was the last one being executed + 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.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() + .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() + .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() + .label("Sound Settings…") + ) + ).match()); + + // start the third test player + EXPECT_TRUE(startTestMprisPlayer("testplayer3")); + + // check that player 3 is the only one with playback controls + 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.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() + .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-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") + ) + ) + .item(mh::MenuItemMatcher() + .label("Sound Settings…") + ) + ).match()); + + // start the rest of players + EXPECT_TRUE(startTestMprisPlayer("testplayer1")); + EXPECT_TRUE(startTestMprisPlayer("testplayer2")); + + 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.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() + .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() + .string_attribute("x-canonical-previous-action","indicator.previous.testplayer2.desktop") + .string_attribute("x-canonical-play-action","indicator.play.testplayer2.desktop") + .string_attribute("x-canonical-next-action","indicator.next.testplayer2.desktop") + .string_attribute("x-canonical-type","com.canonical.unity.playback-item") + ) + ) + .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-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") + ) + ) + .item(mh::MenuItemMatcher() + .label("Sound Settings…") + ) + ).match()); + + // stop all players + EXPECT_TRUE(stopTestMprisPlayer("testplayer1")); + EXPECT_TRUE(stopTestMprisPlayer("testplayer2")); + EXPECT_TRUE(stopTestMprisPlayer("testplayer3")); + + // 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.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() + .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-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") + ) + ) + .item(mh::MenuItemMatcher() + .label("Sound Settings…") + ) + ).match()); } TEST_F(TestIndicator, DesktopMprisPlayerButtonsState) diff --git a/tests/service-mocks/media-player-mpris-mock/applications/testplayer2.desktop b/tests/service-mocks/media-player-mpris-mock/applications/testplayer2.desktop new file mode 100644 index 0000000..579a0bf --- /dev/null +++ b/tests/service-mocks/media-player-mpris-mock/applications/testplayer2.desktop @@ -0,0 +1,21 @@ +[Desktop Entry] +Name=TestPlayer2 +GenericName=Test Player 2 +X-GNOME-FullName=Test Player 2 +Comment=Play and organize your music collection +Keywords=Audio;Song;MP3;CD;Podcast;MTP;iPod;Playlist;Last.fm;UPnP;DLNA;Radio; +Exec=echo %U +Terminal=false +Type=Application +Icon=testplayer +X-GNOME-DocPath=testplayer/testplayer.xml +Categories=GNOME;GTK;AudioVideo;Audio;Player; +MimeType=application/x-ogg;application/ogg;audio/x-vorbis+ogg;audio/x-scpls;audio/x-mp3;audio/x-mpeg;audio/mpeg;audio/x-mpegurl;audio/x-flac;audio/mp4;x-scheme-handler/itms;x-scheme-handler/itmss; +StartupNotify=true +X-GNOME-Bugzilla-Bugzilla=GNOME +X-GNOME-Bugzilla-Product=testplayer +X-GNOME-Bugzilla-Component=general +X-GNOME-Bugzilla-OtherBinaries=rhythmbox-client;rhythmbox-metadata; +X-GNOME-Bugzilla-Version=3.1 +X-GNOME-UsesNotifications=true + diff --git a/tests/service-mocks/media-player-mpris-mock/applications/testplayer3.desktop b/tests/service-mocks/media-player-mpris-mock/applications/testplayer3.desktop new file mode 100644 index 0000000..b3bfc6b --- /dev/null +++ b/tests/service-mocks/media-player-mpris-mock/applications/testplayer3.desktop @@ -0,0 +1,21 @@ +[Desktop Entry] +Name=TestPlayer3 +GenericName=Test Player 3 +X-GNOME-FullName=Test Player 3 +Comment=Play and organize your music collection +Keywords=Audio;Song;MP3;CD;Podcast;MTP;iPod;Playlist;Last.fm;UPnP;DLNA;Radio; +Exec=echo %U +Terminal=false +Type=Application +Icon=testplayer +X-GNOME-DocPath=testplayer/testplayer.xml +Categories=GNOME;GTK;AudioVideo;Audio;Player; +MimeType=application/x-ogg;application/ogg;audio/x-vorbis+ogg;audio/x-scpls;audio/x-mp3;audio/x-mpeg;audio/mpeg;audio/x-mpegurl;audio/x-flac;audio/mp4;x-scheme-handler/itms;x-scheme-handler/itmss; +StartupNotify=true +X-GNOME-Bugzilla-Bugzilla=GNOME +X-GNOME-Bugzilla-Product=testplayer +X-GNOME-Bugzilla-Component=general +X-GNOME-Bugzilla-OtherBinaries=rhythmbox-client;rhythmbox-metadata; +X-GNOME-Bugzilla-Version=3.1 +X-GNOME-UsesNotifications=true + diff --git a/tests/sound-menu.cc b/tests/sound-menu.cc index 75a661b..9f0181c 100644 --- a/tests/sound-menu.cc +++ b/tests/sound-menu.cc @@ -170,20 +170,4 @@ TEST_F(SoundMenuTest, AddRemovePlayer) { return; } -TEST_F(SoundMenuTest, AddRemovePlayerNoPlayNextPrev) { - check_player_control_buttons(false, false, false); -} - -TEST_F(SoundMenuTest, AddRemovePlayerNoNext) { - check_player_control_buttons(true, false, true); -} - -TEST_F(SoundMenuTest, AddRemovePlayerNoPrev) { - check_player_control_buttons(true, true, false); -} - -TEST_F(SoundMenuTest, AddRemovePlayerNoPlay) { - check_player_control_buttons(false, true, true); -} - // -- cgit v1.2.3 From 028e56ca8e6fa0c45f163d2ec0923053f71deb33 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Thu, 4 Feb 2016 14:49:30 +0100 Subject: Added Charles suggestions --- tests/sound-menu.cc | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/sound-menu.cc b/tests/sound-menu.cc index 9f0181c..895b723 100644 --- a/tests/sound-menu.cc +++ b/tests/sound-menu.cc @@ -96,9 +96,22 @@ class SoundMenuTest : public ::testing::Test /* Player control */ verify_item_attribute(section, 1, "x-canonical-type", g_variant_new_string("com.canonical.unity.playback-item")); - verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string(canPlay ? "indicator.play.player-id" : "indicator.play.player-id.disabled")); - verify_item_attribute(section, 1, "x-canonical-next-action", g_variant_new_string(canNext ? "indicator.next.player-id" : "indicator.next.player-id.disabled")); - verify_item_attribute(section, 1, "x-canonical-previous-action", g_variant_new_string(canPrev ? "indicator.previous.player-id" : "indicator.previous.player-id.disabled")); + //verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string("")); + if (!canPlay) { + verify_item_attribute_is_not_set(section, 1, "x-canonical-play-action", G_VARIANT_TYPE_STRING); + } else { + verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string("indicator.play.player-id")); + } + if (!canNext) { + verify_item_attribute_is_not_set(section, 1, "x-canonical-next-action", G_VARIANT_TYPE_STRING); + } else { + verify_item_attribute(section, 1, "x-canonical-next-action", g_variant_new_string("indicator.next.player-id")); + } + if (!canPrev) { + verify_item_attribute_is_not_set(section, 1, "x-canonical-previous-action", G_VARIANT_TYPE_STRING); + } else { + verify_item_attribute(section, 1, "x-canonical-previous-action", g_variant_new_string("indicator.previous.player-id")); + } g_clear_object(§ion); @@ -170,4 +183,21 @@ TEST_F(SoundMenuTest, AddRemovePlayer) { return; } + +TEST_F(SoundMenuTest, AddRemovePlayerNoPlayNextPrev) { + check_player_control_buttons(false, false, false); +} + +TEST_F(SoundMenuTest, AddRemovePlayerNoNext) { + check_player_control_buttons(true, false, true); +} + +TEST_F(SoundMenuTest, AddRemovePlayerNoPrev) { + check_player_control_buttons(true, true, false); +} + +TEST_F(SoundMenuTest, AddRemovePlayerNoPlay) { + check_player_control_buttons(false, true, true); +} + // -- cgit v1.2.3 From d17217847987bc11f139f2676715beb74e0406ff Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Thu, 4 Feb 2016 14:51:35 +0100 Subject: Fixed tabs --- tests/sound-menu.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/sound-menu.cc b/tests/sound-menu.cc index 895b723..ca8b426 100644 --- a/tests/sound-menu.cc +++ b/tests/sound-menu.cc @@ -183,21 +183,20 @@ TEST_F(SoundMenuTest, AddRemovePlayer) { return; } - TEST_F(SoundMenuTest, AddRemovePlayerNoPlayNextPrev) { - check_player_control_buttons(false, false, false); + check_player_control_buttons(false, false, false); } TEST_F(SoundMenuTest, AddRemovePlayerNoNext) { - check_player_control_buttons(true, false, true); + check_player_control_buttons(true, false, true); } TEST_F(SoundMenuTest, AddRemovePlayerNoPrev) { - check_player_control_buttons(true, true, false); + check_player_control_buttons(true, true, false); } TEST_F(SoundMenuTest, AddRemovePlayerNoPlay) { - check_player_control_buttons(false, true, true); + check_player_control_buttons(false, true, true); } // -- cgit v1.2.3 From f1bdb863aea00a03acf9501432e2baa70dd9ee8b Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Wed, 10 Feb 2016 14:08:49 +0100 Subject: Added persistence for last running player --- tests/integration/test-indicator.cpp | 1 - tests/sound-menu.cc | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/integration/test-indicator.cpp b/tests/integration/test-indicator.cpp index 050c306..33a27af 100644 --- a/tests/integration/test-indicator.cpp +++ b/tests/integration/test-indicator.cpp @@ -1385,7 +1385,6 @@ TEST_F(TestIndicator, DISABLED_PhoneNotificationWarningVolume) // try again... notificationsSpy.clear(); - qWarning() << "-----------------------------------------------------------"; // change volume to 1.0... warning should be emitted setActionValue("volume", QVariant::fromValue(1.0)); EXPECT_TRUE(waitVolumeChangedInIndicator()); diff --git a/tests/sound-menu.cc b/tests/sound-menu.cc index ca8b426..2576d19 100644 --- a/tests/sound-menu.cc +++ b/tests/sound-menu.cc @@ -62,7 +62,7 @@ class SoundMenuTest : public ::testing::Test void check_player_control_buttons(bool canPlay, bool canNext, bool canPrev) { - SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE); + SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, ""); MediaPlayerTrack * track = media_player_track_new("Artist", "Title", "Album", "http://art.url"); @@ -125,7 +125,7 @@ class SoundMenuTest : public ::testing::Test }; TEST_F(SoundMenuTest, BasicObject) { - SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE); + SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, ""); ASSERT_NE(nullptr, menu); @@ -134,7 +134,7 @@ TEST_F(SoundMenuTest, BasicObject) { } TEST_F(SoundMenuTest, AddRemovePlayer) { - SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE); + SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE, ""); MediaPlayerTrack * track = media_player_track_new("Artist", "Title", "Album", "http://art.url"); -- cgit v1.2.3