OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "content/public/common/content_switches.h" | 6 #include "content/public/common/content_switches.h" |
| 7 #include "content/renderer/media/mock_media_constraint_factory.h" |
7 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
8 #include "content/renderer/media/webrtc_local_audio_track.h" | 9 #include "content/renderer/media/webrtc_local_audio_track.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 12 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
12 | 13 |
13 using ::testing::_; | 14 using ::testing::_; |
14 using ::testing::AnyNumber; | 15 using ::testing::AnyNumber; |
15 | 16 |
16 namespace content { | 17 namespace content { |
(...skipping 11 matching lines...) Expand all Loading... |
28 int number_of_frames)); | 29 int number_of_frames)); |
29 }; | 30 }; |
30 | 31 |
31 } // namespace | 32 } // namespace |
32 | 33 |
33 class WebRtcLocalAudioTrackAdapterTest : public ::testing::Test { | 34 class WebRtcLocalAudioTrackAdapterTest : public ::testing::Test { |
34 public: | 35 public: |
35 WebRtcLocalAudioTrackAdapterTest() | 36 WebRtcLocalAudioTrackAdapterTest() |
36 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 37 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
37 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 480), | 38 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 480), |
38 adapter_(WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)), | 39 adapter_(WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)) { |
39 capturer_(WebRtcAudioCapturer::CreateCapturer( | 40 MockMediaConstraintFactory constraint_factory; |
40 -1, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "", ""), | 41 capturer_ = WebRtcAudioCapturer::CreateCapturer( |
41 blink::WebMediaConstraints(), NULL, NULL)), | 42 -1, StreamDeviceInfo(MEDIA_DEVICE_AUDIO_CAPTURE, "", ""), |
42 track_(new WebRtcLocalAudioTrack(adapter_, capturer_, NULL)) {} | 43 constraint_factory.CreateWebMediaConstraints(), NULL, NULL); |
| 44 track_.reset(new WebRtcLocalAudioTrack(adapter_, capturer_, NULL)); |
| 45 } |
43 | 46 |
44 protected: | 47 protected: |
45 virtual void SetUp() OVERRIDE { | 48 virtual void SetUp() OVERRIDE { |
46 track_->OnSetFormat(params_); | 49 track_->OnSetFormat(params_); |
47 EXPECT_TRUE(track_->GetAudioAdapter()->enabled()); | 50 EXPECT_TRUE(track_->GetAudioAdapter()->enabled()); |
48 } | 51 } |
49 | 52 |
50 media::AudioParameters params_; | 53 media::AudioParameters params_; |
51 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter_; | 54 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter_; |
52 scoped_refptr<WebRtcAudioCapturer> capturer_; | 55 scoped_refptr<WebRtcAudioCapturer> capturer_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 int signal_level = 0; | 90 int signal_level = 0; |
88 EXPECT_FALSE(webrtc_track->GetSignalLevel(&signal_level)); | 91 EXPECT_FALSE(webrtc_track->GetSignalLevel(&signal_level)); |
89 | 92 |
90 // Enable the audio processing in the audio track. | 93 // Enable the audio processing in the audio track. |
91 CommandLine::ForCurrentProcess()->AppendSwitch( | 94 CommandLine::ForCurrentProcess()->AppendSwitch( |
92 switches::kEnableAudioTrackProcessing); | 95 switches::kEnableAudioTrackProcessing); |
93 EXPECT_TRUE(webrtc_track->GetSignalLevel(&signal_level)); | 96 EXPECT_TRUE(webrtc_track->GetSignalLevel(&signal_level)); |
94 } | 97 } |
95 | 98 |
96 } // namespace content | 99 } // namespace content |
OLD | NEW |