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 <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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 if (audio_device_array.size()) { | 46 if (audio_device_array.size()) { |
47 DCHECK(audio_device_array.size() == 1); | 47 DCHECK(audio_device_array.size() == 1); |
48 audio_device_ = audio_device_array[0]; | 48 audio_device_ = audio_device_array[0]; |
49 } | 49 } |
50 if (video_device_array.size()) { | 50 if (video_device_array.size()) { |
51 DCHECK(video_device_array.size() == 1); | 51 DCHECK(video_device_array.size() == 1); |
52 video_device_ = video_device_array[0]; | 52 video_device_ = video_device_array[0]; |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 virtual void OnStreamGenerationFailed(int request_id) OVERRIDE { | 56 virtual void OnStreamGenerationFailed( |
| 57 int request_id, |
| 58 content::MediaStreamRequestResult result) OVERRIDE { |
57 request_id_ = request_id; | 59 request_id_ = request_id; |
58 } | 60 } |
59 | 61 |
60 virtual void OnDeviceStopped(const std::string& label, | 62 virtual void OnDeviceStopped(const std::string& label, |
61 const StreamDeviceInfo& device_info) OVERRIDE { | 63 const StreamDeviceInfo& device_info) OVERRIDE { |
62 device_stopped_label_ = label; | 64 device_stopped_label_ = label; |
63 if (IsVideoMediaType(device_info.device.type)) { | 65 if (IsVideoMediaType(device_info.device.type)) { |
64 EXPECT_TRUE(StreamDeviceInfo::IsEqual(video_device_, device_info)); | 66 EXPECT_TRUE(StreamDeviceInfo::IsEqual(video_device_, device_info)); |
65 } | 67 } |
66 if (IsAudioMediaType(device_info.device.type)) { | 68 if (IsAudioMediaType(device_info.device.type)) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 scoped_ptr<MockMediaStreamDispatcherEventHandler> | 308 scoped_ptr<MockMediaStreamDispatcherEventHandler> |
307 handler(new MockMediaStreamDispatcherEventHandler); | 309 handler(new MockMediaStreamDispatcherEventHandler); |
308 StreamOptions components(true, true); | 310 StreamOptions components(true, true); |
309 GURL security_origin; | 311 GURL security_origin; |
310 | 312 |
311 // Test failure when creating a stream. | 313 // Test failure when creating a stream. |
312 int ipc_request_id1 = dispatcher->next_ipc_id_; | 314 int ipc_request_id1 = dispatcher->next_ipc_id_; |
313 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(), | 315 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(), |
314 components, security_origin); | 316 components, security_origin); |
315 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerationFailed( | 317 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerationFailed( |
316 kRouteId, ipc_request_id1)); | 318 kRouteId, ipc_request_id1, MEDIA_DEVICE_PERMISSION_DENIED)); |
317 | 319 |
318 // Verify that the request have been completed. | 320 // Verify that the request have been completed. |
319 EXPECT_EQ(handler->request_id_, kRequestId1); | 321 EXPECT_EQ(handler->request_id_, kRequestId1); |
320 EXPECT_EQ(dispatcher->requests_.size(), size_t(0)); | 322 EXPECT_EQ(dispatcher->requests_.size(), size_t(0)); |
321 | 323 |
322 // Create a new stream. | 324 // Create a new stream. |
323 ipc_request_id1 = dispatcher->next_ipc_id_; | 325 ipc_request_id1 = dispatcher->next_ipc_id_; |
324 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(), | 326 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(), |
325 components, security_origin); | 327 components, security_origin); |
326 | 328 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 dispatcher_->OnMessageReceived( | 402 dispatcher_->OnMessageReceived( |
401 MediaStreamMsg_DeviceStopped(kRouteId, label, handler_->video_device_)); | 403 MediaStreamMsg_DeviceStopped(kRouteId, label, handler_->video_device_)); |
402 // Verify that MediaStreamDispatcherEventHandler::OnDeviceStopped has been | 404 // Verify that MediaStreamDispatcherEventHandler::OnDeviceStopped has been |
403 // called. | 405 // called. |
404 EXPECT_EQ(label, handler_->device_stopped_label_); | 406 EXPECT_EQ(label, handler_->device_stopped_label_); |
405 EXPECT_EQ(dispatcher_->video_session_id(label, 0), | 407 EXPECT_EQ(dispatcher_->video_session_id(label, 0), |
406 StreamDeviceInfo::kNoId); | 408 StreamDeviceInfo::kNoId); |
407 } | 409 } |
408 | 410 |
409 } // namespace content | 411 } // namespace content |
OLD | NEW |