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

Unified Diff: content/browser/renderer_host/media/audio_input_device_manager_unittest.cc

Issue 2970053002: Verify that AudioInputDeviceManage stores valid parameters if there are no audio devices in the sys… (Closed)
Patch Set: nit fixes Created 3 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/audio_input_device_manager_unittest.cc
diff --git a/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc b/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc
index e9f5acc6e0d2fa1253766d36d691d1025c2f3712..cfb976b0ee7ccfb8f6262719deb44aeaf88cd8d1 100644
--- a/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc
+++ b/content/browser/renderer_host/media/audio_input_device_manager_unittest.cc
@@ -20,9 +20,9 @@
#include "build/build_config.h"
#include "content/public/common/media_stream_request.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "media/audio/audio_manager_base.h"
#include "media/audio/audio_system_impl.h"
#include "media/audio/audio_thread_impl.h"
+#include "media/audio/mock_audio_manager.h"
#include "media/base/media_switches.h"
#include "media/base/test_helpers.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -64,7 +64,7 @@ class MAYBE_AudioInputDeviceManagerTest : public testing::Test {
MAYBE_AudioInputDeviceManagerTest() {}
protected:
- void SetUp() override {
+ virtual void Initialize() {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kUseFakeDeviceForMediaStream);
// AudioInputDeviceManager accesses AudioSystem from IO thread, so it never
@@ -74,16 +74,20 @@ class MAYBE_AudioInputDeviceManagerTest : public testing::Test {
// Flush the message loop to ensure proper initialization of AudioManager.
base::RunLoop().RunUntilIdle();
- audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
- manager_ = new AudioInputDeviceManager(audio_system_.get());
- audio_input_listener_.reset(new MockAudioInputDeviceManagerListener());
- manager_->RegisterListener(audio_input_listener_.get());
-
// Use fake devices.
devices_.emplace_back(MEDIA_DEVICE_AUDIO_CAPTURE, "Fake Device 1",
"fake_device_1");
devices_.emplace_back(MEDIA_DEVICE_AUDIO_CAPTURE, "Fake Device 2",
"fake_device_2");
+ }
+
+ void SetUp() override {
+ Initialize();
+
+ audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
+ manager_ = new AudioInputDeviceManager(audio_system_.get());
+ audio_input_listener_.reset(new MockAudioInputDeviceManagerListener());
+ manager_->RegisterListener(audio_input_listener_.get());
// Wait until we get the list.
base::RunLoop().RunUntilIdle();
@@ -296,4 +300,62 @@ TEST_F(MAYBE_AudioInputDeviceManagerTest, AccessInvalidSession) {
base::RunLoop().RunUntilIdle();
}
+class AudioInputDeviceManagerNoDevicesTest
+ : public MAYBE_AudioInputDeviceManagerTest {
+ public:
+ AudioInputDeviceManagerNoDevicesTest(){};
+
+ protected:
+ void Initialize() override {
+ // MockAudioManager has no input and no output audio devices.
+ audio_manager_ = base::MakeUnique<media::MockAudioManager>(
+ base::MakeUnique<media::AudioThreadImpl>());
+
+ // Devices to request from AudioInputDeviceManager.
+ devices_.emplace_back(MEDIA_TAB_AUDIO_CAPTURE, "Tab capture",
+ "tab_capture");
+ devices_.emplace_back(MEDIA_DESKTOP_AUDIO_CAPTURE, "Desktop capture",
+ "desktop_capture");
+ devices_.emplace_back(MEDIA_DEVICE_AUDIO_CAPTURE, "Fake Device",
+ "fake_device");
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManagerNoDevicesTest);
+};
+
+TEST_F(AudioInputDeviceManagerNoDevicesTest,
+ ParametersValidWithoutAudioDevices) {
+ ASSERT_FALSE(devices_.empty());
+
+ InSequence s;
+
+ for (const auto& device_request : devices_) {
+ int session_id = manager_->Open(device_request.device);
+
+ EXPECT_CALL(*audio_input_listener_,
+ Opened(device_request.device.type, session_id))
+ .Times(1);
+ WaitForOpenCompletion();
+
+ // Expects that device parameters stored by the manager are valid.
+ const StreamDeviceInfo* device_info =
+ manager_->GetOpenedDeviceInfoById(session_id);
+ EXPECT_TRUE(
+ media::AudioParameters(media::AudioParameters::AUDIO_FAKE,
+ static_cast<media::ChannelLayout>(
+ device_info->device.input.channel_layout),
+ device_info->device.input.sample_rate, 16,
+ device_info->device.input.frames_per_buffer)
+ .IsValid());
+
+ manager_->Close(session_id);
+ EXPECT_CALL(*audio_input_listener_,
+ Closed(device_request.device.type, session_id))
+ .Times(1);
+
+ base::RunLoop().RunUntilIdle();
+ }
+}
+
} // namespace content
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698