aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/unity/gmenuharness/MenuItemMatcher.h2
-rw-r--r--src/gmenuharness/MenuItemMatcher.cpp20
-rw-r--r--src/media-player-mpris.vala2
-rw-r--r--tests/integration/CMakeLists.txt1
-rw-r--r--tests/integration/indicator-sound-test-base.cpp19
-rw-r--r--tests/integration/indicator-sound-test-base.h2
-rw-r--r--tests/integration/test-indicator.cpp228
7 files changed, 268 insertions, 6 deletions
diff --git a/include/unity/gmenuharness/MenuItemMatcher.h b/include/unity/gmenuharness/MenuItemMatcher.h
index 8f6deaf..38a5187 100644
--- a/include/unity/gmenuharness/MenuItemMatcher.h
+++ b/include/unity/gmenuharness/MenuItemMatcher.h
@@ -101,6 +101,8 @@ public:
MenuItemMatcher& double_attribute(const std::string& name, double value);
+ MenuItemMatcher& attribute_not_set(const std::string& name);
+
MenuItemMatcher& toggled(bool toggled);
MenuItemMatcher& mode(Mode mode);
diff --git a/src/gmenuharness/MenuItemMatcher.cpp b/src/gmenuharness/MenuItemMatcher.cpp
index dae9e7d..f39acef 100644
--- a/src/gmenuharness/MenuItemMatcher.cpp
+++ b/src/gmenuharness/MenuItemMatcher.cpp
@@ -191,6 +191,8 @@ struct MenuItemMatcher::Priv
vector<pair<string, shared_ptr<GVariant>>> m_attributes;
+ vector<string> m_not_exist_attributes;
+
vector<pair<string, shared_ptr<GVariant>>> m_pass_through_attributes;
shared_ptr<bool> m_isToggled;
@@ -249,6 +251,7 @@ MenuItemMatcher& MenuItemMatcher::operator=(const MenuItemMatcher& other)
p->m_action = other.p->m_action;
p->m_state_icons = other.p->m_state_icons;
p->m_attributes = other.p->m_attributes;
+ p->m_not_exist_attributes = other.p->m_not_exist_attributes;
p->m_pass_through_attributes = other.p->m_pass_through_attributes;
p->m_isToggled = other.p->m_isToggled;
p->m_linkType = other.p->m_linkType;
@@ -388,6 +391,12 @@ MenuItemMatcher& MenuItemMatcher::double_attribute(const std::string& name, doub
&gvariant_deleter));
}
+MenuItemMatcher& MenuItemMatcher::attribute_not_set(const std::string& name)
+{
+ p->m_not_exist_attributes.emplace_back (name);
+ return *this;
+}
+
MenuItemMatcher& MenuItemMatcher::toggled(bool isToggled)
{
p->m_isToggled = make_shared<bool>(isToggled);
@@ -779,6 +788,17 @@ void MenuItemMatcher::match(
}
}
+ for (const auto& e: p->m_not_exist_attributes)
+ {
+ auto value = get_attribute(menuItem, e.c_str());
+ if (value)
+ {
+ matchResult.failure(location,
+ "Not expected attribute '" + e
+ + "' was found");
+ }
+ }
+
if (p->m_isToggled && (*p->m_isToggled) != isToggled)
{
matchResult.failure(
diff --git a/src/media-player-mpris.vala b/src/media-player-mpris.vala
index 8bc2884..b9961f5 100644
--- a/src/media-player-mpris.vala
+++ b/src/media-player-mpris.vala
@@ -290,7 +290,7 @@ public class MediaPlayerMpris: MediaPlayer {
if (changed_properties.lookup ("PlaybackStatus", "s", null)) {
this.state = this.proxy.PlaybackStatus != null ? this.proxy.PlaybackStatus : "Unknown";
}
- if (changed_properties.lookup ("CanGoNext", "b", null) || changed_properties.lookup ("CanGoPrev", "b", null)) {
+ if (changed_properties.lookup ("CanGoNext", "b", null) || changed_properties.lookup ("CanGoPrevious", "b", null)) {
this.playbackstatus_changed ();
}
diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt
index 5798f14..939e329 100644
--- a/tests/integration/CMakeLists.txt
+++ b/tests/integration/CMakeLists.txt
@@ -31,6 +31,7 @@ add_definitions(-DSOUND_SERVICE_BIN="${CMAKE_BINARY_DIR}/src/indicator-sound-ser
-DVOLUME_SET_BIN="${CMAKE_BINARY_DIR}/tests/integration/set-volume"
-DACCOUNTS_SERVICE_BIN="${CMAKE_BINARY_DIR}/tests/service-mocks/accounts-mock/accounts-service-sound"
-DMEDIA_PLAYER_MPRIS_BIN="${CMAKE_BINARY_DIR}/tests/service-mocks/media-player-mpris-mock/media-player-mpris-mock"
+ -DMEDIA_PLAYER_MPRIS_UPDATE_BIN="${CMAKE_BINARY_DIR}/tests/service-mocks/media-player-mpris-mock/media-player-mpris-mock-update"
-DTEST_SOUND="${CMAKE_SOURCE_DIR}/tests/integration/test-sound.wav"
-DQT_NO_KEYWORDS=1
-DXDG_DATA_DIRS="${XDG_DATA_DIRS}"
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp
index 2b6b3d7..16f0bd6 100644
--- a/tests/integration/indicator-sound-test-base.cpp
+++ b/tests/integration/indicator-sound-test-base.cpp
@@ -109,6 +109,25 @@ bool IndicatorSoundTestBase::startTestMprisPlayer(QString const& playerName)
return true;
}
+bool IndicatorSoundTestBase::setTestMprisPlayerProperty(QString const &testPlayer, QString const &property, bool value)
+{
+ QProcess setProperty;
+ QString strValue;
+ strValue = value ? "true" : "false";
+
+ setProperty.start(MEDIA_PLAYER_MPRIS_UPDATE_BIN, QStringList()
+ << testPlayer
+ << property
+ << strValue);
+ if (!setProperty.waitForStarted())
+ return false;
+
+ if (!setProperty.waitForFinished())
+ return false;
+
+ return setProperty.exitCode() == 0;
+}
+
bool IndicatorSoundTestBase::startTestSound(QString const &role)
{
testSoundProcess.terminate();
diff --git a/tests/integration/indicator-sound-test-base.h b/tests/integration/indicator-sound-test-base.h
index 741580b..00ccf1a 100644
--- a/tests/integration/indicator-sound-test-base.h
+++ b/tests/integration/indicator-sound-test-base.h
@@ -53,6 +53,8 @@ protected:
bool startTestMprisPlayer(QString const& playerName);
+ bool setTestMprisPlayerProperty(QString const &testPlayer, QString const &property, bool value);
+
bool setStreamRestoreVolume(QString const &role, double volume);
bool setSinkVolume(double volume);
diff --git a/tests/integration/test-indicator.cpp b/tests/integration/test-indicator.cpp
index ca3d298..82f06a4 100644
--- a/tests/integration/test-indicator.cpp
+++ b/tests/integration/test-indicator.cpp
@@ -166,10 +166,41 @@ TEST_F(TestIndicator, PhoneBasicInitialVolume)
.item(silentModeSwitch(false))
.item(volumeSlider(INITIAL_VOLUME))
)
-// .item(mh::MenuItemMatcher()
-// .section()
-// .action("indicator.testplayer1.desktop")
-// )
+ .item(mh::MenuItemMatcher()
+ .label("Sound Settings…")
+ .action("indicator.phone-settings")
+ )
+ ).match());
+}
+
+TEST_F(TestIndicator, PhoneAddMprisPlayer)
+{
+ double INITIAL_VOLUME = 0.0;
+
+ ASSERT_NO_THROW(startAccountsService());
+ EXPECT_TRUE(clearGSettingsPlayers());
+ ASSERT_NO_THROW(startPulsePhone());
+
+ // initialize volumes in pulseaudio
+ EXPECT_TRUE(setStreamRestoreVolume("alert", INITIAL_VOLUME));
+
+ // start now the indicator, so it picks the new volumes
+ ASSERT_NO_THROW(startIndicator());
+
+ EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters())
+ .item(mh::MenuItemMatcher()
+ .action("indicator.root")
+ .string_attribute("x-canonical-type", "com.canonical.indicator.root")
+ .string_attribute("x-canonical-scroll-action", "indicator.scroll")
+ .string_attribute("x-canonical-secondary-action", "indicator.mute")
+ .string_attribute("submenu-action", "indicator.indicator-shown")
+ .mode(mh::MenuItemMatcher::Mode::all)
+ .submenu()
+ .item(mh::MenuItemMatcher()
+ .section()
+ .item(silentModeSwitch(false))
+ .item(volumeSlider(INITIAL_VOLUME))
+ )
.item(mh::MenuItemMatcher()
.label("Sound Settings…")
.action("indicator.phone-settings")
@@ -189,9 +220,66 @@ TEST_F(TestIndicator, DesktopBasicInitialVolume)
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());
+
+ 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))
+ )
+ .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, DesktopAddMprisPlayer)
+{
+ 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")
@@ -207,12 +295,27 @@ TEST_F(TestIndicator, DesktopBasicInitialVolume)
.item(volumeSlider(INITIAL_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, DesktopAddPlayer)
+TEST_F(TestIndicator, DesktopMprisPlayerButtonsState)
{
double INITIAL_VOLUME = 0.0;
@@ -264,6 +367,121 @@ TEST_F(TestIndicator, DesktopAddPlayer)
.label("Sound Settings…")
)
).match());
+
+ // change the state of CanGoNext
+ EXPECT_TRUE(setTestMprisPlayerProperty("testplayer1", "CanGoNext", false));
+
+ // verify that the action changes
+ 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))
+ )
+ .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")
+ .attribute_not_set("x-canonical-next-action")
+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
+ )
+ )
+ .item(mh::MenuItemMatcher()
+ .label("Sound Settings…")
+ )
+ ).match());
+
+
+ // change the state of CanGoPrevious
+ EXPECT_TRUE(setTestMprisPlayerProperty("testplayer1", "CanGoPrevious", false));
+
+ // verify that the action changes
+ 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))
+ )
+ .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()
+ .attribute_not_set("x-canonical-previous-action")
+ .string_attribute("x-canonical-play-action","indicator.play.testplayer1.desktop")
+ .attribute_not_set("x-canonical-next-action")
+ .string_attribute("x-canonical-type","com.canonical.unity.playback-item")
+ )
+ )
+ .item(mh::MenuItemMatcher()
+ .label("Sound Settings…")
+ )
+ ).match());
+
+ // set back both to true
+ EXPECT_TRUE(setTestMprisPlayerProperty("testplayer1", "CanGoNext", true));
+ EXPECT_TRUE(setTestMprisPlayerProperty("testplayer1", "CanGoPrevious", true));
+
+ 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))
+ )
+ .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, DesktopChangeRoleVolume)