OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "chrome/browser/chromeos/drive/file_system_util.h" | 10 #include "chrome/browser/chromeos/drive/file_system_util.h" |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 // Loads all users to the current session and sets up necessary fields. | 608 // Loads all users to the current session and sets up necessary fields. |
609 // This is used for preparing all accounts in PRE_ test setup, and for testing | 609 // This is used for preparing all accounts in PRE_ test setup, and for testing |
610 // actual login behavior. | 610 // actual login behavior. |
611 void AddAllUsers() { | 611 void AddAllUsers() { |
612 for (size_t i = 0; i < arraysize(kTestAccounts); ++i) | 612 for (size_t i = 0; i < arraysize(kTestAccounts); ++i) |
613 AddUser(kTestAccounts[i], i >= SECONDARY_ACCOUNT_INDEX_START); | 613 AddUser(kTestAccounts[i], i >= SECONDARY_ACCOUNT_INDEX_START); |
614 } | 614 } |
615 | 615 |
616 // Returns primary profile (if it is already created.) | 616 // Returns primary profile (if it is already created.) |
617 Profile* profile() override { | 617 Profile* profile() override { |
618 Profile* const profile = chromeos::ProfileHelper::GetProfileByUserIdHash( | 618 Profile* const profile = |
619 kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash); | 619 chromeos::ProfileHelper::GetProfileByUserIdHashForTest( |
| 620 kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash); |
620 return profile ? profile : FileManagerBrowserTestBase::profile(); | 621 return profile ? profile : FileManagerBrowserTestBase::profile(); |
621 } | 622 } |
622 | 623 |
623 // Sets the test case name (used as a function name in test_cases.js to call.) | 624 // Sets the test case name (used as a function name in test_cases.js to call.) |
624 void set_test_case_name(const std::string& name) { test_case_name_ = name; } | 625 void set_test_case_name(const std::string& name) { test_case_name_ = name; } |
625 | 626 |
626 // Adds a new user for testing to the current session. | 627 // Adds a new user for testing to the current session. |
627 void AddUser(const TestAccountInfo& info, bool log_in) { | 628 void AddUser(const TestAccountInfo& info, bool log_in) { |
628 base::ThreadRestrictions::ScopedAllowIO allow_io; | 629 base::ThreadRestrictions::ScopedAllowIO allow_io; |
629 const AccountId account_id(AccountId::FromUserEmail(info.email)); | 630 const AccountId account_id(AccountId::FromUserEmail(info.email)); |
630 if (log_in) { | 631 if (log_in) { |
631 session_manager::SessionManager::Get()->CreateSession(account_id, | 632 session_manager::SessionManager::Get()->CreateSession(account_id, |
632 info.hash); | 633 info.hash); |
633 } | 634 } |
634 user_manager::UserManager::Get()->SaveUserDisplayName( | 635 user_manager::UserManager::Get()->SaveUserDisplayName( |
635 account_id, base::UTF8ToUTF16(info.display_name)); | 636 account_id, base::UTF8ToUTF16(info.display_name)); |
636 SigninManagerFactory::GetForProfile( | 637 SigninManagerFactory::GetForProfile( |
637 chromeos::ProfileHelper::GetProfileByUserIdHash(info.hash)) | 638 chromeos::ProfileHelper::GetProfileByUserIdHashForTest(info.hash)) |
638 ->SetAuthenticatedAccountInfo(info.gaia_id, info.email); | 639 ->SetAuthenticatedAccountInfo(info.gaia_id, info.email); |
639 } | 640 } |
640 | 641 |
641 private: | 642 private: |
642 GuestMode GetGuestModeParam() const override { return NOT_IN_GUEST_MODE; } | 643 GuestMode GetGuestModeParam() const override { return NOT_IN_GUEST_MODE; } |
643 const char* GetTestManifestName() const override { | 644 const char* GetTestManifestName() const override { |
644 return "file_manager_test_manifest.json"; | 645 return "file_manager_test_manifest.json"; |
645 } | 646 } |
646 const char* GetTestCaseNameParam() const override { | 647 const char* GetTestCaseNameParam() const override { |
647 return test_case_name_.c_str(); | 648 return test_case_name_.c_str(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 #endif | 689 #endif |
689 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MAYBE_BasicDrive) { | 690 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MAYBE_BasicDrive) { |
690 AddAllUsers(); | 691 AddAllUsers(); |
691 | 692 |
692 // Sanity check that normal operations work in multi-profile setting as well. | 693 // Sanity check that normal operations work in multi-profile setting as well. |
693 set_test_case_name("keyboardCopyDrive"); | 694 set_test_case_name("keyboardCopyDrive"); |
694 StartTest(); | 695 StartTest(); |
695 } | 696 } |
696 | 697 |
697 } // namespace file_manager | 698 } // namespace file_manager |
OLD | NEW |