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

Side by Side Diff: chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc

Issue 247723006: Add HD browser test to WebRTC suite. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/media/webrtc_browsertest_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/command_line.h"
6 #include "base/environment.h" 6 #include "base/environment.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/process/launch.h" 9 #include "base/process/launch.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 static const base::FilePath::CharType kArgbToI420ConverterExecutable[] = 47 static const base::FilePath::CharType kArgbToI420ConverterExecutable[] =
48 #if defined(OS_WIN) 48 #if defined(OS_WIN)
49 FILE_PATH_LITERAL("rgba_to_i420_converter.exe"); 49 FILE_PATH_LITERAL("rgba_to_i420_converter.exe");
50 #else 50 #else
51 FILE_PATH_LITERAL("rgba_to_i420_converter"); 51 FILE_PATH_LITERAL("rgba_to_i420_converter");
52 #endif 52 #endif
53 53
54 static const char kHomeEnvName[] = 54 static const char kHomeEnvName[] =
55 #if defined(OS_WIN) 55 #if defined(OS_WIN)
56 "HOMEPATH"; 56 "USERPROFILE";
kjellander_chromium 2014/04/28 06:03:52 This will make it possible to support the Chromium
57 #else 57 #else
58 "HOME"; 58 "HOME";
59 #endif 59 #endif
60 60
61 // The working dir should be in the user's home folder. 61 // The working dir should be in the user's home folder.
62 static const base::FilePath::CharType kWorkingDirName[] = 62 static const base::FilePath::CharType kWorkingDirName[] =
63 FILE_PATH_LITERAL("webrtc_video_quality"); 63 FILE_PATH_LITERAL("webrtc_video_quality");
64 static const base::FilePath::CharType kCapturedYuvFileName[] = 64 static const base::FilePath::CharType kCapturedYuvFileName[] =
65 FILE_PATH_LITERAL("captured_video.yuv"); 65 FILE_PATH_LITERAL("captured_video.yuv");
66 static const base::FilePath::CharType kStatsFileName[] = 66 static const base::FilePath::CharType kStatsFileName[] =
67 FILE_PATH_LITERAL("stats.txt"); 67 FILE_PATH_LITERAL("stats.txt");
68 static const char kMainWebrtcTestHtmlPage[] = 68 static const char kMainWebrtcTestHtmlPage[] =
69 "/webrtc/webrtc_jsep01_test.html"; 69 "/webrtc/webrtc_jsep01_test.html";
70 static const char kCapturingWebrtcHtmlPage[] =
71 "/webrtc/webrtc_video_quality_test.html";
72 static const int k360pWidth = 640;
73 static const int k360pHeight = 360;
74 70
75 // If you change the port number, don't forget to modify video_extraction.js 71 // If you change the port number, don't forget to modify video_extraction.js
76 // too! 72 // too!
77 static const char kPyWebSocketPortNumber[] = "12221"; 73 static const char kPyWebSocketPortNumber[] = "12221";
78 74
75 // Configuration object containing: test_name, width, height, capture_page,
76 // reference_video, test_constraints.
77 typedef std::tr1::tuple<const char*, int, int, const char*,
78 const base::FilePath::CharType*, const char*> TestConfig;
79
80 static const TestConfig k360pConfig(
81 "360p", 640, 360,
82 "/webrtc/webrtc_video_quality_test.html",
83 test::kReferenceFileName360p,
84 WebRtcTestBase::kAudioVideoCallConstraints360p);
85 static const TestConfig k720pConfig(
86 "720p", 1280, 720,
87 "/webrtc/webrtc_video_quality_test_hd.html",
88 test::kReferenceFileName720p,
89 WebRtcTestBase::kAudioVideoCallConstraints720p);
90
79 // Test the video quality of the WebRTC output. 91 // Test the video quality of the WebRTC output.
80 // 92 //
81 // Prerequisites: This test case must run on a machine with a chrome playing 93 // Prerequisites: This test case must run on a machine with a chrome playing
82 // the video from the reference files located in GetReferenceFilesDir(). 94 // the video from the reference files located in GetReferenceFilesDir().
83 // The file kReferenceY4mFileName.kY4mFileExtension is played using a 95 // The file kReferenceY4mFileName.kY4mFileExtension is played using a
84 // FileVideoCaptureDevice and its sibling with kYuvFileExtension is used for 96 // FileVideoCaptureDevice and its sibling with kYuvFileExtension is used for
85 // comparison. 97 // comparison.
86 // 98 //
87 // You must also compile the chromium_builder_webrtc target before you run this 99 // You must also compile the chromium_builder_webrtc target before you run this
88 // test to get all the tools built. 100 // test to get all the tools built.
89 // 101 //
90 // The external compare_videos.py script also depends on two external 102 // The external compare_videos.py script also depends on two external
91 // executables which must be located in the PATH when running this test. 103 // executables which must be located in the PATH when running this test.
92 // * zxing (see the CPP version at https://code.google.com/p/zxing) 104 // * zxing (see the CPP version at https://code.google.com/p/zxing)
93 // * ffmpeg 0.11.1 or compatible version (see http://www.ffmpeg.org) 105 // * ffmpeg 0.11.1 or compatible version (see http://www.ffmpeg.org)
94 // 106 //
95 // The test case will launch a custom binary (peerconnection_server) which will 107 // The test case will launch a custom binary (peerconnection_server) which will
96 // allow two WebRTC clients to find each other. 108 // allow two WebRTC clients to find each other.
97 // 109 //
98 // The test also runs several other custom binaries - rgba_to_i420 converter and 110 // The test also runs several other custom binaries - rgba_to_i420 converter and
99 // frame_analyzer. Both tools can be found under third_party/webrtc/tools. The 111 // frame_analyzer. Both tools can be found under third_party/webrtc/tools. The
100 // test also runs a stand alone Python implementation of a WebSocket server 112 // test also runs a stand alone Python implementation of a WebSocket server
101 // (pywebsocket) and a barcode_decoder script. 113 // (pywebsocket) and a barcode_decoder script.
102 class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { 114 class WebRtcVideoQualityBrowserTest : public WebRtcTestBase,
115 public testing::WithParamInterface<TestConfig> {
103 public: 116 public:
104 WebRtcVideoQualityBrowserTest() 117 WebRtcVideoQualityBrowserTest()
105 : pywebsocket_server_(0), 118 : test_name_(std::tr1::get<0>(GetParam())),
119 width_(std::tr1::get<1>(GetParam())),
120 height_(std::tr1::get<2>(GetParam())),
121 capture_page_(std::tr1::get<3>(GetParam())),
122 reference_video_(std::tr1::get<4>(GetParam())),
123 test_constraints_(std::tr1::get<5>(GetParam())),
124 pywebsocket_server_(0),
106 environment_(base::Environment::Create()) {} 125 environment_(base::Environment::Create()) {}
107 126
108 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 127 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
109 test::PeerConnectionServerRunner::KillAllPeerConnectionServers(); 128 test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
110 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. 129 DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
111 } 130 }
112 131
113 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 132 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
114 // Set up the command line option with the expected file name. We will check 133 // Set up the command line option with the expected file name. We will check
115 // its existence in HasAllRequiredResources(). 134 // its existence in HasAllRequiredResources().
116 webrtc_reference_video_y4m_ = test::GetReferenceFilesDir() 135 webrtc_reference_video_y4m_ = test::GetReferenceFilesDir()
117 .Append(test::kReferenceFileName360p) 136 .Append(reference_video_)
118 .AddExtension(test::kY4mFileExtension); 137 .AddExtension(test::kY4mFileExtension);
119 command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture, 138 command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture,
120 webrtc_reference_video_y4m_); 139 webrtc_reference_video_y4m_);
121 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); 140 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
122 141
123 // The video playback will not work without a GPU, so force its use here. 142 // The video playback will not work without a GPU, so force its use here.
124 command_line->AppendSwitch(switches::kUseGpuInTests); 143 command_line->AppendSwitch(switches::kUseGpuInTests);
125 } 144 }
126 145
127 bool HasAllRequiredResources() { 146 bool HasAllRequiredResources() {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 << path_to_compare_script.value(); 260 << path_to_compare_script.value();
242 return false; 261 return false;
243 } 262 }
244 263
245 // Note: don't append switches to this command since it will mess up the 264 // Note: don't append switches to this command since it will mess up the
246 // -u in the python invocation! 265 // -u in the python invocation!
247 CommandLine compare_command(CommandLine::NO_PROGRAM); 266 CommandLine compare_command(CommandLine::NO_PROGRAM);
248 EXPECT_TRUE(GetPythonCommand(&compare_command)); 267 EXPECT_TRUE(GetPythonCommand(&compare_command));
249 268
250 compare_command.AppendArgPath(path_to_compare_script); 269 compare_command.AppendArgPath(path_to_compare_script);
251 compare_command.AppendArg("--label=360p"); 270 compare_command.AppendArg(base::StringPrintf("--label=%s", test_name_));
252 compare_command.AppendArg("--ref_video"); 271 compare_command.AppendArg("--ref_video");
253 compare_command.AppendArgPath(reference_video_filename); 272 compare_command.AppendArgPath(reference_video_filename);
254 compare_command.AppendArg("--test_video"); 273 compare_command.AppendArg("--test_video");
255 compare_command.AppendArgPath(captured_video_filename); 274 compare_command.AppendArgPath(captured_video_filename);
256 compare_command.AppendArg("--frame_analyzer"); 275 compare_command.AppendArg("--frame_analyzer");
257 compare_command.AppendArgPath(path_to_analyzer); 276 compare_command.AppendArgPath(path_to_analyzer);
258 compare_command.AppendArg("--yuv_frame_width"); 277 compare_command.AppendArg("--yuv_frame_width");
259 compare_command.AppendArg(base::StringPrintf("%d", width)); 278 compare_command.AppendArg(base::StringPrintf("%d", width));
260 compare_command.AppendArg("--yuv_frame_height"); 279 compare_command.AppendArg("--yuv_frame_height");
261 compare_command.AppendArg(base::StringPrintf("%d", height)); 280 compare_command.AppendArg(base::StringPrintf("%d", height));
(...skipping 10 matching lines...) Expand all
272 } 291 }
273 292
274 base::FilePath GetWorkingDir() { 293 base::FilePath GetWorkingDir() {
275 std::string home_dir; 294 std::string home_dir;
276 environment_->GetVar(kHomeEnvName, &home_dir); 295 environment_->GetVar(kHomeEnvName, &home_dir);
277 base::FilePath::StringType native_home_dir(home_dir.begin(), 296 base::FilePath::StringType native_home_dir(home_dir.begin(),
278 home_dir.end()); 297 home_dir.end());
279 return base::FilePath(native_home_dir).Append(kWorkingDirName); 298 return base::FilePath(native_home_dir).Append(kWorkingDirName);
280 } 299 }
281 300
301 protected:
302 const char* test_name_;
303 int width_;
304 int height_;
305 const char* capture_page_;
306 const base::FilePath::CharType* reference_video_;
307 const char* test_constraints_;
282 test::PeerConnectionServerRunner peerconnection_server_; 308 test::PeerConnectionServerRunner peerconnection_server_;
283 309
284 private: 310 private:
285 base::FilePath GetSourceDir() { 311 base::FilePath GetSourceDir() {
286 base::FilePath source_dir; 312 base::FilePath source_dir;
287 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); 313 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir);
288 return source_dir; 314 return source_dir;
289 } 315 }
290 316
291 base::FilePath GetBrowserDir() { 317 base::FilePath GetBrowserDir() {
292 base::FilePath browser_dir; 318 base::FilePath browser_dir;
293 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &browser_dir)); 319 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &browser_dir));
294 return browser_dir; 320 return browser_dir;
295 } 321 }
296 322
297 base::ProcessHandle pywebsocket_server_; 323 base::ProcessHandle pywebsocket_server_;
298 scoped_ptr<base::Environment> environment_; 324 scoped_ptr<base::Environment> environment_;
299 base::FilePath webrtc_reference_video_y4m_; 325 base::FilePath webrtc_reference_video_y4m_;
300 }; 326 };
301 327
302 IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest, 328 static const TestConfig kVideoConfigurations[] = { k360pConfig, k720pConfig };
303 MANUAL_TestVGAVideoQuality) { 329 INSTANTIATE_TEST_CASE_P(
330 WebRtcVideoQualityBrowserTests,
331 WebRtcVideoQualityBrowserTest,
332 testing::ValuesIn(kVideoConfigurations));
333
334 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest,
335 MANUAL_TestVideoQuality) {
336
304 #if defined(OS_WIN) 337 #if defined(OS_WIN)
305 // Fails on XP. http://crbug.com/353078 338 // Fails on XP. http://crbug.com/353078
306 if (base::win::GetVersion() <= base::win::VERSION_XP) 339 if (base::win::GetVersion() <= base::win::VERSION_XP)
307 return; 340 return;
308 #endif 341 #endif
309 342
310 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150) << 343 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150) <<
311 "This is a long-running test; you must specify " 344 "This is a long-running test; you must specify "
312 "--ui-test-action-max-timeout to have a value of at least 150000."; 345 "--ui-test-action-max-timeout to have a value of at least 150000.";
313
314 ASSERT_TRUE(HasAllRequiredResources()); 346 ASSERT_TRUE(HasAllRequiredResources());
315 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 347 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
316 ASSERT_TRUE(StartPyWebSocketServer()); 348 ASSERT_TRUE(StartPyWebSocketServer());
317 ASSERT_TRUE(peerconnection_server_.Start()); 349 ASSERT_TRUE(peerconnection_server_.Start());
318 350
319 content::WebContents* left_tab = 351 content::WebContents* left_tab =
320 OpenPageAndGetUserMediaInNewTabWithConstraints( 352 OpenPageAndGetUserMediaInNewTabWithConstraints(
321 embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage), 353 embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage),
322 kAudioVideoCallConstraints360p); 354 test_constraints_);
323 content::WebContents* right_tab = 355 content::WebContents* right_tab =
324 OpenPageAndGetUserMediaInNewTabWithConstraints( 356 OpenPageAndGetUserMediaInNewTabWithConstraints(
325 embedded_test_server()->GetURL(kCapturingWebrtcHtmlPage), 357 embedded_test_server()->GetURL(capture_page_),
326 kAudioVideoCallConstraints360p); 358 test_constraints_);
327 359
328 EstablishCall(left_tab, right_tab); 360 EstablishCall(left_tab, right_tab);
329 361
330 // Poll slower here to avoid flooding the log with messages: capturing and 362 // Poll slower here to avoid flooding the log with messages: capturing and
331 // sending frames take quite a bit of time. 363 // sending frames take quite a bit of time.
332 int polling_interval_msec = 1000; 364 int polling_interval_msec = 1000;
333 365
334 EXPECT_TRUE(test::PollingWaitUntil( 366 EXPECT_TRUE(test::PollingWaitUntil(
335 "doneFrameCapturing()", "done-capturing", right_tab, 367 "doneFrameCapturing()", "done-capturing", right_tab,
336 polling_interval_msec)); 368 polling_interval_msec));
337 369
338 HangUp(left_tab); 370 HangUp(left_tab);
339 WaitUntilHangupVerified(left_tab); 371 WaitUntilHangupVerified(left_tab);
340 WaitUntilHangupVerified(right_tab); 372 WaitUntilHangupVerified(right_tab);
341 373
342 EXPECT_TRUE(test::PollingWaitUntil( 374 EXPECT_TRUE(test::PollingWaitUntil(
343 "haveMoreFramesToSend()", "no-more-frames", right_tab, 375 "haveMoreFramesToSend()", "no-more-frames", right_tab,
344 polling_interval_msec)); 376 polling_interval_msec));
345 377
346 // Shut everything down to avoid having the javascript race with the analysis 378 // Shut everything down to avoid having the javascript race with the analysis
347 // tools. For instance, dont have console log printouts interleave with the 379 // tools. For instance, dont have console log printouts interleave with the
348 // RESULT lines from the analysis tools (crbug.com/323200). 380 // RESULT lines from the analysis tools (crbug.com/323200).
349 ASSERT_TRUE(peerconnection_server_.Stop()); 381 ASSERT_TRUE(peerconnection_server_.Stop());
350 ASSERT_TRUE(ShutdownPyWebSocketServer()); 382 ASSERT_TRUE(ShutdownPyWebSocketServer());
351 383
352 chrome::CloseWebContents(browser(), left_tab, false); 384 chrome::CloseWebContents(browser(), left_tab, false);
353 chrome::CloseWebContents(browser(), right_tab, false); 385 chrome::CloseWebContents(browser(), right_tab, false);
354 386
355 RunARGBtoI420Converter( 387 RunARGBtoI420Converter(
356 k360pWidth, k360pHeight, GetWorkingDir().Append(kCapturedYuvFileName)); 388 width_, height_, GetWorkingDir().Append(kCapturedYuvFileName));
357 ASSERT_TRUE(CompareVideosAndPrintResult( 389 ASSERT_TRUE(CompareVideosAndPrintResult(
358 k360pWidth, 390 width_,
359 k360pHeight, 391 height_,
360 GetWorkingDir().Append(kCapturedYuvFileName), 392 GetWorkingDir().Append(kCapturedYuvFileName),
361 test::GetReferenceFilesDir() 393 test::GetReferenceFilesDir()
362 .Append(test::kReferenceFileName360p) 394 .Append(reference_video_)
363 .AddExtension(test::kYuvFileExtension), 395 .AddExtension(test::kYuvFileExtension),
364 GetWorkingDir().Append(kStatsFileName))); 396 GetWorkingDir().Append(kStatsFileName)));
365 } 397 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/webrtc_browsertest_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698