Commit 64855b03 authored by phoglund@chromium.org's avatar phoglund@chromium.org

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
parent 985bcdc8
...@@ -119,9 +119,9 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, ...@@ -119,9 +119,9 @@ IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
// Should fail with permission denied right away with no infobar popping up. // Should fail with permission denied right away with no infobar popping up.
GetUserMedia(tab_contents, kAudioVideoCallConstraints); GetUserMedia(tab_contents, kAudioVideoCallConstraints);
EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
kFailedWithPermissionDeniedError, kFailedWithPermissionDeniedError,
tab_contents)); tab_contents));
InfoBarService* infobar_service = InfoBarService* infobar_service =
InfoBarService::FromWebContents(tab_contents); InfoBarService::FromWebContents(tab_contents);
EXPECT_EQ(0u, infobar_service->infobar_count()); EXPECT_EQ(0u, infobar_service->infobar_count());
......
...@@ -119,7 +119,7 @@ class WebRtcApprtcBrowserTest : public WebRtcTestBase { ...@@ -119,7 +119,7 @@ class WebRtcApprtcBrowserTest : public WebRtcTestBase {
// Apprtc will set remoteVideo.style.opacity to 1 when the call comes up. // Apprtc will set remoteVideo.style.opacity to 1 when the call comes up.
std::string javascript = std::string javascript =
"window.domAutomationController.send(remoteVideo.style.opacity)"; "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, bool EvalInJavascriptFile(content::WebContents* tab_contents,
......
...@@ -94,7 +94,7 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase, ...@@ -94,7 +94,7 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase,
public: public:
WebRtcAudioQualityBrowserTest() {} WebRtcAudioQualityBrowserTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
DetectErrorsInJavaScript(); // Look for errors in our rather complex js. DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
} }
...@@ -137,10 +137,10 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase, ...@@ -137,10 +137,10 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase,
ExecuteJavascript("negotiateCall()", from_tab)); ExecuteJavascript("negotiateCall()", from_tab));
// Ensure the call gets up on both sides. // Ensure the call gets up on both sides.
EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
"active", from_tab)); "active", from_tab));
EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
"active", to_tab)); "active", to_tab));
} }
base::FilePath CreateTemporaryWaveFile() { base::FilePath CreateTemporaryWaveFile() {
...@@ -152,7 +152,7 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase, ...@@ -152,7 +152,7 @@ class WebRtcAudioQualityBrowserTest : public WebRtcTestBase,
return wav_filename; return wav_filename;
} }
PeerConnectionServerRunner peerconnection_server_; test::PeerConnectionServerRunner peerconnection_server_;
}; };
class AudioRecorder { class AudioRecorder {
...@@ -419,7 +419,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcAudioQualityBrowserTest, ...@@ -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 // 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 // establishment and playing to avoid cutting of the beginning of the audio
// file. // file.
SleepInJavascript(left_tab, 2000); test::SleepInJavascript(left_tab, 2000);
base::FilePath recording = CreateTemporaryWaveFile(); base::FilePath recording = CreateTemporaryWaveFile();
......
...@@ -32,18 +32,24 @@ ...@@ -32,18 +32,24 @@
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/perf/perf_test.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[] = static const char kMainWebrtcTestHtmlPage[] =
"/webrtc/webrtc_jsep01_test.html"; "/webrtc/webrtc_jsep01_test.html";
// Top-level integration test for WebRTC. The test methods here must run // 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 // 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, class WebRtcBrowserTest : public WebRtcTestBase,
public testing::WithParamInterface<bool> { public testing::WithParamInterface<bool> {
public: public:
WebRtcBrowserTest() {} WebRtcBrowserTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
DetectErrorsInJavaScript(); // Look for errors in our rather complex js. DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
} }
...@@ -51,8 +57,12 @@ class WebRtcBrowserTest : public WebRtcTestBase, ...@@ -51,8 +57,12 @@ class WebRtcBrowserTest : public WebRtcTestBase,
// Ensure the infobar is enabled, since we expect that in this test. // Ensure the infobar is enabled, since we expect that in this test.
EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream));
// TODO(phoglund): allow this test to also run with real devices once we // Play a suitable, somewhat realistic video file.
// get real webcam bots up. base::FilePath input_video = test::GetReferenceVideosDir()
.Append(test::kReferenceFileName360p)
.AddExtension(test::kY4mFileExtension);
command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture,
input_video);
command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
// Flag used by TestWebAudioMediaStream to force garbage collection. // Flag used by TestWebAudioMediaStream to force garbage collection.
...@@ -113,7 +123,15 @@ class WebRtcBrowserTest : public WebRtcTestBase, ...@@ -113,7 +123,15 @@ class WebRtcBrowserTest : public WebRtcTestBase,
return NULL; 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 }; static const bool kRunTestsWithFlag[] = { false, true };
...@@ -123,6 +141,9 @@ INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests, ...@@ -123,6 +141,9 @@ INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests,
IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) { MANUAL_RunsAudioVideoWebRTCCallInTwoTabs) {
if (OnWinXp()) return;
ASSERT_TRUE(test::HasReferenceFilesInCheckout());
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
ASSERT_TRUE(peerconnection_server_.Start()); ASSERT_TRUE(peerconnection_server_.Start());
...@@ -147,6 +168,9 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, ...@@ -147,6 +168,9 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
} }
IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) {
if (OnWinXp()) return;
ASSERT_TRUE(test::HasReferenceFilesInCheckout());
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
ASSERT_TRUE(peerconnection_server_.Start()); ASSERT_TRUE(peerconnection_server_.Start());
...@@ -182,7 +206,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { ...@@ -182,7 +206,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) {
EstablishCall(left_tab, right_tab); EstablishCall(left_tab, right_tab);
SleepInJavascript(left_tab, 15000); test::SleepInJavascript(left_tab, 15000);
HangUp(left_tab); HangUp(left_tab);
WaitUntilHangupVerified(left_tab); WaitUntilHangupVerified(left_tab);
...@@ -199,6 +223,9 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) { ...@@ -199,6 +223,9 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CpuUsage15Seconds) {
// This is manual for its long execution time. // This is manual for its long execution time.
IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) { MANUAL_RunsAudioVideoCall60SecsAndLogsInternalMetrics) {
if (OnWinXp()) return;
ASSERT_TRUE(test::HasReferenceFilesInCheckout());
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
ASSERT_TRUE(peerconnection_server_.Start()); ASSERT_TRUE(peerconnection_server_.Start());
...@@ -220,7 +247,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, ...@@ -220,7 +247,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
WaitForVideoToPlay(right_tab); WaitForVideoToPlay(right_tab);
// Let values stabilize, bandwidth ramp up, etc. // Let values stabilize, bandwidth ramp up, etc.
SleepInJavascript(left_tab, 60000); test::SleepInJavascript(left_tab, 60000);
// Start measurements. // Start measurements.
chrome::AddTabAt(browser(), GURL(), -1, true); chrome::AddTabAt(browser(), GURL(), -1, true);
...@@ -228,7 +255,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, ...@@ -228,7 +255,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
content::WebContents* webrtc_internals_tab = content::WebContents* webrtc_internals_tab =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
SleepInJavascript(left_tab, 10000); test::SleepInJavascript(left_tab, 10000);
scoped_ptr<base::DictionaryValue> all_data( scoped_ptr<base::DictionaryValue> all_data(
GetWebrtcInternalsData(webrtc_internals_tab)); GetWebrtcInternalsData(webrtc_internals_tab));
...@@ -237,8 +264,8 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, ...@@ -237,8 +264,8 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
const base::DictionaryValue* first_pc_dict = const base::DictionaryValue* first_pc_dict =
GetDataOnFirstPeerConnection(all_data.get()); GetDataOnFirstPeerConnection(all_data.get());
ASSERT_TRUE(first_pc_dict != NULL); ASSERT_TRUE(first_pc_dict != NULL);
PrintBweForVideoMetrics(*first_pc_dict); test::PrintBweForVideoMetrics(*first_pc_dict);
PrintMetricsForAllStreams(*first_pc_dict); test::PrintMetricsForAllStreams(*first_pc_dict);
HangUp(left_tab); HangUp(left_tab);
WaitUntilHangupVerified(left_tab); WaitUntilHangupVerified(left_tab);
...@@ -247,7 +274,10 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, ...@@ -247,7 +274,10 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
ASSERT_TRUE(peerconnection_server_.Stop()); 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()); ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html"));
ui_test_utils::NavigateToURL(browser(), url); ui_test_utils::NavigateToURL(browser(), url);
...@@ -255,7 +285,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, TestWebAudioMediaStream) { ...@@ -255,7 +285,7 @@ IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, TestWebAudioMediaStream) {
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
// A sleep is necessary to be able to detect the crash. // A sleep is necessary to be able to detect the crash.
SleepInJavascript(tab, 1000); test::SleepInJavascript(tab, 1000);
ASSERT_FALSE(tab->IsCrashed()); ASSERT_FALSE(tab->IsCrashed());
} }
...@@ -31,7 +31,7 @@ class WebRtcDisableEncryptionFlagBrowserTest : public WebRtcTestBase { ...@@ -31,7 +31,7 @@ class WebRtcDisableEncryptionFlagBrowserTest : public WebRtcTestBase {
virtual ~WebRtcDisableEncryptionFlagBrowserTest() {} virtual ~WebRtcDisableEncryptionFlagBrowserTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
DetectErrorsInJavaScript(); // Look for errors in our rather complex js. DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
} }
...@@ -44,7 +44,7 @@ class WebRtcDisableEncryptionFlagBrowserTest : public WebRtcTestBase { ...@@ -44,7 +44,7 @@ class WebRtcDisableEncryptionFlagBrowserTest : public WebRtcTestBase {
} }
protected: protected:
PeerConnectionServerRunner peerconnection_server_; test::PeerConnectionServerRunner peerconnection_server_;
private: private:
DISALLOW_COPY_AND_ASSIGN(WebRtcDisableEncryptionFlagBrowserTest); DISALLOW_COPY_AND_ASSIGN(WebRtcDisableEncryptionFlagBrowserTest);
......
...@@ -52,7 +52,7 @@ class WebRtcTypingDetectionBrowserTest : public WebRtcTestBase { ...@@ -52,7 +52,7 @@ class WebRtcTypingDetectionBrowserTest : public WebRtcTestBase {
// TODO(phoglund): clean up duplication from audio quality browser test when // TODO(phoglund): clean up duplication from audio quality browser test when
// this test is complete and is proven to work. // this test is complete and is proven to work.
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
} }
bool HasAllRequiredResources() { bool HasAllRequiredResources() {
...@@ -88,13 +88,13 @@ class WebRtcTypingDetectionBrowserTest : public WebRtcTestBase { ...@@ -88,13 +88,13 @@ class WebRtcTypingDetectionBrowserTest : public WebRtcTestBase {
ExecuteJavascript("negotiateCall()", from_tab)); ExecuteJavascript("negotiateCall()", from_tab));
// Ensure the call gets up on both sides. // Ensure the call gets up on both sides.
EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
"active", from_tab)); "active", from_tab));
EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
"active", to_tab)); "active", to_tab));
} }
PeerConnectionServerRunner peerconnection_server_; test::PeerConnectionServerRunner peerconnection_server_;
}; };
// TODO(phoglund): enable when fully implemented. // TODO(phoglund): enable when fully implemented.
...@@ -133,13 +133,13 @@ IN_PROC_BROWSER_TEST_F(WebRtcTypingDetectionBrowserTest, ...@@ -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 // 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 // establishment and playing to avoid cutting of the beginning of the audio
// file. // file.
SleepInJavascript(left_tab, 2000); test::SleepInJavascript(left_tab, 2000);
PlayAudioFile(left_tab); PlayAudioFile(left_tab);
// TODO(phoglund): simulate key presses, look for changes in typing detection // TODO(phoglund): simulate key presses, look for changes in typing detection
// state. // state.
SleepInJavascript(left_tab, 10000); test::SleepInJavascript(left_tab, 10000);
HangUp(left_tab); HangUp(left_tab);
WaitUntilHangupVerified(left_tab); WaitUntilHangupVerified(left_tab);
......
...@@ -61,14 +61,6 @@ static const char kHomeEnvName[] = ...@@ -61,14 +61,6 @@ static const char kHomeEnvName[] =
// The working dir should be in the user's home folder. // The working dir should be in the user's home folder.
static const base::FilePath::CharType kWorkingDirName[] = static const base::FilePath::CharType kWorkingDirName[] =
FILE_PATH_LITERAL("webrtc_video_quality"); 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[] = static const base::FilePath::CharType kCapturedYuvFileName[] =
FILE_PATH_LITERAL("captured_video.yuv"); FILE_PATH_LITERAL("captured_video.yuv");
static const base::FilePath::CharType kStatsFileName[] = static const base::FilePath::CharType kStatsFileName[] =
...@@ -84,14 +76,6 @@ static const int k360pHeight = 360; ...@@ -84,14 +76,6 @@ static const int k360pHeight = 360;
// too! // too!
static const char kPyWebSocketPortNumber[] = "12221"; 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. // Test the video quality of the WebRTC output.
// //
// Prerequisites: This test case must run on a machine with a chrome playing // Prerequisites: This test case must run on a machine with a chrome playing
...@@ -122,15 +106,16 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { ...@@ -122,15 +106,16 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase {
environment_(base::Environment::Create()) {} environment_(base::Environment::Create()) {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem(); test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
DetectErrorsInJavaScript(); // Look for errors in our rather complex js. DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
} }
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
// Set up the command line option with the expected file name. We will check // Set up the command line option with the expected file name. We will check
// its existence in HasAllRequiredResources(). // its existence in HasAllRequiredResources().
webrtc_reference_video_y4m_ = GetReferenceVideosDir() webrtc_reference_video_y4m_ = test::GetReferenceVideosDir()
.Append(kReferenceFileName360p).AddExtension(kY4mFileExtension); .Append(test::kReferenceFileName360p)
.AddExtension(test::kY4mFileExtension);
command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture, command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture,
webrtc_reference_video_y4m_); webrtc_reference_video_y4m_);
command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
...@@ -145,27 +130,9 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { ...@@ -145,27 +130,9 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase {
"files:" << GetWorkingDir().value(); "files:" << GetWorkingDir().value();
return false; return false;
} }
if (!base::PathExists(GetReferenceVideosDir())) {
LOG(ERROR) << "Cannot find the working directory for the reference video " // Ensure we have the required input files.
"files, expected at " << GetReferenceVideosDir().value() << ". " << return test::HasReferenceFilesInCheckout();
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;
} }
bool StartPyWebSocketServer() { bool StartPyWebSocketServer() {
...@@ -311,23 +278,7 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase { ...@@ -311,23 +278,7 @@ class WebRtcVideoQualityBrowserTest : public WebRtcTestBase {
return base::FilePath(native_home_dir).Append(kWorkingDirName); return base::FilePath(native_home_dir).Append(kWorkingDirName);
} }
base::FilePath GetReferenceVideosDir() { test::PeerConnectionServerRunner peerconnection_server_;
// 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_;
private: private:
base::FilePath GetSourceDir() { base::FilePath GetSourceDir() {
...@@ -379,7 +330,7 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest, ...@@ -379,7 +330,7 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest,
// sending frames take quite a bit of time. // sending frames take quite a bit of time.
int polling_interval_msec = 1000; int polling_interval_msec = 1000;
EXPECT_TRUE(PollingWaitUntil( EXPECT_TRUE(test::PollingWaitUntil(
"doneFrameCapturing()", "done-capturing", right_tab, "doneFrameCapturing()", "done-capturing", right_tab,
polling_interval_msec)); polling_interval_msec));
...@@ -387,7 +338,7 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest, ...@@ -387,7 +338,7 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest,
WaitUntilHangupVerified(left_tab); WaitUntilHangupVerified(left_tab);
WaitUntilHangupVerified(right_tab); WaitUntilHangupVerified(right_tab);
EXPECT_TRUE(PollingWaitUntil( EXPECT_TRUE(test::PollingWaitUntil(
"haveMoreFramesToSend()", "no-more-frames", right_tab, "haveMoreFramesToSend()", "no-more-frames", right_tab,
polling_interval_msec)); polling_interval_msec));
...@@ -406,7 +357,8 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest, ...@@ -406,7 +357,8 @@ IN_PROC_BROWSER_TEST_F(WebRtcVideoQualityBrowserTest,
k360pWidth, k360pWidth,
k360pHeight, k360pHeight,
GetWorkingDir().Append(kCapturedYuvFileName), GetWorkingDir().Append(kCapturedYuvFileName),
GetReferenceVideosDir().Append(kReferenceFileName360p).AddExtension( test::GetReferenceVideosDir()
kYuvFileExtension), .Append(test::kReferenceFileName360p)
.AddExtension(test::kYuvFileExtension),
GetWorkingDir().Append(kStatsFileName))); GetWorkingDir().Append(kStatsFileName)));
} }
...@@ -91,8 +91,8 @@ void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept( ...@@ -91,8 +91,8 @@ void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept(
// Wait for WebRTC to call the success callback. // Wait for WebRTC to call the success callback.
const char kOkGotStream[] = "ok-got-stream"; const char kOkGotStream[] = "ok-got-stream";
EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream, EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream,
tab_contents)); tab_contents));
} }
void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) { void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) {
...@@ -108,8 +108,9 @@ void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny( ...@@ -108,8 +108,9 @@ void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
CloseInfoBarInTab(tab_contents, infobar); CloseInfoBarInTab(tab_contents, infobar);
// Wait for WebRTC to call the fail callback. // Wait for WebRTC to call the fail callback.
EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
kFailedWithPermissionDeniedError, tab_contents)); kFailedWithPermissionDeniedError,
tab_contents));
} }
void WebRtcTestBase::GetUserMediaAndDismiss( void WebRtcTestBase::GetUserMediaAndDismiss(
...@@ -120,9 +121,9 @@ void WebRtcTestBase::GetUserMediaAndDismiss( ...@@ -120,9 +121,9 @@ void WebRtcTestBase::GetUserMediaAndDismiss(
CloseInfoBarInTab(tab_contents, infobar); CloseInfoBarInTab(tab_contents, infobar);
// A dismiss should be treated like a deny. // A dismiss should be treated like a deny.
EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
kFailedWithPermissionDismissedError, kFailedWithPermissionDismissedError,
tab_contents)); tab_contents));
} }
void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents, void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
...@@ -232,7 +233,7 @@ void WebRtcTestBase::ConnectToPeerConnectionServer( ...@@ -232,7 +233,7 @@ void WebRtcTestBase::ConnectToPeerConnectionServer(
content::WebContents* tab_contents) const { content::WebContents* tab_contents) const {
std::string javascript = base::StringPrintf( std::string javascript = base::StringPrintf(
"connect('http://localhost:%s', '%s');", "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)); EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents));
} }
...@@ -247,10 +248,10 @@ void WebRtcTestBase::EstablishCall(content::WebContents* from_tab, ...@@ -247,10 +248,10 @@ void WebRtcTestBase::EstablishCall(content::WebContents* from_tab,
EXPECT_EQ("ok-negotiating", ExecuteJavascript("negotiateCall()", from_tab)); EXPECT_EQ("ok-negotiating", ExecuteJavascript("negotiateCall()", from_tab));
// Ensure the call gets up on both sides. // Ensure the call gets up on both sides.
EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
"active", from_tab)); "active", from_tab));
EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
"active", to_tab)); "active", to_tab));
} }
void WebRtcTestBase::HangUp(content::WebContents* from_tab) const { void WebRtcTestBase::HangUp(content::WebContents* from_tab) const {
...@@ -259,8 +260,8 @@ void WebRtcTestBase::HangUp(content::WebContents* from_tab) const { ...@@ -259,8 +260,8 @@ void WebRtcTestBase::HangUp(content::WebContents* from_tab) const {
void WebRtcTestBase::WaitUntilHangupVerified( void WebRtcTestBase::WaitUntilHangupVerified(
content::WebContents* tab_contents) const { content::WebContents* tab_contents) const {
EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
"no-peer-connection", tab_contents)); "no-peer-connection", tab_contents));
} }
void WebRtcTestBase::DetectErrorsInJavaScript() { void WebRtcTestBase::DetectErrorsInJavaScript() {
...@@ -277,6 +278,6 @@ void WebRtcTestBase::StartDetectingVideo( ...@@ -277,6 +278,6 @@ void WebRtcTestBase::StartDetectingVideo(
void WebRtcTestBase::WaitForVideoToPlay( void WebRtcTestBase::WaitForVideoToPlay(
content::WebContents* tab_contents) const { content::WebContents* tab_contents) const {
EXPECT_TRUE(PollingWaitUntil("isVideoPlaying()", "video-playing", EXPECT_TRUE(test::PollingWaitUntil("isVideoPlaying()", "video-playing",
tab_contents)); tab_contents));
} }
...@@ -15,8 +15,75 @@ ...@@ -15,8 +15,75 @@
#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_tabstrip.h"
#include "content/public/test/browser_test_utils.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; 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) { bool SleepInJavascript(content::WebContents* tab_contents, int timeout_msec) {
const std::string javascript = base::StringPrintf( const std::string javascript = base::StringPrintf(
"setTimeout(function() {" "setTimeout(function() {"
...@@ -62,9 +129,10 @@ bool PollingWaitUntil(const std::string& javascript, ...@@ -62,9 +129,10 @@ bool PollingWaitUntil(const std::string& javascript,
LOG(ERROR) << "Failed to sleep."; LOG(ERROR) << "Failed to sleep.";
} }
} }
LOG(ERROR) << "Timed out while waiting for " << javascript << LOG(ERROR)
" to evaluate to " << evaluates_to << "; last result was '" << result << << "Timed out while waiting for " << javascript
"'"; << " to evaluate to " << evaluates_to << "; last result was '" << result
<< "'";
return false; return false;
} }
...@@ -86,8 +154,9 @@ bool PeerConnectionServerRunner::Start() { ...@@ -86,8 +154,9 @@ bool PeerConnectionServerRunner::Start() {
peerconnection_server = peerconnection_server.Append(kServerExecutable); peerconnection_server = peerconnection_server.Append(kServerExecutable);
if (!base::PathExists(peerconnection_server)) { if (!base::PathExists(peerconnection_server)) {
LOG(ERROR) << "Missing " << kServerExecutable << ". You must build " LOG(ERROR)
"it so it ends up next to the browser test binary."; << "Missing " << kServerExecutable << ". You must build "
<< "it so it ends up next to the browser test binary.";
return false; return false;
} }
...@@ -103,7 +172,7 @@ bool PeerConnectionServerRunner::Stop() { ...@@ -103,7 +172,7 @@ bool PeerConnectionServerRunner::Stop() {
return base::KillProcess(server_pid_, 0, false); return base::KillProcess(server_pid_, 0, false);
} }
void PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem() { void PeerConnectionServerRunner::KillAllPeerConnectionServers() {
if (!base::KillProcesses(kServerExecutable, -1, NULL)) { if (!base::KillProcesses(kServerExecutable, -1, NULL)) {
LOG(ERROR) << "Failed to kill instances of " << kServerExecutable << "."; LOG(ERROR) << "Failed to kill instances of " << kServerExecutable << ".";
return; return;
...@@ -111,3 +180,5 @@ void PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem() { ...@@ -111,3 +180,5 @@ void PeerConnectionServerRunner::KillAllPeerConnectionServersOnCurrentSystem() {
base::WaitForProcessesToExit(kServerExecutable, base::WaitForProcessesToExit(kServerExecutable,
base::TimeDelta::FromSeconds(5), NULL); base::TimeDelta::FromSeconds(5), NULL);
} }
} // namespace test
...@@ -7,12 +7,31 @@ ...@@ -7,12 +7,31 @@
#include <string> #include <string>
#include "base/files/file_path.h"
#include "base/process/process_handle.h" #include "base/process/process_handle.h"
namespace content { namespace content {
class WebContents; 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. // Executes javascript code which will sleep for |timeout_msec| milliseconds.
// Returns true on success. // Returns true on success.
bool SleepInJavascript(content::WebContents* tab_contents, int timeout_msec); bool SleepInJavascript(content::WebContents* tab_contents, int timeout_msec);
...@@ -44,10 +63,12 @@ class PeerConnectionServerRunner { ...@@ -44,10 +63,12 @@ class PeerConnectionServerRunner {
// Stops the peerconnection server. // Stops the peerconnection server.
bool Stop(); bool Stop();
static void KillAllPeerConnectionServersOnCurrentSystem(); static void KillAllPeerConnectionServers();
private: private:
base::ProcessHandle server_pid_; base::ProcessHandle server_pid_;
}; };
} // namespace test
#endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_COMMON_H_ #endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_COMMON_H_
...@@ -172,6 +172,8 @@ static std::set<std::string> FindAllSsrcIdentifiers( ...@@ -172,6 +172,8 @@ static std::set<std::string> FindAllSsrcIdentifiers(
return result; return result;
} }
namespace test {
void PrintBweForVideoMetrics(const base::DictionaryValue& pc_dict) { void PrintBweForVideoMetrics(const base::DictionaryValue& pc_dict) {
const std::string kBweStatsKey = "bweforvideo"; const std::string kBweStatsKey = "bweforvideo";
std::string value; std::string value;
...@@ -218,3 +220,5 @@ void PrintMetricsForAllStreams(const base::DictionaryValue& pc_dict) { ...@@ -218,3 +220,5 @@ void PrintMetricsForAllStreams(const base::DictionaryValue& pc_dict) {
<< " is. "; << " is. ";
} }
} }
} // namespace test
...@@ -9,6 +9,8 @@ namespace base { ...@@ -9,6 +9,8 @@ namespace base {
class DictionaryValue; class DictionaryValue;
} }
namespace test {
// These functions takes parsed data (on one peer connection) from the // These functions takes parsed data (on one peer connection) from the
// peerConnectionDataStore object that is backing webrtc-internals and prints // peerConnectionDataStore object that is backing webrtc-internals and prints
// metrics they consider interesting using testing/perf/perf_test.h primitives. // metrics they consider interesting using testing/perf/perf_test.h primitives.
...@@ -20,4 +22,6 @@ class DictionaryValue; ...@@ -20,4 +22,6 @@ class DictionaryValue;
void PrintBweForVideoMetrics(const base::DictionaryValue& pc_dict); void PrintBweForVideoMetrics(const base::DictionaryValue& pc_dict);
void PrintMetricsForAllStreams(const base::DictionaryValue& pc_dict); void PrintMetricsForAllStreams(const base::DictionaryValue& pc_dict);
} // namespace test
#endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_PERF_H_ #endif // CHROME_BROWSER_MEDIA_WEBRTC_BROWSERTEST_PERF_H_
...@@ -16,10 +16,8 @@ ...@@ -16,10 +16,8 @@
<td>Remote Video</td> <td>Remote Video</td>
</tr> </tr>
<tr> <tr>
<td><video width="320" height="240" id="local-view" <td><video id="local-view" autoplay></video></td>
autoplay="autoplay"></video></td> <td><video id="remote-view" autoplay></video></td>
<td><video width="320" height="240" id="remote-view"
autoplay="autoplay"></video></td>
</tr> </tr>
</table> </table>
</body> </body>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment