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/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 11 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
12 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 12 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
13 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 14 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
14 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 15 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
15 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 16 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
19 #include "chrome/test/base/testing_profile_manager.h" | 20 #include "chrome/test/base/testing_profile_manager.h" |
| 21 #include "components/user_manager/user_manager.h" |
20 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
21 #include "net/cert/x509_certificate.h" | 23 #include "net/cert/x509_certificate.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
23 | 25 |
24 namespace chromeos { | 26 namespace chromeos { |
25 | 27 |
26 namespace { | 28 namespace { |
27 | 29 |
28 const char* kUser = "user@test.com"; | 30 const char* kUser = "user@test.com"; |
29 | 31 |
30 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once | 32 // Weak ptr to PolicyCertVerifier - object is freed in test destructor once |
31 // we've ensured the profile has been shut down. | 33 // we've ensured the profile has been shut down. |
32 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; | 34 policy::PolicyCertVerifier* g_policy_cert_verifier_for_factory = NULL; |
33 | 35 |
34 KeyedService* CreateTestPolicyCertService(content::BrowserContext* context) { | 36 KeyedService* CreateTestPolicyCertService(content::BrowserContext* context) { |
35 return policy::PolicyCertService::CreateForTesting( | 37 return policy::PolicyCertService::CreateForTesting( |
36 kUser, | 38 kUser, |
37 g_policy_cert_verifier_for_factory, | 39 g_policy_cert_verifier_for_factory, |
38 chromeos::UserManager::Get()).release(); | 40 user_manager::UserManager::Get()).release(); |
39 } | 41 } |
40 | 42 |
41 } // namespace | 43 } // namespace |
42 | 44 |
43 class SessionStateDelegateChromeOSTest : public testing::Test { | 45 class SessionStateDelegateChromeOSTest : public testing::Test { |
44 protected: | 46 protected: |
45 SessionStateDelegateChromeOSTest() : user_manager_(NULL) { | 47 SessionStateDelegateChromeOSTest() : user_manager_(NULL) { |
46 } | 48 } |
47 | 49 |
48 virtual ~SessionStateDelegateChromeOSTest() { | 50 virtual ~SessionStateDelegateChromeOSTest() { |
(...skipping 29 matching lines...) Expand all Loading... |
78 } | 80 } |
79 | 81 |
80 // Add and log in a user to the session. | 82 // Add and log in a user to the session. |
81 void UserAddedToSession(std::string user) { | 83 void UserAddedToSession(std::string user) { |
82 user_manager()->AddUser(user); | 84 user_manager()->AddUser(user); |
83 user_manager()->LoginUser(user); | 85 user_manager()->LoginUser(user); |
84 } | 86 } |
85 | 87 |
86 // Get the active user. | 88 // Get the active user. |
87 const std::string& GetActiveUser() { | 89 const std::string& GetActiveUser() { |
88 return chromeos::UserManager::Get()->GetActiveUser()->email(); | 90 return user_manager::UserManager::Get()->GetActiveUser()->email(); |
89 } | 91 } |
90 | 92 |
91 chromeos::FakeUserManager* user_manager() { return user_manager_; } | 93 chromeos::FakeUserManager* user_manager() { return user_manager_; } |
92 SessionStateDelegateChromeos* session_state_delegate() { | 94 SessionStateDelegateChromeos* session_state_delegate() { |
93 return session_state_delegate_.get(); | 95 return session_state_delegate_.get(); |
94 } | 96 } |
95 | 97 |
96 void InitForMultiProfile() { | 98 void InitForMultiProfile() { |
97 profile_manager_.reset( | 99 profile_manager_.reset( |
98 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 100 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 service->OnTrustAnchorsChanged(certificates); | 223 service->OnTrustAnchorsChanged(certificates); |
222 EXPECT_TRUE(service->has_policy_certificates()); | 224 EXPECT_TRUE(service->has_policy_certificates()); |
223 EXPECT_FALSE( | 225 EXPECT_FALSE( |
224 session_state_delegate()->IsMultiProfileAllowedByPrimaryUserPolicy()); | 226 session_state_delegate()->IsMultiProfileAllowedByPrimaryUserPolicy()); |
225 | 227 |
226 // Flush tasks posted to IO. | 228 // Flush tasks posted to IO. |
227 base::RunLoop().RunUntilIdle(); | 229 base::RunLoop().RunUntilIdle(); |
228 } | 230 } |
229 | 231 |
230 } // namespace chromeos | 232 } // namespace chromeos |
OLD | NEW |