Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/test/data/webui/settings/quick_unlock_authenticate_browsertest_chromeos.js

Issue 2376293005: cros: Tweaked the good/bad pin checking on the js to use the new quick unlock api function. (Closed)
Patch Set: Fixed patch set 12 errors. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 var fakeUma = null; 9 var fakeUma = null;
10 10
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 }); 330 });
331 331
332 setup(function() { 332 setup(function() {
333 PolymerTest.clearBody(); 333 PolymerTest.clearBody();
334 334
335 quickUnlockPrivateApi = new settings.FakeQuickUnlockPrivate(); 335 quickUnlockPrivateApi = new settings.FakeQuickUnlockPrivate();
336 fakeUma = new settings.FakeQuickUnlockUma(); 336 fakeUma = new settings.FakeQuickUnlockUma();
337 337
338 // Create setup-pin element. 338 // Create setup-pin element.
339 element = document.createElement('settings-setup-pin-dialog'); 339 element = document.createElement('settings-setup-pin-dialog');
340 element.quickUnlockPrivate_ = quickUnlockPrivateApi;
340 element.setModes = 341 element.setModes =
341 quickUnlockPrivateApi.setModes.bind(quickUnlockPrivateApi, ''); 342 quickUnlockPrivateApi.setModes.bind(quickUnlockPrivateApi, '');
342 element.writeUma_ = fakeUma.recordProgress.bind(fakeUma); 343 element.writeUma_ = fakeUma.recordProgress.bind(fakeUma);
343 344
344 document.body.appendChild(element); 345 document.body.appendChild(element);
345 Polymer.dom.flush(); 346 Polymer.dom.flush();
346 347
347 element.open(); 348 element.open();
348 349
349 titleDiv = getFromElement('div[class="title"]'); 350 titleDiv = getFromElement('div[class="title"]');
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 396
396 pinKeyboard.value = ''; 397 pinKeyboard.value = '';
397 assertTrue(isVisible(problemDiv)); 398 assertTrue(isVisible(problemDiv));
398 }); 399 });
399 400
400 // If the PIN is too short an error problem is shown. 401 // If the PIN is too short an error problem is shown.
401 test('WarningShownForShortPins', function() { 402 test('WarningShownForShortPins', function() {
402 pinKeyboard.value = '11'; 403 pinKeyboard.value = '11';
403 404
404 assertTrue(isVisible(problemDiv)); 405 assertTrue(isVisible(problemDiv));
405 assertHasClass(problemDiv, 'warning'); 406 assertHasClass(problemDiv, 'error');
407 assertTrue(continueButton.disabled);
408 });
409
410 // If the PIN is too long an error problem is shown.
411 test('WarningShownForLongPins', function() {
412 // By default, there is no max length on pins.
413 quickUnlockPrivateApi.credentialRequirements.maxLength = 5;
414
415 // A pin of length five should be valid when max length is five.
416 pinKeyboard.value = '11111';
417 assertFalse(isVisible(problemDiv));
418 assertFalse(continueButton.disabled);
419
420 // A pin of length six should not be valid when max length is five.
421 pinKeyboard.value = '111111';
422 assertTrue(isVisible(problemDiv));
423 assertHasClass(problemDiv, 'error');
406 assertTrue(continueButton.disabled); 424 assertTrue(continueButton.disabled);
407 }); 425 });
408 426
409 // If the PIN is weak a warning problem is shown. 427 // If the PIN is weak a warning problem is shown.
410 test('WarningShownForWeakPins', function() { 428 test('WarningShownForWeakPins', function() {
411 pinKeyboard.value = '111111'; 429 pinKeyboard.value = '1111';
412 430
413 assertTrue(isVisible(problemDiv)); 431 assertTrue(isVisible(problemDiv));
414 assertHasClass(problemDiv, 'warning'); 432 assertHasClass(problemDiv, 'warning');
415 }); 433 });
416 434
417 // If the confirm PIN does not match the initial PIN a warning is shown. 435 // If the confirm PIN does not match the initial PIN a warning is shown.
418 // If the user tries to submit the PIN, the warning changes to an error. 436 // If the user tries to submit the PIN, the warning changes to an error.
419 test('WarningThenErrorShownForMismatchedPins', function() { 437 test('WarningThenErrorShownForMismatchedPins', function() {
420 pinKeyboard.value = '1118'; 438 pinKeyboard.value = '1118';
421 MockInteractions.tap(continueButton); 439 MockInteractions.tap(continueButton);
422 440
423 // Entering a mismatched PIN shows a warning. 441 // Entering a mismatched PIN shows a warning.
424 pinKeyboard.value = '1119'; 442 pinKeyboard.value = '1119';
425 assertTrue(isVisible(problemDiv)); 443 assertTrue(isVisible(problemDiv));
426 assertHasClass(problemDiv, 'warning'); 444 assertHasClass(problemDiv, 'warning');
427 445
428 // Submitting a mistmatched PIN shows an error. 446 // Submitting a mistmatched PIN shows an error. Directly call the button
429 MockInteractions.tap(continueButton); 447 // event since a tap on the disabled button does nothing.
448 element.onPinSubmit_();
430 assertHasClass(problemDiv, 'error'); 449 assertHasClass(problemDiv, 'error');
431 450
432 // Changing the PIN changes the error to a warning. 451 // Changing the PIN changes the error to a warning.
433 pinKeyboard.value = '111'; 452 pinKeyboard.value = '111';
434 assertHasClass(problemDiv, 'warning'); 453 assertHasClass(problemDiv, 'warning');
435 }); 454 });
436 455
437 // Hitting cancel at the setup step dismisses the dialog. 456 // Hitting cancel at the setup step dismisses the dialog.
438 test('HittingBackButtonResetsState', function() { 457 test('HittingBackButtonResetsState', function() {
439 MockInteractions.tap(backButton); 458 MockInteractions.tap(backButton);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 }); 498 });
480 }); 499 });
481 } 500 }
482 501
483 return { 502 return {
484 registerAuthenticateTests: registerAuthenticateTests, 503 registerAuthenticateTests: registerAuthenticateTests,
485 registerLockScreenTests: registerLockScreenTests, 504 registerLockScreenTests: registerLockScreenTests,
486 registerSetupPinDialogTests: registerSetupPinDialogTests 505 registerSetupPinDialogTests: registerSetupPinDialogTests
487 }; 506 };
488 }); 507 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698