aboutsummaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-09-23 16:10:54 +0200
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-09-23 16:10:54 +0200
commiteb22c54e4587e5941378b066ec8220a56d26db4b (patch)
treeae85ae46280dc6bd1c27c85bec9413c59c264808 /tests/integration
parentb9ef4f6abdefb7b1d31d34f35b742016f1b5b87f (diff)
downloadayatana-indicator-sound-eb22c54e4587e5941378b066ec8220a56d26db4b.tar.gz
ayatana-indicator-sound-eb22c54e4587e5941378b066ec8220a56d26db4b.tar.bz2
ayatana-indicator-sound-eb22c54e4587e5941378b066ec8220a56d26db4b.zip
Added test MPRIS player integration test
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/CMakeLists.txt5
-rw-r--r--tests/integration/indicator-sound-test-base.cpp36
-rw-r--r--tests/integration/indicator-sound-test-base.h6
-rw-r--r--tests/integration/test-indicator.cpp74
4 files changed, 97 insertions, 24 deletions
diff --git a/tests/integration/CMakeLists.txt b/tests/integration/CMakeLists.txt
index 52c4e70..5798f14 100644
--- a/tests/integration/CMakeLists.txt
+++ b/tests/integration/CMakeLists.txt
@@ -29,10 +29,11 @@ include_directories("${CMAKE_BINARY_DIR}/tests/dbus-types")
add_definitions(-DSOUND_SERVICE_BIN="${CMAKE_BINARY_DIR}/src/indicator-sound-service"
-DSTREAM_RESTORE_TABLE="${CMAKE_SOURCE_DIR}/tests/integration/touch-stream-restore.table"
-DVOLUME_SET_BIN="${CMAKE_BINARY_DIR}/tests/integration/set-volume"
- -DACCOUNTS_SERVICE_BIN="${CMAKE_BINARY_DIR}/tests/accounts-mock/accounts-service-sound"
+ -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"
-DTEST_SOUND="${CMAKE_SOURCE_DIR}/tests/integration/test-sound.wav"
-DQT_NO_KEYWORDS=1
- -DSCHEMA_DIR="${SCHEMA_DIR}"
+ -DXDG_DATA_DIRS="${XDG_DATA_DIRS}"
)
set(GLIB_REQUIRED_VERSION 2.26)
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp
index bbede82..2b6b3d7 100644
--- a/tests/integration/indicator-sound-test-base.cpp
+++ b/tests/integration/indicator-sound-test-base.cpp
@@ -79,6 +79,36 @@ bool IndicatorSoundTestBase::setSinkVolume(double volume)
return setVolume.exitCode() == 0;
}
+bool IndicatorSoundTestBase::clearGSettingsPlayers()
+{
+ QProcess clearPlayers;
+
+ clearPlayers.start("gsettings", QStringList()
+ << "set"
+ << "com.canonical.indicator.sound"
+ << "interested-media-players"
+ << "[]");
+ if (!clearPlayers.waitForStarted())
+ return false;
+
+ if (!clearPlayers.waitForFinished())
+ return false;
+
+ return clearPlayers.exitCode() == 0;
+}
+
+bool IndicatorSoundTestBase::startTestMprisPlayer(QString const& playerName)
+{
+ testPlayer1.terminate();
+ testPlayer1.start(MEDIA_PLAYER_MPRIS_BIN, QStringList()
+ << playerName);
+ if (!testPlayer1.waitForStarted())
+ return false;
+
+
+ return true;
+}
+
bool IndicatorSoundTestBase::startTestSound(QString const &role)
{
testSoundProcess.terminate();
@@ -218,15 +248,13 @@ mh::MenuMatcher::Parameters IndicatorSoundTestBase::phoneParameters()
void IndicatorSoundTestBase::SetUp()
{
- setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true);
- setenv("GSETTINGS_BACKEND", "memory", true);
+ setenv("XDG_DATA_DIRS", XDG_DATA_DIRS, true);
setenv("DBUS_SYSTEM_BUS_ADDRESS", dbusTestRunner.systemBus().toStdString().c_str(), true);
}
void IndicatorSoundTestBase::TearDown()
{
- unsetenv("GSETTINGS_SCHEMA_DIR");
- unsetenv("GSETTINGS_BACKEND");
+ unsetenv("XDG_DATA_DIRS");
unsetenv("PULSE_SERVER");
}
diff --git a/tests/integration/indicator-sound-test-base.h b/tests/integration/indicator-sound-test-base.h
index 019efc9..741580b 100644
--- a/tests/integration/indicator-sound-test-base.h
+++ b/tests/integration/indicator-sound-test-base.h
@@ -49,6 +49,10 @@ protected:
void startPulsePhone();
void startAccountsService();
+ bool clearGSettingsPlayers();
+
+ bool startTestMprisPlayer(QString const& playerName);
+
bool setStreamRestoreVolume(QString const &role, double volume);
bool setSinkVolume(double volume);
@@ -85,6 +89,8 @@ protected:
QProcess testSoundProcess;
+ QProcess testPlayer1;
+
std::unique_ptr<MenusInterface> menu_interface_;
std::unique_ptr<DBusPropertiesInterface> accounts_interface_;
diff --git a/tests/integration/test-indicator.cpp b/tests/integration/test-indicator.cpp
index a248658..ca3d298 100644
--- a/tests/integration/test-indicator.cpp
+++ b/tests/integration/test-indicator.cpp
@@ -143,6 +143,7 @@ TEST_F(TestIndicator, PhoneBasicInitialVolume)
double INITIAL_VOLUME = 0.0;
ASSERT_NO_THROW(startAccountsService());
+ EXPECT_TRUE(clearGSettingsPlayers());
ASSERT_NO_THROW(startPulsePhone());
// initialize volumes in pulseaudio
@@ -151,7 +152,6 @@ TEST_F(TestIndicator, PhoneBasicInitialVolume)
// start now the indicator, so it picks the new volumes
ASSERT_NO_THROW(startIndicator());
- // check the initial volume for the alert role
EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters())
.item(mh::MenuItemMatcher()
.action("indicator.root")
@@ -159,23 +159,17 @@ TEST_F(TestIndicator, PhoneBasicInitialVolume)
.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::starts_with)
+ .mode(mh::MenuItemMatcher::Mode::all)
.submenu()
.item(mh::MenuItemMatcher()
.section()
.item(silentModeSwitch(false))
.item(volumeSlider(INITIAL_VOLUME))
)
- ).match());
-
- // check that the last item is Sound Settings
- EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters())
- .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::ends_with)
- .submenu()
+// .item(mh::MenuItemMatcher()
+// .section()
+// .action("indicator.testplayer1.desktop")
+// )
.item(mh::MenuItemMatcher()
.label("Sound Settings…")
.action("indicator.phone-settings")
@@ -188,6 +182,7 @@ TEST_F(TestIndicator, DesktopBasicInitialVolume)
double INITIAL_VOLUME = 0.0;
ASSERT_NO_THROW(startAccountsService());
+ EXPECT_TRUE(clearGSettingsPlayers());
ASSERT_NO_THROW(startPulseDesktop());
// initialize volumes in pulseaudio
@@ -197,13 +192,12 @@ TEST_F(TestIndicator, DesktopBasicInitialVolume)
// start now the indicator, so it picks the new volumes
ASSERT_NO_THROW(startIndicator());
- // check the initial volume for the alert role
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::starts_with)
+ .mode(mh::MenuItemMatcher::Mode::all)
.submenu()
.item(mh::MenuItemMatcher()
.section()
@@ -212,19 +206,63 @@ TEST_F(TestIndicator, DesktopBasicInitialVolume)
)
.item(volumeSlider(INITIAL_VOLUME))
)
+ .item(mh::MenuItemMatcher()
+ .label("Sound Settings…")
+ )
).match());
+}
- // check that the last item is Sound Settings
+TEST_F(TestIndicator, DesktopAddPlayer)
+{
+ 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::ends_with)
+ .mode(mh::MenuItemMatcher::Mode::all)
.submenu()
.item(mh::MenuItemMatcher()
- .label("Sound Settings…")
+ .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());
}
@@ -252,7 +290,7 @@ TEST_F(TestIndicator, DesktopChangeRoleVolume)
int randInt = qrand() % 100;
double randomVolume = randInt / 100.0;
-// // play a test sound, it should NOT change the role in the indicator
+ // play a test sound, it should NOT change the role in the indicator
EXPECT_TRUE(startTestSound("multimedia"));
EXPECT_FALSE(waitVolumeChangedInIndicator());