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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome/test/base/in_process_browser_test.h" | 30 #include "chrome/test/base/in_process_browser_test.h" |
31 #include "components/infobars/core/infobar.h" | 31 #include "components/infobars/core/infobar.h" |
32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
33 #include "content/public/test/browser_test_utils.h" | 33 #include "content/public/test/browser_test_utils.h" |
34 #include "media/base/media_switches.h" | 34 #include "media/base/media_switches.h" |
35 #include "net/test/embedded_test_server/embedded_test_server.h" | 35 #include "net/test/embedded_test_server/embedded_test_server.h" |
36 #include "net/test/python_utils.h" | 36 #include "net/test/python_utils.h" |
37 #include "testing/perf/perf_test.h" | 37 #include "testing/perf/perf_test.h" |
38 #include "ui/gl/gl_switches.h" | 38 #include "ui/gl/gl_switches.h" |
39 | 39 |
| 40 namespace { |
| 41 std::string MakeLabel(const char* test_name, const std::string& video_codec) { |
| 42 std::string codec_label = video_codec.empty() ? "" : "_" + video_codec; |
| 43 return base::StringPrintf("%s%s", test_name, codec_label.c_str()); |
| 44 } |
| 45 } // namespace |
| 46 |
40 static const base::FilePath::CharType kFrameAnalyzerExecutable[] = | 47 static const base::FilePath::CharType kFrameAnalyzerExecutable[] = |
41 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
42 FILE_PATH_LITERAL("frame_analyzer.exe"); | 49 FILE_PATH_LITERAL("frame_analyzer.exe"); |
43 #else | 50 #else |
44 FILE_PATH_LITERAL("frame_analyzer"); | 51 FILE_PATH_LITERAL("frame_analyzer"); |
45 #endif | 52 #endif |
46 | 53 |
47 static const base::FilePath::CharType kArgbToI420ConverterExecutable[] = | 54 static const base::FilePath::CharType kArgbToI420ConverterExecutable[] = |
48 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
49 FILE_PATH_LITERAL("rgba_to_i420_converter.exe"); | 56 FILE_PATH_LITERAL("rgba_to_i420_converter.exe"); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 195 |
189 // Compares the |captured_video_filename| with the |reference_video_filename|. | 196 // Compares the |captured_video_filename| with the |reference_video_filename|. |
190 // | 197 // |
191 // The barcode decoder decodes the captured video containing barcodes overlaid | 198 // The barcode decoder decodes the captured video containing barcodes overlaid |
192 // into every frame of the video (produced by rgba_to_i420_converter). It | 199 // into every frame of the video (produced by rgba_to_i420_converter). It |
193 // produces a set of PNG images and a |stats_file| that maps each captured | 200 // produces a set of PNG images and a |stats_file| that maps each captured |
194 // frame to a frame in the reference video. The frames should be of size | 201 // frame to a frame in the reference video. The frames should be of size |
195 // |width| x |height|. | 202 // |width| x |height|. |
196 // All measurements calculated are printed as perf parsable numbers to stdout. | 203 // All measurements calculated are printed as perf parsable numbers to stdout. |
197 bool CompareVideosAndPrintResult( | 204 bool CompareVideosAndPrintResult( |
198 const char* test_label, | 205 const std::string& test_label, |
199 int width, | 206 int width, |
200 int height, | 207 int height, |
201 const base::FilePath& captured_video_filename, | 208 const base::FilePath& captured_video_filename, |
202 const base::FilePath& reference_video_filename, | 209 const base::FilePath& reference_video_filename, |
203 const base::FilePath& stats_file) { | 210 const base::FilePath& stats_file) { |
204 | 211 |
205 base::FilePath path_to_analyzer = base::MakeAbsoluteFilePath( | 212 base::FilePath path_to_analyzer = base::MakeAbsoluteFilePath( |
206 GetBrowserDir().Append(kFrameAnalyzerExecutable)); | 213 GetBrowserDir().Append(kFrameAnalyzerExecutable)); |
207 base::FilePath path_to_compare_script = GetSourceDir().Append( | 214 base::FilePath path_to_compare_script = GetSourceDir().Append( |
208 FILE_PATH_LITERAL("third_party/webrtc/tools/compare_videos.py")); | 215 FILE_PATH_LITERAL("third_party/webrtc/tools/compare_videos.py")); |
(...skipping 20 matching lines...) Expand all Loading... |
229 LOG(ERROR) << "Missing ffmpeg: should be in " << path_to_ffmpeg.value(); | 236 LOG(ERROR) << "Missing ffmpeg: should be in " << path_to_ffmpeg.value(); |
230 return false; | 237 return false; |
231 } | 238 } |
232 | 239 |
233 // Note: don't append switches to this command since it will mess up the | 240 // Note: don't append switches to this command since it will mess up the |
234 // -u in the python invocation! | 241 // -u in the python invocation! |
235 base::CommandLine compare_command(base::CommandLine::NO_PROGRAM); | 242 base::CommandLine compare_command(base::CommandLine::NO_PROGRAM); |
236 EXPECT_TRUE(GetPythonCommand(&compare_command)); | 243 EXPECT_TRUE(GetPythonCommand(&compare_command)); |
237 | 244 |
238 compare_command.AppendArgPath(path_to_compare_script); | 245 compare_command.AppendArgPath(path_to_compare_script); |
239 compare_command.AppendArg(base::StringPrintf("--label=%s", test_label)); | 246 compare_command.AppendArg("--label=" + test_label); |
240 compare_command.AppendArg("--ref_video"); | 247 compare_command.AppendArg("--ref_video"); |
241 compare_command.AppendArgPath(reference_video_filename); | 248 compare_command.AppendArgPath(reference_video_filename); |
242 compare_command.AppendArg("--test_video"); | 249 compare_command.AppendArg("--test_video"); |
243 compare_command.AppendArgPath(captured_video_filename); | 250 compare_command.AppendArgPath(captured_video_filename); |
244 compare_command.AppendArg("--frame_analyzer"); | 251 compare_command.AppendArg("--frame_analyzer"); |
245 compare_command.AppendArgPath(path_to_analyzer); | 252 compare_command.AppendArgPath(path_to_analyzer); |
246 compare_command.AppendArg("--yuv_frame_width"); | 253 compare_command.AppendArg("--yuv_frame_width"); |
247 compare_command.AppendArg(base::IntToString(width)); | 254 compare_command.AppendArg(base::IntToString(width)); |
248 compare_command.AppendArg("--yuv_frame_height"); | 255 compare_command.AppendArg("--yuv_frame_height"); |
249 compare_command.AppendArg(base::IntToString(height)); | 256 compare_command.AppendArg(base::IntToString(height)); |
(...skipping 13 matching lines...) Expand all Loading... |
263 printf("Output was:\n\n%s\n", output.c_str()); | 270 printf("Output was:\n\n%s\n", output.c_str()); |
264 bool has_result_lines = output.find("RESULT") != std::string::npos; | 271 bool has_result_lines = output.find("RESULT") != std::string::npos; |
265 if (!ok || !has_result_lines) { | 272 if (!ok || !has_result_lines) { |
266 LOG(ERROR) << "Failed to compare videos; see output above to see what " | 273 LOG(ERROR) << "Failed to compare videos; see output above to see what " |
267 << "the error was."; | 274 << "the error was."; |
268 return false; | 275 return false; |
269 } | 276 } |
270 return true; | 277 return true; |
271 } | 278 } |
272 | 279 |
| 280 void TestVideoQuality(const std::string& video_codec) { |
| 281 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150) |
| 282 << "This is a long-running test; you must specify " |
| 283 "--ui-test-action-max-timeout to have a value of at least 150000."; |
| 284 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
| 285 ASSERT_TRUE(embedded_test_server()->Start()); |
| 286 |
| 287 content::WebContents* left_tab = |
| 288 OpenPageAndGetUserMediaInNewTabWithConstraints( |
| 289 embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage), |
| 290 test_config_.constraints); |
| 291 content::WebContents* right_tab = |
| 292 OpenPageAndGetUserMediaInNewTabWithConstraints( |
| 293 embedded_test_server()->GetURL(kCapturingWebrtcHtmlPage), |
| 294 test_config_.constraints); |
| 295 |
| 296 SetupPeerconnectionWithLocalStream(left_tab); |
| 297 SetupPeerconnectionWithLocalStream(right_tab); |
| 298 |
| 299 NegotiateCall(left_tab, right_tab, video_codec); |
| 300 |
| 301 // Poll slower here to avoid flooding the log with messages: capturing and |
| 302 // sending frames take quite a bit of time. |
| 303 int polling_interval_msec = 1000; |
| 304 |
| 305 EXPECT_TRUE(test::PollingWaitUntil("doneFrameCapturing()", "done-capturing", |
| 306 right_tab, polling_interval_msec)); |
| 307 |
| 308 HangUp(left_tab); |
| 309 |
| 310 WriteCapturedFramesToWorkingDir(right_tab); |
| 311 |
| 312 // Shut everything down to avoid having the javascript race with the |
| 313 // analysis tools. For instance, dont have console log printouts interleave |
| 314 // with the RESULT lines from the analysis tools (crbug.com/323200). |
| 315 chrome::CloseWebContents(browser(), left_tab, false); |
| 316 chrome::CloseWebContents(browser(), right_tab, false); |
| 317 |
| 318 ASSERT_TRUE( |
| 319 RunARGBtoI420Converter(test_config_.width, test_config_.height, |
| 320 GetWorkingDir().Append(kCapturedYuvFileName))); |
| 321 |
| 322 ASSERT_TRUE(CompareVideosAndPrintResult( |
| 323 MakeLabel(test_config_.test_name, video_codec), test_config_.width, |
| 324 test_config_.height, GetWorkingDir().Append(kCapturedYuvFileName), |
| 325 test::GetReferenceFilesDir() |
| 326 .Append(test_config_.reference_video) |
| 327 .AddExtension(test::kYuvFileExtension), |
| 328 GetWorkingDir().Append(kStatsFileName))); |
| 329 } |
| 330 |
273 protected: | 331 protected: |
274 VideoQualityTestConfig test_config_; | 332 VideoQualityTestConfig test_config_; |
275 | 333 |
276 base::FilePath GetWorkingDir() { | 334 base::FilePath GetWorkingDir() { return temp_working_dir_.path(); } |
277 return temp_working_dir_.path(); | |
278 } | |
279 | 335 |
280 private: | 336 private: |
281 base::FilePath GetSourceDir() { | 337 base::FilePath GetSourceDir() { |
282 base::FilePath source_dir; | 338 base::FilePath source_dir; |
283 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); | 339 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); |
284 return source_dir; | 340 return source_dir; |
285 } | 341 } |
286 | 342 |
287 base::FilePath GetBrowserDir() { | 343 base::FilePath GetBrowserDir() { |
288 base::FilePath browser_dir; | 344 base::FilePath browser_dir; |
289 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &browser_dir)); | 345 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &browser_dir)); |
290 return browser_dir; | 346 return browser_dir; |
291 } | 347 } |
292 | 348 |
293 scoped_ptr<base::Environment> environment_; | 349 scoped_ptr<base::Environment> environment_; |
294 base::FilePath webrtc_reference_video_y4m_; | 350 base::FilePath webrtc_reference_video_y4m_; |
295 base::ScopedTempDir temp_working_dir_; | 351 base::ScopedTempDir temp_working_dir_; |
296 }; | 352 }; |
297 | 353 |
298 INSTANTIATE_TEST_CASE_P( | 354 INSTANTIATE_TEST_CASE_P( |
299 WebRtcVideoQualityBrowserTests, | 355 WebRtcVideoQualityBrowserTests, |
300 WebRtcVideoQualityBrowserTest, | 356 WebRtcVideoQualityBrowserTest, |
301 testing::ValuesIn(kVideoConfigurations)); | 357 testing::ValuesIn(kVideoConfigurations)); |
302 | 358 |
| 359 // The video codec name is now appended to the test label (e.g. '720p_VP8'). |
| 360 // TODO(asapersson): Keep test below using the default video codec (which do |
| 361 // not have the codec name appended ('720p')) until new tests have been |
| 362 // running for some time. |
303 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest, | 363 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest, |
304 MANUAL_TestVideoQuality) { | 364 MANUAL_TestVideoQualityDefault) { |
305 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150) << | 365 TestVideoQuality(""); |
306 "This is a long-running test; you must specify " | 366 } |
307 "--ui-test-action-max-timeout to have a value of at least 150000."; | |
308 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | |
309 ASSERT_TRUE(embedded_test_server()->Start()); | |
310 | 367 |
311 content::WebContents* left_tab = | 368 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest, |
312 OpenPageAndGetUserMediaInNewTabWithConstraints( | 369 MANUAL_TestVideoQualityVp8) { |
313 embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage), | 370 TestVideoQuality("VP8"); |
314 test_config_.constraints); | 371 } |
315 content::WebContents* right_tab = | |
316 OpenPageAndGetUserMediaInNewTabWithConstraints( | |
317 embedded_test_server()->GetURL(kCapturingWebrtcHtmlPage), | |
318 test_config_.constraints); | |
319 | 372 |
320 SetupPeerconnectionWithLocalStream(left_tab); | 373 IN_PROC_BROWSER_TEST_P(WebRtcVideoQualityBrowserTest, |
321 SetupPeerconnectionWithLocalStream(right_tab); | 374 MANUAL_TestVideoQualityVp9) { |
322 | 375 TestVideoQuality("VP9"); |
323 NegotiateCall(left_tab, right_tab); | |
324 | |
325 // Poll slower here to avoid flooding the log with messages: capturing and | |
326 // sending frames take quite a bit of time. | |
327 int polling_interval_msec = 1000; | |
328 | |
329 EXPECT_TRUE(test::PollingWaitUntil( | |
330 "doneFrameCapturing()", "done-capturing", right_tab, | |
331 polling_interval_msec)); | |
332 | |
333 HangUp(left_tab); | |
334 | |
335 WriteCapturedFramesToWorkingDir(right_tab); | |
336 | |
337 // Shut everything down to avoid having the javascript race with the analysis | |
338 // tools. For instance, dont have console log printouts interleave with the | |
339 // RESULT lines from the analysis tools (crbug.com/323200). | |
340 chrome::CloseWebContents(browser(), left_tab, false); | |
341 chrome::CloseWebContents(browser(), right_tab, false); | |
342 | |
343 ASSERT_TRUE(RunARGBtoI420Converter( | |
344 test_config_.width, test_config_.height, | |
345 GetWorkingDir().Append(kCapturedYuvFileName))); | |
346 ASSERT_TRUE(CompareVideosAndPrintResult( | |
347 test_config_.test_name, | |
348 test_config_.width, | |
349 test_config_.height, | |
350 GetWorkingDir().Append(kCapturedYuvFileName), | |
351 test::GetReferenceFilesDir() | |
352 .Append(test_config_.reference_video) | |
353 .AddExtension(test::kYuvFileExtension), | |
354 GetWorkingDir().Append(kStatsFileName))); | |
355 } | 376 } |
OLD | NEW |