Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1541)

Unified Diff: remoting/test/remote_desktop_browsertest.cc

Issue 22274016: Adding the "Authenticate" step to the "MANUAL_Auth" test case. Also added the username and password… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser_tests_v2
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/test/remote_desktop_browsertest.cc
diff --git a/remoting/test/remote_desktop_browsertest.cc b/remoting/test/remote_desktop_browsertest.cc
index 4721e54e051d11dbc7ea4588f75490cdc1282bb5..982895afe2021dc311ad15078aef88417be56ee8 100644
--- a/remoting/test/remote_desktop_browsertest.cc
+++ b/remoting/test/remote_desktop_browsertest.cc
@@ -35,6 +35,8 @@ const char kOverrideUserDataDir[] = "override-user-data-dir";
const char kNoCleanup[] = "no-cleanup";
const char kNoInstall[] = "no-install";
const char kWebAppCrx[] = "webapp-crx";
+const char kUsername[] = "username";
+const char kPassword[] = "password";
}
namespace remoting {
@@ -77,6 +79,8 @@ class RemoteDesktopBrowserTest : public ExtensionBrowserTest {
void Authorize();
+ void Authenticate();
+
// Whether to perform the cleanup tasks (uninstalling chromoting, etc).
// This is useful for diagnostic purposes.
bool NoCleanup() { return no_cleanup_; }
@@ -116,6 +120,8 @@ class RemoteDesktopBrowserTest : public ExtensionBrowserTest {
bool no_install_;
std::string chromoting_id_;
base::FilePath webapp_crx_;
+ std::string username_;
+ std::string password_;
};
void RemoteDesktopBrowserTest::ParseCommandLine() {
@@ -138,6 +144,9 @@ void RemoteDesktopBrowserTest::ParseCommandLine() {
override_user_data_dir);
}
+ username_ = command_line->GetSwitchValueNative(kUsername);
+ password_ = command_line->GetSwitchValueNative(kPassword);
+
no_cleanup_ = command_line->HasSwitch(kNoCleanup);
no_install_ = command_line->HasSwitch(kNoInstall);
@@ -287,6 +296,55 @@ void RemoteDesktopBrowserTest::Authorize() {
EXPECT_TRUE(result);
}
+void RemoteDesktopBrowserTest::Authenticate() {
+ // The chromoting extension should be installed.
+ ASSERT_FALSE(ChromotingID().empty());
+
+ // The active tab should have the "Google Accounts" login page loaded.
+ ASSERT_EQ(GetCurrentURL().host(), "accounts.google.com");
+
+ bool result;
+
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ "window.domAutomationController.send("
+ "document.getElementById(\"Email\") != null);",
+ &result));
+ ASSERT_TRUE(result);
+
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ "window.domAutomationController.send("
+ "document.getElementById(\"Passwd\") != null);",
+ &result));
garykac 2013/08/07 17:52:18 Have you tried extracting this pattern: ASSERT_TR
+ ASSERT_TRUE(result);
+
+ content::WindowedNotificationObserver observer(
+ content::NOTIFICATION_LOAD_STOP,
+ content::Source<content::NavigationController>(
+ &browser()->tab_strip_model()->GetActiveWebContents()->
+ GetController()));
+
+ // Now log in using the username and password passed in from the command line.
+ ASSERT_TRUE(content::ExecuteScript(
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ "document.getElementById(\"Email\").value = \"" + username_ + "\";" +
+ "document.getElementById(\"Passwd\").value = \"" + password_ +"\";" +
+ "document.forms[\"gaia_loginform\"].submit();"));
+ observer.Wait();
+
+ EXPECT_EQ(GetCurrentURL().host(), "accounts.google.com");
+
+ // Is there a better way to verify we are on the "Request for Permission"
+ // page?
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ browser()->tab_strip_model()->GetActiveWebContents(),
+ "window.domAutomationController.send("
+ "document.getElementById(\"submit_approve_access\") != null);",
+ &result));
+ EXPECT_TRUE(result);
+}
+
IN_PROC_BROWSER_TEST_F(RemoteDesktopBrowserTest, MANUAL_Launch) {
VerifyInternetAccess();
@@ -325,6 +383,8 @@ IN_PROC_BROWSER_TEST_F(RemoteDesktopBrowserTest, MANUAL_Auth) {
Authorize();
+ Authenticate();
+
if (!NoCleanup()) {
UninstallChromotingApp();
VerifyChromotingLoaded(false);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698