summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorphoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-11 00:11:35 +0000
committerphoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-11 00:11:35 +0000
commit9551c5d4ed3d3e1aa438940e3b5d79389e3d3963 (patch)
tree17c6eab02ecc849e72b928d75eb3dd679b2b7aba /chrome/browser
parent01d0cfbd24bec331c0ec6ce97f31fdca52eeabb2 (diff)
downloadchromium_src-9551c5d4ed3d3e1aa438940e3b5d79389e3d3963.zip
chromium_src-9551c5d4ed3d3e1aa438940e3b5d79389e3d3963.tar.gz
chromium_src-9551c5d4ed3d3e1aa438940e3b5d79389e3d3963.tar.bz2
Implemented WebRTC-AppRTC integration test.
This test will require a special gclient solution (implemented here: https://codereview.chromium.org/25857002/) which will download the latest apprtc code and the google appengine SDK. Then, it will launch a local appengine instance and verify we can get an AppRTC call up on that by connecting with two browser tabs. This provides a hermetic integration test for WebRTC-AppRTC which should be quite stable - it doesn't involve any connections to external servers. BUG=303021 R=xians@chromium.org Review URL: https://codereview.chromium.org/25652003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc139
-rw-r--r--chrome/browser/media/webrtc_browsertest_base.cc41
-rw-r--r--chrome/browser/media/webrtc_browsertest_base.h18
3 files changed, 182 insertions, 16 deletions
diff --git a/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc b/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc
new file mode 100644
index 0000000..b86d2baf
--- /dev/null
+++ b/chrome/browser/media/chrome_webrtc_apprtc_browsertest.cc
@@ -0,0 +1,139 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/path_service.h"
+#include "base/process/launch.h"
+#include "base/rand_util.h"
+#include "base/strings/stringprintf.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/media/webrtc_browsertest_base.h"
+#include "chrome/browser/media/webrtc_browsertest_common.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_tabstrip.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "chrome/test/ui/ui_test.h"
+#include "content/public/test/browser_test_utils.h"
+#include "net/test/python_utils.h"
+
+
+// You need this solution to run this test. The solution will download appengine
+// and the apprtc code for you.
+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 char kTitlePageOfAppEngineAdminPage[] = "Instances";
+
+
+// WebRTC-AppRTC integration test. Requires a real webcam and microphone
+// on the running system. This test is not meant to run in the main browser
+// test suite since normal tester machines do not have webcams.
+//
+// This test will bring up a AppRTC instance on localhost and verify that the
+// call gets up when connecting to the same room from two tabs in a browser.
+class WebrtcApprtcBrowserTest : public WebRtcTestBase {
+ public:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ EXPECT_FALSE(command_line->HasSwitch(
+ switches::kUseFakeDeviceForMediaStream));
+ EXPECT_FALSE(command_line->HasSwitch(
+ switches::kUseFakeUIForMediaStream));
+
+ // The video playback will not work without a GPU, so force its use here.
+ command_line->AppendSwitch(switches::kUseGpuInTests);
+ }
+
+ protected:
+ bool LaunchApprtcInstanceOnLocalhost() {
+ base::FilePath appengine_dev_appserver =
+ GetSourceDir().Append(
+ FILE_PATH_LITERAL("../google_appengine/dev_appserver.py"));
+ if (!base::PathExists(appengine_dev_appserver)) {
+ LOG(ERROR) << "Missing appengine sdk at " <<
+ appengine_dev_appserver.value() << ". " << kAdviseOnGclientSolution;
+ return false;
+ }
+
+ base::FilePath apprtc_dir =
+ GetSourceDir().Append(
+ FILE_PATH_LITERAL("third_party/webrtc_apprtc/apprtc"));
+ if (!base::PathExists(apprtc_dir)) {
+ LOG(ERROR) << "Missing AppRTC code at " <<
+ apprtc_dir.value() << ". " << kAdviseOnGclientSolution;
+ return false;
+ }
+
+ CommandLine command_line(CommandLine::NO_PROGRAM);
+ EXPECT_TRUE(GetPythonCommand(&command_line));
+
+ command_line.AppendArgPath(appengine_dev_appserver);
+ command_line.AppendArgPath(apprtc_dir);
+ command_line.AppendArg("--port=9999");
+ command_line.AppendArg("--admin_port=9998");
+
+ LOG(INFO) << "Running " << command_line.GetCommandLineString();
+ return base::LaunchProcess(command_line, base::LaunchOptions(),
+ &dev_appserver_);
+ }
+
+ bool LocalApprtcInstanceIsUp() {
+ // Load the admin page and see if we manage to load it right.
+ ui_test_utils::NavigateToURL(browser(), GURL("localhost:9998"));
+ content::WebContents* tab_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ std::string javascript =
+ "window.domAutomationController.send(document.title)";
+ std::string result;
+ if (!content::ExecuteScriptAndExtractString(tab_contents, javascript,
+ &result))
+ return false;
+
+ return result == kTitlePageOfAppEngineAdminPage;
+ }
+
+ bool StopApprtcInstance() {
+ return base::KillProcess(dev_appserver_, 0, false);
+ }
+
+ bool WaitForCallToComeUp(content::WebContents* tab_contents) {
+ // 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);
+ }
+
+ base::FilePath GetSourceDir() {
+ base::FilePath source_dir;
+ PathService::Get(base::DIR_SOURCE_ROOT, &source_dir);
+ return source_dir;
+ }
+
+ private:
+ base::ProcessHandle dev_appserver_;
+};
+
+IN_PROC_BROWSER_TEST_F(WebrtcApprtcBrowserTest, MANUAL_WorksOnApprtc) {
+ ASSERT_TRUE(LaunchApprtcInstanceOnLocalhost());
+ while (!LocalApprtcInstanceIsUp())
+ LOG(INFO) << "Waiting for AppRTC to come up...";
+
+ GURL room_url = GURL(base::StringPrintf("localhost:9999?r=room_%d",
+ base::RandInt(0, 65536)));
+
+ chrome::AddBlankTabAt(browser(), -1, true);
+ content::WebContents* left_tab = OpenPageAndAcceptUserMedia(room_url);
+ chrome::AddBlankTabAt(browser(), -1, true);
+ content::WebContents* right_tab = OpenPageAndAcceptUserMedia(room_url);
+
+ ASSERT_TRUE(WaitForCallToComeUp(left_tab));
+ ASSERT_TRUE(WaitForCallToComeUp(right_tab));
+
+ ASSERT_TRUE(StopApprtcInstance());
+}
diff --git a/chrome/browser/media/webrtc_browsertest_base.cc b/chrome/browser/media/webrtc_browsertest_base.cc
index 5f114f2..2345cea 100644
--- a/chrome/browser/media/webrtc_browsertest_base.cc
+++ b/chrome/browser/media/webrtc_browsertest_base.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/media/media_stream_infobar_delegate.h"
#include "chrome/browser/media/webrtc_browsertest_common.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/browser_test_utils.h"
@@ -28,14 +29,15 @@ WebRtcTestBase::WebRtcTestBase() {
WebRtcTestBase::~WebRtcTestBase() {
}
-void WebRtcTestBase::GetUserMediaAndAccept(content::WebContents* tab_contents) {
+void WebRtcTestBase::GetUserMediaAndAccept(
+ content::WebContents* tab_contents) const {
GetUserMediaWithSpecificConstraintsAndAccept(tab_contents,
kAudioVideoCallConstraints);
}
void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept(
content::WebContents* tab_contents,
- const std::string& constraints) {
+ const std::string& constraints) const {
MediaStreamInfoBarDelegate* infobar =
GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
infobar->Accept();
@@ -54,7 +56,7 @@ void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) {
void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
content::WebContents* tab_contents,
- const std::string& constraints) {
+ const std::string& constraints) const {
MediaStreamInfoBarDelegate* infobar =
GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
infobar->Cancel();
@@ -66,7 +68,7 @@ void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
}
void WebRtcTestBase::GetUserMediaAndDismiss(
- content::WebContents* tab_contents) {
+ content::WebContents* tab_contents) const {
MediaStreamInfoBarDelegate* infobar =
GetUserMediaAndWaitForInfoBar(tab_contents, kAudioVideoCallConstraints);
infobar->InfoBarDismissed();
@@ -78,7 +80,7 @@ void WebRtcTestBase::GetUserMediaAndDismiss(
}
void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
- const std::string& constraints) {
+ const std::string& constraints) const {
// Request user media: this will launch the media stream info bar.
std::string result;
EXPECT_TRUE(content::ExecuteScriptAndExtractString(
@@ -88,7 +90,7 @@ void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
MediaStreamInfoBarDelegate* WebRtcTestBase::GetUserMediaAndWaitForInfoBar(
content::WebContents* tab_contents,
- const std::string& constraints) {
+ const std::string& constraints) const {
content::WindowedNotificationObserver infobar_added(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
content::NotificationService::AllSources());
@@ -104,8 +106,31 @@ MediaStreamInfoBarDelegate* WebRtcTestBase::GetUserMediaAndWaitForInfoBar(
return infobar;
}
-void WebRtcTestBase::CloseInfoBarInTab(content::WebContents* tab_contents,
- MediaStreamInfoBarDelegate* infobar) {
+content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia(
+ const GURL& url) const {
+ content::WindowedNotificationObserver infobar_added(
+ chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
+ content::NotificationService::AllSources());
+
+ ui_test_utils::NavigateToURL(browser(), url);
+
+ infobar_added.Wait();
+
+ content::WebContents* tab_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ content::Details<InfoBarAddedDetails> details(infobar_added.details());
+ MediaStreamInfoBarDelegate* infobar =
+ details->AsMediaStreamInfoBarDelegate();
+ EXPECT_TRUE(infobar);
+ infobar->Accept();
+
+ CloseInfoBarInTab(tab_contents, infobar);
+ return tab_contents;
+}
+
+void WebRtcTestBase::CloseInfoBarInTab(
+ content::WebContents* tab_contents,
+ MediaStreamInfoBarDelegate* infobar) const {
content::WindowedNotificationObserver infobar_removed(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
content::NotificationService::AllSources());
diff --git a/chrome/browser/media/webrtc_browsertest_base.h b/chrome/browser/media/webrtc_browsertest_base.h
index 7afff6f..b1b546b 100644
--- a/chrome/browser/media/webrtc_browsertest_base.h
+++ b/chrome/browser/media/webrtc_browsertest_base.h
@@ -30,17 +30,19 @@ class WebRtcTestBase : public InProcessBrowserTest {
WebRtcTestBase();
virtual ~WebRtcTestBase();
- void GetUserMediaAndAccept(content::WebContents* tab_contents);
+ void GetUserMediaAndAccept(content::WebContents* tab_contents) const;
void GetUserMediaWithSpecificConstraintsAndAccept(
content::WebContents* tab_contents,
- const std::string& constraints);
+ const std::string& constraints) const;
void GetUserMediaAndDeny(content::WebContents* tab_contents);
void GetUserMediaWithSpecificConstraintsAndDeny(
content::WebContents* tab_contents,
- const std::string& constraints);
- void GetUserMediaAndDismiss(content::WebContents* tab_contents);
+ const std::string& constraints) const;
+ void GetUserMediaAndDismiss(content::WebContents* tab_contents) const;
void GetUserMedia(content::WebContents* tab_contents,
- const std::string& constraints);
+ const std::string& constraints) const;
+
+ content::WebContents* OpenPageAndAcceptUserMedia(const GURL& url) const;
void ConnectToPeerConnectionServer(const std::string& peer_name,
content::WebContents* tab_contents) const;
@@ -48,11 +50,11 @@ class WebRtcTestBase : public InProcessBrowserTest {
content::WebContents* tab_contents) const;
private:
+ void CloseInfoBarInTab(content::WebContents* tab_contents,
+ MediaStreamInfoBarDelegate* infobar) const;
MediaStreamInfoBarDelegate* GetUserMediaAndWaitForInfoBar(
content::WebContents* tab_contents,
- const std::string& constraints);
- void CloseInfoBarInTab(content::WebContents* tab_contents,
- MediaStreamInfoBarDelegate* infobar);
+ const std::string& constraints) const;
DISALLOW_COPY_AND_ASSIGN(WebRtcTestBase);
};