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

Unified Diff: chrome/test/remoting/remote_desktop_browsertest.cc

Issue 617103008: Update chromoting browser-tests to obtain user-name and password from a specified file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary member variables. Check for required values in Auth test. Created 6 years, 2 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
Index: chrome/test/remoting/remote_desktop_browsertest.cc
diff --git a/chrome/test/remoting/remote_desktop_browsertest.cc b/chrome/test/remoting/remote_desktop_browsertest.cc
index d9a826510c65ae179654d548cf479c5a20a54af1..826477783a7a69dd3b7b0ee492d7cb90687ecb7c 100644
--- a/chrome/test/remoting/remote_desktop_browsertest.cc
+++ b/chrome/test/remoting/remote_desktop_browsertest.cc
@@ -34,6 +34,7 @@ RemoteDesktopBrowserTest::~RemoteDesktopBrowserTest() {}
void RemoteDesktopBrowserTest::SetUp() {
ParseCommandLine();
+
PlatformAppBrowserTest::SetUp();
}
@@ -474,6 +475,9 @@ void RemoteDesktopBrowserTest::SetUpTestForMe2Me() {
}
void RemoteDesktopBrowserTest::Auth() {
+ // For this test, we must be given the user-name and password.
+ ASSERT_TRUE(!username_.empty() && !password_.empty());
anandc 2014/10/09 00:15:25 Added these just to fail quicker.
+
Authorize();
Authenticate();
Approve();
@@ -572,8 +576,24 @@ void RemoteDesktopBrowserTest::ParseCommandLine() {
override_user_data_dir);
}
- username_ = command_line->GetSwitchValueASCII(kUsername);
- password_ = command_line->GetSwitchValueASCII(kkPassword);
+ std::string accounts_file = command_line->GetSwitchValueASCII(kAccountsFile);
+ std::string account_type = command_line->GetSwitchValueASCII(kAccountType);
+ if (!accounts_file.empty()) {
+ // We've been passed in a file containing accounts information.
+ // In this case, we'll obtain the user-name and password information from
+ // the specified file, even if user-name and password have been specified
+ // on the command-line.
+ base::FilePath accounts_file_path(accounts_file);
+ ASSERT_FALSE(account_type.empty());
+ ASSERT_TRUE(base::PathExists(accounts_file_path));
+ SetUserNameAndPassword(accounts_file_path, account_type);
+ } else {
+ // No file for accounts specified. Read user-name and password from command
+ // line.
+ username_ = command_line->GetSwitchValueASCII(kUserName);
+ password_ = command_line->GetSwitchValueASCII(kPassword);
+ }
+
me2me_pin_ = command_line->GetSwitchValueASCII(kMe2MePin);
remote_host_name_ = command_line->GetSwitchValueASCII(kRemoteHostName);
extension_name_ = command_line->GetSwitchValueASCII(kExtensionName);
@@ -798,6 +818,30 @@ void RemoteDesktopBrowserTest::DismissHostVersionWarningIfVisible() {
ClickOnControl("host-needs-update-connect-button");
}
+void RemoteDesktopBrowserTest::SetUserNameAndPassword(
+ const base::FilePath &accounts_file_path, const std::string account_type) {
+
+ // Read contents of accounts file.
+ std::string accounts_info;
+ ASSERT_TRUE(base::ReadFileToString(accounts_file_path, &accounts_info));
+
+ // Get the root dictionary from the input json file contents.
+ scoped_ptr<base::Value> root(
+ base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS));
+ DCHECK(root.get() != NULL);
weitao 2014/10/09 00:23:28 Change to ASSERT_TRUE?
anandc 2014/10/09 00:39:59 Merged with the following ASSERT_TRUE.
+
+ const base::DictionaryValue* root_dict = NULL;
+ ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict));
weitao 2014/10/09 00:23:28 You have already DCHECKed on root.Get() earlier.
anandc 2014/10/09 00:39:59 Done.
+
+ // Now get the dictionary for the specified account type.
+ const base::DictionaryValue* account_dict = NULL;
+ ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict));
+
weitao 2014/10/09 00:23:28 Remove this blank line.
anandc 2014/10/09 00:39:59 Done.
+ ASSERT_TRUE(account_dict->GetString(kUserName, &username_));
+
weitao 2014/10/09 00:23:28 ditto.
anandc 2014/10/09 00:39:59 Done.
+ ASSERT_TRUE(account_dict->GetString(kPassword, &password_));
+}
+
// static
bool RemoteDesktopBrowserTest::IsAuthenticatedInWindow(
content::WebContents* web_contents) {

Powered by Google App Engine
This is Rietveld 408576698