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

Side by Side Diff: content/renderer/media/media_stream_dispatcher_unittest.cc

Issue 10928043: Media Related changes for TabCapture API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes, fix unit tests. Created 8 years, 2 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 | Annotate | Revision Log
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 <string> 5 #include <string>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/common/media/media_stream_messages.h" 10 #include "content/common/media/media_stream_messages.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 EXPECT_EQ(dispatcher->requests_.size(), size_t(0)); 170 EXPECT_EQ(dispatcher->requests_.size(), size_t(0));
171 } 171 }
172 172
173 TEST(MediaStreamDispatcherTest, BasicStreamForDevice) { 173 TEST(MediaStreamDispatcherTest, BasicStreamForDevice) {
174 static const char kDeviceId[] = "/dev/video0"; 174 static const char kDeviceId[] = "/dev/video0";
175 175
176 scoped_ptr<MessageLoop> message_loop(new MessageLoop()); 176 scoped_ptr<MessageLoop> message_loop(new MessageLoop());
177 scoped_ptr<MediaStreamDispatcher> dispatcher(new MediaStreamDispatcher(NULL)); 177 scoped_ptr<MediaStreamDispatcher> dispatcher(new MediaStreamDispatcher(NULL));
178 scoped_ptr<MockMediaStreamDispatcherEventHandler> 178 scoped_ptr<MockMediaStreamDispatcherEventHandler>
179 handler(new MockMediaStreamDispatcherEventHandler); 179 handler(new MockMediaStreamDispatcherEventHandler);
180 media_stream::StreamOptions components(kNoAudioType, kVideoType); 180 media_stream::StreamOptions components(
181 kNoAudioType, kDeviceId, kVideoType, kDeviceId);
181 GURL security_origin; 182 GURL security_origin;
182 183
183 int ipc_request_id1 = dispatcher->next_ipc_id_; 184 int ipc_request_id1 = dispatcher->next_ipc_id_;
184 dispatcher->GenerateStreamForDevice(kRequestId1, handler.get()->AsWeakPtr(), 185 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(),
185 components, kDeviceId, security_origin); 186 components, security_origin);
186 int ipc_request_id2 = dispatcher->next_ipc_id_; 187 int ipc_request_id2 = dispatcher->next_ipc_id_;
187 EXPECT_NE(ipc_request_id1, ipc_request_id2); 188 EXPECT_NE(ipc_request_id1, ipc_request_id2);
188 dispatcher->GenerateStreamForDevice(kRequestId2, handler.get()->AsWeakPtr(), 189 dispatcher->GenerateStream(kRequestId2, handler.get()->AsWeakPtr(),
189 components, kDeviceId, security_origin); 190 components, security_origin);
190 EXPECT_EQ(dispatcher->requests_.size(), size_t(2)); 191 EXPECT_EQ(dispatcher->requests_.size(), size_t(2));
191 192
192 // No audio requested. 193 // No audio requested.
193 media_stream::StreamDeviceInfoArray audio_device_array; 194 media_stream::StreamDeviceInfoArray audio_device_array;
194 195
195 media_stream::StreamDeviceInfoArray video_device_array(1); 196 media_stream::StreamDeviceInfoArray video_device_array(1);
196 media_stream::StreamDeviceInfo video_device_info; 197 media_stream::StreamDeviceInfo video_device_info;
197 video_device_info.name = "Fake Video Capture Device"; 198 video_device_info.name = "Fake Video Capture Device";
198 video_device_info.stream_type = kVideoType; 199 video_device_info.stream_type = kVideoType;
199 video_device_info.session_id = kVideoSessionId; 200 video_device_info.session_id = kVideoSessionId;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 video_device_array[0] = video_device_info; 427 video_device_array[0] = video_device_info;
427 428
428 std::string stream_label1 = "stream1"; 429 std::string stream_label1 = "stream1";
429 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerated( 430 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerated(
430 kRouteId, ipc_request_id1, stream_label1, 431 kRouteId, ipc_request_id1, stream_label1,
431 audio_device_array, video_device_array)); 432 audio_device_array, video_device_array));
432 EXPECT_EQ(handler->request_id_, kRequestId1); 433 EXPECT_EQ(handler->request_id_, kRequestId1);
433 EXPECT_EQ(handler->label_, stream_label1); 434 EXPECT_EQ(handler->label_, stream_label1);
434 EXPECT_EQ(0u, dispatcher->requests_.size()); 435 EXPECT_EQ(0u, dispatcher->requests_.size());
435 } 436 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698