aboutsummaryrefslogtreecommitdiff
path: root/tests/integration/indicator-sound-test-base.cpp
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-03-07 10:13:52 +0000
committerCI Train Bot <ci-train-bot@canonical.com>2016-03-07 10:13:52 +0000
commita03ba9b8fe38bad63a5b14096dfadc7341e1eac6 (patch)
tree4f9756dc0694d4fd2fe25087317a80a9f468205d /tests/integration/indicator-sound-test-base.cpp
parent5e59aeb7d963648d0975799ad69da865dc552bf7 (diff)
parent1cc5e45c976b428730e928fa10c57288129ba0e1 (diff)
downloadayatana-indicator-sound-a03ba9b8fe38bad63a5b14096dfadc7341e1eac6.tar.gz
ayatana-indicator-sound-a03ba9b8fe38bad63a5b14096dfadc7341e1eac6.tar.bz2
ayatana-indicator-sound-a03ba9b8fe38bad63a5b14096dfadc7341e1eac6.zip
Add changes to show up the microphone controls when an external microphone is detected.
Approved by: PS Jenkins bot, Charles Kerr
Diffstat (limited to 'tests/integration/indicator-sound-test-base.cpp')
-rw-r--r--tests/integration/indicator-sound-test-base.cpp102
1 files changed, 82 insertions, 20 deletions
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp
index cf60868..9225c1d 100644
--- a/tests/integration/indicator-sound-test-base.cpp
+++ b/tests/integration/indicator-sound-test-base.cpp
@@ -296,6 +296,7 @@ void IndicatorSoundTestBase::startPulseDesktop(DevicePortType speakerPort, Devic
<< "-n"
<< QString("--load=module-null-sink sink_name=indicator_sound_test_speaker sink_properties=device.bus=%1").arg(getDevicePortString(speakerPort))
<< QString("--load=module-null-sink sink_name=indicator_sound_test_headphones sink_properties=device.bus=%1").arg(getDevicePortString(headphonesPort))
+ << QString("--load=module-null-sink sink_name=indicator_sound_test_mic")
<< "--log-target=file:/tmp/pulse-daemon.log"
<< "--load=module-dbus-protocol"
<< "--load=module-native-protocol-tcp auth-ip-acl=127.0.0.1"
@@ -327,6 +328,7 @@ void IndicatorSoundTestBase::startPulsePhone(DevicePortType speakerPort, DeviceP
<< "-n"
<< QString("--load=module-null-sink sink_name=indicator_sound_test_speaker sink_properties=device.bus=%1").arg(getDevicePortString(speakerPort))
<< QString("--load=module-null-sink sink_name=indicator_sound_test_headphones sink_properties=device.bus=%1").arg(getDevicePortString(headphonesPort))
+ << QString("--load=module-null-sink sink_name=indicator_sound_test_mic")
<< "--log-target=file:/tmp/pulse-daemon.log"
<< QString("--load=module-stream-restore restore_device=false restore_muted=false fallback_table=%1").arg(STREAM_RESTORE_TABLE)
<< "--load=module-dbus-protocol"
@@ -411,6 +413,20 @@ unity::gmenuharness::MenuItemMatcher IndicatorSoundTestBase::volumeSlider(double
.pass_through_double_attribute("action", volume);
}
+unity::gmenuharness::MenuItemMatcher IndicatorSoundTestBase::micSlider(double volume, QString const &label)
+{
+ return mh::MenuItemMatcher()
+ .label(label.toStdString())
+ .round_doubles(0.1)
+ .double_attribute("min-value", 0.0)
+ .double_attribute("max-value", 1.0)
+ .double_attribute("step", 0.01)
+ .string_attribute("x-canonical-type", "com.canonical.unity.slider")
+ .themed_icon("max-icon", {"audio-input-microphone-high-panel", "audio-input-microphone-high", "audio-input-microphone", "audio-input", "audio"})
+ .themed_icon("min-icon", {"audio-input-microphone-low-zero-panel", "audio-input-microphone-low-zero", "audio-input-microphone-low", "audio-input-microphone", "audio-input", "audio"})
+ .pass_through_double_attribute("action", volume);
+}
+
unity::gmenuharness::MenuItemMatcher IndicatorSoundTestBase::silentModeSwitch(bool toggled)
{
return mh::MenuItemMatcher::checkbox()
@@ -673,53 +689,99 @@ int IndicatorSoundTestBase::getNotificationID(QVariantList call)
return id;
}
-bool IndicatorSoundTestBase::activateHeadphones(bool headphonesActive)
+bool IndicatorSoundTestBase::setDefaultSinkOrSource(bool runForSinks, const QString & active, const QStringList & inactive)
{
+ QString setDefaultCommand = runForSinks ? "set-default-sink" : "set-default-source";
+ QString suspendCommand = "suspend-sink";
+
QProcess pacltProcess;
- QString defaultSinkName = "indicator_sound_test_speaker";
- QString suspendedSinkName = "indicator_sound_test_headphones";
- if (headphonesActive)
- {
- defaultSinkName = "indicator_sound_test_headphones";
- suspendedSinkName = "indicator_sound_test_speaker";
- }
+ QString activeSinkOrSource = runForSinks ? active : active + ".monitor";
pacltProcess.start("pactl", QStringList() << "-s"
<< "127.0.0.1"
- << "set-default-sink"
- << defaultSinkName);
+ << setDefaultCommand
+ << activeSinkOrSource);
if (!pacltProcess.waitForStarted())
+ {
return false;
+ }
if (!pacltProcess.waitForFinished())
+ {
return false;
+ }
pacltProcess.start("pactl", QStringList() << "-s"
<< "127.0.0.1"
- << "suspend-sink"
- << defaultSinkName
+ << suspendCommand
+ << active
<< "0");
if (!pacltProcess.waitForStarted())
+ {
return false;
+ }
if (!pacltProcess.waitForFinished())
+ {
return false;
+ }
- pacltProcess.start("pactl", QStringList() << "-s"
- << "127.0.0.1"
- << "suspend-sink"
- << suspendedSinkName
- << "1");
- if (!pacltProcess.waitForStarted())
+ if (pacltProcess.exitCode() != 0)
+ {
return false;
+ }
+ for (int i = 0; i < inactive.size(); ++i)
+ {
+ pacltProcess.start("pactl", QStringList() << "-s"
+ << "127.0.0.1"
+ << suspendCommand
+ << inactive.at(i)
+ << "1");
+ if (!pacltProcess.waitForStarted())
+ {
+ return false;
+ }
- if (!pacltProcess.waitForFinished())
- return false;
+ if (!pacltProcess.waitForFinished())
+ {
+ return false;
+ }
+ if (pacltProcess.exitCode() != 0)
+ {
+ return false;
+ }
+ }
return pacltProcess.exitCode() == 0;
}
+bool IndicatorSoundTestBase::activateHeadphones(bool headphonesActive)
+{
+ QString defaultSinkName = "indicator_sound_test_speaker";
+ QStringList suspendedSinks = { "indicator_sound_test_mic", "indicator_sound_test_headphones" };
+ if (headphonesActive)
+ {
+ defaultSinkName = "indicator_sound_test_headphones";
+ suspendedSinks = QStringList{ "indicator_sound_test_speaker", "indicator_sound_test_mic" };
+ }
+ return setDefaultSinkOrSource(true, defaultSinkName, suspendedSinks);
+}
+
+bool IndicatorSoundTestBase::plugExternalMic(bool activate)
+{
+ QString defaultSinkName = "indicator_sound_test_mic";
+ QStringList suspendedSinks = { "indicator_sound_test_speaker", "indicator_sound_test_headphones" };
+
+ if (!activate)
+ {
+ defaultSinkName = "indicator_sound_test_speaker";
+ suspendedSinks = QStringList{ "indicator_sound_test_mic", "indicator_sound_test_headphones" };
+ }
+
+ return setDefaultSinkOrSource(false, defaultSinkName, suspendedSinks);
+}
+
QString IndicatorSoundTestBase::getDevicePortString(DevicePortType port)
{
QString portString;