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

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

Issue 10177008: Shift media_stream::StreamOptions to align with the new getUserMedia spec (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" 10 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 scoped_refptr<MockMediaStreamDispatcherHost> host_; 200 scoped_refptr<MockMediaStreamDispatcherHost> host_;
201 scoped_ptr<MessageLoop> message_loop_; 201 scoped_ptr<MessageLoop> message_loop_;
202 scoped_ptr<BrowserThreadImpl> ui_thread_; 202 scoped_ptr<BrowserThreadImpl> ui_thread_;
203 scoped_ptr<BrowserThreadImpl> io_thread_; 203 scoped_ptr<BrowserThreadImpl> io_thread_;
204 scoped_ptr<media::AudioManager> audio_manager_; 204 scoped_ptr<media::AudioManager> audio_manager_;
205 content::MockResourceContext resource_context_; 205 content::MockResourceContext resource_context_;
206 }; 206 };
207 207
208 TEST_F(MediaStreamDispatcherHostTest, GenerateStream) { 208 TEST_F(MediaStreamDispatcherHostTest, GenerateStream) {
209 StreamOptions options(false, StreamOptions::kFacingUser); 209 StreamOptions options(false, true);
210 210
211 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); 211 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1));
212 host_->OnGenerateStream(kPageRequestId, options); 212 host_->OnGenerateStream(kPageRequestId, options);
213 213
214 WaitForResult(); 214 WaitForResult();
215 215
216 std::string label = host_->label_; 216 std::string label = host_->label_;
217 217
218 EXPECT_EQ(host_->audio_devices_.size(), 0u); 218 EXPECT_EQ(host_->audio_devices_.size(), 0u);
219 EXPECT_EQ(host_->video_devices_.size(), 1u); 219 EXPECT_EQ(host_->video_devices_.size(), 1u);
220 EXPECT_EQ(host_->NumberOfStreams(), 1u); 220 EXPECT_EQ(host_->NumberOfStreams(), 1u);
221 221
222 host_->OnStopGeneratedStream(label); 222 host_->OnStopGeneratedStream(label);
223 EXPECT_EQ(host_->NumberOfStreams(), 0u); 223 EXPECT_EQ(host_->NumberOfStreams(), 0u);
224 } 224 }
225 225
226 TEST_F(MediaStreamDispatcherHostTest, GenerateThreeStreams) { 226 TEST_F(MediaStreamDispatcherHostTest, GenerateThreeStreams) {
227 // This test opens three video capture devices. Two fake devices exists and it 227 // This test opens three video capture devices. Two fake devices exists and it
228 // is expected the last call to |Open()| will open the first device again, but 228 // is expected the last call to |Open()| will open the first device again, but
229 // with a different label. 229 // with a different label.
230 StreamOptions options(false, StreamOptions::kFacingUser); 230 StreamOptions options(false, true);
231 231
232 // Generate first stream. 232 // Generate first stream.
233 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); 233 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1));
234 host_->OnGenerateStream(kPageRequestId, options); 234 host_->OnGenerateStream(kPageRequestId, options);
235 235
236 WaitForResult(); 236 WaitForResult();
237 237
238 // Check the latest generated stream. 238 // Check the latest generated stream.
239 EXPECT_EQ(host_->audio_devices_.size(), 0u); 239 EXPECT_EQ(host_->audio_devices_.size(), 0u);
240 EXPECT_EQ(host_->video_devices_.size(), 1u); 240 EXPECT_EQ(host_->video_devices_.size(), 1u);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // Check that we now have three opened streams. 280 // Check that we now have three opened streams.
281 EXPECT_EQ(host_->NumberOfStreams(), 3u); 281 EXPECT_EQ(host_->NumberOfStreams(), 3u);
282 282
283 host_->OnStopGeneratedStream(label1); 283 host_->OnStopGeneratedStream(label1);
284 host_->OnStopGeneratedStream(label2); 284 host_->OnStopGeneratedStream(label2);
285 host_->OnStopGeneratedStream(label3); 285 host_->OnStopGeneratedStream(label3);
286 EXPECT_EQ(host_->NumberOfStreams(), 0u); 286 EXPECT_EQ(host_->NumberOfStreams(), 0u);
287 } 287 }
288 288
289 TEST_F(MediaStreamDispatcherHostTest, FailDevice) { 289 TEST_F(MediaStreamDispatcherHostTest, FailDevice) {
290 StreamOptions options(false, StreamOptions::kFacingUser); 290 StreamOptions options(false, true);
291 291
292 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1)); 292 EXPECT_CALL(*host_, OnStreamGenerated(kRenderId, kPageRequestId, 0, 1));
293 host_->OnGenerateStream(kPageRequestId, options); 293 host_->OnGenerateStream(kPageRequestId, options);
294 WaitForResult(); 294 WaitForResult();
295 std::string label = host_->label_; 295 std::string label = host_->label_;
296 296
297 EXPECT_EQ(host_->audio_devices_.size(), 0u); 297 EXPECT_EQ(host_->audio_devices_.size(), 0u);
298 EXPECT_EQ(host_->video_devices_.size(), 1u); 298 EXPECT_EQ(host_->video_devices_.size(), 1u);
299 EXPECT_EQ(host_->NumberOfStreams(), 1u); 299 EXPECT_EQ(host_->NumberOfStreams(), 1u);
300 300
301 EXPECT_CALL(*host_, OnVideoDeviceFailed(kRenderId, 0)); 301 EXPECT_CALL(*host_, OnVideoDeviceFailed(kRenderId, 0));
302 int session_id = host_->video_devices_[0].session_id; 302 int session_id = host_->video_devices_[0].session_id;
303 MediaStreamManager::GetForResourceContext( 303 MediaStreamManager::GetForResourceContext(
304 &resource_context_, audio_manager_.get())-> 304 &resource_context_, audio_manager_.get())->
305 video_capture_manager()->Error(session_id); 305 video_capture_manager()->Error(session_id);
306 WaitForResult(); 306 WaitForResult();
307 EXPECT_EQ(host_->video_devices_.size(), 0u); 307 EXPECT_EQ(host_->video_devices_.size(), 0u);
308 EXPECT_EQ(host_->NumberOfStreams(), 1u); 308 EXPECT_EQ(host_->NumberOfStreams(), 1u);
309 309
310 // TODO(perkj): test audio device failure? 310 // TODO(perkj): test audio device failure?
311 311
312 host_->OnStopGeneratedStream(label); 312 host_->OnStopGeneratedStream(label);
313 EXPECT_EQ(host_->NumberOfStreams(), 0u); 313 EXPECT_EQ(host_->NumberOfStreams(), 0u);
314 } 314 }
315 315
316 }; // namespace media_stream 316 }; // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698