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

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