Chromium Code Reviews| 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 "chrome/browser/chromeos/drive/file_system_util.h" | 9 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 10 #include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h" | 10 #include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h" |
| 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 12 #include "chrome/browser/signin/signin_manager_factory.h" | 12 #include "chrome/browser/signin/signin_manager_factory.h" |
| 13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
| 14 #include "components/session_manager/core/session_manager.h" | |
| 14 #include "components/signin/core/browser/signin_manager.h" | 15 #include "components/signin/core/browser/signin_manager.h" |
| 15 #include "components/user_manager/user_manager.h" | 16 #include "components/user_manager/user_manager.h" |
| 16 | 17 |
| 17 namespace file_manager { | 18 namespace file_manager { |
| 18 | 19 |
| 19 // Parameter of FileManagerBrowserTest. | 20 // Parameter of FileManagerBrowserTest. |
| 20 // The second value is the case name of JavaScript. | 21 // The second value is the case name of JavaScript. |
| 21 typedef std::tr1::tuple<GuestMode, const char*> TestParameter; | 22 typedef std::tr1::tuple<GuestMode, const char*> TestParameter; |
| 22 | 23 |
| 23 // Test fixture class for normal (not multi-profile related) tests. | 24 // Test fixture class for normal (not multi-profile related) tests. |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 Profile* const profile = chromeos::ProfileHelper::GetProfileByUserIdHash( | 629 Profile* const profile = chromeos::ProfileHelper::GetProfileByUserIdHash( |
| 629 kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash); | 630 kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash); |
| 630 return profile ? profile : FileManagerBrowserTestBase::profile(); | 631 return profile ? profile : FileManagerBrowserTestBase::profile(); |
| 631 } | 632 } |
| 632 | 633 |
| 633 // Sets the test case name (used as a function name in test_cases.js to call.) | 634 // Sets the test case name (used as a function name in test_cases.js to call.) |
| 634 void set_test_case_name(const std::string& name) { test_case_name_ = name; } | 635 void set_test_case_name(const std::string& name) { test_case_name_ = name; } |
| 635 | 636 |
| 636 // Adds a new user for testing to the current session. | 637 // Adds a new user for testing to the current session. |
| 637 void AddUser(const TestAccountInfo& info, bool log_in) { | 638 void AddUser(const TestAccountInfo& info, bool log_in) { |
| 638 user_manager::UserManager* const user_manager = | |
| 639 user_manager::UserManager::Get(); | |
| 640 const AccountId account_id(AccountId::FromUserEmail(info.email)); | 639 const AccountId account_id(AccountId::FromUserEmail(info.email)); |
| 641 if (log_in) | 640 if (log_in) |
|
James Cook
2017/01/11 19:27:20
nit: {}, or "using" to shorten the line
xiyuan
2017/01/11 20:48:38
Done.
| |
| 642 user_manager->UserLoggedIn(account_id, info.hash, false); | 641 session_manager::SessionManager::Get()->CreateSession(account_id, |
| 643 user_manager->SaveUserDisplayName(account_id, | 642 info.hash); |
| 644 base::UTF8ToUTF16(info.display_name)); | 643 user_manager::UserManager::Get()->SaveUserDisplayName( |
| 644 account_id, base::UTF8ToUTF16(info.display_name)); | |
| 645 SigninManagerFactory::GetForProfile( | 645 SigninManagerFactory::GetForProfile( |
| 646 chromeos::ProfileHelper::GetProfileByUserIdHash(info.hash)) | 646 chromeos::ProfileHelper::GetProfileByUserIdHash(info.hash)) |
| 647 ->SetAuthenticatedAccountInfo(info.gaia_id, info.email); | 647 ->SetAuthenticatedAccountInfo(info.gaia_id, info.email); |
| 648 } | 648 } |
| 649 | 649 |
| 650 private: | 650 private: |
| 651 GuestMode GetGuestModeParam() const override { return NOT_IN_GUEST_MODE; } | 651 GuestMode GetGuestModeParam() const override { return NOT_IN_GUEST_MODE; } |
| 652 const char* GetTestManifestName() const override { | 652 const char* GetTestManifestName() const override { |
| 653 return "file_manager_test_manifest.json"; | 653 return "file_manager_test_manifest.json"; |
| 654 } | 654 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 | 696 |
| 697 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MAYBE_BasicDrive) { | 697 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MAYBE_BasicDrive) { |
| 698 AddAllUsers(); | 698 AddAllUsers(); |
| 699 | 699 |
| 700 // Sanity check that normal operations work in multi-profile setting as well. | 700 // Sanity check that normal operations work in multi-profile setting as well. |
| 701 set_test_case_name("keyboardCopyDrive"); | 701 set_test_case_name("keyboardCopyDrive"); |
| 702 StartTest(); | 702 StartTest(); |
| 703 } | 703 } |
| 704 | 704 |
| 705 } // namespace file_manager | 705 } // namespace file_manager |
| OLD | NEW |