| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Unit tests for AudioOutputAuthorizationHandler. | 5 // Unit tests for AudioOutputAuthorizationHandler. |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/media/audio_output_authorization_handler
.h" | 7 #include "content/browser/renderer_host/media/audio_output_authorization_handler
.h" |
| 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/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/test/mock_callback.h" | 13 #include "base/test/mock_callback.h" |
| 14 #include "content/browser/audio_manager_thread.h" | 14 #include "content/browser/audio_manager_thread.h" |
| 15 #include "content/browser/browser_thread_impl.h" | 15 #include "content/browser/browser_thread_impl.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/test/mock_render_process_host.h" | 17 #include "content/public/test/mock_render_process_host.h" |
| 18 #include "content/public/test/test_browser_context.h" | 18 #include "content/public/test/test_browser_context.h" |
| 19 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
| 20 #include "media/audio/audio_device_description.h" | 20 #include "media/audio/audio_device_description.h" |
| 21 #include "media/audio/audio_system_impl.h" |
| 21 #include "media/audio/fake_audio_log_factory.h" | 22 #include "media/audio/fake_audio_log_factory.h" |
| 22 #include "media/audio/fake_audio_manager.h" | 23 #include "media/audio/fake_audio_manager.h" |
| 23 #include "media/base/media_switches.h" | 24 #include "media/base/media_switches.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 27 #include "url/origin.h" | 28 #include "url/origin.h" |
| 28 | 29 |
| 29 using ::testing::_; | 30 using ::testing::_; |
| 30 | 31 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 59 // Not threadsafe, thus set before threads are started: | 60 // Not threadsafe, thus set before threads are started: |
| 60 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 61 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 61 switches::kUseFakeDeviceForMediaStream); | 62 switches::kUseFakeDeviceForMediaStream); |
| 62 | 63 |
| 63 thread_bundle_ = base::MakeUnique<TestBrowserThreadBundle>( | 64 thread_bundle_ = base::MakeUnique<TestBrowserThreadBundle>( |
| 64 TestBrowserThreadBundle::Options::REAL_IO_THREAD); | 65 TestBrowserThreadBundle::Options::REAL_IO_THREAD); |
| 65 audio_thread_ = base::MakeUnique<AudioManagerThread>(); | 66 audio_thread_ = base::MakeUnique<AudioManagerThread>(); |
| 66 audio_manager_.reset(new media::FakeAudioManager( | 67 audio_manager_.reset(new media::FakeAudioManager( |
| 67 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), | 68 audio_thread_->task_runner(), audio_thread_->worker_task_runner(), |
| 68 &log_factory_)); | 69 &log_factory_)); |
| 70 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); |
| 69 media_stream_manager_ = | 71 media_stream_manager_ = |
| 70 base::MakeUnique<MediaStreamManager>(audio_manager_.get()); | 72 base::MakeUnique<MediaStreamManager>(audio_manager_.get()); |
| 71 // Make sure everything is done initializing: | 73 // Make sure everything is done initializing: |
| 72 SyncWithAllThreads(); | 74 SyncWithAllThreads(); |
| 73 } | 75 } |
| 74 | 76 |
| 75 ~AudioOutputAuthorizationHandlerTest() override { SyncWithAllThreads(); } | 77 ~AudioOutputAuthorizationHandlerTest() override { SyncWithAllThreads(); } |
| 76 | 78 |
| 77 protected: | 79 protected: |
| 78 MediaStreamManager* GetMediaStreamManager() { | 80 MediaStreamManager* GetMediaStreamManager() { |
| 79 return media_stream_manager_.get(); | 81 return media_stream_manager_.get(); |
| 80 } | 82 } |
| 81 | 83 |
| 82 media::AudioManager* GetAudioManager() { return audio_manager_.get(); } | 84 media::AudioSystem* GetAudioSystem() { return audio_system_.get(); } |
| 83 | 85 |
| 84 void SyncWithAllThreads() { | 86 void SyncWithAllThreads() { |
| 85 // New tasks might be posted while we are syncing, but in | 87 // New tasks might be posted while we are syncing, but in |
| 86 // every iteration at least one task will be run. 20 iterations should be | 88 // every iteration at least one task will be run. 20 iterations should be |
| 87 // enough for our code. | 89 // enough for our code. |
| 88 for (int i = 0; i < 20; ++i) { | 90 for (int i = 0; i < 20; ++i) { |
| 89 base::RunLoop().RunUntilIdle(); | 91 base::RunLoop().RunUntilIdle(); |
| 90 SyncWith(BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 92 SyncWith(BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
| 91 SyncWith(audio_manager_->GetWorkerTaskRunner()); | 93 SyncWith(audio_manager_->GetWorkerTaskRunner()); |
| 92 } | 94 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 base::Unretained(out))); | 135 base::Unretained(out))); |
| 134 } | 136 } |
| 135 | 137 |
| 136 // media_stream_manager must die after threads since it's a | 138 // media_stream_manager must die after threads since it's a |
| 137 // DestructionObserver. | 139 // DestructionObserver. |
| 138 std::unique_ptr<MediaStreamManager> media_stream_manager_; | 140 std::unique_ptr<MediaStreamManager> media_stream_manager_; |
| 139 std::unique_ptr<TestBrowserThreadBundle> thread_bundle_; | 141 std::unique_ptr<TestBrowserThreadBundle> thread_bundle_; |
| 140 std::unique_ptr<AudioManagerThread> audio_thread_; | 142 std::unique_ptr<AudioManagerThread> audio_thread_; |
| 141 media::FakeAudioLogFactory log_factory_; | 143 media::FakeAudioLogFactory log_factory_; |
| 142 media::ScopedAudioManagerPtr audio_manager_; | 144 media::ScopedAudioManagerPtr audio_manager_; |
| 145 std::unique_ptr<media::AudioSystem> audio_system_; |
| 143 | 146 |
| 144 DISALLOW_COPY_AND_ASSIGN(AudioOutputAuthorizationHandlerTest); | 147 DISALLOW_COPY_AND_ASSIGN(AudioOutputAuthorizationHandlerTest); |
| 145 }; | 148 }; |
| 146 | 149 |
| 147 TEST_F(AudioOutputAuthorizationHandlerTest, AuthorizeDefaultDevice_Ok) { | 150 TEST_F(AudioOutputAuthorizationHandlerTest, AuthorizeDefaultDevice_Ok) { |
| 148 MockAuthorizationCallback listener; | 151 MockAuthorizationCallback listener; |
| 149 EXPECT_CALL(listener, | 152 EXPECT_CALL(listener, |
| 150 Run(media::OUTPUT_DEVICE_STATUS_OK, false, _, kDefaultDeviceId)) | 153 Run(media::OUTPUT_DEVICE_STATUS_OK, false, _, kDefaultDeviceId)) |
| 151 .Times(1); | 154 .Times(1); |
| 152 std::unique_ptr<AudioOutputAuthorizationHandler> handler = | 155 std::unique_ptr<AudioOutputAuthorizationHandler> handler = |
| 153 base::MakeUnique<AudioOutputAuthorizationHandler>( | 156 base::MakeUnique<AudioOutputAuthorizationHandler>( |
| 154 GetAudioManager(), GetMediaStreamManager(), kRenderProcessId, kSalt); | 157 GetAudioSystem(), GetMediaStreamManager(), kRenderProcessId, kSalt); |
| 155 | 158 |
| 156 BrowserThread::PostTask( | 159 BrowserThread::PostTask( |
| 157 BrowserThread::IO, FROM_HERE, | 160 BrowserThread::IO, FROM_HERE, |
| 158 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, | 161 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, |
| 159 base::Unretained(handler.get()), kRenderFrameId, 0, | 162 base::Unretained(handler.get()), kRenderFrameId, 0, |
| 160 kDefaultDeviceId, SecurityOrigin(), listener.Get()))); | 163 kDefaultDeviceId, SecurityOrigin(), listener.Get()))); |
| 161 | 164 |
| 162 SyncWithAllThreads(); | 165 SyncWithAllThreads(); |
| 163 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); | 166 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); |
| 164 SyncWithAllThreads(); | 167 SyncWithAllThreads(); |
| 165 } | 168 } |
| 166 | 169 |
| 167 TEST_F(AudioOutputAuthorizationHandlerTest, | 170 TEST_F(AudioOutputAuthorizationHandlerTest, |
| 168 AuthorizeDefaultDeviceByEmptyId_Ok) { | 171 AuthorizeDefaultDeviceByEmptyId_Ok) { |
| 169 MockAuthorizationCallback listener; | 172 MockAuthorizationCallback listener; |
| 170 EXPECT_CALL(listener, | 173 EXPECT_CALL(listener, |
| 171 Run(media::OUTPUT_DEVICE_STATUS_OK, false, _, kDefaultDeviceId)) | 174 Run(media::OUTPUT_DEVICE_STATUS_OK, false, _, kDefaultDeviceId)) |
| 172 .Times(1); | 175 .Times(1); |
| 173 std::unique_ptr<AudioOutputAuthorizationHandler> handler = | 176 std::unique_ptr<AudioOutputAuthorizationHandler> handler = |
| 174 base::MakeUnique<AudioOutputAuthorizationHandler>( | 177 base::MakeUnique<AudioOutputAuthorizationHandler>( |
| 175 GetAudioManager(), GetMediaStreamManager(), kRenderProcessId, kSalt); | 178 GetAudioSystem(), GetMediaStreamManager(), kRenderProcessId, kSalt); |
| 176 | 179 |
| 177 BrowserThread::PostTask( | 180 BrowserThread::PostTask( |
| 178 BrowserThread::IO, FROM_HERE, | 181 BrowserThread::IO, FROM_HERE, |
| 179 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, | 182 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, |
| 180 base::Unretained(handler.get()), kRenderFrameId, 0, | 183 base::Unretained(handler.get()), kRenderFrameId, 0, |
| 181 kEmptyDeviceId, SecurityOrigin(), listener.Get()))); | 184 kEmptyDeviceId, SecurityOrigin(), listener.Get()))); |
| 182 | 185 |
| 183 SyncWithAllThreads(); | 186 SyncWithAllThreads(); |
| 184 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); | 187 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); |
| 185 SyncWithAllThreads(); | 188 SyncWithAllThreads(); |
| 186 } | 189 } |
| 187 | 190 |
| 188 TEST_F(AudioOutputAuthorizationHandlerTest, | 191 TEST_F(AudioOutputAuthorizationHandlerTest, |
| 189 AuthorizeNondefaultDeviceIdWithoutPermission_NotAuthorized) { | 192 AuthorizeNondefaultDeviceIdWithoutPermission_NotAuthorized) { |
| 190 std::string raw_nondefault_id = GetRawNondefaultId(); | 193 std::string raw_nondefault_id = GetRawNondefaultId(); |
| 191 std::string hashed_id = MediaStreamManager::GetHMACForMediaDeviceID( | 194 std::string hashed_id = MediaStreamManager::GetHMACForMediaDeviceID( |
| 192 kSalt, SecurityOrigin(), raw_nondefault_id); | 195 kSalt, SecurityOrigin(), raw_nondefault_id); |
| 193 | 196 |
| 194 MockAuthorizationCallback listener; | 197 MockAuthorizationCallback listener; |
| 195 std::unique_ptr<AudioOutputAuthorizationHandler> handler = | 198 std::unique_ptr<AudioOutputAuthorizationHandler> handler = |
| 196 base::MakeUnique<AudioOutputAuthorizationHandler>( | 199 base::MakeUnique<AudioOutputAuthorizationHandler>( |
| 197 GetAudioManager(), GetMediaStreamManager(), kRenderProcessId, kSalt); | 200 GetAudioSystem(), GetMediaStreamManager(), kRenderProcessId, kSalt); |
| 198 BrowserThread::PostTask( | 201 BrowserThread::PostTask( |
| 199 BrowserThread::IO, FROM_HERE, | 202 BrowserThread::IO, FROM_HERE, |
| 200 base::Bind( | 203 base::Bind( |
| 201 &AudioOutputAuthorizationHandler::OverridePermissionsForTesting, | 204 &AudioOutputAuthorizationHandler::OverridePermissionsForTesting, |
| 202 base::Unretained(handler.get()), false)); | 205 base::Unretained(handler.get()), false)); |
| 203 SyncWithAllThreads(); | 206 SyncWithAllThreads(); |
| 204 | 207 |
| 205 EXPECT_CALL(listener, Run(media::OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED, | 208 EXPECT_CALL(listener, Run(media::OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED, |
| 206 false, _, std::string())) | 209 false, _, std::string())) |
| 207 .Times(1); | 210 .Times(1); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 218 } | 221 } |
| 219 | 222 |
| 220 TEST_F(AudioOutputAuthorizationHandlerTest, | 223 TEST_F(AudioOutputAuthorizationHandlerTest, |
| 221 AuthorizeNondefaultDeviceIdWithPermission_Ok) { | 224 AuthorizeNondefaultDeviceIdWithPermission_Ok) { |
| 222 std::string raw_nondefault_id = GetRawNondefaultId(); | 225 std::string raw_nondefault_id = GetRawNondefaultId(); |
| 223 std::string hashed_id = MediaStreamManager::GetHMACForMediaDeviceID( | 226 std::string hashed_id = MediaStreamManager::GetHMACForMediaDeviceID( |
| 224 kSalt, SecurityOrigin(), raw_nondefault_id); | 227 kSalt, SecurityOrigin(), raw_nondefault_id); |
| 225 MockAuthorizationCallback listener; | 228 MockAuthorizationCallback listener; |
| 226 std::unique_ptr<AudioOutputAuthorizationHandler> handler = | 229 std::unique_ptr<AudioOutputAuthorizationHandler> handler = |
| 227 base::MakeUnique<AudioOutputAuthorizationHandler>( | 230 base::MakeUnique<AudioOutputAuthorizationHandler>( |
| 228 GetAudioManager(), GetMediaStreamManager(), kRenderProcessId, kSalt); | 231 GetAudioSystem(), GetMediaStreamManager(), kRenderProcessId, kSalt); |
| 229 BrowserThread::PostTask( | 232 BrowserThread::PostTask( |
| 230 BrowserThread::IO, FROM_HERE, | 233 BrowserThread::IO, FROM_HERE, |
| 231 base::Bind( | 234 base::Bind( |
| 232 &AudioOutputAuthorizationHandler::OverridePermissionsForTesting, | 235 &AudioOutputAuthorizationHandler::OverridePermissionsForTesting, |
| 233 base::Unretained(handler.get()), true)); | 236 base::Unretained(handler.get()), true)); |
| 234 | 237 |
| 235 EXPECT_CALL(listener, | 238 EXPECT_CALL(listener, |
| 236 Run(media::OUTPUT_DEVICE_STATUS_OK, false, _, raw_nondefault_id)) | 239 Run(media::OUTPUT_DEVICE_STATUS_OK, false, _, raw_nondefault_id)) |
| 237 .Times(1); | 240 .Times(1); |
| 238 | 241 |
| 239 BrowserThread::PostTask( | 242 BrowserThread::PostTask( |
| 240 BrowserThread::IO, FROM_HERE, | 243 BrowserThread::IO, FROM_HERE, |
| 241 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, | 244 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, |
| 242 base::Unretained(handler.get()), kRenderFrameId, 0, hashed_id, | 245 base::Unretained(handler.get()), kRenderFrameId, 0, hashed_id, |
| 243 SecurityOrigin(), listener.Get()))); | 246 SecurityOrigin(), listener.Get()))); |
| 244 | 247 |
| 245 SyncWithAllThreads(); | 248 SyncWithAllThreads(); |
| 246 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); | 249 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); |
| 247 SyncWithAllThreads(); | 250 SyncWithAllThreads(); |
| 248 } | 251 } |
| 249 | 252 |
| 250 TEST_F(AudioOutputAuthorizationHandlerTest, AuthorizeInvalidDeviceId_NotFound) { | 253 TEST_F(AudioOutputAuthorizationHandlerTest, AuthorizeInvalidDeviceId_NotFound) { |
| 251 std::unique_ptr<TestBrowserContext> context = | 254 std::unique_ptr<TestBrowserContext> context = |
| 252 base::MakeUnique<TestBrowserContext>(); | 255 base::MakeUnique<TestBrowserContext>(); |
| 253 std::unique_ptr<MockRenderProcessHost> RPH = | 256 std::unique_ptr<MockRenderProcessHost> RPH = |
| 254 base::MakeUnique<MockRenderProcessHost>(context.get()); | 257 base::MakeUnique<MockRenderProcessHost>(context.get()); |
| 255 MockAuthorizationCallback listener; | 258 MockAuthorizationCallback listener; |
| 256 std::unique_ptr<AudioOutputAuthorizationHandler> handler = | 259 std::unique_ptr<AudioOutputAuthorizationHandler> handler = |
| 257 base::MakeUnique<AudioOutputAuthorizationHandler>( | 260 base::MakeUnique<AudioOutputAuthorizationHandler>( |
| 258 GetAudioManager(), GetMediaStreamManager(), RPH->GetID(), kSalt); | 261 GetAudioSystem(), GetMediaStreamManager(), RPH->GetID(), kSalt); |
| 259 EXPECT_EQ(RPH->bad_msg_count(), 0); | 262 EXPECT_EQ(RPH->bad_msg_count(), 0); |
| 260 | 263 |
| 261 EXPECT_CALL(listener, | 264 EXPECT_CALL(listener, |
| 262 Run(media::OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND, _, _, _)) | 265 Run(media::OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND, _, _, _)) |
| 263 .Times(1); | 266 .Times(1); |
| 264 | 267 |
| 265 BrowserThread::PostTask( | 268 BrowserThread::PostTask( |
| 266 BrowserThread::IO, FROM_HERE, | 269 BrowserThread::IO, FROM_HERE, |
| 267 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, | 270 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, |
| 268 base::Unretained(handler.get()), kRenderFrameId, 0, | 271 base::Unretained(handler.get()), kRenderFrameId, 0, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 283 std::string raw_nondefault_id = GetRawNondefaultId(); | 286 std::string raw_nondefault_id = GetRawNondefaultId(); |
| 284 std::string hashed_id = MediaStreamManager::GetHMACForMediaDeviceID( | 287 std::string hashed_id = MediaStreamManager::GetHMACForMediaDeviceID( |
| 285 kSalt, SecurityOrigin(), raw_nondefault_id); | 288 kSalt, SecurityOrigin(), raw_nondefault_id); |
| 286 std::unique_ptr<TestBrowserContext> context = | 289 std::unique_ptr<TestBrowserContext> context = |
| 287 base::MakeUnique<TestBrowserContext>(); | 290 base::MakeUnique<TestBrowserContext>(); |
| 288 std::unique_ptr<MockRenderProcessHost> RPH = | 291 std::unique_ptr<MockRenderProcessHost> RPH = |
| 289 base::MakeUnique<MockRenderProcessHost>(context.get()); | 292 base::MakeUnique<MockRenderProcessHost>(context.get()); |
| 290 MockAuthorizationCallback listener; | 293 MockAuthorizationCallback listener; |
| 291 std::unique_ptr<AudioOutputAuthorizationHandler> handler = | 294 std::unique_ptr<AudioOutputAuthorizationHandler> handler = |
| 292 base::MakeUnique<AudioOutputAuthorizationHandler>( | 295 base::MakeUnique<AudioOutputAuthorizationHandler>( |
| 293 GetAudioManager(), GetMediaStreamManager(), RPH->GetID(), kSalt); | 296 GetAudioSystem(), GetMediaStreamManager(), RPH->GetID(), kSalt); |
| 294 | 297 |
| 295 EXPECT_EQ(RPH->bad_msg_count(), 0); | 298 EXPECT_EQ(RPH->bad_msg_count(), 0); |
| 296 EXPECT_CALL(listener, Run(_, _, _, _)).Times(0); | 299 EXPECT_CALL(listener, Run(_, _, _, _)).Times(0); |
| 297 | 300 |
| 298 BrowserThread::PostTask( | 301 BrowserThread::PostTask( |
| 299 BrowserThread::IO, FROM_HERE, | 302 BrowserThread::IO, FROM_HERE, |
| 300 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, | 303 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, |
| 301 base::Unretained(handler.get()), kRenderFrameId, 0, hashed_id, | 304 base::Unretained(handler.get()), kRenderFrameId, 0, hashed_id, |
| 302 BadSecurityOrigin(), listener.Get()))); | 305 BadSecurityOrigin(), listener.Get()))); |
| 303 | 306 |
| 304 SyncWithAllThreads(); | 307 SyncWithAllThreads(); |
| 305 EXPECT_EQ(RPH->bad_msg_count(), 1); | 308 EXPECT_EQ(RPH->bad_msg_count(), 1); |
| 306 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); | 309 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); |
| 307 SyncWithAllThreads(); | 310 SyncWithAllThreads(); |
| 308 RPH.reset(); | 311 RPH.reset(); |
| 309 context.reset(); | 312 context.reset(); |
| 310 } | 313 } |
| 311 | 314 |
| 312 TEST_F(AudioOutputAuthorizationHandlerTest, | 315 TEST_F(AudioOutputAuthorizationHandlerTest, |
| 313 AuthorizeWithSessionIdWithoutDevice_GivesDefault) { | 316 AuthorizeWithSessionIdWithoutDevice_GivesDefault) { |
| 314 MockAuthorizationCallback listener; | 317 MockAuthorizationCallback listener; |
| 315 std::unique_ptr<AudioOutputAuthorizationHandler> handler = | 318 std::unique_ptr<AudioOutputAuthorizationHandler> handler = |
| 316 base::MakeUnique<AudioOutputAuthorizationHandler>( | 319 base::MakeUnique<AudioOutputAuthorizationHandler>( |
| 317 GetAudioManager(), GetMediaStreamManager(), kRenderProcessId, kSalt); | 320 GetAudioSystem(), GetMediaStreamManager(), kRenderProcessId, kSalt); |
| 318 | 321 |
| 319 EXPECT_CALL(listener, | 322 EXPECT_CALL(listener, |
| 320 Run(media::OUTPUT_DEVICE_STATUS_OK, false, _, kDefaultDeviceId)) | 323 Run(media::OUTPUT_DEVICE_STATUS_OK, false, _, kDefaultDeviceId)) |
| 321 .Times(1); | 324 .Times(1); |
| 322 | 325 |
| 323 BrowserThread::PostTask( | 326 BrowserThread::PostTask( |
| 324 BrowserThread::IO, FROM_HERE, | 327 BrowserThread::IO, FROM_HERE, |
| 325 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, | 328 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, |
| 326 base::Unretained(handler.get()), kRenderFrameId, kSessionId, | 329 base::Unretained(handler.get()), kRenderFrameId, kSessionId, |
| 327 std::string(), BadSecurityOrigin(), listener.Get()))); | 330 std::string(), BadSecurityOrigin(), listener.Get()))); |
| 328 | 331 |
| 329 SyncWithAllThreads(); | 332 SyncWithAllThreads(); |
| 330 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); | 333 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); |
| 331 SyncWithAllThreads(); | 334 SyncWithAllThreads(); |
| 332 } | 335 } |
| 333 | 336 |
| 334 } // namespace content | 337 } // namespace content |
| OLD | NEW |