| 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/synchronization/waitable_event.h" | 5 #include "base/synchronization/waitable_event.h" |
| 6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
| 7 #include "content/public/renderer/media_stream_audio_sink.h" | 7 #include "content/public/renderer/media_stream_audio_sink.h" |
| 8 #include "content/renderer/media/media_stream_audio_source.h" | 8 #include "content/renderer/media/media_stream_audio_source.h" |
| 9 #include "content/renderer/media/mock_media_constraint_factory.h" | 9 #include "content/renderer/media/mock_media_constraint_factory.h" |
| 10 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 10 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void Start() override { | 106 void Start() override { |
| 107 audio_thread_.reset(new FakeAudioThread(capturer_, params_)); | 107 audio_thread_.reset(new FakeAudioThread(capturer_, params_)); |
| 108 audio_thread_->Start(); | 108 audio_thread_->Start(); |
| 109 OnStart(); | 109 OnStart(); |
| 110 } | 110 } |
| 111 void Stop() override { | 111 void Stop() override { |
| 112 audio_thread_->Stop(); | 112 audio_thread_->Stop(); |
| 113 audio_thread_.reset(); | 113 audio_thread_.reset(); |
| 114 OnStop(); | 114 OnStop(); |
| 115 } | 115 } |
| 116 |
| 116 protected: | 117 protected: |
| 117 ~MockCapturerSource() override {} | 118 ~MockCapturerSource() override {} |
| 118 | 119 |
| 119 private: | 120 private: |
| 120 scoped_ptr<FakeAudioThread> audio_thread_; | 121 scoped_ptr<FakeAudioThread> audio_thread_; |
| 121 WebRtcAudioCapturer* capturer_; | 122 WebRtcAudioCapturer* capturer_; |
| 122 media::AudioParameters params_; | 123 media::AudioParameters params_; |
| 123 }; | 124 }; |
| 124 | 125 |
| 125 class MockMediaStreamAudioSink : public MediaStreamAudioSink { | 126 class MockMediaStreamAudioSink : public MediaStreamAudioSink { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 145 private: | 146 private: |
| 146 media::AudioParameters params_; | 147 media::AudioParameters params_; |
| 147 }; | 148 }; |
| 148 | 149 |
| 149 } // namespace | 150 } // namespace |
| 150 | 151 |
| 151 class WebRtcLocalAudioTrackTest : public ::testing::Test { | 152 class WebRtcLocalAudioTrackTest : public ::testing::Test { |
| 152 protected: | 153 protected: |
| 153 void SetUp() override { | 154 void SetUp() override { |
| 154 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 155 params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| 155 media::CHANNEL_LAYOUT_STEREO, 2, 48000, 16, 480); | 156 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 480); |
| 156 MockMediaConstraintFactory constraint_factory; | 157 MockMediaConstraintFactory constraint_factory; |
| 157 blink_source_.initialize("dummy", blink::WebMediaStreamSource::TypeAudio, | 158 blink_source_.initialize("dummy", blink::WebMediaStreamSource::TypeAudio, |
| 158 "dummy", | 159 "dummy", |
| 159 false /* remote */, true /* readonly */); | 160 false /* remote */, true /* readonly */); |
| 160 MediaStreamAudioSource* audio_source = new MediaStreamAudioSource(); | 161 MediaStreamAudioSource* audio_source = new MediaStreamAudioSource(); |
| 161 blink_source_.setExtraData(audio_source); | 162 blink_source_.setExtraData(audio_source); |
| 162 | 163 |
| 163 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, | 164 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_CAPTURE, |
| 164 std::string(), std::string()); | 165 std::string(), std::string()); |
| 165 capturer_ = WebRtcAudioCapturer::CreateCapturer( | 166 capturer_ = WebRtcAudioCapturer::CreateCapturer( |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // Stopping the new source will stop the second track. | 500 // Stopping the new source will stop the second track. |
| 500 EXPECT_CALL(*source.get(), OnStop()).Times(1); | 501 EXPECT_CALL(*source.get(), OnStop()).Times(1); |
| 501 capturer->Stop(); | 502 capturer->Stop(); |
| 502 | 503 |
| 503 // Even though this test don't use |capturer_source_| it will be stopped | 504 // Even though this test don't use |capturer_source_| it will be stopped |
| 504 // during teardown of the test harness. | 505 // during teardown of the test harness. |
| 505 EXPECT_CALL(*capturer_source_.get(), OnStop()); | 506 EXPECT_CALL(*capturer_source_.get(), OnStop()); |
| 506 } | 507 } |
| 507 | 508 |
| 508 } // namespace content | 509 } // namespace content |
| OLD | NEW |