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/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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // comparison. | 99 // comparison. |
100 // | 100 // |
101 // You must also compile the chromium_builder_webrtc target before you run this | 101 // You must also compile the chromium_builder_webrtc target before you run this |
102 // test to get all the tools built. | 102 // test to get all the tools built. |
103 // | 103 // |
104 // The external compare_videos.py script also depends on two external | 104 // The external compare_videos.py script also depends on two external |
105 // executables which must be located in the PATH when running this test. | 105 // executables which must be located in the PATH when running this test. |
106 // * zxing (see the CPP version at https://code.google.com/p/zxing) | 106 // * zxing (see the CPP version at https://code.google.com/p/zxing) |
107 // * ffmpeg 0.11.1 or compatible version (see http://www.ffmpeg.org) | 107 // * ffmpeg 0.11.1 or compatible version (see http://www.ffmpeg.org) |
108 // | 108 // |
109 // The test case will launch a custom binary (peerconnection_server) which will | 109 // The test runs several custom binaries - rgba_to_i420 converter and |
110 // allow two WebRTC clients to find each other. | |
111 // | |
112 // The test also runs several other custom binaries - rgba_to_i420 converter and | |
113 // frame_analyzer. Both tools can be found under third_party/webrtc/tools. The | 110 // frame_analyzer. Both tools can be found under third_party/webrtc/tools. The |
114 // test also runs a stand alone Python implementation of a WebSocket server | 111 // test also runs a stand alone Python implementation of a WebSocket server |
115 // (pywebsocket) and a barcode_decoder script. | 112 // (pywebsocket) and a barcode_decoder script. |
116 class WebRtcVideoQualityBrowserTest : public WebRtcTestBase, | 113 class WebRtcVideoQualityBrowserTest : public WebRtcTestBase, |
117 public testing::WithParamInterface<VideoQualityTestConfig> { | 114 public testing::WithParamInterface<VideoQualityTestConfig> { |
118 public: | 115 public: |
119 WebRtcVideoQualityBrowserTest() | 116 WebRtcVideoQualityBrowserTest() |
120 : pywebsocket_server_(0), | 117 : pywebsocket_server_(0), |
121 environment_(base::Environment::Create()) { | 118 environment_(base::Environment::Create()) { |
122 test_config_ = GetParam(); | 119 test_config_ = GetParam(); |
123 } | 120 } |
124 | 121 |
125 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 122 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
126 test::PeerConnectionServerRunner::KillAllPeerConnectionServers(); | |
127 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 123 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
128 } | 124 } |
129 | 125 |
130 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 126 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
131 // Set up the command line option with the expected file name. We will check | 127 // Set up the command line option with the expected file name. We will check |
132 // its existence in HasAllRequiredResources(). | 128 // its existence in HasAllRequiredResources(). |
133 webrtc_reference_video_y4m_ = test::GetReferenceFilesDir() | 129 webrtc_reference_video_y4m_ = test::GetReferenceFilesDir() |
134 .Append(test_config_.reference_video) | 130 .Append(test_config_.reference_video) |
135 .AddExtension(test::kY4mFileExtension); | 131 .AddExtension(test::kY4mFileExtension); |
136 command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture, | 132 command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 287 |
292 base::FilePath GetWorkingDir() { | 288 base::FilePath GetWorkingDir() { |
293 std::string home_dir; | 289 std::string home_dir; |
294 environment_->GetVar(kHomeEnvName, &home_dir); | 290 environment_->GetVar(kHomeEnvName, &home_dir); |
295 base::FilePath::StringType native_home_dir(home_dir.begin(), | 291 base::FilePath::StringType native_home_dir(home_dir.begin(), |
296 home_dir.end()); | 292 home_dir.end()); |
297 return base::FilePath(native_home_dir).Append(kWorkingDirName); | 293 return base::FilePath(native_home_dir).Append(kWorkingDirName); |
298 } | 294 } |
299 | 295 |
300 protected: | 296 protected: |
301 test::PeerConnectionServerRunner peerconnection_server_; | |
302 VideoQualityTestConfig test_config_; | 297 VideoQualityTestConfig test_config_; |
303 | 298 |
304 private: | 299 private: |
305 base::FilePath GetSourceDir() { | 300 base::FilePath GetSourceDir() { |
306 base::FilePath source_dir; | 301 base::FilePath source_dir; |
307 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); | 302 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); |
308 return source_dir; | 303 return source_dir; |
309 } | 304 } |
310 | 305 |
311 base::FilePath GetBrowserDir() { | 306 base::FilePath GetBrowserDir() { |
(...skipping 20 matching lines...) Expand all Loading... |
332 if (base::win::GetVersion() <= base::win::VERSION_XP) | 327 if (base::win::GetVersion() <= base::win::VERSION_XP) |
333 return; | 328 return; |
334 #endif | 329 #endif |
335 | 330 |
336 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150) << | 331 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 150) << |
337 "This is a long-running test; you must specify " | 332 "This is a long-running test; you must specify " |
338 "--ui-test-action-max-timeout to have a value of at least 150000."; | 333 "--ui-test-action-max-timeout to have a value of at least 150000."; |
339 ASSERT_TRUE(HasAllRequiredResources()); | 334 ASSERT_TRUE(HasAllRequiredResources()); |
340 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 335 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
341 ASSERT_TRUE(StartPyWebSocketServer()); | 336 ASSERT_TRUE(StartPyWebSocketServer()); |
342 ASSERT_TRUE(peerconnection_server_.Start()); | |
343 | 337 |
344 content::WebContents* left_tab = | 338 content::WebContents* left_tab = |
345 OpenPageAndGetUserMediaInNewTabWithConstraints( | 339 OpenPageAndGetUserMediaInNewTabWithConstraints( |
346 embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage), | 340 embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage), |
347 test_config_.constraints); | 341 test_config_.constraints); |
348 content::WebContents* right_tab = | 342 content::WebContents* right_tab = |
349 OpenPageAndGetUserMediaInNewTabWithConstraints( | 343 OpenPageAndGetUserMediaInNewTabWithConstraints( |
350 embedded_test_server()->GetURL(test_config_.capture_page), | 344 embedded_test_server()->GetURL(test_config_.capture_page), |
351 test_config_.constraints); | 345 test_config_.constraints); |
352 | 346 |
353 EstablishCall(left_tab, right_tab); | 347 SetupPeerconnectionWithLocalStream(left_tab); |
| 348 SetupPeerconnectionWithLocalStream(right_tab); |
| 349 |
| 350 NegotiateCall(left_tab, right_tab); |
354 | 351 |
355 // Poll slower here to avoid flooding the log with messages: capturing and | 352 // Poll slower here to avoid flooding the log with messages: capturing and |
356 // sending frames take quite a bit of time. | 353 // sending frames take quite a bit of time. |
357 int polling_interval_msec = 1000; | 354 int polling_interval_msec = 1000; |
358 | 355 |
359 EXPECT_TRUE(test::PollingWaitUntil( | 356 EXPECT_TRUE(test::PollingWaitUntil( |
360 "doneFrameCapturing()", "done-capturing", right_tab, | 357 "doneFrameCapturing()", "done-capturing", right_tab, |
361 polling_interval_msec)); | 358 polling_interval_msec)); |
362 | 359 |
363 HangUp(left_tab); | 360 HangUp(left_tab); |
364 WaitUntilHangupVerified(left_tab); | |
365 WaitUntilHangupVerified(right_tab); | |
366 | 361 |
367 EXPECT_TRUE(test::PollingWaitUntil( | 362 EXPECT_TRUE(test::PollingWaitUntil( |
368 "haveMoreFramesToSend()", "no-more-frames", right_tab, | 363 "haveMoreFramesToSend()", "no-more-frames", right_tab, |
369 polling_interval_msec)); | 364 polling_interval_msec)); |
370 | 365 |
371 // Shut everything down to avoid having the javascript race with the analysis | 366 // Shut everything down to avoid having the javascript race with the analysis |
372 // tools. For instance, dont have console log printouts interleave with the | 367 // tools. For instance, dont have console log printouts interleave with the |
373 // RESULT lines from the analysis tools (crbug.com/323200). | 368 // RESULT lines from the analysis tools (crbug.com/323200). |
374 ASSERT_TRUE(peerconnection_server_.Stop()); | |
375 ASSERT_TRUE(ShutdownPyWebSocketServer()); | 369 ASSERT_TRUE(ShutdownPyWebSocketServer()); |
376 | 370 |
377 chrome::CloseWebContents(browser(), left_tab, false); | 371 chrome::CloseWebContents(browser(), left_tab, false); |
378 chrome::CloseWebContents(browser(), right_tab, false); | 372 chrome::CloseWebContents(browser(), right_tab, false); |
379 | 373 |
380 RunARGBtoI420Converter( | 374 RunARGBtoI420Converter( |
381 test_config_.width, test_config_.height, | 375 test_config_.width, test_config_.height, |
382 GetWorkingDir().Append(kCapturedYuvFileName)); | 376 GetWorkingDir().Append(kCapturedYuvFileName)); |
383 ASSERT_TRUE(CompareVideosAndPrintResult( | 377 ASSERT_TRUE(CompareVideosAndPrintResult( |
384 test_config_.test_name, | 378 test_config_.test_name, |
385 test_config_.width, | 379 test_config_.width, |
386 test_config_.height, | 380 test_config_.height, |
387 GetWorkingDir().Append(kCapturedYuvFileName), | 381 GetWorkingDir().Append(kCapturedYuvFileName), |
388 test::GetReferenceFilesDir() | 382 test::GetReferenceFilesDir() |
389 .Append(test_config_.reference_video) | 383 .Append(test_config_.reference_video) |
390 .AddExtension(test::kYuvFileExtension), | 384 .AddExtension(test::kYuvFileExtension), |
391 GetWorkingDir().Append(kStatsFileName))); | 385 GetWorkingDir().Append(kStatsFileName))); |
392 } | 386 } |
OLD | NEW |