| 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/launch.h" | 8 #include "base/process/launch.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" |
| 11 #include "base/test/test_timeouts.h" | 11 #include "base/test/test_timeouts.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/infobars/infobar.h" | 14 #include "chrome/browser/infobars/infobar.h" |
| 15 #include "chrome/browser/infobars/infobar_service.h" | 15 #include "chrome/browser/infobars/infobar_service.h" |
| 16 #include "chrome/browser/media/media_stream_infobar_delegate.h" | 16 #include "chrome/browser/media/media_stream_infobar_delegate.h" |
| 17 #include "chrome/browser/media/webrtc_browsertest_base.h" |
| 17 #include "chrome/browser/media/webrtc_browsertest_common.h" | 18 #include "chrome/browser/media/webrtc_browsertest_common.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "chrome/test/perf/perf_test.h" | 26 #include "chrome/test/perf/perf_test.h" |
| 26 #include "chrome/test/ui/ui_test.h" | 27 #include "chrome/test/ui/ui_test.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // * zxing (see the CPP version at https://code.google.com/p/zxing) | 92 // * zxing (see the CPP version at https://code.google.com/p/zxing) |
| 92 // * ffmpeg 0.11.1 or compatible version (see http://www.ffmpeg.org) | 93 // * ffmpeg 0.11.1 or compatible version (see http://www.ffmpeg.org) |
| 93 // | 94 // |
| 94 // The test case will launch a custom binary (peerconnection_server) which will | 95 // The test case will launch a custom binary (peerconnection_server) which will |
| 95 // allow two WebRTC clients to find each other. | 96 // allow two WebRTC clients to find each other. |
| 96 // | 97 // |
| 97 // The test also runs several other custom binaries - rgba_to_i420 converter and | 98 // The test also runs several other custom binaries - rgba_to_i420 converter and |
| 98 // frame_analyzer. Both tools can be found under third_party/webrtc/tools. The | 99 // frame_analyzer. Both tools can be found under third_party/webrtc/tools. The |
| 99 // test also runs a stand alone Python implementation of a WebSocket server | 100 // test also runs a stand alone Python implementation of a WebSocket server |
| 100 // (pywebsocket) and a barcode_decoder script. | 101 // (pywebsocket) and a barcode_decoder script. |
| 101 class WebrtcVideoQualityBrowserTest : public InProcessBrowserTest { | 102 class WebrtcVideoQualityBrowserTest : public WebRtcTestBase { |
| 102 public: | 103 public: |
| 103 WebrtcVideoQualityBrowserTest() | 104 WebrtcVideoQualityBrowserTest() |
| 104 : peerconnection_server_(0), | 105 : peerconnection_server_(0), |
| 105 pywebsocket_server_(0), | 106 pywebsocket_server_(0), |
| 106 environment_(base::Environment::Create()) {} | 107 environment_(base::Environment::Create()) {} |
| 107 | 108 |
| 108 virtual void SetUp() OVERRIDE { | 109 virtual void SetUp() OVERRIDE { |
| 109 RunPeerConnectionServer(); | 110 RunPeerConnectionServer(); |
| 110 InProcessBrowserTest::SetUp(); | 111 InProcessBrowserTest::SetUp(); |
| 111 | 112 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // Convenience method which executes the provided javascript in the context | 174 // Convenience method which executes the provided javascript in the context |
| 174 // of the provided web contents and returns what it evaluated to. | 175 // of the provided web contents and returns what it evaluated to. |
| 175 std::string ExecuteJavascript(const std::string& javascript, | 176 std::string ExecuteJavascript(const std::string& javascript, |
| 176 content::WebContents* tab_contents) { | 177 content::WebContents* tab_contents) { |
| 177 std::string result; | 178 std::string result; |
| 178 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 179 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 179 tab_contents, javascript, &result)); | 180 tab_contents, javascript, &result)); |
| 180 return result; | 181 return result; |
| 181 } | 182 } |
| 182 | 183 |
| 183 void GetUserMedia(content::WebContents* tab_contents) { | |
| 184 content::WindowedNotificationObserver infobar_added( | |
| 185 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | |
| 186 content::NotificationService::AllSources()); | |
| 187 | |
| 188 // Request user media: this will launch the media stream info bar. | |
| 189 EXPECT_EQ("ok-requested", | |
| 190 ExecuteJavascript("getUserMedia('{video: true, audio: true}');", | |
| 191 tab_contents)); | |
| 192 | |
| 193 // Wait for the bar to pop up, then accept. | |
| 194 infobar_added.Wait(); | |
| 195 content::Details<InfoBarAddedDetails> details(infobar_added.details()); | |
| 196 MediaStreamInfoBarDelegate* media_infobar = | |
| 197 details->AsMediaStreamInfoBarDelegate(); | |
| 198 media_infobar->Accept(); | |
| 199 | |
| 200 // Wait for WebRTC to call the success callback. | |
| 201 EXPECT_TRUE(PollingWaitUntil( | |
| 202 "obtainGetUserMediaResult();", "ok-got-stream", tab_contents)); | |
| 203 } | |
| 204 | |
| 205 // Ensures we didn't get any errors asynchronously (e.g. while no javascript | 184 // Ensures we didn't get any errors asynchronously (e.g. while no javascript |
| 206 // call from this test was outstanding). | 185 // call from this test was outstanding). |
| 207 // TODO(phoglund): this becomes obsolete when we switch to communicating with | 186 // TODO(phoglund): this becomes obsolete when we switch to communicating with |
| 208 // the DOM message queue. | 187 // the DOM message queue. |
| 209 void AssertNoAsynchronousErrors(content::WebContents* tab_contents) { | 188 void AssertNoAsynchronousErrors(content::WebContents* tab_contents) { |
| 210 EXPECT_EQ("ok-no-errors", | 189 EXPECT_EQ("ok-no-errors", |
| 211 ExecuteJavascript("getAnyTestFailures()", tab_contents)); | 190 ExecuteJavascript("getAnyTestFailures()", tab_contents)); |
| 212 } | 191 } |
| 213 | 192 |
| 214 // The peer connection server lets our two tabs find each other and talk to | 193 // The peer connection server lets our two tabs find each other and talk to |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 419 |
| 441 base::ProcessHandle peerconnection_server_; | 420 base::ProcessHandle peerconnection_server_; |
| 442 base::ProcessHandle pywebsocket_server_; | 421 base::ProcessHandle pywebsocket_server_; |
| 443 scoped_ptr<base::Environment> environment_; | 422 scoped_ptr<base::Environment> environment_; |
| 444 }; | 423 }; |
| 445 | 424 |
| 446 // Broken on Win: failing to start pywebsocket_server. http://crbug.com/255499. | 425 // Broken on Win: failing to start pywebsocket_server. http://crbug.com/255499. |
| 447 #define MAYBE_MANUAL_TestVGAVideoQuality DISABLED_MANUAL_TestVGAVideoQuality | 426 #define MAYBE_MANUAL_TestVGAVideoQuality DISABLED_MANUAL_TestVGAVideoQuality |
| 448 | 427 |
| 449 IN_PROC_BROWSER_TEST_F(WebrtcVideoQualityBrowserTest, | 428 IN_PROC_BROWSER_TEST_F(WebrtcVideoQualityBrowserTest, |
| 450 MAYBE_MANUAL_TestVGAVideoQuality) { | 429 MANUAL_TestVGAVideoQuality) { |
| 451 // TODO(phoglund): de-dupe from chrome_webrtc_browsertest.cc. | 430 // TODO(phoglund): de-dupe from chrome_webrtc_browsertest.cc. |
| 452 StartPyWebSocketServer(); | 431 StartPyWebSocketServer(); |
| 453 | 432 |
| 454 EXPECT_TRUE(test_server()->Start()); | 433 EXPECT_TRUE(test_server()->Start()); |
| 455 | 434 |
| 456 ui_test_utils::NavigateToURL(browser(), | 435 ui_test_utils::NavigateToURL(browser(), |
| 457 test_server()->GetURL(kMainWebrtcTestHtmlPage)); | 436 test_server()->GetURL(kMainWebrtcTestHtmlPage)); |
| 458 content::WebContents* left_tab = | 437 content::WebContents* left_tab = |
| 459 browser()->tab_strip_model()->GetActiveWebContents(); | 438 browser()->tab_strip_model()->GetActiveWebContents(); |
| 460 GetUserMedia(left_tab); | 439 GetUserMediaAndAccept(left_tab); |
| 461 | 440 |
| 462 chrome::AddBlankTabAt(browser(), -1, true); | 441 chrome::AddBlankTabAt(browser(), -1, true); |
| 463 content::WebContents* right_tab = | 442 content::WebContents* right_tab = |
| 464 browser()->tab_strip_model()->GetActiveWebContents(); | 443 browser()->tab_strip_model()->GetActiveWebContents(); |
| 465 // TODO(phoglund): (de-dupe later) different from original flow. | 444 // TODO(phoglund): (de-dupe later) different from original flow. |
| 466 ui_test_utils::NavigateToURL(browser(), | 445 ui_test_utils::NavigateToURL(browser(), |
| 467 test_server()->GetURL(kCapturingWebrtcHtmlPage)); | 446 test_server()->GetURL(kCapturingWebrtcHtmlPage)); |
| 468 GetUserMedia(right_tab); | 447 GetUserMediaAndAccept(right_tab); |
| 469 | 448 |
| 470 ConnectToPeerConnectionServer("peer 1", left_tab); | 449 ConnectToPeerConnectionServer("peer 1", left_tab); |
| 471 ConnectToPeerConnectionServer("peer 2", right_tab); | 450 ConnectToPeerConnectionServer("peer 2", right_tab); |
| 472 | 451 |
| 473 EstablishCall(left_tab, right_tab); | 452 EstablishCall(left_tab, right_tab); |
| 474 | 453 |
| 475 AssertNoAsynchronousErrors(left_tab); | 454 AssertNoAsynchronousErrors(left_tab); |
| 476 AssertNoAsynchronousErrors(right_tab); | 455 AssertNoAsynchronousErrors(right_tab); |
| 477 | 456 |
| 478 // Poll slower here to avoid flooding the log with messages: capturing and | 457 // Poll slower here to avoid flooding the log with messages: capturing and |
| (...skipping 22 matching lines...) Expand all Loading... |
| 501 std::string output = | 480 std::string output = |
| 502 CompareVideos(kVgaWidth, | 481 CompareVideos(kVgaWidth, |
| 503 kVgaHeight, | 482 kVgaHeight, |
| 504 GetWorkingDir().Append(kCapturedYuvFileName), | 483 GetWorkingDir().Append(kCapturedYuvFileName), |
| 505 GetWorkingDir().Append(kReferenceYuvFileName), | 484 GetWorkingDir().Append(kReferenceYuvFileName), |
| 506 GetWorkingDir().Append(kStatsFileName)); | 485 GetWorkingDir().Append(kStatsFileName)); |
| 507 | 486 |
| 508 PrintFramesCountPerfResults(output); | 487 PrintFramesCountPerfResults(output); |
| 509 PrintPsnrAndSsimPerfResults(output); | 488 PrintPsnrAndSsimPerfResults(output); |
| 510 } | 489 } |
| OLD | NEW |