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

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

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

Powered by Google App Engine
This is Rietveld 408576698