| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.define('settings_people_page_quick_unlock', function() { | 5 cr.define('settings_people_page_quick_unlock', function() { |
| 6 var element = null; | 6 var element = null; |
| 7 var quickUnlockPrivateApi = null; | 7 var quickUnlockPrivateApi = null; |
| 8 var QuickUnlockMode = chrome.quickUnlockPrivate.QuickUnlockMode; | 8 var QuickUnlockMode = chrome.quickUnlockPrivate.QuickUnlockMode; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 pinKeyboard.value = '111'; | 363 pinKeyboard.value = '111'; |
| 364 assertTrue(continueButton.disabled); | 364 assertTrue(continueButton.disabled); |
| 365 | 365 |
| 366 pinKeyboard.value = ''; | 366 pinKeyboard.value = ''; |
| 367 assertTrue(continueButton.disabled); | 367 assertTrue(continueButton.disabled); |
| 368 | 368 |
| 369 pinKeyboard.value = '1111111'; | 369 pinKeyboard.value = '1111111'; |
| 370 assertFalse(continueButton.disabled); | 370 assertFalse(continueButton.disabled); |
| 371 }); | 371 }); |
| 372 | 372 |
| 373 // Problem messages are hidden if the PIN is cleared. | 373 // Problem message is always shown. |
| 374 test('NoProblemShownWithEmptyPin', function() { | 374 test('ProblemShownEvenWithEmptyPin', function() { |
| 375 pinKeyboard.value = '11'; | 375 pinKeyboard.value = '11'; |
| 376 assertTrue(isVisible(problemDiv)); | 376 assertTrue(isVisible(problemDiv)); |
| 377 | 377 |
| 378 pinKeyboard.value = ''; | 378 pinKeyboard.value = ''; |
| 379 assertFalse(isVisible(problemDiv)); | 379 assertTrue(isVisible(problemDiv)); |
| 380 }); | 380 }); |
| 381 | 381 |
| 382 // If the PIN is too short an error problem is shown. | 382 // If the PIN is too short an error problem is shown. |
| 383 test('ErrorShownForShortPins', function() { | 383 test('WarningShownForShortPins', function() { |
| 384 assertFalse(isVisible(problemDiv)); | |
| 385 | |
| 386 pinKeyboard.value = '11'; | 384 pinKeyboard.value = '11'; |
| 387 | 385 |
| 388 assertTrue(isVisible(problemDiv)); | 386 assertTrue(isVisible(problemDiv)); |
| 389 assertHasClass(problemDiv, 'error'); | 387 assertHasClass(problemDiv, 'warning'); |
| 390 assertTrue(continueButton.disabled); | 388 assertTrue(continueButton.disabled); |
| 391 }); | 389 }); |
| 392 | 390 |
| 393 // If the PIN is weak a warning problem is shown. | 391 // If the PIN is weak a warning problem is shown. |
| 394 test('WarningShownForWeakPins', function() { | 392 test('WarningShownForWeakPins', function() { |
| 395 assertFalse(isVisible(problemDiv)); | 393 pinKeyboard.value = '111111'; |
| 396 | |
| 397 pinKeyboard.value = '1111'; | |
| 398 | 394 |
| 399 assertTrue(isVisible(problemDiv)); | 395 assertTrue(isVisible(problemDiv)); |
| 400 assertHasClass(problemDiv, 'warning'); | 396 assertHasClass(problemDiv, 'warning'); |
| 401 }); | 397 }); |
| 402 | 398 |
| 403 // If the confirm PIN does not match the initial PIN an error is shown and | 399 // If the confirm PIN does not match the initial PIN a warning is shown. |
| 404 // the submit button is disabled. | 400 // If the user tries to submit the PIN, the warning changes to an error. |
| 405 test('ErrorShownForMismatchedPins', function() { | 401 test('WarningThenErrorShownForMismatchedPins', function() { |
| 406 pinKeyboard.value = '1118'; | 402 pinKeyboard.value = '1118'; |
| 407 MockInteractions.tap(continueButton); | 403 MockInteractions.tap(continueButton); |
| 404 |
| 405 // Entering a mismatched PIN shows a warning. |
| 408 pinKeyboard.value = '1119'; | 406 pinKeyboard.value = '1119'; |
| 407 assertTrue(isVisible(problemDiv)); |
| 408 assertHasClass(problemDiv, 'warning'); |
| 409 | 409 |
| 410 assertTrue(isVisible(problemDiv)); | 410 // Submitting a mistmatched PIN shows an error. |
| 411 MockInteractions.tap(continueButton); |
| 411 assertHasClass(problemDiv, 'error'); | 412 assertHasClass(problemDiv, 'error'); |
| 412 assertTrue(continueButton.disabled); | 413 |
| 414 // Changing the PIN changes the error to a warning. |
| 415 pinKeyboard.value = '111'; |
| 416 assertHasClass(problemDiv, 'warning'); |
| 413 }); | 417 }); |
| 414 | 418 |
| 415 // Hitting cancel at the setup step dismisses the dialog. | 419 // Hitting cancel at the setup step dismisses the dialog. |
| 416 test('HittingBackButtonResetsState', function() { | 420 test('HittingBackButtonResetsState', function() { |
| 417 MockInteractions.tap(backButton); | 421 MockInteractions.tap(backButton); |
| 418 assertFalse(element.$.dialog.open); | 422 assertFalse(element.$.dialog.open); |
| 419 }); | 423 }); |
| 420 | 424 |
| 421 // Hitting cancel at the confirm step dismisses the dialog. | 425 // Hitting cancel at the confirm step dismisses the dialog. |
| 422 test('HittingBackButtonResetsState', function() { | 426 test('HittingBackButtonResetsState', function() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 447 }); | 451 }); |
| 448 }); | 452 }); |
| 449 } | 453 } |
| 450 | 454 |
| 451 return { | 455 return { |
| 452 registerAuthenticateTests: registerAuthenticateTests, | 456 registerAuthenticateTests: registerAuthenticateTests, |
| 453 registerLockScreenTests: registerLockScreenTests, | 457 registerLockScreenTests: registerLockScreenTests, |
| 454 registerSetupPinDialogTests: registerSetupPinDialogTests | 458 registerSetupPinDialogTests: registerSetupPinDialogTests |
| 455 }; | 459 }; |
| 456 }); | 460 }); |
| OLD | NEW |