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

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

Issue 639123010: Chromoting browser-tests should be able to read files specified with relative paths. (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 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 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Read contents of accounts file.
825 std::string accounts_info; 825 // To handle relative paths, we'll first get the size of the file.
Jamie 2014/10/22 23:02:26 Getting the size of the file is not only needed fo
anandc 2014/10/23 00:00:40 Done.
826 ASSERT_TRUE(base::ReadFileToString(accounts_file_path, &accounts_info)); 826 int64 accounts_file_size;
anandc 2014/10/18 02:33:45 ReadFileToString returns an error if the file-path
827 base::GetFileSize(accounts_file_path, &accounts_file_size);
828 // Then read the contents of the file.
829 char buf[accounts_file_size];
830 ASSERT_FALSE(base::ReadFile(accounts_file_path, buf, sizeof(buf)-1) == -1);
Jamie 2014/10/22 23:02:26 Nit: spaces around the subtraction operator.
anandc 2014/10/23 00:00:40 Done.
827 831
828 // Get the root dictionary from the input json file contents. 832 // Get the root dictionary from the input json file contents.
833 std::string accounts_info(buf);
829 scoped_ptr<base::Value> root( 834 scoped_ptr<base::Value> root(
830 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS)); 835 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS));
831 836
832 const base::DictionaryValue* root_dict = NULL; 837 const base::DictionaryValue* root_dict = NULL;
833 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict)); 838 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict));
834 839
835 // Now get the dictionary for the specified account type. 840 // Now get the dictionary for the specified account type.
836 const base::DictionaryValue* account_dict = NULL; 841 const base::DictionaryValue* account_dict = NULL;
837 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict)); 842 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict));
838 ASSERT_TRUE(account_dict->GetString(kUserName, &username_)); 843 ASSERT_TRUE(account_dict->GetString(kUserName, &username_));
(...skipping 19 matching lines...) Expand all
858 // static 863 // static
859 bool RemoteDesktopBrowserTest::IsEnabled( 864 bool RemoteDesktopBrowserTest::IsEnabled(
860 content::WebContents* client_web_content, 865 content::WebContents* client_web_content,
861 const std::string& element_name) { 866 const std::string& element_name) {
862 return !ExecuteScriptAndExtractBool( 867 return !ExecuteScriptAndExtractBool(
863 client_web_content, 868 client_web_content,
864 "document.getElementById(\"" + element_name + "\").disabled"); 869 "document.getElementById(\"" + element_name + "\").disabled");
865 } 870 }
866 871
867 } // namespace remoting 872 } // 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