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

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

Issue 2721113002: getUserMedia: handle the device starting status report. (Closed)
Patch Set: address nits Created 3 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 "content/browser/renderer_host/media/media_stream_dispatcher_host.h" 5 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 int page_request_id, 115 int page_request_id,
116 const std::string& device_id, 116 const std::string& device_id,
117 MediaStreamType type, 117 MediaStreamType type,
118 const url::Origin& security_origin, 118 const url::Origin& security_origin,
119 const base::Closure& quit_closure) { 119 const base::Closure& quit_closure) {
120 quit_closures_.push(quit_closure); 120 quit_closures_.push(quit_closure);
121 MediaStreamDispatcherHost::OnOpenDevice( 121 MediaStreamDispatcherHost::OnOpenDevice(
122 render_frame_id, page_request_id, device_id, type, security_origin); 122 render_frame_id, page_request_id, device_id, type, security_origin);
123 } 123 }
124 124
125 void OnStreamStarted(const std::string label) {
126 MediaStreamDispatcherHost::OnStreamStarted(label);
127 }
128
125 std::string label_; 129 std::string label_;
126 StreamDeviceInfoArray audio_devices_; 130 StreamDeviceInfoArray audio_devices_;
127 StreamDeviceInfoArray video_devices_; 131 StreamDeviceInfoArray video_devices_;
128 StreamDeviceInfo opened_device_; 132 StreamDeviceInfo opened_device_;
129 133
130 private: 134 private:
131 ~MockMediaStreamDispatcherHost() override {} 135 ~MockMediaStreamDispatcherHost() override {}
132 136
133 // This method is used to dispatch IPC messages to the renderer. We intercept 137 // This method is used to dispatch IPC messages to the renderer. We intercept
134 // these messages here and dispatch to our mock methods to verify the 138 // these messages here and dispatch to our mock methods to verify the
(...skipping 22 matching lines...) Expand all
157 } 161 }
158 162
159 // These handler methods do minimal things and delegate to the mock methods. 163 // These handler methods do minimal things and delegate to the mock methods.
160 void OnStreamGeneratedInternal( 164 void OnStreamGeneratedInternal(
161 int request_id, 165 int request_id,
162 std::string label, 166 std::string label,
163 StreamDeviceInfoArray audio_device_list, 167 StreamDeviceInfoArray audio_device_list,
164 StreamDeviceInfoArray video_device_list) { 168 StreamDeviceInfoArray video_device_list) {
165 OnStreamGenerated(current_ipc_->routing_id(), request_id, 169 OnStreamGenerated(current_ipc_->routing_id(), request_id,
166 audio_device_list.size(), video_device_list.size()); 170 audio_device_list.size(), video_device_list.size());
171 // Simulate the stream started event back to host for UI testing.
172 OnStreamStarted(label);
173
167 // Notify that the event have occurred. 174 // Notify that the event have occurred.
168 base::Closure quit_closure = quit_closures_.front(); 175 base::Closure quit_closure = quit_closures_.front();
169 quit_closures_.pop(); 176 quit_closures_.pop();
170 task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure)); 177 task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&quit_closure));
171 178
172 label_ = label; 179 label_ = label;
173 audio_devices_ = audio_device_list; 180 audio_devices_ = audio_device_list;
174 video_devices_ = video_device_list; 181 video_devices_ = video_device_list;
175 } 182 }
176 183
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 base::RunLoop run_loop; 849 base::RunLoop run_loop;
843 EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId)) 850 EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId))
844 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); 851 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit));
845 media_stream_manager_->media_devices_manager()->OnDevicesChanged( 852 media_stream_manager_->media_devices_manager()->OnDevicesChanged(
846 base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE); 853 base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE);
847 854
848 run_loop.Run(); 855 run_loop.Run();
849 } 856 }
850 857
851 }; // namespace content 858 }; // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698