Chromium Code Reviews| 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..adaaa992507aee7f531e8d7337201a4e1abf03a3 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(); |
| } |
| @@ -572,8 +573,24 @@ 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); |
| + 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); |
| + } 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 +815,30 @@ void RemoteDesktopBrowserTest::DismissHostVersionWarningIfVisible() { |
| ClickOnControl("host-needs-update-connect-button"); |
| } |
| +void RemoteDesktopBrowserTest::SetUserNameAndPassword( |
|
weitao
2014/10/08 23:19:16
I suggest that we don't store the accounts file pa
anandc
2014/10/09 00:15:25
Done.
|
| + const base::FilePath &accounts_file_path) { |
| + |
| + // Read contents of accounts file. |
| + std::string accounts_info; |
| + ASSERT_TRUE(base::ReadFileToString(accounts_file_path, &accounts_info)); |
| + |
| + scoped_ptr<base::Value> root( |
| + base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS)); |
| + DCHECK(root.get() != NULL); |
| + ASSERT_TRUE(root.get() && root->GetType() == base::Value::TYPE_DICTIONARY); |
| + |
| + // Get the root dictionary from the input json file contents. |
| + const base::DictionaryValue* root_dict = |
| + static_cast<base::DictionaryValue*>(root.get()); |
|
weitao
2014/10/08 23:19:16
Please use GetAsDictionary. And instead of asserti
anandc
2014/10/09 00:15:25
Done.
|
| + // And now the dictionary for the specified account type. |
| + const base::DictionaryValue* account_dict = NULL; |
| + root_dict->GetDictionary(account_type_, &account_dict); |
|
weitao
2014/10/08 23:19:16
assert the result of GetDictionary.
anandc
2014/10/09 00:15:24
Done.
|
| + |
| + ASSERT_TRUE(account_dict->GetString(kUserName, &username_)); |
| + |
| + ASSERT_TRUE(account_dict->GetString(kPassword, &password_)); |
| +} |
| + |
| // static |
| bool RemoteDesktopBrowserTest::IsAuthenticatedInWindow( |
| content::WebContents* web_contents) { |