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

Side by Side Diff: chrome/test/remoting/remote_desktop_browsertest.cc

Issue 680643003: Read contents of test file after getting its absolute path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create absolute path, for use in call to ReadFileToString. Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // ReadFileToString returns an error if the file-path is relative. 824 // Read contents of accounts file, using its absolute path.
825 // Tests that run on the swarming slaves use relative paths, so we have to use 825 base::FilePath absolute_path = base::MakeAbsoluteFilePath(accounts_file_path);
826 // ReadFile instead. 826 std::string accounts_info;
827 int64 accounts_file_size; 827 ASSERT_TRUE(base::ReadFileToString(absolute_path, &accounts_info));
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);
834 828
835 // Get the root dictionary from the input json file contents. 829 // Get the root dictionary from the input json file contents.
836 std::string accounts_info(buf);
837 scoped_ptr<base::Value> root( 830 scoped_ptr<base::Value> root(
838 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS)); 831 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS));
839 832
840 const base::DictionaryValue* root_dict = NULL; 833 const base::DictionaryValue* root_dict = NULL;
841 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict)); 834 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict));
842 835
843 // Now get the dictionary for the specified account type. 836 // Now get the dictionary for the specified account type.
844 const base::DictionaryValue* account_dict = NULL; 837 const base::DictionaryValue* account_dict = NULL;
845 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict)); 838 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict));
846 ASSERT_TRUE(account_dict->GetString(kUserName, &username_)); 839 ASSERT_TRUE(account_dict->GetString(kUserName, &username_));
(...skipping 19 matching lines...) Expand all
866 // static 859 // static
867 bool RemoteDesktopBrowserTest::IsEnabled( 860 bool RemoteDesktopBrowserTest::IsEnabled(
868 content::WebContents* client_web_content, 861 content::WebContents* client_web_content,
869 const std::string& element_name) { 862 const std::string& element_name) {
870 return !ExecuteScriptAndExtractBool( 863 return !ExecuteScriptAndExtractBool(
871 client_web_content, 864 client_web_content,
872 "document.getElementById(\"" + element_name + "\").disabled"); 865 "document.getElementById(\"" + element_name + "\").disabled");
873 } 866 }
874 867
875 } // namespace remoting 868 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698