summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-28 18:39:59 +0000
committerphoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-28 18:39:59 +0000
commit64855b0398e677321127b38ded175a2ca10f1853 (patch)
tree9a7f97975b9bebff5c086898013f7bc9d28e15b6
parent985bcdc8377046460ac7b2238b2dab441ebc296a (diff)
downloadchromium_src-64855b0398e677321127b38ded175a2ca10f1853.zip
chromium_src-64855b0398e677321127b38ded175a2ca10f1853.tar.gz
chromium_src-64855b0398e677321127b38ded175a2ca10f1853.tar.bz2
Relanding Switched main WebRTC browser tests to use a more realistic video
> Switched main WebRTC browser tests to use a more realistic video. > After switching to fake device flags instead of software webcams, we > noticed a ton of video-related metrics changed. This is because the > spinning green ball is an unrealistic encode/decode example. This patch > will use the new fake device file flag to play a more realistic video. > BUG=352261, 343504 > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=259887 TBR=tommi@chromium.org BUG=352261, 343504 Review URL: https://codereview.chromium.org/216773002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260213 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/media/chrome_media_stream_infobar_browsertest.cc6
-rw-r--r--chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc2
-rw-r--r--chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc14
-rw-r--r--chrome/browser/media/chrome_webrtc_browsertest.cc54
-rw-r--r--chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc4
-rw-r--r--chrome/browser/media/chrome_webrtc_typing_detection_browsertest.cc16
-rw-r--r--chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc74
-rw-r--r--chrome/browser/media/webrtc_browsertest_base.cc33
-rw-r--r--chrome/browser/media/webrtc_browsertest_common.cc83
-rw-r--r--chrome/browser/media/webrtc_browsertest_common.h23
-rw-r--r--chrome/browser/media/webrtc_browsertest_perf.cc4
-rw-r--r--chrome/browser/media/webrtc_browsertest_perf.h4
-rw-r--r--chrome/test/data/webrtc/webrtc_jsep01_test.html6
13 files changed, 202 insertions, 121 deletions
diff --git a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
index 4e686d5..b3ac70a 100644
--- a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
+++ b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
@@ -119,9 +119,9 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
// Should fail with permission denied right away with no infobar popping up.
GetUserMedia(tab_contents, kAudioVideoCallConstraints);
- EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()",
- kFailedWithPermissionDeniedError,
- tab_contents));
+ EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
+ kFailedWithPermissionDeniedError,
+ tab_contents));
InfoBarService* infobar_service =
InfoBarService::FromWebContents(tab_contents);
EXPECT_EQ(0u, infobar_service->infobar_count());
diff --git a/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc b/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc
index fdd51d0..d508977 100644
--- a/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc
+++ b/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc
@@ -119,7 +119,7 @@ class WebRtcApprtcBrowserTest : public WebRtcTestBase {
// Apprtc will set remoteVideo.style.opacity to 1 when the call comes up.
std::string javascript =
"window.domAutomationController.send(remoteVideo.style.opacity)";
- return PollingWaitUntil(javascript, "1", tab_contents);
+ return test::PollingWaitUntil(javascript, "1", tab_contents);
}
bool EvalInJavascriptFile(content::WebContents* tab_contents,
diff --git a/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc b/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc
index 562a715..6107928 100644
--- a/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc
+++ b/chrome/browser/media/chrome_webrtc_audio_quality_browsertest.cc
@@ -94,7 +94,7 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase,
public:
WebRtcAudioQualityBrowserTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
- PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem();
+ test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
}
@@ -137,10 +137,10 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase,
ExecuteJavascript("negotiateCall()", from_tab));
// Ensure the call gets up on both sides.
- EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()",
- "active", from_tab));
- EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()",
- "active", to_tab));
+ EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
+ "active", from_tab));
+ EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
+ "active", to_tab));
}
base::FilePath CreateTemporaryWaveFile() {
@@ -152,7 +152,7 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase,
return wav_filename;
}
- PeerConnectionServerRunner peerconnection_server_;
+ test::PeerConnectionServerRunner peerconnection_server_;
};
class AudioRecorder {
@@ -419,7 +419,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcAudioQualityBrowserTest,
// because the ready state is ok on both sides. We sleep a bit between call
// establishment and playing to avoid cutting of the beginning of the audio
// file.
- SleepInJavascript(left_tab, 2000);
+ test::SleepInJavascript(left_tab, 2000);
base::FilePath recording = CreateTemporaryWaveFile();
diff --git a/chrome/browser/media/chrome_webrtc_browsertest.cc b/chrome/browser/media/chrome_webrtc_browsertest.cc
index e70eaef..570374c 100644
--- a/chrome/browser/media/chrome_webrtc_browsertest.cc
+++ b/chrome/browser/media/chrome_webrtc_browsertest.cc
@@ -32,18 +32,24 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/perf/perf_test.h"
+// For fine-grained suppression.
+#if defined(OS_WIN)
+#include "base/win/windows_version.h"
+#endif
+
static const char kMainWebrtcTestHtmlPage[] =
"/webrtc/webrtc_jsep01_test.html";
// Top-level integration test for WebRTC. The test methods here must run
// sequentially since they use a server binary on the system (hence they are
-// tagged as MANUAL).
+// tagged as MANUAL). In addition, they need the reference videos which require
+// the webrtc.DEPS solution, which is not generally available on Chromium bots.
class WebRtcBrowserTest : public WebRtcTestBase,
public testing::WithParamInterface<bool> {
public:
WebRtcBrowserTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
- PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem();
+ test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
}
@@ -51,8 +57,12 @@ class WebRtcBrowserTest : public WebRtcTestBase,
// Ensure the infobar is enabled, since we expect that in this test.
EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream));
- // TODO(phoglund): allow this test to also run with real devices once we
- // get real webcam bots up.
+ // Play a suitable, somewhat realistic video file.
+ base::FilePath input_video = test::GetReferenceVideosDir()
+ .Append(test::kReferenceFileName360p)
+ .AddExtension(test::kY4mFileExtension);
+ command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture,
+ input_video);
command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
// Flag used by TestWebAudioMediaStream to force garbage collection.
@@ -113,7 +123,15 @@ class WebRtcBrowserTest : public WebRtcTestBase,
return NULL;
}
- PeerConnectionServerRunner peerconnection_server_;
+ bool OnWinXp() {
+#if defined(OS_WIN)
+ return base::win::GetVersion() <= base::win::VERSION_XP;
+#else
+ return false;
+#endif
+ }
+
+ test::PeerConnectionServerRunner peerconnection_server_;
};
static const bool kRunTestsWithFlag[] = { false, true };
@@ -123,6 +141,9 @@ INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests,
IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) {
+ if (OnWinXp()) return;
+
+ ASSERT_TRUE(test::HasReferenceFilesInCheckout());
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
ASSERT_TRUE(peerconnection_server_.Start());
@@ -147,6 +168,9 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
}
IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) {
+ if (OnWinXp()) return;
+
+ ASSERT_TRUE(test::HasReferenceFilesInCheckout());
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
ASSERT_TRUE(peerconnection_server_.Start());
@@ -182,7 +206,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) {
EstablishCall(left_tab, right_tab);
- SleepInJavascript(left_tab, 15000);
+ test::SleepInJavascript(left_tab, 15000);
HangUp(left_tab);
WaitUntilHangupVerified(left_tab);
@@ -199,6 +223,9 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) {
// This is manual for its long execution time.
IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) {
+ if (OnWinXp()) return;
+
+ ASSERT_TRUE(test::HasReferenceFilesInCheckout());
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
ASSERT_TRUE(peerconnection_server_.Start());
@@ -220,7 +247,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
WaitForVideoToPlay(right_tab);
// Let values stabilize, bandwidth ramp up, etc.
- SleepInJavascript(left_tab, 60000);
+ test::SleepInJavascript(left_tab, 60000);
// Start measurements.
chrome::AddTabAt(browser(), GURL(), -1, true);
@@ -228,7 +255,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
content::WebContents* webrtc_internals_tab =
browser()->tab_strip_model()->GetActiveWebContents();
- SleepInJavascript(left_tab, 10000);
+ test::SleepInJavascript(left_tab, 10000);
scoped_ptr<base::DictionaryValue> all_data(
GetWebrtcInternalsData(webrtc_internals_tab));
@@ -237,8 +264,8 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
const base::DictionaryValue* first_pc_dict =
GetDataOnFirstPeerConnection(all_data.get());
ASSERT_TRUE(first_pc_dict != NULL);
- PrintBweForVideoMetrics(*first_pc_dict);
- PrintMetricsForAllStreams(*first_pc_dict);
+ test::PrintBweForVideoMetrics(*first_pc_dict);
+ test::PrintMetricsForAllStreams(*first_pc_dict);
HangUp(left_tab);
WaitUntilHangupVerified(left_tab);
@@ -247,7 +274,10 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
ASSERT_TRUE(peerconnection_server_.Stop());
}
-IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, TestWebAudioMediaStream) {
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_TestWebAudioMediaStream) {
+ if (OnWinXp()) return;
+
+ ASSERT_TRUE(test::HasReferenceFilesInCheckout());
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html"));
ui_test_utils::NavigateToURL(browser(), url);
@@ -255,7 +285,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, TestWebAudioMediaStream) {
browser()->tab_strip_model()->GetActiveWebContents();
// A sleep is necessary to be able to detect the crash.
- SleepInJavascript(tab, 1000);
+ test::SleepInJavascript(tab, 1000);
ASSERT_FALSE(tab->IsCrashed());
}
diff --git a/chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc b/chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc
index 398bc99..b51aaa6 100644
--- a/chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc
+++ b/chrome/browser/media/chrome_webrtc_disable_encryption_flag_browsertest.cc
@@ -31,7 +31,7 @@ class WebRtcDisableEncryptionFlagBrowserTest : public WebRtcTestBase {
virtual ~WebRtcDisableEncryptionFlagBrowserTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
- PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem();
+ test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
}
@@ -44,7 +44,7 @@ class WebRtcDisableEncryptionFlagBrowserTest : public WebRtcTestBase {
}
protected:
- PeerConnectionServerRunner peerconnection_server_;
+ test::PeerConnectionServerRunner peerconnection_server_;
private:
DISALLOW_COPY_AND_ASSIGN(WebRtcDisableEncryptionFlagBrowserTest);
diff --git a/chrome/browser/media/chrome_webrtc_typing_detection_browsertest.cc b/chrome/browser/media/chrome_webrtc_typing_detection_browsertest.cc
index 465d241..241f1ea 100644
--- a/chrome/browser/media/chrome_webrtc_typing_detection_browsertest.cc
+++ b/chrome/browser/media/chrome_webrtc_typing_detection_browsertest.cc
@@ -52,7 +52,7 @@ class WebRtcTypingDetectionBrowserTest : public WebRtcTestBase {
// TODO(phoglund): clean up duplication from audio quality browser test when
// this test is complete and is proven to work.
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
- PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem();
+ test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
}
bool HasAllRequiredResources() {
@@ -88,13 +88,13 @@ class WebRtcTypingDetectionBrowserTest : public WebRtcTestBase {
ExecuteJavascript("negotiateCall()", from_tab));
// Ensure the call gets up on both sides.
- EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()",
- "active", from_tab));
- EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()",
- "active", to_tab));
+ EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
+ "active", from_tab));
+ EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
+ "active", to_tab));
}
- PeerConnectionServerRunner peerconnection_server_;
+ test::PeerConnectionServerRunner peerconnection_server_;
};
// TODO(phoglund): enable when fully implemented.
@@ -133,13 +133,13 @@ IN_PROC_BROWSER_TEST_F(WebRtcTypingDetectionBrowserTest,
// because the ready state is ok on both sides. We sleep a bit between call
// establishment and playing to avoid cutting of the beginning of the audio
// file.
- SleepInJavascript(left_tab, 2000);
+ test::SleepInJavascript(left_tab, 2000);
PlayAudioFile(left_tab);
// TODO(phoglund): simulate key presses, look for changes in typing detection
// state.
- SleepInJavascript(left_tab, 10000);
+ test::SleepInJavascript(left_tab, 10000);
HangUp(left_tab);
WaitUntilHangupVerified(left_tab);
diff --git a/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc b/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc
index 9b88ff9..f64d52c 100644
--- a/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc
+++ b/chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc
@@ -61,14 +61,6 @@ static const char kHomeEnvName[] =
// The working dir should be in the user's home folder.
static const base::FilePath::CharType kWorkingDirName[] =
FILE_PATH_LITERAL("webrtc_video_quality");
-static const base::FilePath::CharType kReferenceVideosDirName[] =
- FILE_PATH_LITERAL("webrtc.DEPS/webrtc_videos");
-static const base::FilePath::CharType kReferenceFileName360p[] =
- FILE_PATH_LITERAL("reference_video_640x360_30fps");
-static const base::FilePath::CharType kYuvFileExtension[] =
- FILE_PATH_LITERAL("yuv");
-static const base::FilePath::CharType kY4mFileExtension[] =
- FILE_PATH_LITERAL("y4m");
static const base::FilePath::CharType kCapturedYuvFileName[] =
FILE_PATH_LITERAL("captured_video.yuv");
static const base::FilePath::CharType kStatsFileName[] =
@@ -84,14 +76,6 @@ static const int k360pHeight = 360;
// too!
static const char kPyWebSocketPortNumber[] = "12221";
-const char kAdviseOnGclientSolution[] =
- "You need to add this solution to your .gclient to run this test:\n"
- "{\n"
- " \"name\" : \"webrtc.DEPS\",\n"
- " \"url\" : \"svn://svn.chromium.org/chrome/trunk/deps/"
- "third_party/webrtc/webrtc.DEPS\",\n"
- "}";
-
// Test the video quality of the WebRTC output.
//
// Prerequisites: This test case must run on a machine with a chrome playing
@@ -122,15 +106,16 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase {
environment_(base::Environment::Create()) {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
- PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem();
+ test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
// Set up the command line option with the expected file name. We will check
// its existence in HasAllRequiredResources().
- webrtc_reference_video_y4m_ = GetReferenceVideosDir()
- .Append(kReferenceFileName360p).AddExtension(kY4mFileExtension);
+ webrtc_reference_video_y4m_ = test::GetReferenceVideosDir()
+ .Append(test::kReferenceFileName360p)
+ .AddExtension(test::kY4mFileExtension);
command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture,
webrtc_reference_video_y4m_);
command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
@@ -145,27 +130,9 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase {
"files:" << GetWorkingDir().value();
return false;
}
- if (!base::PathExists(GetReferenceVideosDir())) {
- LOG(ERROR) << "Cannot find the working directory for the reference video "
- "files, expected at " << GetReferenceVideosDir().value() << ". " <<
- kAdviseOnGclientSolution;
- return false;
- }
- base::FilePath webrtc_reference_video_yuv = GetReferenceVideosDir()
- .Append(kReferenceFileName360p).AddExtension(kYuvFileExtension);
- if (!base::PathExists(webrtc_reference_video_yuv)) {
- LOG(ERROR) << "Missing YUV reference video to be used for quality"
- << " comparison, expected at " << webrtc_reference_video_yuv.value()
- << ". " << kAdviseOnGclientSolution;
- return false;
- }
- if (!base::PathExists(webrtc_reference_video_y4m_)) {
- LOG(ERROR) << "Missing Y4M reference video to be used for quality"
- << " comparison, expected at "<< webrtc_reference_video_y4m_.value()
- << ". " << kAdviseOnGclientSolution;
- return false;
- }
- return true;
+
+ // Ensure we have the required input files.
+ return test::HasReferenceFilesInCheckout();
}
bool StartPyWebSocketServer() {
@@ -311,23 +278,7 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase {
return base::FilePath(native_home_dir).Append(kWorkingDirName);
}
- base::FilePath GetReferenceVideosDir() {
- // FilePath does not tolerate relative paths, and we want to hang the
- // kReferenceVideosDirName at the same level as Chromium codebase, so we
- // need to subtract the trailing .../src manually from the path.
- const size_t src_token_length = 3u;
- const base::FilePath::StringType src_token(FILE_PATH_LITERAL("src"));
- base::FilePath::StringType path = GetSourceDir().value();
- DCHECK_GT(path.size(), src_token_length);
- std::size_t found = path.rfind(src_token);
- if (found != std::string::npos)
- path.replace(found,
- src_token_length,
- base::FilePath::StringType(FILE_PATH_LITERAL("")));
- return base::FilePath(path).Append(kReferenceVideosDirName);
- }
-
- PeerConnectionServerRunner peerconnection_server_;
+ test::PeerConnectionServerRunner peerconnection_server_;
private:
base::FilePath GetSourceDir() {
@@ -379,7 +330,7 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest,
// sending frames take quite a bit of time.
int polling_interval_msec = 1000;
- EXPECT_TRUE(PollingWaitUntil(
+ EXPECT_TRUE(test::PollingWaitUntil(
"doneFrameCapturing()", "done-capturing", right_tab,
polling_interval_msec));
@@ -387,7 +338,7 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest,
WaitUntilHangupVerified(left_tab);
WaitUntilHangupVerified(right_tab);
- EXPECT_TRUE(PollingWaitUntil(
+ EXPECT_TRUE(test::PollingWaitUntil(
"haveMoreFramesToSend()", "no-more-frames", right_tab,
polling_interval_msec));
@@ -406,7 +357,8 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest,
k360pWidth,
k360pHeight,
GetWorkingDir().Append(kCapturedYuvFileName),
- GetReferenceVideosDir().Append(kReferenceFileName360p).AddExtension(
- kYuvFileExtension),
+ test::GetReferenceVideosDir()
+ .Append(test::kReferenceFileName360p)
+ .AddExtension(test::kYuvFileExtension),
GetWorkingDir().Append(kStatsFileName)));
}
diff --git a/chrome/browser/media/webrtc_browsertest_base.cc b/chrome/browser/media/webrtc_browsertest_base.cc
index 21c18b5..fafaacc 100644
--- a/chrome/browser/media/webrtc_browsertest_base.cc
+++ b/chrome/browser/media/webrtc_browsertest_base.cc
@@ -91,8 +91,8 @@ void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept(
// Wait for WebRTC to call the success callback.
const char kOkGotStream[] = "ok-got-stream";
- EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream,
- tab_contents));
+ EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream,
+ tab_contents));
}
void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) {
@@ -108,8 +108,9 @@ void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
CloseInfoBarInTab(tab_contents, infobar);
// Wait for WebRTC to call the fail callback.
- EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()",
- kFailedWithPermissionDeniedError, tab_contents));
+ EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
+ kFailedWithPermissionDeniedError,
+ tab_contents));
}
void WebRtcTestBase::GetUserMediaAndDismiss(
@@ -120,9 +121,9 @@ void WebRtcTestBase::GetUserMediaAndDismiss(
CloseInfoBarInTab(tab_contents, infobar);
// A dismiss should be treated like a deny.
- EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()",
- kFailedWithPermissionDismissedError,
- tab_contents));
+ EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
+ kFailedWithPermissionDismissedError,
+ tab_contents));
}
void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
@@ -232,7 +233,7 @@ void WebRtcTestBase::ConnectToPeerConnectionServer(
content::WebContents* tab_contents) const {
std::string javascript = base::StringPrintf(
"connect('http://localhost:%s', '%s');",
- PeerConnectionServerRunner::kDefaultPort, peer_name.c_str());
+ test::PeerConnectionServerRunner::kDefaultPort, peer_name.c_str());
EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents));
}
@@ -247,10 +248,10 @@ void WebRtcTestBase::EstablishCall(content::WebContents* from_tab,
EXPECT_EQ("ok-negotiating", ExecuteJavascript("negotiateCall()", from_tab));
// Ensure the call gets up on both sides.
- EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()",
- "active", from_tab));
- EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()",
- "active", to_tab));
+ EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
+ "active", from_tab));
+ EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
+ "active", to_tab));
}
void WebRtcTestBase::HangUp(content::WebContents* from_tab) const {
@@ -259,8 +260,8 @@ void WebRtcTestBase::HangUp(content::WebContents* from_tab) const {
void WebRtcTestBase::WaitUntilHangupVerified(
content::WebContents* tab_contents) const {
- EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()",
- "no-peer-connection", tab_contents));
+ EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
+ "no-peer-connection", tab_contents));
}
void WebRtcTestBase::DetectErrorsInJavaScript() {
@@ -277,6 +278,6 @@ void WebRtcTestBase::StartDetectingVideo(
void WebRtcTestBase::WaitForVideoToPlay(
content::WebContents* tab_contents) const {
- EXPECT_TRUE(PollingWaitUntil("isVideoPlaying()", "video-playing",
- tab_contents));
+ EXPECT_TRUE(test::PollingWaitUntil("isVideoPlaying()", "video-playing",
+ tab_contents));
}
diff --git a/chrome/browser/media/webrtc_browsertest_common.cc b/chrome/browser/media/webrtc_browsertest_common.cc
index 0c18313..9928514 100644
--- a/chrome/browser/media/webrtc_browsertest_common.cc
+++ b/chrome/browser/media/webrtc_browsertest_common.cc
@@ -15,8 +15,75 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "content/public/test/browser_test_utils.h"
+namespace test {
+
+const base::FilePath::CharType kReferenceVideosDirName[] =
+ FILE_PATH_LITERAL("webrtc.DEPS/webrtc_videos");
+const base::FilePath::CharType kReferenceFileName360p[] =
+ FILE_PATH_LITERAL("reference_video_640x360_30fps");
+const base::FilePath::CharType kYuvFileExtension[] = FILE_PATH_LITERAL("yuv");
+const base::FilePath::CharType kY4mFileExtension[] = FILE_PATH_LITERAL("y4m");
+
+// This message describes how to modify your .gclient to get the reference
+// video files downloaded for you.
+static const char kAdviseOnGclientSolution[] =
+ "You need to add this solution to your .gclient to run this test:\n"
+ "{\n"
+ " \"name\" : \"webrtc.DEPS\",\n"
+ " \"url\" : \"svn://svn.chromium.org/chrome/trunk/deps/"
+ "third_party/webrtc/webrtc.DEPS\",\n"
+ "}";
+
const int kDefaultPollIntervalMsec = 250;
+base::FilePath GetReferenceVideosDir() {
+ // FilePath does not tolerate relative paths, and we want to hang the
+ // kReferenceVideosDirName at the same level as Chromium codebase, so we
+ // need to subtract the trailing .../src manually from the path.
+ const size_t src_token_length = 3u;
+ const base::FilePath::StringType src_token(FILE_PATH_LITERAL("src"));
+
+ base::FilePath source_dir;
+ PathService::Get(base::DIR_SOURCE_ROOT, &source_dir);
+
+ base::FilePath::StringType path = source_dir.value();
+ DCHECK_GT(path.size(), src_token_length);
+ std::size_t found = path.rfind(src_token);
+ if (found != std::string::npos)
+ path.erase(found, src_token_length);
+ return base::FilePath(path).Append(kReferenceVideosDirName);
+}
+
+bool HasReferenceFilesInCheckout() {
+ if (!base::PathExists(GetReferenceVideosDir())) {
+ LOG(ERROR)
+ << "Cannot find the working directory for the reference video "
+ << "files, expected at " << GetReferenceVideosDir().value() << ". " <<
+ kAdviseOnGclientSolution;
+ return false;
+ }
+ base::FilePath webrtc_reference_video_yuv = GetReferenceVideosDir()
+ .Append(kReferenceFileName360p).AddExtension(kYuvFileExtension);
+ if (!base::PathExists(webrtc_reference_video_yuv)) {
+ LOG(ERROR)
+ << "Missing YUV reference video to be used for quality"
+ << " comparison, expected at " << webrtc_reference_video_yuv.value()
+ << ". " << kAdviseOnGclientSolution;
+ return false;
+ }
+
+ base::FilePath webrtc_reference_video_y4m = GetReferenceVideosDir()
+ .Append(kReferenceFileName360p).AddExtension(kY4mFileExtension);
+ if (!base::PathExists(webrtc_reference_video_y4m)) {
+ LOG(ERROR)
+ << "Missing Y4M reference video to be used for quality"
+ << " comparison, expected at "<< webrtc_reference_video_y4m.value()
+ << ". " << kAdviseOnGclientSolution;
+ return false;
+ }
+ return true;
+}
+
bool SleepInJavascript(content::WebContents* tab_contents, int timeout_msec) {
const std::string javascript = base::StringPrintf(
"setTimeout(function() {"
@@ -62,9 +129,10 @@ bool PollingWaitUntil(const std::string& javascript,
LOG(ERROR) << "Failed to sleep.";
}
}
- LOG(ERROR) << "Timed out while waiting for " << javascript <<
- " to evaluate to " << evaluates_to << "; last result was '" << result <<
- "'";
+ LOG(ERROR)
+ << "Timed out while waiting for " << javascript
+ << " to evaluate to " << evaluates_to << "; last result was '" << result
+ << "'";
return false;
}
@@ -86,8 +154,9 @@ bool PeerConnectionServerRunner::Start() {
peerconnection_server = peerconnection_server.Append(kServerExecutable);
if (!base::PathExists(peerconnection_server)) {
- LOG(ERROR) << "Missing " << kServerExecutable << ". You must build "
- "it so it ends up next to the browser test binary.";
+ LOG(ERROR)
+ << "Missing " << kServerExecutable << ". You must build "
+ << "it so it ends up next to the browser test binary.";
return false;
}
@@ -103,7 +172,7 @@ bool PeerConnectionServerRunner::Stop() {
return base::KillProcess(server_pid_, 0, false);
}
-void PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem() {
+void PeerConnectionServerRunner::KillAllPeerConnectionServers() {
if (!base::KillProcesses(kServerExecutable, -1, NULL)) {
LOG(ERROR) << "Failed to kill instances of " << kServerExecutable << ".";
return;
@@ -111,3 +180,5 @@ void PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem() {
base::WaitForProcessesToExit(kServerExecutable,
base::TimeDelta::FromSeconds(5), NULL);
}
+
+} // namespace test
diff --git a/chrome/browser/media/webrtc_browsertest_common.h b/chrome/browser/media/webrtc_browsertest_common.h
index 9d51c17..56d3ece 100644
--- a/chrome/browser/media/webrtc_browsertest_common.h
+++ b/chrome/browser/media/webrtc_browsertest_common.h
@@ -7,12 +7,31 @@
#include <string>
+#include "base/files/file_path.h"
#include "base/process/process_handle.h"
namespace content {
class WebContents;
}
+namespace test {
+
+// Reference video locations.
+
+// Checks if the user has the reference video files, returns true if so.
+// If the user's checkout don't have these dirs, they need to configure their
+// .gclient as described in kAdviseOnGclientSolution. The reason for this is
+// that we don't want to burden regular chrome devs with downloading these
+// sizable reference files by default.
+bool HasReferenceFilesInCheckout();
+
+// Retrieves the reference video dir, to which file names can be appended.
+base::FilePath GetReferenceVideosDir();
+
+extern const base::FilePath::CharType kReferenceFileName360p[];
+extern const base::FilePath::CharType kYuvFileExtension[];
+extern const base::FilePath::CharType kY4mFileExtension[];
+
// Executes javascript code which will sleep for |timeout_msec| milliseconds.
// Returns true on success.
bool SleepInJavascript(content::WebContents* tab_contents, int timeout_msec);
@@ -44,10 +63,12 @@ class PeerConnectionServerRunner {
// Stops the peerconnection server.
bool Stop();
- static void KillAllPeerConnectionServersOnCurrentSystem();
+ static void KillAllPeerConnectionServers();
private:
base::ProcessHandle server_pid_;
};
+} // namespace test
+
#endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_COMMON_H_
diff --git a/chrome/browser/media/webrtc_browsertest_perf.cc b/chrome/browser/media/webrtc_browsertest_perf.cc
index 18327427..fcf731a 100644
--- a/chrome/browser/media/webrtc_browsertest_perf.cc
+++ b/chrome/browser/media/webrtc_browsertest_perf.cc
@@ -172,6 +172,8 @@ static std::set<std::string> FindAllSsrcIdentifiers(
return result;
}
+namespace test {
+
void PrintBweForVideoMetrics(const base::DictionaryValue& pc_dict) {
const std::string kBweStatsKey = "bweforvideo";
std::string value;
@@ -218,3 +220,5 @@ void PrintMetricsForAllStreams(const base::DictionaryValue& pc_dict) {
<< " is. ";
}
}
+
+} // namespace test
diff --git a/chrome/browser/media/webrtc_browsertest_perf.h b/chrome/browser/media/webrtc_browsertest_perf.h
index d469a73..19934f68 100644
--- a/chrome/browser/media/webrtc_browsertest_perf.h
+++ b/chrome/browser/media/webrtc_browsertest_perf.h
@@ -9,6 +9,8 @@ namespace base {
class DictionaryValue;
}
+namespace test {
+
// These functions takes parsed data (on one peer connection) from the
// peerConnectionDataStore object that is backing webrtc-internals and prints
// metrics they consider interesting using testing/perf/perf_test.h primitives.
@@ -20,4 +22,6 @@ class DictionaryValue;
void PrintBweForVideoMetrics(const base::DictionaryValue& pc_dict);
void PrintMetricsForAllStreams(const base::DictionaryValue& pc_dict);
+} // namespace test
+
#endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_PERF_H_
diff --git a/chrome/test/data/webrtc/webrtc_jsep01_test.html b/chrome/test/data/webrtc/webrtc_jsep01_test.html
index 7270dc7..2f66f6e 100644
--- a/chrome/test/data/webrtc/webrtc_jsep01_test.html
+++ b/chrome/test/data/webrtc/webrtc_jsep01_test.html
@@ -16,10 +16,8 @@
<td>Remote Video</td>
</tr>
<tr>
- <td><video width="320" height="240" id="local-view"
- autoplay="autoplay"></video></td>
- <td><video width="320" height="240" id="remote-view"
- autoplay="autoplay"></video></td>
+ <td><video id="local-view" autoplay></video></td>
+ <td><video id="remote-view" autoplay></video></td>
</tr>
</table>
</body>