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

Side by Side Diff: content/browser/media/webrtc_getusermedia_browsertest.cc

Issue 194713010: duplicate the webrtc content_browser tests and browser tests with --enable-audio-track-processing on (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: used testing::WithParamInterface Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/command_line.h"
5 #include "base/debug/trace_event_impl.h" 6 #include "base/debug/trace_event_impl.h"
6 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
7 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
8 #include "base/test/trace_event_analyzer.h" 9 #include "base/test/trace_event_analyzer.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "content/browser/media/webrtc_internals.h" 11 #include "content/browser/media/webrtc_internals.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 12 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/public/common/content_switches.h"
12 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
14 #include "content/shell/browser/shell.h" 16 #include "content/shell/browser/shell.h"
15 #include "content/test/content_browser_test_utils.h" 17 #include "content/test/content_browser_test_utils.h"
16 #include "content/test/webrtc_content_browsertest_base.h" 18 #include "content/test/webrtc_content_browsertest_base.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h" 19 #include "net/test/embedded_test_server/embedded_test_server.h"
18 #include "testing/perf/perf_test.h" 20 #include "testing/perf/perf_test.h"
19 21
20 #if defined(OS_WIN) 22 #if defined(OS_WIN)
21 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 60
59 const std::string video_constraint = 61 const std::string video_constraint =
60 "video: {optional: [{ sourceId:\"" + video_source_id + "\"}]}"; 62 "video: {optional: [{ sourceId:\"" + video_source_id + "\"}]}";
61 return function_name + "({" + audio_constraint + video_constraint + "});"; 63 return function_name + "({" + audio_constraint + video_constraint + "});";
62 } 64 }
63 65
64 } // namespace 66 } // namespace
65 67
66 namespace content { 68 namespace content {
67 69
68 class WebRtcGetUserMediaBrowserTest: public WebRtcContentBrowserTest { 70 class WebRtcGetUserMediaBrowserTest: public WebRtcContentBrowserTest,
71 public testing::WithParamInterface<bool> {
69 public: 72 public:
70 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) {} 73 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) {
74 if (GetParam()) {
phoglund_chromium 2014/03/12 17:27:18 Same here.
no longer working on chromium 2014/03/12 18:06:08 ditto, I hope not add a SetUpCommandLine(CommandLi
75 CommandLine::ForCurrentProcess()->AppendSwitch(
76 switches::kEnableAudioTrackProcessing);
77 }
78 }
71 virtual ~WebRtcGetUserMediaBrowserTest() {} 79 virtual ~WebRtcGetUserMediaBrowserTest() {}
72 80
73 void StartTracing() { 81 void StartTracing() {
74 CHECK(trace_log_ == NULL) << "Can only can start tracing once"; 82 CHECK(trace_log_ == NULL) << "Can only can start tracing once";
75 trace_log_ = base::debug::TraceLog::GetInstance(); 83 trace_log_ = base::debug::TraceLog::GetInstance();
76 trace_log_->SetEnabled(base::debug::CategoryFilter("video"), 84 trace_log_->SetEnabled(base::debug::CategoryFilter("video"),
77 base::debug::TraceLog::RECORDING_MODE, 85 base::debug::TraceLog::RECORDING_MODE,
78 base::debug::TraceLog::ENABLE_SAMPLING); 86 base::debug::TraceLog::ENABLE_SAMPLING);
79 // Check that we are indeed recording. 87 // Check that we are indeed recording.
80 EXPECT_EQ(trace_log_->GetNumTracesRecorded(), 1); 88 EXPECT_EQ(trace_log_->GetNumTracesRecorded(), 1);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ASSERT_FALSE(audio_ids->empty()); 209 ASSERT_FALSE(audio_ids->empty());
202 ASSERT_FALSE(video_ids->empty()); 210 ASSERT_FALSE(video_ids->empty());
203 } 211 }
204 212
205 private: 213 private:
206 base::debug::TraceLog* trace_log_; 214 base::debug::TraceLog* trace_log_;
207 scoped_refptr<base::RefCountedString> recorded_trace_data_; 215 scoped_refptr<base::RefCountedString> recorded_trace_data_;
208 scoped_refptr<MessageLoopRunner> message_loop_runner_; 216 scoped_refptr<MessageLoopRunner> message_loop_runner_;
209 }; 217 };
210 218
219 static const bool kRunTestsWithFlag[] = { false, true };
220 INSTANTIATE_TEST_CASE_P(WebRtcGetUserMediaBrowserTests,
221 WebRtcGetUserMediaBrowserTest,
222 testing::ValuesIn(kRunTestsWithFlag));
223
211 // These tests will all make a getUserMedia call with different constraints and 224 // These tests will all make a getUserMedia call with different constraints and
212 // see that the success callback is called. If the error callback is called or 225 // see that the success callback is called. If the error callback is called or
213 // none of the callbacks are called the tests will simply time out and fail. 226 // none of the callbacks are called the tests will simply time out and fail.
214 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, GetVideoStreamAndStop) { 227 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, GetVideoStreamAndStop) {
215 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 228 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
216 229
217 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 230 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
218 NavigateToURL(shell(), url); 231 NavigateToURL(shell(), url);
219 232
220 ExecuteJavascriptAndWaitForOk( 233 ExecuteJavascriptAndWaitForOk(
221 base::StringPrintf("%s({video: true});", kGetUserMediaAndStop)); 234 base::StringPrintf("%s({video: true});", kGetUserMediaAndStop));
222 } 235 }
223 236
224 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 237 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest,
225 GetAudioAndVideoStreamAndStop) { 238 GetAudioAndVideoStreamAndStop) {
226 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 239 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
227 240
228 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 241 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
229 NavigateToURL(shell(), url); 242 NavigateToURL(shell(), url);
230 243
231 ExecuteJavascriptAndWaitForOk(base::StringPrintf( 244 ExecuteJavascriptAndWaitForOk(base::StringPrintf(
232 "%s({video: true, audio: true});", kGetUserMediaAndStop)); 245 "%s({video: true, audio: true});", kGetUserMediaAndStop));
233 } 246 }
234 247
235 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 248 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest,
236 GetAudioAndVideoStreamAndClone) { 249 GetAudioAndVideoStreamAndClone) {
237 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 250 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
238 251
239 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 252 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
240 NavigateToURL(shell(), url); 253 NavigateToURL(shell(), url);
241 254
242 ExecuteJavascriptAndWaitForOk("getUserMediaAndClone();"); 255 ExecuteJavascriptAndWaitForOk("getUserMediaAndClone();");
243 } 256 }
244 257
245 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 258 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest,
246 GetUserMediaWithMandatorySourceID) { 259 GetUserMediaWithMandatorySourceID) {
247 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 260 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
248 261
249 std::vector<std::string> audio_ids; 262 std::vector<std::string> audio_ids;
250 std::vector<std::string> video_ids; 263 std::vector<std::string> video_ids;
251 GetSources(&audio_ids, &video_ids); 264 GetSources(&audio_ids, &video_ids);
252 265
253 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 266 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
254 267
255 // Test all combinations of mandatory sourceID; 268 // Test all combinations of mandatory sourceID;
256 for (std::vector<std::string>::const_iterator video_it = video_ids.begin(); 269 for (std::vector<std::string>::const_iterator video_it = video_ids.begin();
257 video_it != video_ids.end(); ++video_it) { 270 video_it != video_ids.end(); ++video_it) {
258 for (std::vector<std::string>::const_iterator audio_it = audio_ids.begin(); 271 for (std::vector<std::string>::const_iterator audio_it = audio_ids.begin();
259 audio_it != audio_ids.end(); ++audio_it) { 272 audio_it != audio_ids.end(); ++audio_it) {
260 NavigateToURL(shell(), url); 273 NavigateToURL(shell(), url);
261 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult( 274 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult(
262 GenerateGetUserMediaWithMandatorySourceID( 275 GenerateGetUserMediaWithMandatorySourceID(
263 kGetUserMediaAndStop, 276 kGetUserMediaAndStop,
264 *audio_it, 277 *audio_it,
265 *video_it))); 278 *video_it)));
266 } 279 }
267 } 280 }
268 } 281 }
269 282
270 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 283 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest,
271 GetUserMediaWithInvalidMandatorySourceID) { 284 GetUserMediaWithInvalidMandatorySourceID) {
272 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 285 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
273 286
274 std::vector<std::string> audio_ids; 287 std::vector<std::string> audio_ids;
275 std::vector<std::string> video_ids; 288 std::vector<std::string> video_ids;
276 GetSources(&audio_ids, &video_ids); 289 GetSources(&audio_ids, &video_ids);
277 290
278 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 291 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
279 292
280 // Test with invalid mandatory audio sourceID. 293 // Test with invalid mandatory audio sourceID.
(...skipping 12 matching lines...) Expand all
293 "something invalid")); 306 "something invalid"));
294 307
295 // Test with empty mandatory audio sourceID. 308 // Test with empty mandatory audio sourceID.
296 ExecuteJavascriptAndWaitForOk( 309 ExecuteJavascriptAndWaitForOk(
297 GenerateGetUserMediaWithMandatorySourceID( 310 GenerateGetUserMediaWithMandatorySourceID(
298 kGetUserMediaAndExpectFailure, 311 kGetUserMediaAndExpectFailure,
299 "", 312 "",
300 video_ids[0])); 313 video_ids[0]));
301 } 314 }
302 315
303 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 316 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest,
304 GetUserMediaWithInvalidOptionalSourceID) { 317 GetUserMediaWithInvalidOptionalSourceID) {
305 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 318 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
306 319
307 std::vector<std::string> audio_ids; 320 std::vector<std::string> audio_ids;
308 std::vector<std::string> video_ids; 321 std::vector<std::string> video_ids;
309 GetSources(&audio_ids, &video_ids); 322 GetSources(&audio_ids, &video_ids);
310 323
311 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 324 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
312 325
313 // Test with invalid optional audio sourceID. 326 // Test with invalid optional audio sourceID.
(...skipping 12 matching lines...) Expand all
326 "something invalid"))); 339 "something invalid")));
327 340
328 // Test with empty optional audio sourceID. 341 // Test with empty optional audio sourceID.
329 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult( 342 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult(
330 GenerateGetUserMediaWithOptionalSourceID( 343 GenerateGetUserMediaWithOptionalSourceID(
331 kGetUserMediaAndStop, 344 kGetUserMediaAndStop,
332 "", 345 "",
333 video_ids[0]))); 346 video_ids[0])));
334 } 347 }
335 348
336 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, TwoGetUserMediaAndStop) { 349 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, TwoGetUserMediaAndStop) {
337 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 350 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
338 351
339 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 352 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
340 NavigateToURL(shell(), url); 353 NavigateToURL(shell(), url);
341 354
342 ExecuteJavascriptAndWaitForOk( 355 ExecuteJavascriptAndWaitForOk(
343 "twoGetUserMediaAndStop({video: true, audio: true});"); 356 "twoGetUserMediaAndStop({video: true, audio: true});");
344 } 357 }
345 358
346 // This test will make a simple getUserMedia page, verify that video is playing 359 // This test will make a simple getUserMedia page, verify that video is playing
347 // in a simple local <video>, and for a couple of seconds, collect some 360 // in a simple local <video>, and for a couple of seconds, collect some
348 // performance traces from VideoCaptureController colorspace conversion and 361 // performance traces from VideoCaptureController colorspace conversion and
349 // potential resizing. 362 // potential resizing.
350 IN_PROC_BROWSER_TEST_F( 363 IN_PROC_BROWSER_TEST_P(
351 WebRtcGetUserMediaBrowserTest, 364 WebRtcGetUserMediaBrowserTest,
352 TraceVideoCaptureControllerPerformanceDuringGetUserMedia) { 365 TraceVideoCaptureControllerPerformanceDuringGetUserMedia) {
353 RunGetUserMediaAndCollectMeasures( 366 RunGetUserMediaAndCollectMeasures(
354 10, 367 10,
355 "VideoCaptureController::OnIncomingCapturedData", 368 "VideoCaptureController::OnIncomingCapturedData",
356 "VideoCaptureController"); 369 "VideoCaptureController");
357 } 370 }
358 371
359 // This test calls getUserMedia and checks for aspect ratio behavior. 372 // This test calls getUserMedia and checks for aspect ratio behavior.
360 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 373 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest,
361 TestGetUserMediaAspectRatio4To3) { 374 TestGetUserMediaAspectRatio4To3) {
362 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 375 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
363 376
364 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 377 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
365 378
366 std::string constraints_4_3 = GenerateGetUserMediaCall( 379 std::string constraints_4_3 = GenerateGetUserMediaCall(
367 kGetUserMediaAndAnalyseAndStop, 640, 640, 480, 480, 30, 30); 380 kGetUserMediaAndAnalyseAndStop, 640, 640, 480, 480, 30, 30);
368 381
369 // TODO(mcasas): add more aspect ratios, in particular 16:10 crbug.com/275594. 382 // TODO(mcasas): add more aspect ratios, in particular 16:10 crbug.com/275594.
370 383
371 NavigateToURL(shell(), url); 384 NavigateToURL(shell(), url);
372 ASSERT_EQ("4:3 letterbox", 385 ASSERT_EQ("4:3 letterbox",
373 ExecuteJavascriptAndReturnResult(constraints_4_3)); 386 ExecuteJavascriptAndReturnResult(constraints_4_3));
374 } 387 }
375 388
376 // This test calls getUserMedia and checks for aspect ratio behavior. 389 // This test calls getUserMedia and checks for aspect ratio behavior.
377 // TODO(perkj): Enable this test as soon as crbug/349450 is fixed. 390 // TODO(perkj): Enable this test as soon as crbug/349450 is fixed.
378 // Currently the render pipeline doesn't support cropping where the new cropped 391 // Currently the render pipeline doesn't support cropping where the new cropped
379 // frame doesn't have the same top left coordinates as the original frame. 392 // frame doesn't have the same top left coordinates as the original frame.
380 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, 393 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest,
381 DISABLED_TestGetUserMediaAspectRatio16To9) { 394 DISABLED_TestGetUserMediaAspectRatio16To9) {
382 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 395 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
383 396
384 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); 397 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
385 398
386 std::string constraints_16_9 = GenerateGetUserMediaCall( 399 std::string constraints_16_9 = GenerateGetUserMediaCall(
387 kGetUserMediaAndAnalyseAndStop, 640, 640, 360, 360, 30, 30); 400 kGetUserMediaAndAnalyseAndStop, 640, 640, 360, 360, 30, 30);
388 401
389 NavigateToURL(shell(), url); 402 NavigateToURL(shell(), url);
390 ASSERT_EQ("16:9 letterbox", 403 ASSERT_EQ("16:9 letterbox",
391 ExecuteJavascriptAndReturnResult(constraints_16_9)); 404 ExecuteJavascriptAndReturnResult(constraints_16_9));
392 } 405 }
393 406
394 namespace { 407 namespace {
395 408
396 struct UserMediaSizes { 409 struct UserMediaSizes {
397 int min_width; 410 int min_width;
398 int max_width; 411 int max_width;
399 int min_height; 412 int min_height;
400 int max_height; 413 int max_height;
401 int min_frame_rate; 414 int min_frame_rate;
402 int max_frame_rate; 415 int max_frame_rate;
403 }; 416 };
404 417
405 } // namespace 418 } // namespace
406 419
407 class WebRtcConstraintsBrowserTest 420 class WebRtcConstraintsBrowserTest
408 : public WebRtcGetUserMediaBrowserTest, 421 : public WebRtcContentBrowserTest,
409 public testing::WithParamInterface<UserMediaSizes> { 422 public testing::WithParamInterface<UserMediaSizes> {
410 public: 423 public:
411 WebRtcConstraintsBrowserTest() : user_media_(GetParam()) {} 424 WebRtcConstraintsBrowserTest() : user_media_(GetParam()) {}
412 const UserMediaSizes& user_media() const { return user_media_; } 425 const UserMediaSizes& user_media() const { return user_media_; }
413 426
414 private: 427 private:
415 UserMediaSizes user_media_; 428 UserMediaSizes user_media_;
416 }; 429 };
417 430
418 // This test calls getUserMedia in sequence with different constraints. 431 // This test calls getUserMedia in sequence with different constraints.
(...skipping 21 matching lines...) Expand all
440 {640, 640, 480, 480, 30, 30}, 453 {640, 640, 480, 480, 30, 30},
441 {960, 960, 720, 720, 30, 30}, 454 {960, 960, 720, 720, 30, 30},
442 {1280, 1280, 720, 720, 30, 30}, 455 {1280, 1280, 720, 720, 30, 30},
443 {1920, 1920, 1080, 1080, 30, 30}}; 456 {1920, 1920, 1080, 1080, 30, 30}};
444 457
445 INSTANTIATE_TEST_CASE_P(UserMedia, 458 INSTANTIATE_TEST_CASE_P(UserMedia,
446 WebRtcConstraintsBrowserTest, 459 WebRtcConstraintsBrowserTest,
447 testing::ValuesIn(kAllUserMediaSizes)); 460 testing::ValuesIn(kAllUserMediaSizes));
448 461
449 } // namespace content 462 } // namespace content
OLDNEW
« content/browser/media/webrtc_browsertest.cc ('K') | « content/browser/media/webrtc_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698