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

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

Issue 18420011: Support cancellation of request for opening device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: add IsThisRequest method and some comments Created 7 years, 5 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 handler(new MockMediaStreamDispatcherEventHandler); 373 handler(new MockMediaStreamDispatcherEventHandler);
374 StreamOptions components(kAudioType, kVideoType); 374 StreamOptions components(kAudioType, kVideoType);
375 int ipc_request_id1 = dispatcher->next_ipc_id_; 375 int ipc_request_id1 = dispatcher->next_ipc_id_;
376 376
377 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(), 377 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(),
378 components, GURL()); 378 components, GURL());
379 dispatcher->GenerateStream(kRequestId2, handler.get()->AsWeakPtr(), 379 dispatcher->GenerateStream(kRequestId2, handler.get()->AsWeakPtr(),
380 components, GURL()); 380 components, GURL());
381 381
382 EXPECT_EQ(2u, dispatcher->requests_.size()); 382 EXPECT_EQ(2u, dispatcher->requests_.size());
383 dispatcher->CancelGenerateStream(kRequestId2); 383 dispatcher->CancelGenerateStream(kRequestId2, handler.get()->AsWeakPtr());
384 EXPECT_EQ(1u, dispatcher->requests_.size()); 384 EXPECT_EQ(1u, dispatcher->requests_.size());
385 385
386 // Complete the creation of stream1. 386 // Complete the creation of stream1.
387 StreamDeviceInfo audio_device_info; 387 StreamDeviceInfo audio_device_info;
388 audio_device_info.device.name = "Microphone"; 388 audio_device_info.device.name = "Microphone";
389 audio_device_info.device.type = kAudioType; 389 audio_device_info.device.type = kAudioType;
390 audio_device_info.session_id = kAudioSessionId; 390 audio_device_info.session_id = kAudioSessionId;
391 StreamDeviceInfoArray audio_device_array(1); 391 StreamDeviceInfoArray audio_device_array(1);
392 audio_device_array[0] = audio_device_info; 392 audio_device_array[0] = audio_device_info;
393 393
394 StreamDeviceInfo video_device_info; 394 StreamDeviceInfo video_device_info;
395 video_device_info.device.name = "Camera"; 395 video_device_info.device.name = "Camera";
396 video_device_info.device.type = kVideoType; 396 video_device_info.device.type = kVideoType;
397 video_device_info.session_id = kVideoSessionId; 397 video_device_info.session_id = kVideoSessionId;
398 StreamDeviceInfoArray video_device_array(1); 398 StreamDeviceInfoArray video_device_array(1);
399 video_device_array[0] = video_device_info; 399 video_device_array[0] = video_device_info;
400 400
401 std::string stream_label1 = "stream1"; 401 std::string stream_label1 = "stream1";
402 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerated( 402 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerated(
403 kRouteId, ipc_request_id1, stream_label1, 403 kRouteId, ipc_request_id1, stream_label1,
404 audio_device_array, video_device_array)); 404 audio_device_array, video_device_array));
405 EXPECT_EQ(handler->request_id_, kRequestId1); 405 EXPECT_EQ(handler->request_id_, kRequestId1);
406 EXPECT_EQ(handler->label_, stream_label1); 406 EXPECT_EQ(handler->label_, stream_label1);
407 EXPECT_EQ(0u, dispatcher->requests_.size()); 407 EXPECT_EQ(0u, dispatcher->requests_.size());
408 } 408 }
409 409
410 } // namespace content 410 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_dispatcher.cc ('k') | content/renderer/media/media_stream_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698