Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: media/audio/audio_system_impl_unittest.cc

Issue 2763383002: Switching AudioInputDeviceManager from using AudioManager interface to AudioSystem one. (Closed)
Patch Set: WeakPtr removed; combined GetInputDeviceInfo operation introduced Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/audio/audio_system_impl_unittest.cc
diff --git a/media/audio/audio_system_impl_unittest.cc b/media/audio/audio_system_impl_unittest.cc
index 26f19873b429029da9ed76986fd47464ee278d3b..5f730ab56cb6da124f81449778e17ba862aa05b5 100644
--- a/media/audio/audio_system_impl_unittest.cc
+++ b/media/audio/audio_system_impl_unittest.cc
@@ -106,6 +106,21 @@ class AudioSystemImplTest : public testing::TestWithParam<bool> {
DeviceDescriptionsReceived();
}
+ void OnInputDeviceInfo(const AudioParameters& expected_input,
+ const AudioParameters& expected_associated_output,
+ const std::string& expected_associated_device_id,
+ const AudioParameters& input,
+ const AudioParameters& associated_output,
+ const std::string& associated_device_id) {
+ EXPECT_TRUE(thread_checker_.CalledOnValidThread());
+ EXPECT_EQ(expected_input.AsHumanReadableString(),
+ input.AsHumanReadableString());
+ EXPECT_EQ(expected_associated_output.AsHumanReadableString(),
+ associated_output.AsHumanReadableString());
+ EXPECT_EQ(expected_associated_device_id, associated_device_id);
+ InputDeviceInfoReceived();
+ }
+
void WaitForCallback() {
if (!use_audio_thread_) {
base::RunLoop().RunUntilIdle();
@@ -125,6 +140,8 @@ class AudioSystemImplTest : public testing::TestWithParam<bool> {
MOCK_METHOD0(AudioParametersReceived, void(void));
MOCK_METHOD1(HasInputDevicesCallback, void(bool));
MOCK_METHOD0(DeviceDescriptionsReceived, void(void));
+ MOCK_METHOD1(AssociatedOutputDeviceIDReceived, void(const std::string&));
+ MOCK_METHOD0(InputDeviceInfoReceived, void(void));
protected:
base::MessageLoop message_loop_;
@@ -159,7 +176,7 @@ TEST_P(AudioSystemImplTest, GetInputStreamParametersNoDevice) {
WaitForCallback();
}
-TEST_P(AudioSystemImplTest, GetStreamParameters) {
+TEST_P(AudioSystemImplTest, GetOutputStreamParameters) {
EXPECT_CALL(*this, AudioParametersReceived());
audio_system_->GetOutputStreamParameters(
kNonDefaultDeviceId, base::Bind(&AudioSystemImplTest::OnAudioParams,
@@ -268,6 +285,48 @@ TEST_P(AudioSystemImplTest, GetOutputDeviceDescriptions) {
WaitForCallback();
}
+TEST_P(AudioSystemImplTest, GetAssociatedOutputDeviceID) {
+ const std::string associated_id("associated_id");
+ audio_manager_->SetAssociatedOutputDeviceIDCallback(
+ base::Bind([](const std::string& result,
+ const std::string&) -> std::string { return result; },
+ associated_id));
+
+ EXPECT_CALL(*this, AssociatedOutputDeviceIDReceived(associated_id));
+
+ audio_system_->GetAssociatedOutputDeviceID(
+ std::string(),
+ base::Bind(&AudioSystemImplTest::AssociatedOutputDeviceIDReceived,
+ base::Unretained(this)));
+ WaitForCallback();
+}
+
+TEST_P(AudioSystemImplTest, GetInputDeviceInfoNoAssociation) {
+ EXPECT_CALL(*this, InputDeviceInfoReceived());
+
+ audio_system_->GetInputDeviceInfo(
+ kNonDefaultDeviceId, base::Bind(&AudioSystemImplTest::OnInputDeviceInfo,
+ base::Unretained(this), input_params_,
+ AudioParameters(), std::string()));
+ WaitForCallback();
+}
+
+TEST_P(AudioSystemImplTest, GetInputDeviceInfoWithAssociation) {
+ EXPECT_CALL(*this, InputDeviceInfoReceived());
+
+ const std::string associated_id("associated_id");
+ audio_manager_->SetAssociatedOutputDeviceIDCallback(
+ base::Bind([](const std::string& result,
+ const std::string&) -> std::string { return result; },
+ associated_id));
+
+ audio_system_->GetInputDeviceInfo(
+ kNonDefaultDeviceId, base::Bind(&AudioSystemImplTest::OnInputDeviceInfo,
+ base::Unretained(this), input_params_,
+ output_params_, associated_id));
+ WaitForCallback();
+}
+
INSTANTIATE_TEST_CASE_P(, AudioSystemImplTest, testing::Values(false, true));
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698