| OLD | NEW |
| 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/environment.h" | 5 #include "base/environment.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 WebrtcVideoQualityBrowserTest() | 102 WebrtcVideoQualityBrowserTest() |
| 103 : peerconnection_server_(0), | 103 : peerconnection_server_(0), |
| 104 pywebsocket_server_(0), | 104 pywebsocket_server_(0), |
| 105 environment_(base::Environment::Create()) {} | 105 environment_(base::Environment::Create()) {} |
| 106 | 106 |
| 107 virtual void SetUp() OVERRIDE { | 107 virtual void SetUp() OVERRIDE { |
| 108 RunPeerConnectionServer(); | 108 RunPeerConnectionServer(); |
| 109 InProcessBrowserTest::SetUp(); | 109 InProcessBrowserTest::SetUp(); |
| 110 | 110 |
| 111 // Ensure we have the stuff we need. | 111 // Ensure we have the stuff we need. |
| 112 EXPECT_TRUE(file_util::PathExists(GetWorkingDir())) | 112 EXPECT_TRUE(base::PathExists(GetWorkingDir())) |
| 113 << "Cannot find the working directory for the reference video and " | 113 << "Cannot find the working directory for the reference video and " |
| 114 "the temporary files:" << GetWorkingDir().value(); | 114 "the temporary files:" << GetWorkingDir().value(); |
| 115 base::FilePath reference_file = | 115 base::FilePath reference_file = |
| 116 GetWorkingDir().Append(kReferenceYuvFileName); | 116 GetWorkingDir().Append(kReferenceYuvFileName); |
| 117 EXPECT_TRUE(file_util::PathExists(reference_file)) | 117 EXPECT_TRUE(base::PathExists(reference_file)) |
| 118 << "Cannot find the reference file to be used for video quality " | 118 << "Cannot find the reference file to be used for video quality " |
| 119 << "comparison: " << reference_file.value(); | 119 << "comparison: " << reference_file.value(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 virtual void TearDown() OVERRIDE { | 122 virtual void TearDown() OVERRIDE { |
| 123 ShutdownPeerConnectionServer(); | 123 ShutdownPeerConnectionServer(); |
| 124 InProcessBrowserTest::TearDown(); | 124 InProcessBrowserTest::TearDown(); |
| 125 ShutdownPyWebSocketServer(); | 125 ShutdownPyWebSocketServer(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 128 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 129 // TODO(phoglund): check that user actually has the requisite devices and | 129 // TODO(phoglund): check that user actually has the requisite devices and |
| 130 // print a nice message if not; otherwise the test just times out which can | 130 // print a nice message if not; otherwise the test just times out which can |
| 131 // be confusing. | 131 // be confusing. |
| 132 // This test expects real device handling and requires a real webcam / audio | 132 // This test expects real device handling and requires a real webcam / audio |
| 133 // device; it will not work with fake devices. | 133 // device; it will not work with fake devices. |
| 134 EXPECT_FALSE( | 134 EXPECT_FALSE( |
| 135 command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream)) | 135 command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream)) |
| 136 << "You cannot run this test with fake devices."; | 136 << "You cannot run this test with fake devices."; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void StartPyWebSocketServer() { | 139 void StartPyWebSocketServer() { |
| 140 base::FilePath path_pywebsocket_dir = | 140 base::FilePath path_pywebsocket_dir = |
| 141 GetSourceDir().Append(FILE_PATH_LITERAL("third_party/pywebsocket/src")); | 141 GetSourceDir().Append(FILE_PATH_LITERAL("third_party/pywebsocket/src")); |
| 142 base::FilePath pywebsocket_server = path_pywebsocket_dir.Append( | 142 base::FilePath pywebsocket_server = path_pywebsocket_dir.Append( |
| 143 FILE_PATH_LITERAL("mod_pywebsocket/standalone.py")); | 143 FILE_PATH_LITERAL("mod_pywebsocket/standalone.py")); |
| 144 base::FilePath path_to_data_handler = | 144 base::FilePath path_to_data_handler = |
| 145 GetSourceDir().Append(FILE_PATH_LITERAL("chrome/test/functional")); | 145 GetSourceDir().Append(FILE_PATH_LITERAL("chrome/test/functional")); |
| 146 | 146 |
| 147 EXPECT_TRUE(file_util::PathExists(pywebsocket_server)) | 147 EXPECT_TRUE(base::PathExists(pywebsocket_server)) |
| 148 << "Fatal: missing pywebsocket server."; | 148 << "Fatal: missing pywebsocket server."; |
| 149 EXPECT_TRUE(file_util::PathExists(path_to_data_handler)) | 149 EXPECT_TRUE(base::PathExists(path_to_data_handler)) |
| 150 << "Fatal: missing data handler for pywebsocket server."; | 150 << "Fatal: missing data handler for pywebsocket server."; |
| 151 | 151 |
| 152 AppendToPythonPath(path_pywebsocket_dir); | 152 AppendToPythonPath(path_pywebsocket_dir); |
| 153 CommandLine pywebsocket_command = MakePythonCommand(pywebsocket_server); | 153 CommandLine pywebsocket_command = MakePythonCommand(pywebsocket_server); |
| 154 | 154 |
| 155 // Construct the command line manually, the server doesn't support -arg=val. | 155 // Construct the command line manually, the server doesn't support -arg=val. |
| 156 pywebsocket_command.AppendArg("-p"); | 156 pywebsocket_command.AppendArg("-p"); |
| 157 pywebsocket_command.AppendArg(kPyWebSocketPortNumber); | 157 pywebsocket_command.AppendArg(kPyWebSocketPortNumber); |
| 158 pywebsocket_command.AppendArg("-d"); | 158 pywebsocket_command.AppendArg("-d"); |
| 159 pywebsocket_command.AppendArgPath(path_to_data_handler); | 159 pywebsocket_command.AppendArgPath(path_to_data_handler); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // which should contain frames of size |width| x |height|. | 270 // which should contain frames of size |width| x |height|. |
| 271 // | 271 // |
| 272 // The rgba_to_i420_converter is part of the webrtc_test_tools target which | 272 // The rgba_to_i420_converter is part of the webrtc_test_tools target which |
| 273 // should be build prior to running this test. The resulting binary should | 273 // should be build prior to running this test. The resulting binary should |
| 274 // live next to Chrome. | 274 // live next to Chrome. |
| 275 void RunARGBtoI420Converter(int width, | 275 void RunARGBtoI420Converter(int width, |
| 276 int height, | 276 int height, |
| 277 const base::FilePath& captured_video_filename) { | 277 const base::FilePath& captured_video_filename) { |
| 278 base::FilePath path_to_converter = base::MakeAbsoluteFilePath( | 278 base::FilePath path_to_converter = base::MakeAbsoluteFilePath( |
| 279 GetBrowserDir().Append(kArgbToI420ConverterExecutable)); | 279 GetBrowserDir().Append(kArgbToI420ConverterExecutable)); |
| 280 EXPECT_TRUE(file_util::PathExists(path_to_converter)) | 280 EXPECT_TRUE(base::PathExists(path_to_converter)) |
| 281 << "Missing ARGB->I420 converter: should be in " | 281 << "Missing ARGB->I420 converter: should be in " |
| 282 << path_to_converter.value(); | 282 << path_to_converter.value(); |
| 283 | 283 |
| 284 CommandLine converter_command(path_to_converter); | 284 CommandLine converter_command(path_to_converter); |
| 285 converter_command.AppendSwitchPath("--frames_dir", GetWorkingDir()); | 285 converter_command.AppendSwitchPath("--frames_dir", GetWorkingDir()); |
| 286 converter_command.AppendSwitchPath("--output_file", | 286 converter_command.AppendSwitchPath("--output_file", |
| 287 captured_video_filename); | 287 captured_video_filename); |
| 288 converter_command.AppendSwitchASCII("--width", | 288 converter_command.AppendSwitchASCII("--width", |
| 289 base::StringPrintf("%d", width)); | 289 base::StringPrintf("%d", width)); |
| 290 converter_command.AppendSwitchASCII("--height", | 290 converter_command.AppendSwitchASCII("--height", |
| (...skipping 17 matching lines...) Expand all Loading... |
| 308 std::string CompareVideos(int width, | 308 std::string CompareVideos(int width, |
| 309 int height, | 309 int height, |
| 310 const base::FilePath& captured_video_filename, | 310 const base::FilePath& captured_video_filename, |
| 311 const base::FilePath& reference_video_filename, | 311 const base::FilePath& reference_video_filename, |
| 312 const base::FilePath& stats_file) { | 312 const base::FilePath& stats_file) { |
| 313 base::FilePath path_to_analyzer = base::MakeAbsoluteFilePath( | 313 base::FilePath path_to_analyzer = base::MakeAbsoluteFilePath( |
| 314 GetBrowserDir().Append(kFrameAnalyzerExecutable)); | 314 GetBrowserDir().Append(kFrameAnalyzerExecutable)); |
| 315 base::FilePath path_to_compare_script = GetSourceDir().Append( | 315 base::FilePath path_to_compare_script = GetSourceDir().Append( |
| 316 FILE_PATH_LITERAL("third_party/webrtc/tools/compare_videos.py")); | 316 FILE_PATH_LITERAL("third_party/webrtc/tools/compare_videos.py")); |
| 317 | 317 |
| 318 EXPECT_TRUE(file_util::PathExists(path_to_analyzer)) | 318 EXPECT_TRUE(base::PathExists(path_to_analyzer)) |
| 319 << "Missing frame analyzer: should be in " << path_to_analyzer.value(); | 319 << "Missing frame analyzer: should be in " << path_to_analyzer.value(); |
| 320 EXPECT_TRUE(file_util::PathExists(path_to_compare_script)) | 320 EXPECT_TRUE(base::PathExists(path_to_compare_script)) |
| 321 << "Missing video compare script: should be in " | 321 << "Missing video compare script: should be in " |
| 322 << path_to_compare_script.value(); | 322 << path_to_compare_script.value(); |
| 323 | 323 |
| 324 CommandLine compare_command = MakePythonCommand(path_to_compare_script); | 324 CommandLine compare_command = MakePythonCommand(path_to_compare_script); |
| 325 compare_command.AppendSwitchPath("--ref_video", reference_video_filename); | 325 compare_command.AppendSwitchPath("--ref_video", reference_video_filename); |
| 326 compare_command.AppendSwitchPath("--test_video", captured_video_filename); | 326 compare_command.AppendSwitchPath("--test_video", captured_video_filename); |
| 327 compare_command.AppendSwitchPath("--frame_analyzer", path_to_analyzer); | 327 compare_command.AppendSwitchPath("--frame_analyzer", path_to_analyzer); |
| 328 compare_command.AppendSwitchASCII("--yuv_frame_width", | 328 compare_command.AppendSwitchASCII("--yuv_frame_width", |
| 329 base::StringPrintf("%d", width)); | 329 base::StringPrintf("%d", width)); |
| 330 compare_command.AppendSwitchASCII("--yuv_frame_height", | 330 compare_command.AppendSwitchASCII("--yuv_frame_height", |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 home_dir.end()); | 420 home_dir.end()); |
| 421 return base::FilePath(native_home_dir).Append(kWorkingDirName); | 421 return base::FilePath(native_home_dir).Append(kWorkingDirName); |
| 422 } | 422 } |
| 423 | 423 |
| 424 private: | 424 private: |
| 425 void RunPeerConnectionServer() { | 425 void RunPeerConnectionServer() { |
| 426 // TODO(phoglund): de-dupe later: next line differs from original. | 426 // TODO(phoglund): de-dupe later: next line differs from original. |
| 427 base::FilePath peerconnection_server = | 427 base::FilePath peerconnection_server = |
| 428 GetBrowserDir().Append(kPeerConnectionServer); | 428 GetBrowserDir().Append(kPeerConnectionServer); |
| 429 | 429 |
| 430 EXPECT_TRUE(file_util::PathExists(peerconnection_server)) | 430 EXPECT_TRUE(base::PathExists(peerconnection_server)) |
| 431 << "Missing peerconnection_server. You must build " | 431 << "Missing peerconnection_server. You must build " |
| 432 "it so it ends up next to the browser test binary."; | 432 "it so it ends up next to the browser test binary."; |
| 433 EXPECT_TRUE(base::LaunchProcess(CommandLine(peerconnection_server), | 433 EXPECT_TRUE(base::LaunchProcess(CommandLine(peerconnection_server), |
| 434 base::LaunchOptions(), | 434 base::LaunchOptions(), |
| 435 &peerconnection_server_)) | 435 &peerconnection_server_)) |
| 436 << "Failed to launch peerconnection_server."; | 436 << "Failed to launch peerconnection_server."; |
| 437 } | 437 } |
| 438 | 438 |
| 439 void ShutdownPeerConnectionServer() { | 439 void ShutdownPeerConnectionServer() { |
| 440 EXPECT_TRUE(base::KillProcess(peerconnection_server_, 0, false)) | 440 EXPECT_TRUE(base::KillProcess(peerconnection_server_, 0, false)) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 std::string output = | 518 std::string output = |
| 519 CompareVideos(kVgaWidth, | 519 CompareVideos(kVgaWidth, |
| 520 kVgaHeight, | 520 kVgaHeight, |
| 521 GetWorkingDir().Append(kCapturedYuvFileName), | 521 GetWorkingDir().Append(kCapturedYuvFileName), |
| 522 GetWorkingDir().Append(kReferenceYuvFileName), | 522 GetWorkingDir().Append(kReferenceYuvFileName), |
| 523 GetWorkingDir().Append(kStatsFileName)); | 523 GetWorkingDir().Append(kStatsFileName)); |
| 524 | 524 |
| 525 PrintFramesCountPerfResults(output); | 525 PrintFramesCountPerfResults(output); |
| 526 PrintPsnrAndSsimPerfResults(output); | 526 PrintPsnrAndSsimPerfResults(output); |
| 527 } | 527 } |
| OLD | NEW |