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