diff options
author | kjellander@chromium.org <kjellander@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-29 14:50:16 +0000 |
---|---|---|
committer | kjellander@chromium.org <kjellander@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-29 14:50:16 +0000 |
commit | 6a395d6c2acced22569668ea8fce3654ca1e5071 (patch) | |
tree | 344d48de0338987dfc3a336c33a140b6431ad281 | |
parent | e24667314f37afdfe103e022a1ed510e0d37d7c4 (diff) | |
download | chromium_src-6a395d6c2acced22569668ea8fce3654ca1e5071.zip chromium_src-6a395d6c2acced22569668ea8fce3654ca1e5071.tar.gz chromium_src-6a395d6c2acced22569668ea8fce3654ca1e5071.tar.bz2 |
Add HD browser test to WebRTC suite.
Uses gtest parameterization for two of the WebRTC
browser tests so they can be re-run with different
constraints (and reference files).
To run 360p only:
out/Release/browser_tests --gtest_filter=WebRtcVideoQualityBrowserTest*0 --run-manual --ui-test-action-max-timeout=300000
and 720p only:
out/Release/browser_tests --gtest_filter=WebRtcVideoQualityBrowserTest*1 --run-manual --ui-test-action-max-timeout=600000
This CL should get a follow-up after
https://codereview.chromium.org/254803002/ is landed
(then webrtc_video_quality_test_hd.html can be removed).
We also really should look into making the test more hermetic
so ffmpeg and zxing is bundled and auto-downloaded on all the
target platforms (using Google storage).
BUG=286290
TEST=locally running the test on Linux, Mac and Windows.
Review URL: https://codereview.chromium.org/247723006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266884 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 112 insertions, 24 deletions
diff --git a/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc b/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc index 32cfdd9..280a8c0 100644 --- a/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc +++ b/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc @@ -53,7 +53,7 @@ static const base::FilePath::CharType kArgbToI420ConverterExecutable[] = static const char kHomeEnvName[] = #if defined(OS_WIN) - "HOMEPATH"; + "USERPROFILE"; #else "HOME"; #endif @@ -67,15 +67,29 @@ static const base::FilePath::CharType kStatsFileName[] = FILE_PATH_LITERAL("stats.txt"); static const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html"; -static const char kCapturingWebrtcHtmlPage[] = - "/webrtc/webrtc_video_quality_test.html"; -static const int k360pWidth = 640; -static const int k360pHeight = 360; // If you change the port number, don't forget to modify video_extraction.js // too! static const char kPyWebSocketPortNumber[] = "12221"; +static const struct VideoQualityTestConfig { + const char* test_name; + int width; + int height; + const char* capture_page; + const base::FilePath::CharType* reference_video; + const char* constraints; +} kVideoConfigurations[] = { + { "360p", 640, 360, + "/webrtc/webrtc_video_quality_test.html", + test::kReferenceFileName360p, + WebRtcTestBase::kAudioVideoCallConstraints360p }, + { "720p", 1280, 720, + "/webrtc/webrtc_video_quality_test_hd.html", + test::kReferenceFileName720p, + WebRtcTestBase::kAudioVideoCallConstraints720p }, +}; + // Test the video quality of the WebRTC output. // // Prerequisites: This test case must run on a machine with a chrome playing @@ -99,11 +113,14 @@ static const char kPyWebSocketPortNumber[] = "12221"; // frame_analyzer. Both tools can be found under third_party/webrtc/tools. The // test also runs a stand alone Python implementation of a WebSocket server // (pywebsocket) and a barcode_decoder script. -class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { +class WebRtcVideoQualityBrowserTest : public WebRtcTestBase, + public testing::WithParamInterface<VideoQualityTestConfig> { public: WebRtcVideoQualityBrowserTest() : pywebsocket_server_(0), - environment_(base::Environment::Create()) {} + environment_(base::Environment::Create()) { + test_config_ = GetParam(); + } virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { test::PeerConnectionServerRunner::KillAllPeerConnectionServers(); @@ -114,7 +131,7 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { // Set up the command line option with the expected file name. We will check // its existence in HasAllRequiredResources(). webrtc_reference_video_y4m_ = test::GetReferenceFilesDir() - .Append(test::kReferenceFileName360p) + .Append(test_config_.reference_video) .AddExtension(test::kY4mFileExtension); command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture, webrtc_reference_video_y4m_); @@ -220,6 +237,7 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { // |width| x |height|. // All measurements calculated are printed as perf parsable numbers to stdout. bool CompareVideosAndPrintResult( + const char* test_label, int width, int height, const base::FilePath& captured_video_filename, @@ -248,7 +266,7 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { EXPECT_TRUE(GetPythonCommand(&compare_command)); compare_command.AppendArgPath(path_to_compare_script); - compare_command.AppendArg("--label=360p"); + compare_command.AppendArg(base::StringPrintf("--label=%s", test_label)); compare_command.AppendArg("--ref_video"); compare_command.AppendArgPath(reference_video_filename); compare_command.AppendArg("--test_video"); @@ -279,7 +297,9 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { return base::FilePath(native_home_dir).Append(kWorkingDirName); } + protected: test::PeerConnectionServerRunner peerconnection_server_; + VideoQualityTestConfig test_config_; private: base::FilePath GetSourceDir() { @@ -299,8 +319,14 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { base::FilePath webrtc_reference_video_y4m_; }; -IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest, - MANUAL_TestVGAVideoQuality) { +INSTANTIATE_TEST_CASE_P( + WebRtcVideoQualityBrowserTests, + WebRtcVideoQualityBrowserTest, + testing::ValuesIn(kVideoConfigurations)); + +IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest, + MANUAL_TestVideoQuality) { + #if defined(OS_WIN) // Fails on XP. http://crbug.com/353078 if (base::win::GetVersion() <= base::win::VERSION_XP) @@ -310,7 +336,6 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest, ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150) << "This is a long-running test; you must specify " "--ui-test-action-max-timeout to have a value of at least 150000."; - ASSERT_TRUE(HasAllRequiredResources()); ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); ASSERT_TRUE(StartPyWebSocketServer()); @@ -319,11 +344,11 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest, content::WebContents* left_tab = OpenPageAndGetUserMediaInNewTabWithConstraints( embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage), - kAudioVideoCallConstraints360p); + test_config_.constraints); content::WebContents* right_tab = OpenPageAndGetUserMediaInNewTabWithConstraints( - embedded_test_server()->GetURL(kCapturingWebrtcHtmlPage), - kAudioVideoCallConstraints360p); + embedded_test_server()->GetURL(test_config_.capture_page), + test_config_.constraints); EstablishCall(left_tab, right_tab); @@ -353,13 +378,15 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest, chrome::CloseWebContents(browser(), right_tab, false); RunARGBtoI420Converter( - k360pWidth, k360pHeight, GetWorkingDir().Append(kCapturedYuvFileName)); + test_config_.width, test_config_.height, + GetWorkingDir().Append(kCapturedYuvFileName)); ASSERT_TRUE(CompareVideosAndPrintResult( - k360pWidth, - k360pHeight, + test_config_.test_name, + test_config_.width, + test_config_.height, GetWorkingDir().Append(kCapturedYuvFileName), test::GetReferenceFilesDir() - .Append(test::kReferenceFileName360p) + .Append(test_config_.reference_video) .AddExtension(test::kYuvFileExtension), GetWorkingDir().Append(kStatsFileName))); } diff --git a/chrome/browser/media/webrtc_browsertest_base.h b/chrome/browser/media/webrtc_browsertest_base.h index bea46c7..217e5e3 100644 --- a/chrome/browser/media/webrtc_browsertest_base.h +++ b/chrome/browser/media/webrtc_browsertest_base.h @@ -21,7 +21,7 @@ class WebContents; // getUserMedia. We use inheritance here because it makes the test code look // as clean as it can be. class WebRtcTestBase : public InProcessBrowserTest { - protected: + public: // Typical constraints. static const char kAudioVideoCallConstraints[]; static const char kAudioOnlyCallConstraints[]; @@ -35,6 +35,7 @@ class WebRtcTestBase : public InProcessBrowserTest { static const char kFailedWithPermissionDeniedError[]; static const char kFailedWithPermissionDismissedError[]; + protected: WebRtcTestBase(); virtual ~WebRtcTestBase(); diff --git a/chrome/browser/media/webrtc_browsertest_common.cc b/chrome/browser/media/webrtc_browsertest_common.cc index 8eae1f8..eb2e0ce 100644 --- a/chrome/browser/media/webrtc_browsertest_common.cc +++ b/chrome/browser/media/webrtc_browsertest_common.cc @@ -23,6 +23,8 @@ const base::FilePath::CharType kReferenceFilesDirName[] = FILE_PATH_LITERAL("webrtc/resources"); const base::FilePath::CharType kReferenceFileName360p[] = FILE_PATH_LITERAL("reference_video_640x360_30fps"); +const base::FilePath::CharType kReferenceFileName720p[] = + FILE_PATH_LITERAL("reference_video_1280x720_30fps"); const base::FilePath::CharType kYuvFileExtension[] = FILE_PATH_LITERAL("yuv"); const base::FilePath::CharType kY4mFileExtension[] = FILE_PATH_LITERAL("y4m"); @@ -53,8 +55,13 @@ bool HasReferenceFilesInCheckout() { kAdviseOnGclientSolution; return false; } + return HasYuvAndY4mFile(test::kReferenceFileName360p) && + HasYuvAndY4mFile(test::kReferenceFileName720p); +} + +bool HasYuvAndY4mFile(const base::FilePath::CharType* reference_file) { base::FilePath webrtc_reference_video_yuv = GetReferenceFilesDir() - .Append(kReferenceFileName360p).AddExtension(kYuvFileExtension); + .Append(reference_file).AddExtension(kYuvFileExtension); if (!base::PathExists(webrtc_reference_video_yuv)) { LOG(ERROR) << "Missing YUV reference video to be used for quality" @@ -64,7 +71,7 @@ bool HasReferenceFilesInCheckout() { } base::FilePath webrtc_reference_video_y4m = GetReferenceFilesDir() - .Append(kReferenceFileName360p).AddExtension(kY4mFileExtension); + .Append(reference_file).AddExtension(kY4mFileExtension); if (!base::PathExists(webrtc_reference_video_y4m)) { LOG(ERROR) << "Missing Y4M reference video to be used for quality" diff --git a/chrome/browser/media/webrtc_browsertest_common.h b/chrome/browser/media/webrtc_browsertest_common.h index 12b130d..0de994d 100644 --- a/chrome/browser/media/webrtc_browsertest_common.h +++ b/chrome/browser/media/webrtc_browsertest_common.h @@ -25,10 +25,14 @@ namespace test { // these sizable reference files by default. bool HasReferenceFilesInCheckout(); +// Verifies both the YUV and Y4M version of the reference file exists. +bool HasYuvAndY4mFile(const base::FilePath::CharType* reference_file); + // Retrieves the reference files dir, to which file names can be appended. base::FilePath GetReferenceFilesDir(); extern const base::FilePath::CharType kReferenceFileName360p[]; +extern const base::FilePath::CharType kReferenceFileName720p[]; extern const base::FilePath::CharType kYuvFileExtension[]; extern const base::FilePath::CharType kY4mFileExtension[]; diff --git a/chrome/test/data/webrtc/webrtc_video_quality_test_hd.html b/chrome/test/data/webrtc/webrtc_video_quality_test_hd.html new file mode 100644 index 0000000..d6d57ea --- /dev/null +++ b/chrome/test/data/webrtc/webrtc_video_quality_test_hd.html @@ -0,0 +1,49 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> + <title>WebRTC Automated Test</title> + <script type="text/javascript" src="adapter.js"></script> + <script type="text/javascript" src="test_functions.js"></script> + <script type="text/javascript" src="message_handling.js"></script> + <script type="text/javascript" src="getusermedia.js"></script> + <script type="text/javascript" src="jsep01_call.js"></script> + <script type="text/javascript" src="video_extraction.js"></script> +</head> +<body> + <table border="0"> + <tr> + <td>Local Preview</td> + <td>Remote Video</td> + </tr> + <tr> + <td> + <video width="1280" height="720" id="local-view" + autoplay="autoplay"></video> + </td> + <td> + <!-- startFrameCapture() takes 5 parameters: + 1. width: width of the video/canvas area. + 2. height: height of the video area. + 3. canvas_height: Height of the canvas. + 4. fps: fps at which we would like to sample. + 5. duration: The duration of the capturing. --> + <video width="1280" height="720" id="remote-view" + autoplay="autoplay" onplay="startFrameCapture(1280,720,720,30,5)"> + </video> + </td> + </tr> + <tr> + <td></td> + <td> + <div id="output" style="display: inline-block; + position: relative; width: 1280; height: 720"> + <!-- Canvas height should be equal to video height if we want to + capture the whole frames. If we only want to capture the barcode, + canvas height should equal the barcode height. --> + <canvas id="remote-canvas" width="1280" height="720"></canvas> + </div> + </td> + </tr> + </table> +</body> +</html> diff --git a/chrome/test/data/webrtc/wsh/webrtc_write_wsh.py b/chrome/test/data/webrtc/wsh/webrtc_write_wsh.py index 7c1b48f..f6a2531 100644 --- a/chrome/test/data/webrtc/wsh/webrtc_write_wsh.py +++ b/chrome/test/data/webrtc/wsh/webrtc_write_wsh.py @@ -14,7 +14,7 @@ import threading _NUMBER_OF_WRITER_THREADS = 10 -_HOME_ENV_NAME = 'HOMEPATH' if 'win32' == sys.platform else 'HOME' +_HOME_ENV_NAME = 'USERPROFILE' if 'win32' == sys.platform else 'HOME' _WORKING_DIR = os.path.join(os.environ[_HOME_ENV_NAME], 'webrtc_video_quality') # I couldn't think of other way to handle this but through a global variable @@ -73,4 +73,4 @@ def start_threads(): # code of the standalone pywebsocket server. If we put this start_threads() call # inside a if __name__ == '__main__' clause it wouldn't run this code at all # (tested). -start_threads()
\ No newline at end of file +start_threads() |