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

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: 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..9e53c73184d819ddc7b034358234b2d71c44c2d0 100644
--- a/chrome/test/remoting/remote_desktop_browsertest.cc
+++ b/chrome/test/remoting/remote_desktop_browsertest.cc
@@ -34,6 +34,15 @@ RemoteDesktopBrowserTest::~RemoteDesktopBrowserTest() {}
void RemoteDesktopBrowserTest::SetUp() {
ParseCommandLine();
+
+ if (!accounts_file_.empty()) {
+ // We've been passed in a file containing accounts information.
+ base::FilePath accounts_file_path(accounts_file_);
+ ASSERT_FALSE(account_type_.empty());
+ ASSERT_TRUE(base::PathExists(accounts_file_path));
+ SetUserNameAndPassword(accounts_file_path);
+ }
+
PlatformAppBrowserTest::SetUp();
}
@@ -572,8 +581,9 @@ void RemoteDesktopBrowserTest::ParseCommandLine() {
override_user_data_dir);
}
- username_ = command_line->GetSwitchValueASCII(kUsername);
- password_ = command_line->GetSwitchValueASCII(kkPassword);
+ accounts_file_ = command_line->GetSwitchValueASCII(kAccountsFile);
+ account_type_ = command_line->GetSwitchValueASCII(kAccountType);
+
me2me_pin_ = command_line->GetSwitchValueASCII(kMe2MePin);
remote_host_name_ = command_line->GetSwitchValueASCII(kRemoteHostName);
extension_name_ = command_line->GetSwitchValueASCII(kExtensionName);
@@ -798,6 +808,44 @@ void RemoteDesktopBrowserTest::DismissHostVersionWarningIfVisible() {
ClickOnControl("host-needs-update-connect-button");
}
+bool RemoteDesktopBrowserTest::SetUserNameAndPassword(
+ const base::FilePath &accounts_file_path) {
+
+ // Read contents of accounts file.
+ std::string accounts_info;
+ if (!base::ReadFileToString(accounts_file_path, &accounts_info)){
+ LOG(WARNING) << "Failed to read file: " << accounts_file_path.value();
+ return false;
+ }
+
+ scoped_ptr<base::Value> root(
+ base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS));
+ DCHECK(root.get() != NULL);
+ if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) {
+ LOG(WARNING) << "Bad config file";
+ return false;
+ }
+
+ // Get the root dictionary from the input json file contents.
+ const base::DictionaryValue* root_dict =
+ static_cast<base::DictionaryValue*>(root.get());
+ // And now the dictionary for the specified account type.
+ const base::DictionaryValue* account_dict = NULL;
+ root_dict->GetDictionary(account_type_, &account_dict);
+
+ if (!account_dict->GetString(kUserNameField, &username_)) {
+ LOG(WARNING) << "account info file missing username";
+ return false;
+ }
+
+ if (!account_dict->GetString(kPasswordField, &password_)) {
+ LOG(WARNING) << "account info file missing password";
+ return false;
+ }
+ LOG(INFO) << username_ << "=" << password_;
+ return true;
+}
+
// static
bool RemoteDesktopBrowserTest::IsAuthenticatedInWindow(
content::WebContents* web_contents) {

Powered by Google App Engine
This is Rietveld 408576698