| OLD | NEW | 
|    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/browser/ui/ash/session_state_delegate_chromeos.h" |    5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" | 
|    6  |    6  | 
 |    7 #include <memory> | 
|    7 #include <string> |    8 #include <string> | 
|    8 #include <vector> |    9 #include <vector> | 
|    9  |   10  | 
|   10 #include "base/macros.h" |   11 #include "base/macros.h" | 
|   11 #include "base/memory/scoped_ptr.h" |  | 
|   12 #include "base/run_loop.h" |   12 #include "base/run_loop.h" | 
|   13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |   13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 
|   14 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |   14 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 
|   15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |   15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 
|   16 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |   16 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 
|   17 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |   17 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 
|   18 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |   18 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 
|   19 #include "chrome/browser/chromeos/profiles/profile_helper.h" |   19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 
|   20 #include "chrome/common/pref_names.h" |   20 #include "chrome/common/pref_names.h" | 
|   21 #include "chrome/test/base/testing_browser_process.h" |   21 #include "chrome/test/base/testing_browser_process.h" | 
|   22 #include "chrome/test/base/testing_profile_manager.h" |   22 #include "chrome/test/base/testing_profile_manager.h" | 
|   23 #include "components/signin/core/account_id/account_id.h" |   23 #include "components/signin/core/account_id/account_id.h" | 
|   24 #include "components/user_manager/user_manager.h" |   24 #include "components/user_manager/user_manager.h" | 
|   25 #include "content/public/test/test_browser_thread_bundle.h" |   25 #include "content/public/test/test_browser_thread_bundle.h" | 
|   26 #include "net/cert/x509_certificate.h" |   26 #include "net/cert/x509_certificate.h" | 
|   27 #include "testing/gtest/include/gtest/gtest.h" |   27 #include "testing/gtest/include/gtest/gtest.h" | 
|   28  |   28  | 
|   29 namespace chromeos { |   29 namespace chromeos { | 
|   30  |   30  | 
|   31 namespace { |   31 namespace { | 
|   32  |   32  | 
|   33 const char* kUser = "user@test.com"; |   33 const char* kUser = "user@test.com"; | 
|   34  |   34  | 
|   35 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once |   35 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once | 
|   36 // we've ensured the profile has been shut down. |   36 // we've ensured the profile has been shut down. | 
|   37 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; |   37 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; | 
|   38  |   38  | 
|   39 scoped_ptr<KeyedService> CreateTestPolicyCertService( |   39 std::unique_ptr<KeyedService> CreateTestPolicyCertService( | 
|   40     content::BrowserContext* context) { |   40     content::BrowserContext* context) { | 
|   41   return policy::PolicyCertService::CreateForTesting( |   41   return policy::PolicyCertService::CreateForTesting( | 
|   42       kUser, g_policy_cert_verifier_for_factory, |   42       kUser, g_policy_cert_verifier_for_factory, | 
|   43       user_manager::UserManager::Get()); |   43       user_manager::UserManager::Get()); | 
|   44 } |   44 } | 
|   45  |   45  | 
|   46 }  // namespace |   46 }  // namespace | 
|   47  |   47  | 
|   48 class SessionStateDelegateChromeOSTest : public testing::Test { |   48 class SessionStateDelegateChromeOSTest : public testing::Test { | 
|   49  protected: |   49  protected: | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  108  |  108  | 
|  109     // Note that user profiles are created after user login in reality. |  109     // Note that user profiles are created after user login in reality. | 
|  110     user_profile_ = |  110     user_profile_ = | 
|  111         profile_manager_->CreateTestingProfile(account_id.GetUserEmail()); |  111         profile_manager_->CreateTestingProfile(account_id.GetUserEmail()); | 
|  112     user_profile_->set_profile_name(account_id.GetUserEmail()); |  112     user_profile_->set_profile_name(account_id.GetUserEmail()); | 
|  113     chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting( |  113     chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting( | 
|  114         user, user_profile_); |  114         user, user_profile_); | 
|  115   } |  115   } | 
|  116  |  116  | 
|  117   content::TestBrowserThreadBundle threads_; |  117   content::TestBrowserThreadBundle threads_; | 
|  118   scoped_ptr<policy::PolicyCertVerifier> cert_verifier_; |  118   std::unique_ptr<policy::PolicyCertVerifier> cert_verifier_; | 
|  119   scoped_ptr<TestingProfileManager> profile_manager_; |  119   std::unique_ptr<TestingProfileManager> profile_manager_; | 
|  120   TestingProfile* user_profile_; |  120   TestingProfile* user_profile_; | 
|  121  |  121  | 
|  122  private: |  122  private: | 
|  123   scoped_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; |  123   std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; | 
|  124   scoped_ptr<SessionStateDelegateChromeos> session_state_delegate_; |  124   std::unique_ptr<SessionStateDelegateChromeos> session_state_delegate_; | 
|  125  |  125  | 
|  126   // Not owned. |  126   // Not owned. | 
|  127   FakeChromeUserManager* user_manager_; |  127   FakeChromeUserManager* user_manager_; | 
|  128  |  128  | 
|  129   DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateChromeOSTest); |  129   DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateChromeOSTest); | 
|  130 }; |  130 }; | 
|  131  |  131  | 
|  132 // Make sure that cycling one user does not cause any harm. |  132 // Make sure that cycling one user does not cause any harm. | 
|  133 TEST_F(SessionStateDelegateChromeOSTest, CyclingOneUser) { |  133 TEST_F(SessionStateDelegateChromeOSTest, CyclingOneUser) { | 
|  134   UserAddedToSession("firstuser@test.com"); |  134   UserAddedToSession("firstuser@test.com"); | 
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  287       prefs::kMultiProfileUserBehavior, |  287       prefs::kMultiProfileUserBehavior, | 
|  288       chromeos::MultiProfileUserController::kBehaviorNotAllowed); |  288       chromeos::MultiProfileUserController::kBehaviorNotAllowed); | 
|  289   user_manager()->AddUser(AccountId::FromUserEmail("bb@b.b")); |  289   user_manager()->AddUser(AccountId::FromUserEmail("bb@b.b")); | 
|  290   EXPECT_FALSE( |  290   EXPECT_FALSE( | 
|  291       session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); |  291       session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); | 
|  292   EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER, |  292   EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER, | 
|  293             add_user_error); |  293             add_user_error); | 
|  294 } |  294 } | 
|  295  |  295  | 
|  296 }  // namespace chromeos |  296 }  // namespace chromeos | 
| OLD | NEW |