| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 11 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 12 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 12 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 13 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 14 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 14 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 15 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 15 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 16 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 16 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 17 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
| 20 #include "chrome/test/base/testing_profile_manager.h" | 21 #include "chrome/test/base/testing_profile_manager.h" |
| 21 #include "components/user_manager/user_manager.h" | 22 #include "components/user_manager/user_manager.h" |
| 22 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
| 23 #include "net/cert/x509_certificate.h" | 24 #include "net/cert/x509_certificate.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 26 |
| 26 namespace chromeos { | 27 namespace chromeos { |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 const char* kUser = "user@test.com"; | 31 const char* kUser = "user@test.com"; |
| 31 | 32 |
| 32 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once | 33 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once |
| 33 // we've ensured the profile has been shut down. | 34 // we've ensured the profile has been shut down. |
| 34 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; | 35 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; |
| 35 | 36 |
| 36 KeyedService* CreateTestPolicyCertService(content::BrowserContext* context) { | 37 scoped_ptr<KeyedService> CreateTestPolicyCertService( |
| 38 content::BrowserContext* context) { |
| 37 return policy::PolicyCertService::CreateForTesting( | 39 return policy::PolicyCertService::CreateForTesting( |
| 38 kUser, | 40 kUser, g_policy_cert_verifier_for_factory, |
| 39 g_policy_cert_verifier_for_factory, | 41 user_manager::UserManager::Get()); |
| 40 user_manager::UserManager::Get()).release(); | |
| 41 } | 42 } |
| 42 | 43 |
| 43 } // namespace | 44 } // namespace |
| 44 | 45 |
| 45 class SessionStateDelegateChromeOSTest : public testing::Test { | 46 class SessionStateDelegateChromeOSTest : public testing::Test { |
| 46 protected: | 47 protected: |
| 47 SessionStateDelegateChromeOSTest() : user_manager_(NULL) { | 48 SessionStateDelegateChromeOSTest() : user_manager_(NULL) { |
| 48 } | 49 } |
| 49 | 50 |
| 50 ~SessionStateDelegateChromeOSTest() override {} | 51 ~SessionStateDelegateChromeOSTest() override {} |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 prefs::kMultiProfileUserBehavior, | 283 prefs::kMultiProfileUserBehavior, |
| 283 chromeos::MultiProfileUserController::kBehaviorNotAllowed); | 284 chromeos::MultiProfileUserController::kBehaviorNotAllowed); |
| 284 user_manager()->AddUser("bb@b.b"); | 285 user_manager()->AddUser("bb@b.b"); |
| 285 EXPECT_FALSE( | 286 EXPECT_FALSE( |
| 286 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); | 287 session_state_delegate()->CanAddUserToMultiProfile(&add_user_error)); |
| 287 EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER, | 288 EXPECT_EQ(ash::SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER, |
| 288 add_user_error); | 289 add_user_error); |
| 289 } | 290 } |
| 290 | 291 |
| 291 } // namespace chromeos | 292 } // namespace chromeos |
| OLD | NEW |