| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/renderer/media/mock_media_constraint_factory.h" | 7 #include "content/renderer/media/mock_media_constraint_factory.h" |
| 8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
| 9 #include "content/renderer/media/webrtc_audio_capturer.h" | 9 #include "content/renderer/media/webrtc_audio_capturer.h" |
| 10 #include "content/renderer/media/webrtc_local_audio_source_provider.h" | 10 #include "content/renderer/media/webrtc_local_audio_source_provider.h" |
| 11 #include "content/renderer/media/webrtc_local_audio_track.h" | 11 #include "content/renderer/media/webrtc_local_audio_track.h" |
| 12 #include "media/audio/audio_parameters.h" | 12 #include "media/audio/audio_parameters.h" |
| 13 #include "media/base/audio_bus.h" | 13 #include "media/base/audio_bus.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 16 #include "third_party/WebKit/public/web/WebHeap.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class WebRtcLocalAudioSourceProviderTest : public testing::Test { | 20 class WebRtcLocalAudioSourceProviderTest : public testing::Test { |
| 20 protected: | 21 protected: |
| 21 virtual void SetUp() OVERRIDE { | 22 virtual void SetUp() OVERRIDE { |
| 22 source_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 23 source_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 23 media::CHANNEL_LAYOUT_MONO, 1, 48000, 16, 480); | 24 media::CHANNEL_LAYOUT_MONO, 1, 48000, 16, 480); |
| 24 sink_params_.Reset( | 25 sink_params_.Reset( |
| 25 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 26 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 blink::WebMediaStreamSource::TypeAudio, | 44 blink::WebMediaStreamSource::TypeAudio, |
| 44 base::UTF8ToUTF16("dummy_source_name")); | 45 base::UTF8ToUTF16("dummy_source_name")); |
| 45 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"), | 46 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"), |
| 46 audio_source); | 47 audio_source); |
| 47 blink_track_.setExtraData(native_track.release()); | 48 blink_track_.setExtraData(native_track.release()); |
| 48 source_provider_.reset(new WebRtcLocalAudioSourceProvider(blink_track_)); | 49 source_provider_.reset(new WebRtcLocalAudioSourceProvider(blink_track_)); |
| 49 source_provider_->SetSinkParamsForTesting(sink_params_); | 50 source_provider_->SetSinkParamsForTesting(sink_params_); |
| 50 source_provider_->OnSetFormat(source_params_); | 51 source_provider_->OnSetFormat(source_params_); |
| 51 } | 52 } |
| 52 | 53 |
| 54 virtual void TearDown() OVERRIDE { |
| 55 source_provider_.reset(); |
| 56 blink_track_.reset(); |
| 57 blink::WebHeap::collectAllGarbageForTesting(); |
| 58 } |
| 59 |
| 53 media::AudioParameters source_params_; | 60 media::AudioParameters source_params_; |
| 54 scoped_ptr<int16[]> source_data_; | 61 scoped_ptr<int16[]> source_data_; |
| 55 media::AudioParameters sink_params_; | 62 media::AudioParameters sink_params_; |
| 56 scoped_ptr<media::AudioBus> sink_bus_; | 63 scoped_ptr<media::AudioBus> sink_bus_; |
| 57 blink::WebMediaStreamTrack blink_track_; | 64 blink::WebMediaStreamTrack blink_track_; |
| 58 scoped_ptr<WebRtcLocalAudioSourceProvider> source_provider_; | 65 scoped_ptr<WebRtcLocalAudioSourceProvider> source_provider_; |
| 59 }; | 66 }; |
| 60 | 67 |
| 61 TEST_F(WebRtcLocalAudioSourceProviderTest, VerifyDataFlow) { | 68 TEST_F(WebRtcLocalAudioSourceProviderTest, VerifyDataFlow) { |
| 62 // Point the WebVector into memory owned by |sink_bus_|. | 69 // Point the WebVector into memory owned by |sink_bus_|. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // Stop the audio track. | 136 // Stop the audio track. |
| 130 WebRtcLocalAudioTrack* native_track = static_cast<WebRtcLocalAudioTrack*>( | 137 WebRtcLocalAudioTrack* native_track = static_cast<WebRtcLocalAudioTrack*>( |
| 131 MediaStreamTrack::GetTrack(blink_track_)); | 138 MediaStreamTrack::GetTrack(blink_track_)); |
| 132 native_track->Stop(); | 139 native_track->Stop(); |
| 133 | 140 |
| 134 // Delete the source provider. | 141 // Delete the source provider. |
| 135 source_provider_.reset(); | 142 source_provider_.reset(); |
| 136 } | 143 } |
| 137 | 144 |
| 138 } // namespace content | 145 } // namespace content |
| OLD | NEW |