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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" | 11 #include "chrome/browser/signin/easy_unlock_screenlock_state_handler.h" |
12 #include "chrome/browser/signin/easy_unlock_service.h" | 12 #include "chrome/browser/signin/easy_unlock_service.h" |
13 #include "chrome/browser/signin/screenlock_bridge.h" | 13 #include "chrome/browser/signin/signin_screen_bridge.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
16 #include "chrome/test/base/testing_pref_service_syncable.h" | 16 #include "chrome/test/base/testing_pref_service_syncable.h" |
17 #include "components/pref_registry/pref_registry_syncable.h" | 17 #include "components/pref_registry/pref_registry_syncable.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // Resource URLs for icons used by EasyUnlockScreenlockStateHandler. | 23 // Resource URLs for icons used by EasyUnlockScreenlockStateHandler. |
24 const char kLockedIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_LOCKED"; | 24 const char kLockedIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_LOCKED"; |
25 const char kUnlockedIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_UNLOCKED"; | 25 const char kUnlockedIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_UNLOCKED"; |
26 const char kSpinnerIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_SPINNER"; | 26 const char kSpinnerIconURL[] = "chrome://theme/IDR_EASY_UNLOCK_SPINNER"; |
27 | 27 |
28 // The expected size of user pod custom icons set by | 28 // The expected size of user pod custom icons set by |
29 // EasyUnlockScreenlockStateHandler. | 29 // EasyUnlockScreenlockStateHandler. |
30 const int kExpectedIconSize = 27; | 30 const int kExpectedIconSize = 27; |
31 | 31 |
32 // Checks if |input| string has any unreplaced placeholders. | 32 // Checks if |input| string has any unreplaced placeholders. |
33 bool StringHasPlaceholders(const base::string16& input) { | 33 bool StringHasPlaceholders(const base::string16& input) { |
34 std::vector<size_t> offsets; | 34 std::vector<size_t> offsets; |
35 std::vector<base::string16> subst; | 35 std::vector<base::string16> subst; |
36 subst.push_back(base::string16()); | 36 subst.push_back(base::string16()); |
37 | 37 |
38 base::string16 replaced = ReplaceStringPlaceholders(input, subst, &offsets); | 38 base::string16 replaced = ReplaceStringPlaceholders(input, subst, &offsets); |
39 return !offsets.empty(); | 39 return !offsets.empty(); |
40 } | 40 } |
41 | 41 |
42 // Fake lock handler to be used in these tests. | 42 // Fake lock handler to be used in these tests. |
43 class TestLockHandler : public ScreenlockBridge::LockHandler { | 43 class TestLockHandler : public SigninScreenBridge::LockHandler { |
44 public: | 44 public: |
45 explicit TestLockHandler(const std::string& user_email) | 45 explicit TestLockHandler(const std::string& user_email) |
46 : user_email_(user_email), | 46 : user_email_(user_email), |
47 show_icon_count_(0u), | 47 show_icon_count_(0u), |
48 auth_type_(OFFLINE_PASSWORD) { | 48 auth_type_(OFFLINE_PASSWORD) { |
49 } | 49 } |
50 virtual ~TestLockHandler() {} | 50 virtual ~TestLockHandler() {} |
51 | 51 |
52 // ScreenlockBridge::LockHandler implementation: | 52 // SigninScreenBridge::LockHandler implementation: |
53 virtual void ShowBannerMessage(const base::string16& message) OVERRIDE { | 53 virtual void ShowBannerMessage(const base::string16& message) OVERRIDE { |
54 ASSERT_FALSE(true) << "Should not be reached."; | 54 ASSERT_FALSE(true) << "Should not be reached."; |
55 } | 55 } |
56 | 56 |
57 virtual void ShowUserPodCustomIcon( | 57 virtual void ShowUserPodCustomIcon( |
58 const std::string& user_email, | 58 const std::string& user_email, |
59 const ScreenlockBridge::UserPodCustomIconOptions& icon) OVERRIDE { | 59 const SigninScreenBridge::UserPodCustomIconOptions& icon) OVERRIDE { |
60 ASSERT_EQ(user_email_, user_email); | 60 ASSERT_EQ(user_email_, user_email); |
61 ++show_icon_count_; | 61 ++show_icon_count_; |
62 last_custom_icon_ = icon.ToDictionaryValue().Pass(); | 62 last_custom_icon_ = icon.ToDictionaryValue().Pass(); |
63 ValidateCustomIcon(); | 63 ValidateCustomIcon(); |
64 } | 64 } |
65 | 65 |
66 virtual void HideUserPodCustomIcon(const std::string& user_email) OVERRIDE { | 66 virtual void HideUserPodCustomIcon(const std::string& user_email) OVERRIDE { |
67 ASSERT_EQ(user_email_, user_email); | 67 ASSERT_EQ(user_email_, user_email); |
68 last_custom_icon_.reset(); | 68 last_custom_icon_.reset(); |
69 } | 69 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 virtual void SetUp() OVERRIDE { | 236 virtual void SetUp() OVERRIDE { |
237 pref_service_.reset(new TestingPrefServiceSyncable()); | 237 pref_service_.reset(new TestingPrefServiceSyncable()); |
238 | 238 |
239 // The preference used to determine if easy unlock was previously used by | 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. | 240 // the user on the device ought to be registered by the EasyUnlockService. |
241 EasyUnlockService::RegisterProfilePrefs(pref_service_->registry()); | 241 EasyUnlockService::RegisterProfilePrefs(pref_service_->registry()); |
242 | 242 |
243 // Create and inject fake lock handler to the screenlock bridge. | 243 // Create and inject fake lock handler to the screenlock bridge. |
244 lock_handler_.reset(new TestLockHandler(user_email_)); | 244 lock_handler_.reset(new TestLockHandler(user_email_)); |
245 ScreenlockBridge* screenlock_bridge = ScreenlockBridge::Get(); | 245 SigninScreenBridge* signin_screen_bridge = SigninScreenBridge::Get(); |
246 screenlock_bridge->SetLockHandler(lock_handler_.get()); | 246 signin_screen_bridge->SetLockHandler(lock_handler_.get()); |
247 | 247 |
248 // Create the screenlock state handler object that will be tested. | 248 // Create the screenlock state handler object that will be tested. |
249 state_handler_.reset( | 249 state_handler_.reset( |
250 new EasyUnlockScreenlockStateHandler(user_email_, | 250 new EasyUnlockScreenlockStateHandler(user_email_, |
251 pref_service_.get(), | 251 pref_service_.get(), |
252 screenlock_bridge)); | 252 signin_screen_bridge)); |
253 } | 253 } |
254 | 254 |
255 virtual void TearDown() OVERRIDE { | 255 virtual void TearDown() OVERRIDE { |
256 ScreenlockBridge::Get()->SetLockHandler(NULL); | 256 SigninScreenBridge::Get()->SetLockHandler(NULL); |
257 lock_handler_.reset(); | 257 lock_handler_.reset(); |
258 state_handler_.reset(); | 258 state_handler_.reset(); |
259 } | 259 } |
260 | 260 |
261 protected: | 261 protected: |
262 // The state handler that is being tested. | 262 // The state handler that is being tested. |
263 scoped_ptr<EasyUnlockScreenlockStateHandler> state_handler_; | 263 scoped_ptr<EasyUnlockScreenlockStateHandler> state_handler_; |
264 | 264 |
265 // The user associated with |state_handler_|. | 265 // The user associated with |state_handler_|. |
266 const std::string user_email_; | 266 const std::string user_email_; |
267 | 267 |
268 // Faked lock handler given to ScreenlockBridge during the test. Abstracts | 268 // Faked lock handler given to SigninScreenBridge during the test. Abstracts |
269 // the screen lock UI. | 269 // the screen lock UI. |
270 scoped_ptr<TestLockHandler> lock_handler_; | 270 scoped_ptr<TestLockHandler> lock_handler_; |
271 | 271 |
272 // The user's preferences. | 272 // The user's preferences. |
273 scoped_ptr<TestingPrefServiceSyncable> pref_service_; | 273 scoped_ptr<TestingPrefServiceSyncable> pref_service_; |
274 }; | 274 }; |
275 | 275 |
276 TEST_F(EasyUnlockScreenlockStateHandlerTest, AuthenticatedInitialRun) { | 276 TEST_F(EasyUnlockScreenlockStateHandlerTest, AuthenticatedInitialRun) { |
277 state_handler_->ChangeState( | 277 state_handler_->ChangeState( |
278 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 278 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
279 | 279 |
280 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 280 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
281 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK, | 281 EXPECT_EQ(SigninScreenBridge::LockHandler::USER_CLICK, |
282 lock_handler_->GetAuthType(user_email_)); | 282 lock_handler_->GetAuthType(user_email_)); |
283 | 283 |
284 ASSERT_TRUE(lock_handler_->HasCustomIcon()); | 284 ASSERT_TRUE(lock_handler_->HasCustomIcon()); |
285 EXPECT_EQ(kUnlockedIconURL, lock_handler_->GetCustomIconURL()); | 285 EXPECT_EQ(kUnlockedIconURL, lock_handler_->GetCustomIconURL()); |
286 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip()); | 286 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip()); |
287 EXPECT_TRUE(lock_handler_->IsCustomIconTooltipAutoshown()); | 287 EXPECT_TRUE(lock_handler_->IsCustomIconTooltipAutoshown()); |
288 EXPECT_FALSE(lock_handler_->CustomIconHardlocksOnClick()); | 288 EXPECT_FALSE(lock_handler_->CustomIconHardlocksOnClick()); |
289 EXPECT_FALSE(lock_handler_->IsCustomIconAnimated()); | 289 EXPECT_FALSE(lock_handler_->IsCustomIconAnimated()); |
290 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity()); | 290 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity()); |
291 | 291 |
292 state_handler_->ChangeState( | 292 state_handler_->ChangeState( |
293 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 293 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
294 // Duplicated state change should be ignored. | 294 // Duplicated state change should be ignored. |
295 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); | 295 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); |
296 } | 296 } |
297 | 297 |
298 TEST_F(EasyUnlockScreenlockStateHandlerTest, AuthenticatedNotInitialRun) { | 298 TEST_F(EasyUnlockScreenlockStateHandlerTest, AuthenticatedNotInitialRun) { |
299 // Update preference for showing tutorial. | 299 // Update preference for showing tutorial. |
300 pref_service_->SetBoolean(prefs::kEasyUnlockShowTutorial, false); | 300 pref_service_->SetBoolean(prefs::kEasyUnlockShowTutorial, false); |
301 | 301 |
302 state_handler_->ChangeState( | 302 state_handler_->ChangeState( |
303 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 303 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
304 | 304 |
305 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 305 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
306 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK, | 306 EXPECT_EQ(SigninScreenBridge::LockHandler::USER_CLICK, |
307 lock_handler_->GetAuthType(user_email_)); | 307 lock_handler_->GetAuthType(user_email_)); |
308 | 308 |
309 ASSERT_TRUE(lock_handler_->HasCustomIcon()); | 309 ASSERT_TRUE(lock_handler_->HasCustomIcon()); |
310 EXPECT_EQ(kUnlockedIconURL, lock_handler_->GetCustomIconURL()); | 310 EXPECT_EQ(kUnlockedIconURL, lock_handler_->GetCustomIconURL()); |
311 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip()); | 311 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip()); |
312 EXPECT_FALSE(lock_handler_->IsCustomIconTooltipAutoshown()); | 312 EXPECT_FALSE(lock_handler_->IsCustomIconTooltipAutoshown()); |
313 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick()); | 313 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick()); |
314 EXPECT_FALSE(lock_handler_->IsCustomIconAnimated()); | 314 EXPECT_FALSE(lock_handler_->IsCustomIconAnimated()); |
315 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity()); | 315 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity()); |
316 } | 316 } |
317 | 317 |
318 TEST_F(EasyUnlockScreenlockStateHandlerTest, BluetoothConnecting) { | 318 TEST_F(EasyUnlockScreenlockStateHandlerTest, BluetoothConnecting) { |
319 pref_service_->SetBoolean(prefs::kEasyUnlockShowTutorial, false); | 319 pref_service_->SetBoolean(prefs::kEasyUnlockShowTutorial, false); |
320 state_handler_->ChangeState( | 320 state_handler_->ChangeState( |
321 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); | 321 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); |
322 | 322 |
323 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 323 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
324 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 324 EXPECT_EQ(SigninScreenBridge::LockHandler::OFFLINE_PASSWORD, |
325 lock_handler_->GetAuthType(user_email_)); | 325 lock_handler_->GetAuthType(user_email_)); |
326 | 326 |
327 ASSERT_TRUE(lock_handler_->HasCustomIcon()); | 327 ASSERT_TRUE(lock_handler_->HasCustomIcon()); |
328 EXPECT_EQ(kSpinnerIconURL, lock_handler_->GetCustomIconURL()); | 328 EXPECT_EQ(kSpinnerIconURL, lock_handler_->GetCustomIconURL()); |
329 EXPECT_FALSE(lock_handler_->CustomIconHasTooltip()); | 329 EXPECT_FALSE(lock_handler_->CustomIconHasTooltip()); |
330 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick()); | 330 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick()); |
331 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated()); | 331 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated()); |
332 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity()); | 332 EXPECT_EQ(100, lock_handler_->GetCustomIconOpacity()); |
333 | 333 |
334 state_handler_->ChangeState( | 334 state_handler_->ChangeState( |
(...skipping 12 matching lines...) Expand all Loading... |
347 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE); | 347 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE); |
348 states.push_back( | 348 states.push_back( |
349 EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED); | 349 EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED); |
350 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED); | 350 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_LOCKED); |
351 | 351 |
352 for (size_t i = 0; i < states.size(); ++i) { | 352 for (size_t i = 0; i < states.size(); ++i) { |
353 state_handler_->ChangeState(states[i]); | 353 state_handler_->ChangeState(states[i]); |
354 | 354 |
355 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()) | 355 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()) |
356 << "State: " << states[i]; | 356 << "State: " << states[i]; |
357 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 357 EXPECT_EQ(SigninScreenBridge::LockHandler::OFFLINE_PASSWORD, |
358 lock_handler_->GetAuthType(user_email_)) | 358 lock_handler_->GetAuthType(user_email_)) |
359 << "State: " << states[i]; | 359 << "State: " << states[i]; |
360 | 360 |
361 ASSERT_TRUE(lock_handler_->HasCustomIcon()) | 361 ASSERT_TRUE(lock_handler_->HasCustomIcon()) |
362 << "State: " << states[i]; | 362 << "State: " << states[i]; |
363 EXPECT_EQ(kLockedIconURL, lock_handler_->GetCustomIconURL()) | 363 EXPECT_EQ(kLockedIconURL, lock_handler_->GetCustomIconURL()) |
364 << "State: " << states[i]; | 364 << "State: " << states[i]; |
365 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip()) | 365 EXPECT_TRUE(lock_handler_->CustomIconHasTooltip()) |
366 << "State: " << states[i]; | 366 << "State: " << states[i]; |
367 EXPECT_FALSE(lock_handler_->IsCustomIconTooltipAutoshown()) | 367 EXPECT_FALSE(lock_handler_->IsCustomIconTooltipAutoshown()) |
(...skipping 10 matching lines...) Expand all Loading... |
378 << "State: " << states[i]; | 378 << "State: " << states[i]; |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 TEST_F(EasyUnlockScreenlockStateHandlerTest, | 382 TEST_F(EasyUnlockScreenlockStateHandlerTest, |
383 LockScreenClearedOnStateHandlerDestruction) { | 383 LockScreenClearedOnStateHandlerDestruction) { |
384 state_handler_->ChangeState( | 384 state_handler_->ChangeState( |
385 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 385 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
386 | 386 |
387 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 387 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
388 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK, | 388 EXPECT_EQ(SigninScreenBridge::LockHandler::USER_CLICK, |
389 lock_handler_->GetAuthType(user_email_)); | 389 lock_handler_->GetAuthType(user_email_)); |
390 | 390 |
391 ASSERT_TRUE(lock_handler_->HasCustomIcon()); | 391 ASSERT_TRUE(lock_handler_->HasCustomIcon()); |
392 | 392 |
393 state_handler_.reset(); | 393 state_handler_.reset(); |
394 | 394 |
395 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); | 395 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); |
396 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 396 EXPECT_EQ(SigninScreenBridge::LockHandler::OFFLINE_PASSWORD, |
397 lock_handler_->GetAuthType(user_email_)); | 397 lock_handler_->GetAuthType(user_email_)); |
398 | 398 |
399 ASSERT_FALSE(lock_handler_->HasCustomIcon()); | 399 ASSERT_FALSE(lock_handler_->HasCustomIcon()); |
400 } | 400 } |
401 | 401 |
402 TEST_F(EasyUnlockScreenlockStateHandlerTest, StatePreservedWhenScreenUnlocks) { | 402 TEST_F(EasyUnlockScreenlockStateHandlerTest, StatePreservedWhenScreenUnlocks) { |
403 state_handler_->ChangeState( | 403 state_handler_->ChangeState( |
404 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 404 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
405 | 405 |
406 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 406 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
407 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK, | 407 EXPECT_EQ(SigninScreenBridge::LockHandler::USER_CLICK, |
408 lock_handler_->GetAuthType(user_email_)); | 408 lock_handler_->GetAuthType(user_email_)); |
409 ASSERT_TRUE(lock_handler_->HasCustomIcon()); | 409 ASSERT_TRUE(lock_handler_->HasCustomIcon()); |
410 | 410 |
411 ScreenlockBridge::Get()->SetLockHandler(NULL); | 411 SigninScreenBridge::Get()->SetLockHandler(NULL); |
412 lock_handler_.reset(new TestLockHandler(user_email_)); | 412 lock_handler_.reset(new TestLockHandler(user_email_)); |
413 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); | 413 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); |
414 ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get()); | 414 SigninScreenBridge::Get()->SetLockHandler(lock_handler_.get()); |
415 | 415 |
416 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 416 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
417 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK, | 417 EXPECT_EQ(SigninScreenBridge::LockHandler::USER_CLICK, |
418 lock_handler_->GetAuthType(user_email_)); | 418 lock_handler_->GetAuthType(user_email_)); |
419 ASSERT_TRUE(lock_handler_->HasCustomIcon()); | 419 ASSERT_TRUE(lock_handler_->HasCustomIcon()); |
420 } | 420 } |
421 | 421 |
422 TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangeWhileScreenUnlocked) { | 422 TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangeWhileScreenUnlocked) { |
423 state_handler_->ChangeState( | 423 state_handler_->ChangeState( |
424 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 424 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
425 | 425 |
426 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 426 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
427 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK, | 427 EXPECT_EQ(SigninScreenBridge::LockHandler::USER_CLICK, |
428 lock_handler_->GetAuthType(user_email_)); | 428 lock_handler_->GetAuthType(user_email_)); |
429 ASSERT_TRUE(lock_handler_->HasCustomIcon()); | 429 ASSERT_TRUE(lock_handler_->HasCustomIcon()); |
430 | 430 |
431 ScreenlockBridge::Get()->SetLockHandler(NULL); | 431 SigninScreenBridge::Get()->SetLockHandler(NULL); |
432 lock_handler_.reset(new TestLockHandler(user_email_)); | 432 lock_handler_.reset(new TestLockHandler(user_email_)); |
433 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); | 433 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); |
434 | 434 |
435 state_handler_->ChangeState( | 435 state_handler_->ChangeState( |
436 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); | 436 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); |
437 | 437 |
438 ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get()); | 438 SigninScreenBridge::Get()->SetLockHandler(lock_handler_.get()); |
439 | 439 |
440 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 440 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
441 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 441 EXPECT_EQ(SigninScreenBridge::LockHandler::OFFLINE_PASSWORD, |
442 lock_handler_->GetAuthType(user_email_)); | 442 lock_handler_->GetAuthType(user_email_)); |
443 ASSERT_TRUE(lock_handler_->HasCustomIcon()); | 443 ASSERT_TRUE(lock_handler_->HasCustomIcon()); |
444 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated()); | 444 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated()); |
445 } | 445 } |
446 | 446 |
447 TEST_F(EasyUnlockScreenlockStateHandlerTest, | 447 TEST_F(EasyUnlockScreenlockStateHandlerTest, |
448 HardlockEnabledAfterInitialUnlock) { | 448 HardlockEnabledAfterInitialUnlock) { |
449 std::vector<EasyUnlockScreenlockStateHandler::State> states; | 449 std::vector<EasyUnlockScreenlockStateHandler::State> states; |
450 states.push_back( | 450 states.push_back( |
451 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); | 451 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); |
452 states.push_back( | 452 states.push_back( |
453 EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED); | 453 EasyUnlockScreenlockStateHandler::STATE_PHONE_NOT_AUTHENTICATED); |
454 states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH); | 454 states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_BLUETOOTH); |
455 states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_PHONE); | 455 states.push_back(EasyUnlockScreenlockStateHandler::STATE_NO_PHONE); |
456 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED); | 456 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNSUPPORTED); |
457 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE); | 457 states.push_back(EasyUnlockScreenlockStateHandler::STATE_PHONE_UNLOCKABLE); |
458 // This one should go last as changing state to AUTHENTICATED enables hard | 458 // This one should go last as changing state to AUTHENTICATED enables hard |
459 // locking. | 459 // locking. |
460 states.push_back(EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 460 states.push_back(EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
461 | 461 |
462 for (size_t i = 0; i < states.size(); ++i) { | 462 for (size_t i = 0; i < states.size(); ++i) { |
463 state_handler_->ChangeState(states[i]); | 463 state_handler_->ChangeState(states[i]); |
464 ASSERT_TRUE(lock_handler_->HasCustomIcon()) << "State: " << states[i]; | 464 ASSERT_TRUE(lock_handler_->HasCustomIcon()) << "State: " << states[i]; |
465 EXPECT_FALSE(lock_handler_->CustomIconHardlocksOnClick()) | 465 EXPECT_FALSE(lock_handler_->CustomIconHardlocksOnClick()) |
466 << "State: " << states[i]; | 466 << "State: " << states[i]; |
467 } | 467 } |
468 | 468 |
469 ScreenlockBridge::Get()->SetLockHandler(NULL); | 469 SigninScreenBridge::Get()->SetLockHandler(NULL); |
470 lock_handler_.reset(new TestLockHandler(user_email_)); | 470 lock_handler_.reset(new TestLockHandler(user_email_)); |
471 ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get()); | 471 SigninScreenBridge::Get()->SetLockHandler(lock_handler_.get()); |
472 | 472 |
473 for (size_t i = 0; i < states.size(); ++i) { | 473 for (size_t i = 0; i < states.size(); ++i) { |
474 state_handler_->ChangeState(states[i]); | 474 state_handler_->ChangeState(states[i]); |
475 ASSERT_TRUE(lock_handler_->HasCustomIcon()) << "State: " << states[i]; | 475 ASSERT_TRUE(lock_handler_->HasCustomIcon()) << "State: " << states[i]; |
476 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick()) | 476 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick()) |
477 << "State: " << states[i]; | 477 << "State: " << states[i]; |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 TEST_F(EasyUnlockScreenlockStateHandlerTest, InactiveStateHidesIcon) { | 481 TEST_F(EasyUnlockScreenlockStateHandlerTest, InactiveStateHidesIcon) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 EXPECT_EQ(base::ASCIIToUTF16("xxx"), lock_handler_->GetAuthValue()); | 527 EXPECT_EQ(base::ASCIIToUTF16("xxx"), lock_handler_->GetAuthValue()); |
528 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated()); | 528 EXPECT_TRUE(lock_handler_->IsCustomIconAnimated()); |
529 } | 529 } |
530 | 530 |
531 TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangesIgnoredIfHardlocked) { | 531 TEST_F(EasyUnlockScreenlockStateHandlerTest, StateChangesIgnoredIfHardlocked) { |
532 state_handler_->ChangeState( | 532 state_handler_->ChangeState( |
533 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 533 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
534 | 534 |
535 lock_handler_->SetAuthType( | 535 lock_handler_->SetAuthType( |
536 user_email_, | 536 user_email_, |
537 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, | 537 SigninScreenBridge::LockHandler::FORCE_OFFLINE_PASSWORD, |
538 base::string16()); | 538 base::string16()); |
539 lock_handler_->HideUserPodCustomIcon(user_email_); | 539 lock_handler_->HideUserPodCustomIcon(user_email_); |
540 | 540 |
541 state_handler_->ChangeState( | 541 state_handler_->ChangeState( |
542 EasyUnlockScreenlockStateHandler::STATE_NO_PHONE); | 542 EasyUnlockScreenlockStateHandler::STATE_NO_PHONE); |
543 EXPECT_FALSE(lock_handler_->HasCustomIcon()); | 543 EXPECT_FALSE(lock_handler_->HasCustomIcon()); |
544 | 544 |
545 state_handler_->ChangeState( | 545 state_handler_->ChangeState( |
546 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 546 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
547 EXPECT_FALSE(lock_handler_->HasCustomIcon()); | 547 EXPECT_FALSE(lock_handler_->HasCustomIcon()); |
548 EXPECT_EQ(ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, | 548 EXPECT_EQ(SigninScreenBridge::LockHandler::FORCE_OFFLINE_PASSWORD, |
549 lock_handler_->GetAuthType(user_email_)); | 549 lock_handler_->GetAuthType(user_email_)); |
550 } | 550 } |
551 | 551 |
552 TEST_F(EasyUnlockScreenlockStateHandlerTest, | 552 TEST_F(EasyUnlockScreenlockStateHandlerTest, |
553 LockScreenChangeableAfterHardlockUnlocked) { | 553 LockScreenChangeableAfterHardlockUnlocked) { |
554 state_handler_->ChangeState( | 554 state_handler_->ChangeState( |
555 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 555 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
556 | 556 |
557 lock_handler_->SetAuthType( | 557 lock_handler_->SetAuthType( |
558 user_email_, | 558 user_email_, |
559 ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, | 559 SigninScreenBridge::LockHandler::FORCE_OFFLINE_PASSWORD, |
560 base::string16()); | 560 base::string16()); |
561 lock_handler_->HideUserPodCustomIcon(user_email_); | 561 lock_handler_->HideUserPodCustomIcon(user_email_); |
562 | 562 |
563 state_handler_->ChangeState( | 563 state_handler_->ChangeState( |
564 EasyUnlockScreenlockStateHandler::STATE_NO_PHONE); | 564 EasyUnlockScreenlockStateHandler::STATE_NO_PHONE); |
565 EXPECT_FALSE(lock_handler_->HasCustomIcon()); | 565 EXPECT_FALSE(lock_handler_->HasCustomIcon()); |
566 | 566 |
567 ScreenlockBridge::Get()->SetLockHandler(NULL); | 567 SigninScreenBridge::Get()->SetLockHandler(NULL); |
568 lock_handler_.reset(new TestLockHandler(user_email_)); | 568 lock_handler_.reset(new TestLockHandler(user_email_)); |
569 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); | 569 EXPECT_EQ(0u, lock_handler_->GetAndResetShowIconCount()); |
570 ScreenlockBridge::Get()->SetLockHandler(lock_handler_.get()); | 570 SigninScreenBridge::Get()->SetLockHandler(lock_handler_.get()); |
571 | 571 |
572 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 572 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
573 EXPECT_TRUE(lock_handler_->HasCustomIcon()); | 573 EXPECT_TRUE(lock_handler_->HasCustomIcon()); |
574 EXPECT_EQ(ScreenlockBridge::LockHandler::OFFLINE_PASSWORD, | 574 EXPECT_EQ(SigninScreenBridge::LockHandler::OFFLINE_PASSWORD, |
575 lock_handler_->GetAuthType(user_email_)); | 575 lock_handler_->GetAuthType(user_email_)); |
576 | 576 |
577 state_handler_->ChangeState( | 577 state_handler_->ChangeState( |
578 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); | 578 EasyUnlockScreenlockStateHandler::STATE_AUTHENTICATED); |
579 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); | 579 EXPECT_EQ(1u, lock_handler_->GetAndResetShowIconCount()); |
580 EXPECT_TRUE(lock_handler_->HasCustomIcon()); | 580 EXPECT_TRUE(lock_handler_->HasCustomIcon()); |
581 EXPECT_EQ(ScreenlockBridge::LockHandler::USER_CLICK, | 581 EXPECT_EQ(SigninScreenBridge::LockHandler::USER_CLICK, |
582 lock_handler_->GetAuthType(user_email_)); | 582 lock_handler_->GetAuthType(user_email_)); |
583 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick()); | 583 EXPECT_TRUE(lock_handler_->CustomIconHardlocksOnClick()); |
584 } | 584 } |
585 | 585 |
586 } // namespace | 586 } // namespace |
OLD | NEW |