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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager_unittest.cc

Issue 2697033006: Switching MediaStreamManager from using AudioManager to AudioSystem (Closed)
Patch Set: weak pointers removed Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "content/browser/browser_thread_impl.h" 18 #include "content/browser/browser_thread_impl.h"
19 #include "content/browser/renderer_host/media/media_stream_manager.h" 19 #include "content/browser/renderer_host/media/media_stream_manager.h"
20 #include "content/browser/renderer_host/media/media_stream_requester.h" 20 #include "content/browser/renderer_host/media/media_stream_requester.h"
21 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 21 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
22 #include "content/common/media/media_stream_options.h" 22 #include "content/common/media/media_stream_options.h"
23 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
24 #include "content/public/test/test_browser_thread_bundle.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
25 #include "media/audio/audio_device_description.h" 25 #include "media/audio/audio_device_description.h"
26 #include "media/audio/audio_system_impl.h"
26 #include "media/audio/fake_audio_log_factory.h" 27 #include "media/audio/fake_audio_log_factory.h"
27 #include "media/base/media_switches.h" 28 #include "media/base/media_switches.h"
28 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 #include "url/gurl.h" 31 #include "url/gurl.h"
31 #include "url/origin.h" 32 #include "url/origin.h"
32 33
33 #if defined(USE_ALSA) 34 #if defined(USE_ALSA)
34 #include "media/audio/alsa/audio_manager_alsa.h" 35 #include "media/audio/alsa/audio_manager_alsa.h"
35 #elif defined(OS_ANDROID) 36 #elif defined(OS_ANDROID)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamRequester); 160 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamRequester);
160 }; 161 };
161 162
162 } // namespace 163 } // namespace
163 164
164 class MediaStreamManagerTest : public ::testing::Test { 165 class MediaStreamManagerTest : public ::testing::Test {
165 public: 166 public:
166 MediaStreamManagerTest() 167 MediaStreamManagerTest()
167 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { 168 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
168 audio_manager_.reset(new MockAudioManager()); 169 audio_manager_.reset(new MockAudioManager());
169 media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); 170 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
171 media_stream_manager_ =
172 base::MakeUnique<MediaStreamManager>(audio_system_.get());
170 base::RunLoop().RunUntilIdle(); 173 base::RunLoop().RunUntilIdle();
171 } 174 }
172 175
173 ~MediaStreamManagerTest() override {} 176 ~MediaStreamManagerTest() override {}
174 177
175 MOCK_METHOD1(Response, void(int index)); 178 MOCK_METHOD1(Response, void(int index));
176 void ResponseCallback(int index, 179 void ResponseCallback(int index,
177 const MediaStreamDevices& devices, 180 const MediaStreamDevices& devices,
178 std::unique_ptr<MediaStreamUIProxy> ui_proxy) { 181 std::unique_ptr<MediaStreamUIProxy> ui_proxy) {
179 Response(index); 182 Response(index);
(...skipping 15 matching lines...) Expand all
195 render_process_id, render_frame_id, page_request_id, controls, 198 render_process_id, render_frame_id, page_request_id, controls,
196 security_origin, callback); 199 security_origin, callback);
197 } 200 }
198 201
199 // media_stream_manager_ needs to outlive thread_bundle_ because it is a 202 // media_stream_manager_ needs to outlive thread_bundle_ because it is a
200 // MessageLoop::DestructionObserver. audio_manager_ needs to outlive 203 // MessageLoop::DestructionObserver. audio_manager_ needs to outlive
201 // thread_bundle_ because it uses the underlying message loop. 204 // thread_bundle_ because it uses the underlying message loop.
202 std::unique_ptr<MediaStreamManager> media_stream_manager_; 205 std::unique_ptr<MediaStreamManager> media_stream_manager_;
203 content::TestBrowserThreadBundle thread_bundle_; 206 content::TestBrowserThreadBundle thread_bundle_;
204 std::unique_ptr<MockAudioManager, media::AudioManagerDeleter> audio_manager_; 207 std::unique_ptr<MockAudioManager, media::AudioManagerDeleter> audio_manager_;
208 std::unique_ptr<media::AudioSystem> audio_system_;
205 base::RunLoop run_loop_; 209 base::RunLoop run_loop_;
206 210
207 private: 211 private:
208 DISALLOW_COPY_AND_ASSIGN(MediaStreamManagerTest); 212 DISALLOW_COPY_AND_ASSIGN(MediaStreamManagerTest);
209 }; 213 };
210 214
211 TEST_F(MediaStreamManagerTest, MakeMediaAccessRequest) { 215 TEST_F(MediaStreamManagerTest, MakeMediaAccessRequest) {
212 MakeMediaAccessRequest(0); 216 MakeMediaAccessRequest(0);
213 217
214 // Expecting the callback will be triggered and quit the test. 218 // Expecting the callback will be triggered and quit the test.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 unique_other_id); 290 unique_other_id);
287 EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC( 291 EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC(
288 kMockSalt, security_origin, hashed_other_id, unique_other_id)); 292 kMockSalt, security_origin, hashed_other_id, unique_other_id));
289 EXPECT_NE(unique_other_id, hashed_other_id); 293 EXPECT_NE(unique_other_id, hashed_other_id);
290 EXPECT_EQ(hashed_other_id.size(), 64U); 294 EXPECT_EQ(hashed_other_id.size(), 64U);
291 for (const char& c : hashed_other_id) 295 for (const char& c : hashed_other_id)
292 EXPECT_TRUE(base::IsAsciiDigit(c) || (c >= 'a' && c <= 'f')); 296 EXPECT_TRUE(base::IsAsciiDigit(c) || (c >= 'a' && c <= 'f'));
293 } 297 }
294 298
295 } // namespace content 299 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698