OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/media/capture/audio_mirroring_manager.h" | 5 #include "content/browser/media/capture/audio_mirroring_manager.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/message_loop/message_loop.h" | |
14 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
15 #include "content/browser/browser_thread_impl.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "media/base/audio_parameters.h" | 15 #include "media/base/audio_parameters.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 | 18 |
20 using media::AudioOutputStream; | 19 using media::AudioOutputStream; |
21 using media::AudioParameters; | 20 using media::AudioParameters; |
22 using media::AudioPushSink; | 21 using media::AudioPushSink; |
23 using testing::_; | 22 using testing::_; |
24 using testing::Invoke; | 23 using testing::Invoke; |
25 using testing::NotNull; | 24 using testing::NotNull; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 100 |
102 } // namespace | 101 } // namespace |
103 | 102 |
104 class AudioMirroringManagerTest : public testing::Test { | 103 class AudioMirroringManagerTest : public testing::Test { |
105 public: | 104 public: |
106 typedef AudioMirroringManager::Diverter Diverter; | 105 typedef AudioMirroringManager::Diverter Diverter; |
107 typedef AudioMirroringManager::MirroringDestination MirroringDestination; | 106 typedef AudioMirroringManager::MirroringDestination MirroringDestination; |
108 typedef AudioMirroringManager::StreamRoutes StreamRoutes; | 107 typedef AudioMirroringManager::StreamRoutes StreamRoutes; |
109 | 108 |
110 AudioMirroringManagerTest() | 109 AudioMirroringManagerTest() |
111 : io_thread_(BrowserThread::IO, &message_loop_), | 110 : params_(AudioParameters::AUDIO_FAKE, |
112 params_(AudioParameters::AUDIO_FAKE, media::CHANNEL_LAYOUT_STEREO, | 111 media::CHANNEL_LAYOUT_STEREO, |
113 AudioParameters::kAudioCDSampleRate, 16, | 112 AudioParameters::kAudioCDSampleRate, |
| 113 16, |
114 AudioParameters::kAudioCDSampleRate / 10) {} | 114 AudioParameters::kAudioCDSampleRate / 10) {} |
115 | 115 |
116 MockDiverter* CreateStream(int render_process_id, | 116 MockDiverter* CreateStream(int render_process_id, |
117 int render_frame_id, | 117 int render_frame_id, |
118 int expected_times_diverted, | 118 int expected_times_diverted, |
119 int expected_times_duplicated) { | 119 int expected_times_duplicated) { |
120 MockDiverter* const diverter = new MockDiverter(); | 120 MockDiverter* const diverter = new MockDiverter(); |
121 | 121 |
122 if (expected_times_diverted + expected_times_duplicated > 0) { | 122 if (expected_times_diverted + expected_times_duplicated > 0) { |
123 EXPECT_CALL(*diverter, GetAudioParameters()) | 123 EXPECT_CALL(*diverter, GetAudioParameters()) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 return count; | 201 return count; |
202 } | 202 } |
203 | 203 |
204 void ExpectNoLongerManagingAnything() const { | 204 void ExpectNoLongerManagingAnything() const { |
205 EXPECT_TRUE(mirroring_manager_.routes_.empty()); | 205 EXPECT_TRUE(mirroring_manager_.routes_.empty()); |
206 EXPECT_TRUE(mirroring_manager_.sessions_.empty()); | 206 EXPECT_TRUE(mirroring_manager_.sessions_.empty()); |
207 } | 207 } |
208 | 208 |
209 private: | 209 private: |
210 base::MessageLoopForIO message_loop_; | 210 TestBrowserThreadBundle thread_bundle_; |
211 BrowserThreadImpl io_thread_; | |
212 AudioParameters params_; | 211 AudioParameters params_; |
213 AudioMirroringManager mirroring_manager_; | 212 AudioMirroringManager mirroring_manager_; |
214 | 213 |
215 DISALLOW_COPY_AND_ASSIGN(AudioMirroringManagerTest); | 214 DISALLOW_COPY_AND_ASSIGN(AudioMirroringManagerTest); |
216 }; | 215 }; |
217 | 216 |
218 namespace { | 217 namespace { |
219 const int kRenderProcessId = 123; | 218 const int kRenderProcessId = 123; |
220 const int kRenderFrameId = 456; | 219 const int kRenderFrameId = 456; |
221 const int kAnotherRenderProcessId = 789; | 220 const int kAnotherRenderProcessId = 789; |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 KillStream(stream); | 764 KillStream(stream); |
766 EXPECT_EQ(1, divert_destination->query_count()); | 765 EXPECT_EQ(1, divert_destination->query_count()); |
767 EXPECT_EQ(0, CountStreamsDivertedTo(divert_destination)); | 766 EXPECT_EQ(0, CountStreamsDivertedTo(divert_destination)); |
768 EXPECT_EQ(2, duplicated_destination->query_count()); | 767 EXPECT_EQ(2, duplicated_destination->query_count()); |
769 EXPECT_EQ(0, CountStreamsDuplicatedTo(duplicated_destination)); | 768 EXPECT_EQ(0, CountStreamsDuplicatedTo(duplicated_destination)); |
770 | 769 |
771 ExpectNoLongerManagingAnything(); | 770 ExpectNoLongerManagingAnything(); |
772 } | 771 } |
773 | 772 |
774 } // namespace content | 773 } // namespace content |
OLD | NEW |