| OLD | NEW |
| 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 "content/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 const ResourceContext::SaltCallback& salt_callback) | 69 const ResourceContext::SaltCallback& salt_callback) |
| 70 : AudioRendererHost(kRenderProcessId, | 70 : AudioRendererHost(kRenderProcessId, |
| 71 audio_manager, | 71 audio_manager, |
| 72 mirroring_manager, | 72 mirroring_manager, |
| 73 media_internals, | 73 media_internals, |
| 74 media_stream_manager, | 74 media_stream_manager, |
| 75 salt_callback), | 75 salt_callback), |
| 76 shared_memory_length_(0) {} | 76 shared_memory_length_(0) {} |
| 77 | 77 |
| 78 // A list of mock methods. | 78 // A list of mock methods. |
| 79 MOCK_METHOD3(OnDeviceAuthorized, | 79 MOCK_METHOD4(OnDeviceAuthorized, |
| 80 void(int stream_id, | 80 void(int stream_id, |
| 81 media::OutputDeviceStatus device_status, | 81 media::OutputDeviceStatus device_status, |
| 82 const media::AudioParameters& output_params)); | 82 const media::AudioParameters& output_params, |
| 83 const std::string& matched_device_id)); |
| 83 MOCK_METHOD2(OnStreamCreated, void(int stream_id, int length)); | 84 MOCK_METHOD2(OnStreamCreated, void(int stream_id, int length)); |
| 84 MOCK_METHOD1(OnStreamPlaying, void(int stream_id)); | 85 MOCK_METHOD1(OnStreamPlaying, void(int stream_id)); |
| 85 MOCK_METHOD1(OnStreamPaused, void(int stream_id)); | 86 MOCK_METHOD1(OnStreamPaused, void(int stream_id)); |
| 86 MOCK_METHOD1(OnStreamError, void(int stream_id)); | 87 MOCK_METHOD1(OnStreamError, void(int stream_id)); |
| 87 | 88 |
| 88 private: | 89 private: |
| 89 virtual ~MockAudioRendererHost() { | 90 virtual ~MockAudioRendererHost() { |
| 90 // Make sure all audio streams have been deleted. | 91 // Make sure all audio streams have been deleted. |
| 91 EXPECT_TRUE(audio_entries_.empty()); | 92 EXPECT_TRUE(audio_entries_.empty()); |
| 92 } | 93 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 110 IPC_MESSAGE_UNHANDLED(handled = false) | 111 IPC_MESSAGE_UNHANDLED(handled = false) |
| 111 IPC_END_MESSAGE_MAP() | 112 IPC_END_MESSAGE_MAP() |
| 112 EXPECT_TRUE(handled); | 113 EXPECT_TRUE(handled); |
| 113 | 114 |
| 114 delete message; | 115 delete message; |
| 115 return true; | 116 return true; |
| 116 } | 117 } |
| 117 | 118 |
| 118 void OnNotifyDeviceAuthorized(int stream_id, | 119 void OnNotifyDeviceAuthorized(int stream_id, |
| 119 media::OutputDeviceStatus device_status, | 120 media::OutputDeviceStatus device_status, |
| 120 const media::AudioParameters& output_params) { | 121 const media::AudioParameters& output_params, |
| 121 OnDeviceAuthorized(stream_id, device_status, output_params); | 122 const std::string& matched_device_id) { |
| 123 OnDeviceAuthorized(stream_id, device_status, output_params, |
| 124 matched_device_id); |
| 122 } | 125 } |
| 123 | 126 |
| 124 void OnNotifyStreamCreated( | 127 void OnNotifyStreamCreated( |
| 125 int stream_id, | 128 int stream_id, |
| 126 base::SharedMemoryHandle handle, | 129 base::SharedMemoryHandle handle, |
| 127 base::SyncSocket::TransitDescriptor socket_descriptor, | 130 base::SyncSocket::TransitDescriptor socket_descriptor, |
| 128 uint32_t length) { | 131 uint32_t length) { |
| 129 // Maps the shared memory. | 132 // Maps the shared memory. |
| 130 shared_memory_.reset(new base::SharedMemory(handle, false)); | 133 shared_memory_.reset(new base::SharedMemory(handle, false)); |
| 131 CHECK(shared_memory_->Map(length)); | 134 CHECK(shared_memory_->Map(length)); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 const std::string& device_id, | 230 const std::string& device_id, |
| 228 const url::Origin& security_origin) { | 231 const url::Origin& security_origin) { |
| 229 media::OutputDeviceStatus expected_device_status = | 232 media::OutputDeviceStatus expected_device_status = |
| 230 device_id == kDefaultDeviceId | 233 device_id == kDefaultDeviceId |
| 231 ? media::OUTPUT_DEVICE_STATUS_OK | 234 ? media::OUTPUT_DEVICE_STATUS_OK |
| 232 : device_id == kBadDeviceId | 235 : device_id == kBadDeviceId |
| 233 ? media::OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED | 236 ? media::OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED |
| 234 : media::OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND; | 237 : media::OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND; |
| 235 | 238 |
| 236 EXPECT_CALL(*host_.get(), | 239 EXPECT_CALL(*host_.get(), |
| 237 OnDeviceAuthorized(kStreamId, expected_device_status, _)); | 240 OnDeviceAuthorized(kStreamId, expected_device_status, _, _)); |
| 238 | 241 |
| 239 if (expected_device_status == media::OUTPUT_DEVICE_STATUS_OK) { | 242 if (expected_device_status == media::OUTPUT_DEVICE_STATUS_OK) { |
| 240 EXPECT_CALL(*host_.get(), OnStreamCreated(kStreamId, _)); | 243 EXPECT_CALL(*host_.get(), OnStreamCreated(kStreamId, _)); |
| 241 EXPECT_CALL(mirroring_manager_, | 244 EXPECT_CALL(mirroring_manager_, |
| 242 AddDiverter(kRenderProcessId, kRenderFrameId, NotNull())) | 245 AddDiverter(kRenderProcessId, kRenderFrameId, NotNull())) |
| 243 .RetiresOnSaturation(); | 246 .RetiresOnSaturation(); |
| 244 } | 247 } |
| 245 | 248 |
| 246 // Send a create stream message to the audio output stream and wait until | 249 // Send a create stream message to the audio output stream and wait until |
| 247 // we receive the created message. | 250 // we receive the created message. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 406 } |
| 404 | 407 |
| 405 TEST_F(AudioRendererHostTest, CreateInvalidDevice) { | 408 TEST_F(AudioRendererHostTest, CreateInvalidDevice) { |
| 406 Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin))); | 409 Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin))); |
| 407 Close(); | 410 Close(); |
| 408 } | 411 } |
| 409 | 412 |
| 410 // TODO(hclam): Add tests for data conversation in low latency mode. | 413 // TODO(hclam): Add tests for data conversation in low latency mode. |
| 411 | 414 |
| 412 } // namespace content | 415 } // namespace content |
| OLD | NEW |