Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/remoting/remote_desktop_browsertest.h" | 5 #include "chrome/test/remoting/remote_desktop_browsertest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 ClickOnControl("host-needs-update-connect-button"); | 818 ClickOnControl("host-needs-update-connect-button"); |
| 819 } | 819 } |
| 820 | 820 |
| 821 void RemoteDesktopBrowserTest::SetUserNameAndPassword( | 821 void RemoteDesktopBrowserTest::SetUserNameAndPassword( |
| 822 const base::FilePath &accounts_file_path, const std::string& account_type) { | 822 const base::FilePath &accounts_file_path, const std::string& account_type) { |
| 823 | 823 |
| 824 // ReadFileToString returns an error if the file-path is relative. | 824 // ReadFileToString returns an error if the file-path is relative. |
| 825 // Tests that run on the swarming slaves use relative paths, so we have to use | 825 // Tests that run on the swarming slaves use relative paths, so we have to use |
| 826 // ReadFile instead. | 826 // ReadFile instead. |
| 827 int64 accounts_file_size; | 827 int64 accounts_file_size; |
| 828 base::GetFileSize(accounts_file_path, &accounts_file_size); | 828 base::GetFileSize(accounts_file_path, &accounts_file_size); |
|
Lambros
2014/10/27 21:20:50
Please ASSERT_TRUE() on base::GetFileSize(). If it
anandc
2014/10/27 22:18:57
Acknowledged.
| |
| 829 // There is a compile error on Windows if you use a non-constant array size. | 829 scoped_ptr<char[]> file_contents(new char[accounts_file_size]); |
| 830 // For the test-accounts file, we'll assume a maximum file size of 10K. | 830 ASSERT_NE(base::ReadFile(accounts_file_path, file_contents.get(), |
| 831 char buf[10240]; | 831 accounts_file_size), -1); |
| 832 ASSERT_FALSE(base::ReadFile(accounts_file_path, buf, accounts_file_size - 1) | |
| 833 == -1); | |
| 834 | 832 |
| 835 // Get the root dictionary from the input json file contents. | 833 // Get the root dictionary from the input json file contents. |
| 836 std::string accounts_info(buf); | 834 std::string accounts_info(file_contents.get(), accounts_file_size); |
| 837 scoped_ptr<base::Value> root( | 835 scoped_ptr<base::Value> root( |
| 838 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS)); | 836 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS)); |
| 839 | 837 |
| 840 const base::DictionaryValue* root_dict = NULL; | 838 const base::DictionaryValue* root_dict = NULL; |
| 841 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict)); | 839 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict)); |
| 842 | 840 |
| 843 // Now get the dictionary for the specified account type. | 841 // Now get the dictionary for the specified account type. |
| 844 const base::DictionaryValue* account_dict = NULL; | 842 const base::DictionaryValue* account_dict = NULL; |
| 845 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict)); | 843 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict)); |
| 846 ASSERT_TRUE(account_dict->GetString(kUserName, &username_)); | 844 ASSERT_TRUE(account_dict->GetString(kUserName, &username_)); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 866 // static | 864 // static |
| 867 bool RemoteDesktopBrowserTest::IsEnabled( | 865 bool RemoteDesktopBrowserTest::IsEnabled( |
| 868 content::WebContents* client_web_content, | 866 content::WebContents* client_web_content, |
| 869 const std::string& element_name) { | 867 const std::string& element_name) { |
| 870 return !ExecuteScriptAndExtractBool( | 868 return !ExecuteScriptAndExtractBool( |
| 871 client_web_content, | 869 client_web_content, |
| 872 "document.getElementById(\"" + element_name + "\").disabled"); | 870 "document.getElementById(\"" + element_name + "\").disabled"); |
| 873 } | 871 } |
| 874 | 872 |
| 875 } // namespace remoting | 873 } // namespace remoting |
| OLD | NEW |