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" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 private: | 130 private: |
131 policy::MockConfigurationPolicyProvider provider_; | 131 policy::MockConfigurationPolicyProvider provider_; |
132 scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_; | 132 scoped_refptr<testing::NiceMock<MockBluetoothAdapter> > mock_adapter_; |
133 bool is_bluetooth_adapter_present_; | 133 bool is_bluetooth_adapter_present_; |
134 FakePowerManagerClient* power_manager_client_; | 134 FakePowerManagerClient* power_manager_client_; |
135 | 135 |
136 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceTest); | 136 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceTest); |
137 }; | 137 }; |
138 | 138 |
139 // Tests that EasyUnlock is on by default. | 139 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceTest, NoFinchNoService) { |
140 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceTest, DefaultOn) { | 140 EXPECT_FALSE(service()->IsAllowed()); |
141 EXPECT_TRUE(service()->IsAllowed()); | |
142 #if defined(GOOGLE_CHROME_BUILD) | 141 #if defined(GOOGLE_CHROME_BUILD) |
143 EXPECT_TRUE(HasEasyUnlockApp()); | 142 EXPECT_FALSE(HasEasyUnlockApp()); |
144 #endif | 143 #endif |
145 } | 144 } |
146 | 145 |
147 #if defined(GOOGLE_CHROME_BUILD) | |
148 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceTest, UnloadsOnSuspend) { | |
149 EXPECT_TRUE(HasEasyUnlockApp()); | |
150 power_manager_client()->SendSuspendImminent(); | |
151 EXPECT_FALSE(HasEasyUnlockApp()); | |
152 power_manager_client()->SendSuspendDone(); | |
153 EXPECT_TRUE(HasEasyUnlockApp()); | |
154 } | |
155 #endif | |
156 | |
157 class EasyUnlockServiceNoBluetoothTest : public EasyUnlockServiceTest { | 146 class EasyUnlockServiceNoBluetoothTest : public EasyUnlockServiceTest { |
158 public: | 147 public: |
159 EasyUnlockServiceNoBluetoothTest() {} | 148 EasyUnlockServiceNoBluetoothTest() {} |
160 virtual ~EasyUnlockServiceNoBluetoothTest() {} | 149 virtual ~EasyUnlockServiceNoBluetoothTest() {} |
161 | 150 |
162 // InProcessBrowserTest: | 151 // InProcessBrowserTest: |
163 virtual void SetUpInProcessBrowserTestFixture() override { | 152 virtual void SetUpInProcessBrowserTestFixture() override { |
164 set_is_bluetooth_adapter_present(false); | 153 set_is_bluetooth_adapter_present(false); |
165 EasyUnlockServiceTest::SetUpInProcessBrowserTestFixture(); | 154 EasyUnlockServiceTest::SetUpInProcessBrowserTestFixture(); |
166 } | 155 } |
(...skipping 17 matching lines...) Expand all Loading... |
184 // InProcessBrowserTest: | 173 // InProcessBrowserTest: |
185 virtual void SetUpCommandLine(CommandLine* command_line) override { | 174 virtual void SetUpCommandLine(CommandLine* command_line) override { |
186 command_line->AppendSwitchASCII(switches::kForceFieldTrials, | 175 command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
187 "EasyUnlock/Enable/"); | 176 "EasyUnlock/Enable/"); |
188 } | 177 } |
189 | 178 |
190 private: | 179 private: |
191 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceFinchEnabledTest); | 180 DISALLOW_COPY_AND_ASSIGN(EasyUnlockServiceFinchEnabledTest); |
192 }; | 181 }; |
193 | 182 |
| 183 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceFinchEnabledTest, Enabled) { |
| 184 EXPECT_TRUE(service()->IsAllowed()); |
| 185 #if defined(GOOGLE_CHROME_BUILD) |
| 186 EXPECT_TRUE(HasEasyUnlockApp()); |
| 187 #endif |
| 188 } |
| 189 |
| 190 #if defined(GOOGLE_CHROME_BUILD) |
| 191 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceFinchEnabledTest, UnloadsOnSuspend) { |
| 192 EXPECT_TRUE(HasEasyUnlockApp()); |
| 193 power_manager_client()->SendSuspendImminent(); |
| 194 EXPECT_FALSE(HasEasyUnlockApp()); |
| 195 power_manager_client()->SendSuspendDone(); |
| 196 EXPECT_TRUE(HasEasyUnlockApp()); |
| 197 } |
| 198 #endif |
| 199 |
194 // Tests that policy can override finch to turn easy unlock off. | 200 // Tests that policy can override finch to turn easy unlock off. |
195 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceFinchEnabledTest, PolicyOveride) { | 201 IN_PROC_BROWSER_TEST_F(EasyUnlockServiceFinchEnabledTest, PolicyOveride) { |
196 EXPECT_TRUE(service()->IsAllowed()); | 202 EXPECT_TRUE(service()->IsAllowed()); |
197 #if defined(GOOGLE_CHROME_BUILD) | 203 #if defined(GOOGLE_CHROME_BUILD) |
198 EXPECT_TRUE(HasEasyUnlockApp()); | 204 EXPECT_TRUE(HasEasyUnlockApp()); |
199 #endif | 205 #endif |
200 | 206 |
201 // Overridden by policy. | 207 // Overridden by policy. |
202 SetEasyUnlockAllowedPolicy(false); | 208 SetEasyUnlockAllowedPolicy(false); |
203 EXPECT_FALSE(service()->IsAllowed()); | 209 EXPECT_FALSE(service()->IsAllowed()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 Profile* secondary_profile = ProfileHelper::Get()->GetProfileByUserIdHash( | 292 Profile* secondary_profile = ProfileHelper::Get()->GetProfileByUserIdHash( |
287 secondary_user->username_hash()); | 293 secondary_user->username_hash()); |
288 | 294 |
289 EXPECT_TRUE(EasyUnlockService::Get(primary_profile)->IsAllowed()); | 295 EXPECT_TRUE(EasyUnlockService::Get(primary_profile)->IsAllowed()); |
290 EXPECT_FALSE(EasyUnlockService::Get(secondary_profile)->IsAllowed()); | 296 EXPECT_FALSE(EasyUnlockService::Get(secondary_profile)->IsAllowed()); |
291 #if defined(GOOGLE_CHROME_BUILD) | 297 #if defined(GOOGLE_CHROME_BUILD) |
292 EXPECT_TRUE(HasEasyUnlockAppForProfile(primary_profile)); | 298 EXPECT_TRUE(HasEasyUnlockAppForProfile(primary_profile)); |
293 EXPECT_FALSE(HasEasyUnlockAppForProfile(secondary_profile)); | 299 EXPECT_FALSE(HasEasyUnlockAppForProfile(secondary_profile)); |
294 #endif | 300 #endif |
295 } | 301 } |
OLD | NEW |