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

Unified Diff: content/renderer/media/webrtc_audio_device_unittest.cc

Issue 11783059: Ensures that WebRTC works for device selection using a different sample rate than default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix after review from Chris Created 7 years, 11 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 | « content/renderer/media/webrtc_audio_device_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_audio_device_unittest.cc
diff --git a/content/renderer/media/webrtc_audio_device_unittest.cc b/content/renderer/media/webrtc_audio_device_unittest.cc
index 192514a9272997c19742ec9186aa616360623ef3..30157b0c0b7235644b10b9e3a46bb5c648e2b0fc 100644
--- a/content/renderer/media/webrtc_audio_device_unittest.cc
+++ b/content/renderer/media/webrtc_audio_device_unittest.cc
@@ -5,6 +5,7 @@
#include "base/environment.h"
#include "base/test/test_timeouts.h"
#include "content/renderer/media/audio_hardware.h"
+#include "content/renderer/media/webrtc_audio_capturer.h"
#include "content/renderer/media/webrtc_audio_device_impl.h"
#include "content/renderer/media/webrtc_audio_renderer.h"
#include "content/test/webrtc_audio_device_test.h"
@@ -114,6 +115,27 @@ bool HardwareSampleRatesAreValid() {
return true;
}
+// Utility method which initializes the audio capturer contained in the
+// WebRTC audio device. This method should be used in tests where
+// HardwareSampleRatesAreValid() has been called and returned true.
+bool InitializeCapturer(WebRtcAudioDeviceImpl* webrtc_audio_device) {
+ // Access the capturer owned and created by the audio device.
+ WebRtcAudioCapturer* capturer = webrtc_audio_device->capturer();
+ if (!capturer)
+ return false;
+
+ // Use native capture sample rate and channel configuration to get some
+ // action in this test.
+ int sample_rate = GetAudioInputSampleRate();
+ media::ChannelLayout channel_layout = GetAudioInputChannelLayout();
+ if (!capturer->Initialize(channel_layout, sample_rate))
+ return false;
+
+ // Ensures that the default capture device is utilized.
+ webrtc_audio_device->capturer()->SetDevice(1);
+ return true;
+}
+
class WebRTCMediaProcessImpl : public webrtc::VoEMediaProcess {
public:
@@ -229,13 +251,17 @@ TEST_F(WebRTCAudioDeviceTest, Construct) {
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new WebRtcAudioDeviceImpl());
- webrtc_audio_device->SetSessionId(1);
+
+ // The capturer is not created until after the WebRtcAudioDeviceImpl has
+ // been initialized.
+ EXPECT_FALSE(InitializeCapturer(webrtc_audio_device.get()));
WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create());
ASSERT_TRUE(engine.valid());
ScopedWebRTCPtr<webrtc::VoEBase> base(engine.get());
int err = base->Init(webrtc_audio_device);
+ EXPECT_TRUE(InitializeCapturer(webrtc_audio_device.get()));
EXPECT_EQ(0, err);
EXPECT_EQ(0, base->Terminate());
}
@@ -272,7 +298,6 @@ TEST_F(WebRTCAudioDeviceTest, DISABLED_StartPlayout) {
new WebRtcAudioRenderer(kRenderViewId);
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new WebRtcAudioDeviceImpl());
- webrtc_audio_device->SetSessionId(1);
EXPECT_TRUE(webrtc_audio_device->SetRenderer(renderer));
WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create());
@@ -343,7 +368,6 @@ TEST_F(WebRTCAudioDeviceTest, StartRecording) {
// EXPECT_CALL() macros here.
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new WebRtcAudioDeviceImpl());
- webrtc_audio_device->SetSessionId(1);
WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create());
ASSERT_TRUE(engine.valid());
@@ -353,6 +377,8 @@ TEST_F(WebRTCAudioDeviceTest, StartRecording) {
int err = base->Init(webrtc_audio_device);
ASSERT_EQ(0, err);
+ EXPECT_TRUE(InitializeCapturer(webrtc_audio_device.get()));
+
int ch = base->CreateChannel();
EXPECT_NE(-1, ch);
@@ -423,7 +449,6 @@ TEST_F(WebRTCAudioDeviceTest, DISABLED_PlayLocalFile) {
new WebRtcAudioRenderer(kRenderViewId);
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new WebRtcAudioDeviceImpl());
- webrtc_audio_device->SetSessionId(1);
EXPECT_TRUE(webrtc_audio_device->SetRenderer(renderer));
WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create());
@@ -495,7 +520,6 @@ TEST_F(WebRTCAudioDeviceTest, FullDuplexAudioWithAGC) {
new WebRtcAudioRenderer(kRenderViewId);
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new WebRtcAudioDeviceImpl());
- webrtc_audio_device->SetSessionId(1);
EXPECT_TRUE(webrtc_audio_device->SetRenderer(renderer));
WebRTCAutoDelete<webrtc::VoiceEngine> engine(webrtc::VoiceEngine::Create());
@@ -506,6 +530,8 @@ TEST_F(WebRTCAudioDeviceTest, FullDuplexAudioWithAGC) {
int err = base->Init(webrtc_audio_device);
ASSERT_EQ(0, err);
+ EXPECT_TRUE(InitializeCapturer(webrtc_audio_device.get()));
+
ScopedWebRTCPtr<webrtc::VoEAudioProcessing> audio_processing(engine.get());
ASSERT_TRUE(audio_processing.valid());
bool enabled = false;
« no previous file with comments | « content/renderer/media/webrtc_audio_device_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698