OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/login/login_manager_test.h" | 9 #include "chrome/browser/chromeos/login/login_manager_test.h" |
10 #include "chrome/browser/chromeos/login/startup_utils.h" | 10 #include "chrome/browser/chromeos/login/startup_utils.h" |
11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 11 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
12 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
13 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 12 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/signin/easy_unlock_service.h" | 15 #include "chrome/browser/signin/easy_unlock_service.h" |
17 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "components/policy/core/browser/browser_policy_connector.h" | 19 #include "components/policy/core/browser/browser_policy_connector.h" |
21 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 20 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
22 #include "components/policy/core/common/policy_map.h" | 21 #include "components/policy/core/common/policy_map.h" |
23 #include "components/policy/core/common/policy_types.h" | 22 #include "components/policy/core/common/policy_types.h" |
| 23 #include "components/user_manager/user_manager.h" |
24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
25 #include "extensions/browser/extension_system.h" | 25 #include "extensions/browser/extension_system.h" |
26 #include "policy/policy_constants.h" | 26 #include "policy/policy_constants.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
28 | 28 |
29 using chromeos::ProfileHelper; | 29 using chromeos::ProfileHelper; |
30 using chromeos::LoginManagerTest; | 30 using chromeos::LoginManagerTest; |
31 using chromeos::StartupUtils; | 31 using chromeos::StartupUtils; |
32 using chromeos::UserAddingScreen; | 32 using chromeos::UserAddingScreen; |
33 using chromeos::UserManager; | 33 using user_manager::UserManager; |
34 using testing::_; | 34 using testing::_; |
35 using testing::Return; | 35 using testing::Return; |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 const char kTestUser1[] = "primary.user@example.com"; | 39 const char kTestUser1[] = "primary.user@example.com"; |
40 const char kTestUser2[] = "secondary.user@example.com"; | 40 const char kTestUser2[] = "secondary.user@example.com"; |
41 | 41 |
42 #if defined(GOOGLE_CHROME_BUILD) | 42 #if defined(GOOGLE_CHROME_BUILD) |
43 bool HasEasyUnlockAppForProfile(Profile* profile) { | 43 bool HasEasyUnlockAppForProfile(Profile* profile) { |
44 extensions::ExtensionSystem* extension_system = | 44 extensions::ExtensionSystem* extension_system = |
45 extensions::ExtensionSystem::Get(profile); | 45 extensions::ExtensionSystem::Get(profile); |
46 ExtensionService* extension_service = extension_system->extension_service(); | 46 ExtensionService* extension_service = extension_system->extension_service(); |
47 return !!extension_service->GetExtensionById( | 47 return !!extension_service->GetExtensionById( |
48 extension_misc::kEasyUnlockAppId, false); | 48 extension_misc::kEasyUnlockAppId, false); |
49 } | 49 } |
50 #endif | 50 #endif |
51 | 51 |
52 } //namespace | 52 } // namespace |
53 | 53 |
54 class EasyUnlockServiceTest : public InProcessBrowserTest { | 54 class EasyUnlockServiceTest : public InProcessBrowserTest { |
55 public: | 55 public: |
56 EasyUnlockServiceTest() {} | 56 EasyUnlockServiceTest() {} |
57 virtual ~EasyUnlockServiceTest() {} | 57 virtual ~EasyUnlockServiceTest() {} |
58 | 58 |
59 void SetEasyUnlockAllowedPolicy(bool allowed) { | 59 void SetEasyUnlockAllowedPolicy(bool allowed) { |
60 policy::PolicyMap policy; | 60 policy::PolicyMap policy; |
61 policy.Set(policy::key::kEasyUnlockAllowed, | 61 policy.Set(policy::key::kEasyUnlockAllowed, |
62 policy::POLICY_LEVEL_MANDATORY, | 62 policy::POLICY_LEVEL_MANDATORY, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 StartupUtils::MarkOobeCompleted(); | 183 StartupUtils::MarkOobeCompleted(); |
184 } | 184 } |
185 | 185 |
186 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceMultiProfileTest, | 186 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceMultiProfileTest, |
187 DisallowedOnSecondaryProfile) { | 187 DisallowedOnSecondaryProfile) { |
188 LoginUser(kTestUser1); | 188 LoginUser(kTestUser1); |
189 chromeos::UserAddingScreen::Get()->Start(); | 189 chromeos::UserAddingScreen::Get()->Start(); |
190 base::RunLoop().RunUntilIdle(); | 190 base::RunLoop().RunUntilIdle(); |
191 AddUser(kTestUser2); | 191 AddUser(kTestUser2); |
192 const user_manager::User* primary_user = | 192 const user_manager::User* primary_user = |
193 UserManager::Get()->FindUser(kTestUser1); | 193 user_manager::UserManager::Get()->FindUser(kTestUser1); |
194 const user_manager::User* secondary_user = | 194 const user_manager::User* secondary_user = |
195 UserManager::Get()->FindUser(kTestUser2); | 195 user_manager::UserManager::Get()->FindUser(kTestUser2); |
196 | 196 |
197 Profile* primary_profile = ProfileHelper::Get()->GetProfileByUserIdHash( | 197 Profile* primary_profile = ProfileHelper::Get()->GetProfileByUserIdHash( |
198 primary_user->username_hash()); | 198 primary_user->username_hash()); |
199 Profile* secondary_profile = ProfileHelper::Get()->GetProfileByUserIdHash( | 199 Profile* secondary_profile = ProfileHelper::Get()->GetProfileByUserIdHash( |
200 secondary_user->username_hash()); | 200 secondary_user->username_hash()); |
201 | 201 |
202 EXPECT_TRUE(EasyUnlockService::Get(primary_profile)->IsAllowed()); | 202 EXPECT_TRUE(EasyUnlockService::Get(primary_profile)->IsAllowed()); |
203 EXPECT_FALSE(EasyUnlockService::Get(secondary_profile)->IsAllowed()); | 203 EXPECT_FALSE(EasyUnlockService::Get(secondary_profile)->IsAllowed()); |
204 #if defined(GOOGLE_CHROME_BUILD) | 204 #if defined(GOOGLE_CHROME_BUILD) |
205 EXPECT_TRUE(HasEasyUnlockAppForProfile(primary_profile)); | 205 EXPECT_TRUE(HasEasyUnlockAppForProfile(primary_profile)); |
206 EXPECT_FALSE(HasEasyUnlockAppForProfile(secondary_profile)); | 206 EXPECT_FALSE(HasEasyUnlockAppForProfile(secondary_profile)); |
207 #endif | 207 #endif |
208 } | 208 } |
OLD | NEW |