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 23 matching lines...) Expand all Loading... |
34 : public MediaStreamDispatcherEventHandler, | 34 : public MediaStreamDispatcherEventHandler, |
35 public base::SupportsWeakPtr<MockMediaStreamDispatcherEventHandler> { | 35 public base::SupportsWeakPtr<MockMediaStreamDispatcherEventHandler> { |
36 public: | 36 public: |
37 MockMediaStreamDispatcherEventHandler() | 37 MockMediaStreamDispatcherEventHandler() |
38 : request_id_(-1) {} | 38 : request_id_(-1) {} |
39 | 39 |
40 virtual void OnStreamGenerated( | 40 virtual void OnStreamGenerated( |
41 int request_id, | 41 int request_id, |
42 const std::string &label, | 42 const std::string &label, |
43 const StreamDeviceInfoArray& audio_device_array, | 43 const StreamDeviceInfoArray& audio_device_array, |
44 const StreamDeviceInfoArray& video_device_array) OVERRIDE { | 44 const StreamDeviceInfoArray& video_device_array) override { |
45 request_id_ = request_id; | 45 request_id_ = request_id; |
46 label_ = label; | 46 label_ = label; |
47 if (audio_device_array.size()) { | 47 if (audio_device_array.size()) { |
48 DCHECK(audio_device_array.size() == 1); | 48 DCHECK(audio_device_array.size() == 1); |
49 audio_device_ = audio_device_array[0]; | 49 audio_device_ = audio_device_array[0]; |
50 } | 50 } |
51 if (video_device_array.size()) { | 51 if (video_device_array.size()) { |
52 DCHECK(video_device_array.size() == 1); | 52 DCHECK(video_device_array.size() == 1); |
53 video_device_ = video_device_array[0]; | 53 video_device_ = video_device_array[0]; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 virtual void OnStreamGenerationFailed( | 57 virtual void OnStreamGenerationFailed( |
58 int request_id, | 58 int request_id, |
59 content::MediaStreamRequestResult result) OVERRIDE { | 59 content::MediaStreamRequestResult result) override { |
60 request_id_ = request_id; | 60 request_id_ = request_id; |
61 } | 61 } |
62 | 62 |
63 virtual void OnDeviceStopped(const std::string& label, | 63 virtual void OnDeviceStopped(const std::string& label, |
64 const StreamDeviceInfo& device_info) OVERRIDE { | 64 const StreamDeviceInfo& device_info) override { |
65 device_stopped_label_ = label; | 65 device_stopped_label_ = label; |
66 if (IsVideoMediaType(device_info.device.type)) { | 66 if (IsVideoMediaType(device_info.device.type)) { |
67 EXPECT_TRUE(StreamDeviceInfo::IsEqual(video_device_, device_info)); | 67 EXPECT_TRUE(StreamDeviceInfo::IsEqual(video_device_, device_info)); |
68 } | 68 } |
69 if (IsAudioInputMediaType(device_info.device.type)) { | 69 if (IsAudioInputMediaType(device_info.device.type)) { |
70 EXPECT_TRUE(StreamDeviceInfo::IsEqual(audio_device_, device_info)); | 70 EXPECT_TRUE(StreamDeviceInfo::IsEqual(audio_device_, device_info)); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 virtual void OnDevicesEnumerated( | 74 virtual void OnDevicesEnumerated( |
75 int request_id, | 75 int request_id, |
76 const StreamDeviceInfoArray& device_array) OVERRIDE { | 76 const StreamDeviceInfoArray& device_array) override { |
77 request_id_ = request_id; | 77 request_id_ = request_id; |
78 } | 78 } |
79 | 79 |
80 virtual void OnDeviceOpened( | 80 virtual void OnDeviceOpened( |
81 int request_id, | 81 int request_id, |
82 const std::string& label, | 82 const std::string& label, |
83 const StreamDeviceInfo& video_device) OVERRIDE { | 83 const StreamDeviceInfo& video_device) override { |
84 request_id_ = request_id; | 84 request_id_ = request_id; |
85 label_ = label; | 85 label_ = label; |
86 } | 86 } |
87 | 87 |
88 virtual void OnDeviceOpenFailed(int request_id) OVERRIDE { | 88 virtual void OnDeviceOpenFailed(int request_id) override { |
89 request_id_ = request_id; | 89 request_id_ = request_id; |
90 } | 90 } |
91 | 91 |
92 void ResetStoredParameters() { | 92 void ResetStoredParameters() { |
93 request_id_ = -1; | 93 request_id_ = -1; |
94 label_ = ""; | 94 label_ = ""; |
95 device_stopped_label_ = ""; | 95 device_stopped_label_ = ""; |
96 audio_device_ = StreamDeviceInfo(); | 96 audio_device_ = StreamDeviceInfo(); |
97 video_device_ = StreamDeviceInfo(); | 97 video_device_ = StreamDeviceInfo(); |
98 } | 98 } |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 // Ducking should still be reported as not active. | 465 // Ducking should still be reported as not active. |
466 EXPECT_FALSE(dispatcher->IsAudioDuckingActive()); | 466 EXPECT_FALSE(dispatcher->IsAudioDuckingActive()); |
467 | 467 |
468 // Stop the device (removes the stream). | 468 // Stop the device (removes the stream). |
469 dispatcher->OnMessageReceived( | 469 dispatcher->OnMessageReceived( |
470 MediaStreamMsg_DeviceStopped(kRouteId, kStreamLabel, | 470 MediaStreamMsg_DeviceStopped(kRouteId, kStreamLabel, |
471 handler->audio_device_)); | 471 handler->audio_device_)); |
472 } | 472 } |
473 | 473 |
474 } // namespace content | 474 } // namespace content |
OLD | NEW |