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
3 // found in the LICENSE file.
8 #include "base/strings/string16.h"
9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h"
12 #include "chrome/browser/signin/easy_unlock_service.h"
13 #include "chrome/browser/signin/screenlock_bridge.h"
14 #include "chrome/common/pref_names.h"
15 #include "chrome/grit/generated_resources.h"
16 #include "chrome/test/base/testing_pref_service_syncable.h"
17 #include "components/pref_registry/pref_registry_syncable.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/base/l10n/l10n_util.h"
23 // Resource URLs for icons used by EasyUnlockScreenlockStateHandler.
24 const char kLockedIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_LOCKED";
25 const char kUnlockedIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_UNLOCKED";
26 const char kSpinnerIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_SPINNER";
28 // The expected size of user pod custom icons set by
29 // EasyUnlockScreenlockStateHandler.
30 const int kExpectedIconSize = 27;
32 // Checks if |input| string has any unreplaced placeholders.
33 bool StringHasPlaceholders(const base::string16& input) {
34 std::vector<size_t> offsets;
35 std::vector<base::string16> subst;
36 subst.push_back(base::string16());
38 base::string16 replaced = ReplaceStringPlaceholders(input, subst, &offsets);
39 return !offsets.empty();
42 // Fake lock handler to be used in these tests.
43 class TestLockHandler : public ScreenlockBridge::LockHandler {
45 explicit TestLockHandler(const std::string& user_email)
46 : user_email_(user_email),
48 auth_type_(OFFLINE_PASSWORD) {
50 virtual ~TestLockHandler() {}
52 // ScreenlockBridge::LockHandler implementation:
53 virtual void ShowBannerMessage(const base::string16& message) OVERRIDE {
54 ASSERT_FALSE(true) << "Should not be reached.";
57 virtual void ShowUserPodCustomIcon(
58 const std::string& user_email,
59 const ScreenlockBridge::UserPodCustomIconOptions& icon) OVERRIDE {
60 ASSERT_EQ(user_email_, user_email);
62 last_custom_icon_ = icon.ToDictionaryValue().Pass();
66 virtual void HideUserPodCustomIcon(const std::string& user_email) OVERRIDE {
67 ASSERT_EQ(user_email_, user_email);
68 last_custom_icon_.reset();
71 virtual void EnableInput() OVERRIDE {
72 ASSERT_FALSE(true) << "Should not be reached.";
75 virtual void SetAuthType(const std::string& user_email,
77 const base::string16& auth_value) OVERRIDE {
78 ASSERT_EQ(user_email_, user_email);
79 // Generally, this is allowed, but EasyUnlockScreenlockStateHandler should
80 // avoid resetting the same auth type.
81 EXPECT_NE(auth_type_, auth_type);
83 auth_type_ = auth_type;
84 auth_value_ = auth_value;
87 virtual AuthType GetAuthType(const std::string& user_email) const OVERRIDE {
88 EXPECT_EQ(user_email_, user_email);
92 virtual void Unlock(const std::string& user_email) OVERRIDE {
93 ASSERT_FALSE(true) << "Should not be reached.";
96 virtual void AttemptEasySignin(const std::string& user_email,
97 const std::string& secret,
98 const std::string& key_label) OVERRIDE {
99 ASSERT_FALSE(true) << "Should not be reached.";
102 // Utility methods used by tests:
104 // Gets last set auth value.
105 base::string16 GetAuthValue() const {
109 // Sets the auth value.
110 void SetAuthValue(const base::string16& value) {
114 // Returns the number of times an icon was shown since the last call to this
116 size_t GetAndResetShowIconCount() {
117 size_t result = show_icon_count_;
118 show_icon_count_ = 0u;
122 // Whether the custom icon is set.
123 bool HasCustomIcon() const {
124 return last_custom_icon_;
127 // If custom icon is set, returns the icon's resource URL.
128 // If there is no icon, or if it doesn't have a resource URL set, returns
130 std::string GetCustomIconURL() const {
132 if (last_custom_icon_)
133 last_custom_icon_->GetString("resourceUrl", &result);
137 // Whether the custom icon is set and it has a tooltip.
138 bool CustomIconHasTooltip() const {
139 return last_custom_icon_ && last_custom_icon_->HasKey("tooltip");
142 // Gets the custom icon's tooltip text, if one is set.
143 base::string16 GetCustomIconTooltip() const {
144 base::string16 result;
145 if (last_custom_icon_)
146 last_custom_icon_->GetString("tooltip.text", &result);
150 // Whether the custom icon's tooltip should be autoshown. If the icon is not
151 // set, or it doesn't have a tooltip, returns false.
152 bool IsCustomIconTooltipAutoshown() const {
154 if (last_custom_icon_)
155 last_custom_icon_->GetBoolean("tooltip.autoshow", &result);
159 // Returns the custom icon's opacity. If the icon is not set, a negative value
161 int GetCustomIconOpacity() const {
163 if (last_custom_icon_)
164 last_custom_icon_->GetInteger("opacity", &result);
168 // Whether the custom icon is set and if has hardlock capability enabed.
169 bool CustomIconHardlocksOnClick() const {
171 if (last_custom_icon_)
172 last_custom_icon_->GetBoolean("hardlockOnClick", &result);
176 // Whether the custom icon is set and has an animation set.
177 bool IsCustomIconAnimated() const {
178 return last_custom_icon_ && last_custom_icon_->HasKey("animation");
182 // Does some sanity checks on the last icon set by |ShowUserPodCustomIcon|.
183 // It will cause a test failure if the icon is not valid.
184 void ValidateCustomIcon() {
185 ASSERT_TRUE(last_custom_icon_.get());
187 EXPECT_FALSE(last_custom_icon_->HasKey("data"));
190 last_custom_icon_->GetInteger("size.height", &height);
191 EXPECT_EQ(kExpectedIconSize, height);
194 last_custom_icon_->GetInteger("size.width", &width);
195 EXPECT_EQ(kExpectedIconSize, width);
197 if (last_custom_icon_->HasKey("animation")) {
198 int animation_resource_width = -1;
199 EXPECT_TRUE(last_custom_icon_->GetInteger("animation.resourceWidth",
200 &animation_resource_width));
201 EXPECT_GT(animation_resource_width, kExpectedIconSize);
202 EXPECT_EQ(0, animation_resource_width % kExpectedIconSize);
204 last_custom_icon_->GetInteger("animation.frameLengthMs", NULL));
207 if (last_custom_icon_->HasKey("tooltip")) {
208 base::string16 tooltip;
209 EXPECT_TRUE(last_custom_icon_->GetString("tooltip.text", &tooltip));
210 EXPECT_FALSE(tooltip.empty());
211 EXPECT_FALSE(StringHasPlaceholders(tooltip));
215 // The fake user email used in test. All methods called on |this| should be
216 // associated with this user.
217 const std::string user_email_;
219 // The last icon set using |SetUserPodCustomIcon|. Call to
220 // |HideUserPodcustomIcon| resets it.
221 scoped_ptr<base::DictionaryValue> last_custom_icon_;
222 size_t show_icon_count_;
224 // Auth type and value set using |SetAuthType|.
226 base::string16 auth_value_;
228 DISALLOW_COPY_AND_ASSIGN(TestLockHandler);
231 class EasyUnlockScreenlockStateHandlerTest : public testing::Test {
233 EasyUnlockScreenlockStateHandlerTest() : user_email_("test_user@gmail.com") {}
234 virtual ~EasyUnlockScreenlockStateHandlerTest() {}
236 virtual void SetUp() OVERRIDE {
237 pref_service_.reset(new TestingPrefServiceSyncable());
239 // The preference used to determine if easy unlock was previously used by
240 // the user on the device ought to be registered by the EasyUnlockService.
241 EasyUnlockService::RegisterProfilePrefs(pref_service_->registry());
243 // Create and inject fake lock handler to the screenlock bridge.
244 lock_handler_.reset(new TestLockHandler(user_email_));
245 ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get();
246 screenlock_bridge->SetLockHandler(lock_handler_.get());
248 // Create the screenlock state handler object that will be tested.
249 state_handler_.reset(
250 new EasyUnlockScreenlockStateHandler(user_email_,
255 virtual void TearDown() OVERRIDE {
256 ScreenlockBridge::Get()->SetLockHandler(NULL);
257 lock_handler_.reset();
258 state_handler_.reset();
262 // The state handler that is being tested.
263 scoped_ptr<EasyUnlockScreenlockStateHandler> state_handler_;
265 // The user associated with |state_handler_|.
266 const std::string user_email_;
268 // Faked lock handler given to ScreenlockBridge during the test. Abstracts
269 // the screen lock UI.
270 scoped_ptr<TestLockHandler> lock_handler_;
272 // The user's preferences.
273 scoped_ptr<TestingPrefServiceSyncable> pref_service_;
276 TEST_F(EasyUnlockScreenlockStateHandlerTest, AuthenticatedInitialRun) {
277 state_handler_->ChangeState(
278 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
280 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
281 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
282 lock_handler_->GetAuthType(user_email_));
284 ASSERT_TRUE(lock_handler_->HasCustomIcon());
285 EXPECT_EQ(kUnlockedIconURL, lock_handler_->GetCustomIconURL());
286 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip());
287 EXPECT_TRUE(lock_handler_->IsCustomIconTooltipAutoshown());
288 EXPECT_FALSE(lock_handler_->CustomIconHardlocksOnClick());
289 EXPECT_FALSE(lock_handler_->IsCustomIconAnimated());
290 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity());
292 state_handler_->ChangeState(
293 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
294 // Duplicated state change should be ignored.
295 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
298 TEST_F(EasyUnlockScreenlockStateHandlerTest, AuthenticatedNotInitialRun) {
299 // Update preference for showing tutorial.
300 pref_service_->SetBoolean(prefs::kEasyUnlockShowTutorial, false);
302 state_handler_->ChangeState(
303 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
305 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
306 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
307 lock_handler_->GetAuthType(user_email_));
309 ASSERT_TRUE(lock_handler_->HasCustomIcon());
310 EXPECT_EQ(kUnlockedIconURL, lock_handler_->GetCustomIconURL());
311 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip());
312 EXPECT_FALSE(lock_handler_->IsCustomIconTooltipAutoshown());
313 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick());
314 EXPECT_FALSE(lock_handler_->IsCustomIconAnimated());
315 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity());
318 TEST_F(EasyUnlockScreenlockStateHandlerTest, BluetoothConnecting) {
319 pref_service_->SetBoolean(prefs::kEasyUnlockShowTutorial, false);
320 state_handler_->ChangeState(
321 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
323 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
324 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
325 lock_handler_->GetAuthType(user_email_));
327 ASSERT_TRUE(lock_handler_->HasCustomIcon());
328 EXPECT_EQ(kSpinnerIconURL, lock_handler_->GetCustomIconURL());
329 EXPECT_FALSE(lock_handler_->CustomIconHasTooltip());
330 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick());
331 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated());
332 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity());
334 state_handler_->ChangeState(
335 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
336 // Duplicated state change should be ignored.
337 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
340 TEST_F(EasyUnlockScreenlockStateHandlerTest, StatesWithLockedIcon) {
341 pref_service_->SetBoolean(prefs::kEasyUnlockShowTutorial, false);
343 std::vector<EasyUnlockScreenlockStateHandler::State> states;
344 states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH);
345 states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_PHONE);
346 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED);
347 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE);
349 EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED);
350 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED);
352 for (size_t i = 0; i < states.size(); ++i) {
353 state_handler_->ChangeState(states[i]);
355 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount())
356 << "State: " << states[i];
357 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
358 lock_handler_->GetAuthType(user_email_))
359 << "State: " << states[i];
361 ASSERT_TRUE(lock_handler_->HasCustomIcon())
362 << "State: " << states[i];
363 EXPECT_EQ(kLockedIconURL, lock_handler_->GetCustomIconURL())
364 << "State: " << states[i];
365 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip())
366 << "State: " << states[i];
367 EXPECT_FALSE(lock_handler_->IsCustomIconTooltipAutoshown())
368 << "State: " << states[i];
369 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick())
370 << "State: " << states[i];
371 EXPECT_FALSE(lock_handler_->IsCustomIconAnimated())
372 << "State: " << states[i];
373 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity())
374 << "State: " << states[i];
376 state_handler_->ChangeState(states[i]);
377 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount())
378 << "State: " << states[i];
382 TEST_F(EasyUnlockScreenlockStateHandlerTest,
383 LockScreenClearedOnStateHandlerDestruction) {
384 state_handler_->ChangeState(
385 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
387 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
388 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
389 lock_handler_->GetAuthType(user_email_));
391 ASSERT_TRUE(lock_handler_->HasCustomIcon());
393 state_handler_.reset();
395 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
396 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
397 lock_handler_->GetAuthType(user_email_));
399 ASSERT_FALSE(lock_handler_->HasCustomIcon());
402 TEST_F(EasyUnlockScreenlockStateHandlerTest, StatePreservedWhenScreenUnlocks) {
403 state_handler_->ChangeState(
404 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
406 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
407 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
408 lock_handler_->GetAuthType(user_email_));
409 ASSERT_TRUE(lock_handler_->HasCustomIcon());
411 ScreenlockBridge::Get()->SetLockHandler(NULL);
412 lock_handler_.reset(new TestLockHandler(user_email_));
413 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
414 ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
416 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
417 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
418 lock_handler_->GetAuthType(user_email_));
419 ASSERT_TRUE(lock_handler_->HasCustomIcon());
422 TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangeWhileScreenUnlocked) {
423 state_handler_->ChangeState(
424 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
426 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
427 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
428 lock_handler_->GetAuthType(user_email_));
429 ASSERT_TRUE(lock_handler_->HasCustomIcon());
431 ScreenlockBridge::Get()->SetLockHandler(NULL);
432 lock_handler_.reset(new TestLockHandler(user_email_));
433 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
435 state_handler_->ChangeState(
436 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
438 ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
440 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
441 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
442 lock_handler_->GetAuthType(user_email_));
443 ASSERT_TRUE(lock_handler_->HasCustomIcon());
444 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated());
447 TEST_F(EasyUnlockScreenlockStateHandlerTest,
448 HardlockEnabledAfterInitialUnlock) {
449 std::vector<EasyUnlockScreenlockStateHandler::State> states;
451 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
453 EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED);
454 states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH);
455 states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_PHONE);
456 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED);
457 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE);
458 // This one should go last as changing state to AUTHENTICATED enables hard
460 states.push_back(EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
462 for (size_t i = 0; i < states.size(); ++i) {
463 state_handler_->ChangeState(states[i]);
464 ASSERT_TRUE(lock_handler_->HasCustomIcon()) << "State: " << states[i];
465 EXPECT_FALSE(lock_handler_->CustomIconHardlocksOnClick())
466 << "State: " << states[i];
469 ScreenlockBridge::Get()->SetLockHandler(NULL);
470 lock_handler_.reset(new TestLockHandler(user_email_));
471 ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
473 for (size_t i = 0; i < states.size(); ++i) {
474 state_handler_->ChangeState(states[i]);
475 ASSERT_TRUE(lock_handler_->HasCustomIcon()) << "State: " << states[i];
476 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick())
477 << "State: " << states[i];
481 TEST_F(EasyUnlockScreenlockStateHandlerTest, InactiveStateHidesIcon) {
482 state_handler_->ChangeState(
483 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
485 ASSERT_TRUE(lock_handler_->HasCustomIcon());
487 state_handler_->ChangeState(
488 EasyUnlockScreenlockStateHandler::STATE_INACTIVE);
490 ASSERT_FALSE(lock_handler_->HasCustomIcon());
493 TEST_F(EasyUnlockScreenlockStateHandlerTest,
494 AuthenticatedStateClearsPreviousAuthValue) {
495 state_handler_->ChangeState(
496 EasyUnlockScreenlockStateHandler::STATE_INACTIVE);
498 lock_handler_->SetAuthValue(base::ASCIIToUTF16("xxx"));
500 state_handler_->ChangeState(
501 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
503 EXPECT_EQ(l10n_util::GetStringUTF16(
504 IDS_EASY_UNLOCK_SCREENLOCK_USER_POD_AUTH_VALUE),
505 lock_handler_->GetAuthValue());
507 state_handler_->ChangeState(
508 EasyUnlockScreenlockStateHandler::STATE_NO_PHONE);
510 EXPECT_EQ(base::string16(), lock_handler_->GetAuthValue());
513 TEST_F(EasyUnlockScreenlockStateHandlerTest,
514 ChangingStateDoesNotAffectAuthValueIfAuthTypeDoesNotChange) {
515 lock_handler_->SetAuthValue(base::ASCIIToUTF16("xxx"));
517 state_handler_->ChangeState(
518 EasyUnlockScreenlockStateHandler::STATE_NO_PHONE);
519 EXPECT_EQ(base::ASCIIToUTF16("xxx"), lock_handler_->GetAuthValue());
521 state_handler_->ChangeState(
522 EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED);
523 EXPECT_EQ(base::ASCIIToUTF16("xxx"), lock_handler_->GetAuthValue());
525 state_handler_->ChangeState(
526 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING);
527 EXPECT_EQ(base::ASCIIToUTF16("xxx"), lock_handler_->GetAuthValue());
528 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated());
531 TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangesIgnoredIfHardlocked) {
532 state_handler_->ChangeState(
533 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
535 lock_handler_->SetAuthType(
537 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
539 lock_handler_->HideUserPodCustomIcon(user_email_);
541 state_handler_->ChangeState(
542 EasyUnlockScreenlockStateHandler::STATE_NO_PHONE);
543 EXPECT_FALSE(lock_handler_->HasCustomIcon());
545 state_handler_->ChangeState(
546 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
547 EXPECT_FALSE(lock_handler_->HasCustomIcon());
548 EXPECT_EQ(ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
549 lock_handler_->GetAuthType(user_email_));
552 TEST_F(EasyUnlockScreenlockStateHandlerTest,
553 LockScreenChangeableAfterHardlockUnlocked) {
554 state_handler_->ChangeState(
555 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
557 lock_handler_->SetAuthType(
559 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
561 lock_handler_->HideUserPodCustomIcon(user_email_);
563 state_handler_->ChangeState(
564 EasyUnlockScreenlockStateHandler::STATE_NO_PHONE);
565 EXPECT_FALSE(lock_handler_->HasCustomIcon());
567 ScreenlockBridge::Get()->SetLockHandler(NULL);
568 lock_handler_.reset(new TestLockHandler(user_email_));
569 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount());
570 ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get());
572 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
573 EXPECT_TRUE(lock_handler_->HasCustomIcon());
574 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD,
575 lock_handler_->GetAuthType(user_email_));
577 state_handler_->ChangeState(
578 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED);
579 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount());
580 EXPECT_TRUE(lock_handler_->HasCustomIcon());
581 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK,
582 lock_handler_->GetAuthType(user_email_));
583 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick());