| 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" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 void GetRawNondefaultIdOnIOThread(std::string* out) { | 126 void GetRawNondefaultIdOnIOThread(std::string* out) { |
| 127 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 127 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 128 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; | 128 MediaDevicesManager::BoolDeviceTypes devices_to_enumerate; |
| 129 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] = true; | 129 devices_to_enumerate[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] = true; |
| 130 | 130 |
| 131 media_stream_manager_->media_devices_manager()->EnumerateDevices( | 131 media_stream_manager_->media_devices_manager()->EnumerateDevices( |
| 132 devices_to_enumerate, | 132 devices_to_enumerate, |
| 133 base::Bind( | 133 base::Bind( |
| 134 [](std::string* out, const MediaDeviceEnumeration& result) { | 134 [](std::string* out, const MediaDeviceEnumeration& result) { |
| 135 // Index 0 is default, so use 1. | 135 // Index 0 is default, so use 1. We expect to have a nondefault |
| 136 // device. |
| 136 CHECK(result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] | 137 CHECK(result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT] |
| 137 .size() > 1) | 138 .size() > 1); |
| 138 << "Expected to have a nondefault device."; | |
| 139 *out = result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT][1] | 139 *out = result[MediaDeviceType::MEDIA_DEVICE_TYPE_AUDIO_OUTPUT][1] |
| 140 .device_id; | 140 .device_id; |
| 141 }, | 141 }, |
| 142 base::Unretained(out))); | 142 base::Unretained(out))); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // media_stream_manager must die after threads since it's a | 145 // media_stream_manager must die after threads since it's a |
| 146 // DestructionObserver. | 146 // DestructionObserver. |
| 147 std::unique_ptr<MediaStreamManager> media_stream_manager_; | 147 std::unique_ptr<MediaStreamManager> media_stream_manager_; |
| 148 std::unique_ptr<TestBrowserThreadBundle> thread_bundle_; | 148 std::unique_ptr<TestBrowserThreadBundle> thread_bundle_; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, | 336 (base::Bind(&AudioOutputAuthorizationHandler::RequestDeviceAuthorization, |
| 337 base::Unretained(handler.get()), kRenderFrameId, kSessionId, | 337 base::Unretained(handler.get()), kRenderFrameId, kSessionId, |
| 338 std::string(), BadSecurityOrigin(), listener.GetCallback()))); | 338 std::string(), BadSecurityOrigin(), listener.GetCallback()))); |
| 339 | 339 |
| 340 SyncWithAllThreads(); | 340 SyncWithAllThreads(); |
| 341 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); | 341 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); |
| 342 SyncWithAllThreads(); | 342 SyncWithAllThreads(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace content | 345 } // namespace content |
| OLD | NEW |