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 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 } | 814 } |
815 | 815 |
816 void RemoteDesktopBrowserTest::DismissHostVersionWarningIfVisible() { | 816 void RemoteDesktopBrowserTest::DismissHostVersionWarningIfVisible() { |
817 if (HtmlElementVisible("host-needs-update-connect-button")) | 817 if (HtmlElementVisible("host-needs-update-connect-button")) |
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 // Read contents of accounts file. | 824 // ReadFileToString returns an error if the file-path is relative. |
825 std::string accounts_info; | 825 // Tests that run on the swarming slaves use relative paths, so we have to use |
826 ASSERT_TRUE(base::ReadFileToString(accounts_file_path, &accounts_info)); | 826 // ReadFile instead. |
| 827 int64 accounts_file_size; |
| 828 base::GetFileSize(accounts_file_path, &accounts_file_size); |
| 829 // There is a compile error on Windows if you use a non-constant array size. |
| 830 // For the test-accounts file, we'll assume a maximum file size of 10K. |
| 831 char buf[10240]; |
| 832 ASSERT_FALSE(base::ReadFile(accounts_file_path, buf, accounts_file_size - 1) |
| 833 == -1); |
827 | 834 |
828 // Get the root dictionary from the input json file contents. | 835 // Get the root dictionary from the input json file contents. |
| 836 std::string accounts_info(buf); |
829 scoped_ptr<base::Value> root( | 837 scoped_ptr<base::Value> root( |
830 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS)); | 838 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS)); |
831 | 839 |
832 const base::DictionaryValue* root_dict = NULL; | 840 const base::DictionaryValue* root_dict = NULL; |
833 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict)); | 841 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict)); |
834 | 842 |
835 // Now get the dictionary for the specified account type. | 843 // Now get the dictionary for the specified account type. |
836 const base::DictionaryValue* account_dict = NULL; | 844 const base::DictionaryValue* account_dict = NULL; |
837 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict)); | 845 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict)); |
838 ASSERT_TRUE(account_dict->GetString(kUserName, &username_)); | 846 ASSERT_TRUE(account_dict->GetString(kUserName, &username_)); |
(...skipping 19 matching lines...) Expand all Loading... |
858 // static | 866 // static |
859 bool RemoteDesktopBrowserTest::IsEnabled( | 867 bool RemoteDesktopBrowserTest::IsEnabled( |
860 content::WebContents* client_web_content, | 868 content::WebContents* client_web_content, |
861 const std::string& element_name) { | 869 const std::string& element_name) { |
862 return !ExecuteScriptAndExtractBool( | 870 return !ExecuteScriptAndExtractBool( |
863 client_web_content, | 871 client_web_content, |
864 "document.getElementById(\"" + element_name + "\").disabled"); | 872 "document.getElementById(\"" + element_name + "\").disabled"); |
865 } | 873 } |
866 | 874 |
867 } // namespace remoting | 875 } // namespace remoting |
OLD | NEW |