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

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

Issue 617103008: Update chromoting browser-tests to obtain user-name and password from a specified file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows-specific compile error. 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 | « chrome/test/remoting/remote_desktop_browsertest.h ('k') | 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 VerifyInternetAccess(); 467 VerifyInternetAccess();
468 Install(); 468 Install();
469 LaunchChromotingApp(); 469 LaunchChromotingApp();
470 Auth(); 470 Auth();
471 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js")); 471 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js"));
472 ExpandMe2Me(); 472 ExpandMe2Me();
473 EnsureRemoteConnectionEnabled(); 473 EnsureRemoteConnectionEnabled();
474 } 474 }
475 475
476 void RemoteDesktopBrowserTest::Auth() { 476 void RemoteDesktopBrowserTest::Auth() {
477 // For this test, we must be given the user-name and password.
478 ASSERT_TRUE(!username_.empty() && !password_.empty());
479
477 Authorize(); 480 Authorize();
478 Authenticate(); 481 Authenticate();
479 Approve(); 482 Approve();
480 } 483 }
481 484
482 void RemoteDesktopBrowserTest::EnsureRemoteConnectionEnabled() { 485 void RemoteDesktopBrowserTest::EnsureRemoteConnectionEnabled() {
483 // browser_test.ensureRemoteConnectionEnabled is defined in 486 // browser_test.ensureRemoteConnectionEnabled is defined in
484 // browser_test.js, which must be loaded before calling this function. 487 // browser_test.js, which must be loaded before calling this function.
485 // TODO(kelvinp): This function currently only works on linux when the user is 488 // TODO(kelvinp): This function currently only works on linux when the user is
486 // already part of the chrome-remote-desktop group. Extend this functionality 489 // already part of the chrome-remote-desktop group. Extend this functionality
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 if (command_line->HasSwitch(kOverrideUserDataDir)) { 568 if (command_line->HasSwitch(kOverrideUserDataDir)) {
566 const base::FilePath& override_user_data_dir = 569 const base::FilePath& override_user_data_dir =
567 command_line->GetSwitchValuePath(kOverrideUserDataDir); 570 command_line->GetSwitchValuePath(kOverrideUserDataDir);
568 571
569 ASSERT_FALSE(override_user_data_dir.empty()); 572 ASSERT_FALSE(override_user_data_dir.empty());
570 573
571 command_line->AppendSwitchPath(switches::kUserDataDir, 574 command_line->AppendSwitchPath(switches::kUserDataDir,
572 override_user_data_dir); 575 override_user_data_dir);
573 } 576 }
574 577
575 username_ = command_line->GetSwitchValueASCII(kUsername); 578 CommandLine::StringType accounts_file =
576 password_ = command_line->GetSwitchValueASCII(kkPassword); 579 command_line->GetSwitchValueNative(kAccountsFile);
580 std::string account_type = command_line->GetSwitchValueASCII(kAccountType);
581 if (!accounts_file.empty()) {
582 // We've been passed in a file containing accounts information.
583 // In this case, we'll obtain the user-name and password information from
584 // the specified file, even if user-name and password have been specified
585 // on the command-line.
586 base::FilePath accounts_file_path((base::FilePath(accounts_file)));
587 ASSERT_FALSE(account_type.empty());
588 ASSERT_TRUE(base::PathExists((base::FilePath(accounts_file))));
589 SetUserNameAndPassword((base::FilePath(accounts_file)), account_type);
590 } else {
591 // No file for accounts specified. Read user-name and password from command
592 // line.
593 username_ = command_line->GetSwitchValueASCII(kUserName);
594 password_ = command_line->GetSwitchValueASCII(kUserPassword);
595 }
596
577 me2me_pin_ = command_line->GetSwitchValueASCII(kMe2MePin); 597 me2me_pin_ = command_line->GetSwitchValueASCII(kMe2MePin);
578 remote_host_name_ = command_line->GetSwitchValueASCII(kRemoteHostName); 598 remote_host_name_ = command_line->GetSwitchValueASCII(kRemoteHostName);
579 extension_name_ = command_line->GetSwitchValueASCII(kExtensionName); 599 extension_name_ = command_line->GetSwitchValueASCII(kExtensionName);
580 http_server_ = command_line->GetSwitchValueASCII(kHttpServer); 600 http_server_ = command_line->GetSwitchValueASCII(kHttpServer);
581 601
582 no_cleanup_ = command_line->HasSwitch(kNoCleanup); 602 no_cleanup_ = command_line->HasSwitch(kNoCleanup);
583 no_install_ = command_line->HasSwitch(kNoInstall); 603 no_install_ = command_line->HasSwitch(kNoInstall);
584 604
585 if (!no_install_) { 605 if (!no_install_) {
586 webapp_crx_ = command_line->GetSwitchValuePath(kWebAppCrx); 606 webapp_crx_ = command_line->GetSwitchValuePath(kWebAppCrx);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 bool RemoteDesktopBrowserTest::IsPinFormVisible() { 811 bool RemoteDesktopBrowserTest::IsPinFormVisible() {
792 DismissHostVersionWarningIfVisible(); 812 DismissHostVersionWarningIfVisible();
793 return HtmlElementVisible("pin-form"); 813 return HtmlElementVisible("pin-form");
794 } 814 }
795 815
796 void RemoteDesktopBrowserTest::DismissHostVersionWarningIfVisible() { 816 void RemoteDesktopBrowserTest::DismissHostVersionWarningIfVisible() {
797 if (HtmlElementVisible("host-needs-update-connect-button")) 817 if (HtmlElementVisible("host-needs-update-connect-button"))
798 ClickOnControl("host-needs-update-connect-button"); 818 ClickOnControl("host-needs-update-connect-button");
799 } 819 }
800 820
821 void RemoteDesktopBrowserTest::SetUserNameAndPassword(
822 const base::FilePath &accounts_file_path, const std::string& account_type) {
823
824 // Read contents of accounts file.
825 std::string accounts_info;
826 ASSERT_TRUE(base::ReadFileToString(accounts_file_path, &accounts_info));
827
828 // Get the root dictionary from the input json file contents.
829 scoped_ptr<base::Value> root(
830 base::JSONReader::Read(accounts_info, base::JSON_ALLOW_TRAILING_COMMAS));
831
832 const base::DictionaryValue* root_dict = NULL;
833 ASSERT_TRUE(root.get() && root->GetAsDictionary(&root_dict));
834
835 // Now get the dictionary for the specified account type.
836 const base::DictionaryValue* account_dict = NULL;
837 ASSERT_TRUE(root_dict->GetDictionary(account_type, &account_dict));
838 ASSERT_TRUE(account_dict->GetString(kUserName, &username_));
839 ASSERT_TRUE(account_dict->GetString(kUserPassword, &password_));
840 }
841
801 // static 842 // static
802 bool RemoteDesktopBrowserTest::IsAuthenticatedInWindow( 843 bool RemoteDesktopBrowserTest::IsAuthenticatedInWindow(
803 content::WebContents* web_contents) { 844 content::WebContents* web_contents) {
804 return ExecuteScriptAndExtractBool( 845 return ExecuteScriptAndExtractBool(
805 web_contents, "remoting.identity.isAuthenticated()"); 846 web_contents, "remoting.identity.isAuthenticated()");
806 } 847 }
807 848
808 // static 849 // static
809 bool RemoteDesktopBrowserTest::IsHostActionComplete( 850 bool RemoteDesktopBrowserTest::IsHostActionComplete(
810 content::WebContents* client_web_content, 851 content::WebContents* client_web_content,
811 std::string host_action_var) { 852 std::string host_action_var) {
812 return ExecuteScriptAndExtractBool( 853 return ExecuteScriptAndExtractBool(
813 client_web_content, 854 client_web_content,
814 host_action_var); 855 host_action_var);
815 } 856 }
816 857
817 // static 858 // static
818 bool RemoteDesktopBrowserTest::IsEnabled( 859 bool RemoteDesktopBrowserTest::IsEnabled(
819 content::WebContents* client_web_content, 860 content::WebContents* client_web_content,
820 const std::string& element_name) { 861 const std::string& element_name) {
821 return !ExecuteScriptAndExtractBool( 862 return !ExecuteScriptAndExtractBool(
822 client_web_content, 863 client_web_content,
823 "document.getElementById(\"" + element_name + "\").disabled"); 864 "document.getElementById(\"" + element_name + "\").disabled");
824 } 865 }
825 866
826 } // namespace remoting 867 } // namespace remoting
OLDNEW
« no previous file with comments | « chrome/test/remoting/remote_desktop_browsertest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698