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

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: Rebased. Created 3 years, 12 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 pinKeyboard.value = '111111';
416
417 assertTrue(isVisible(problemDiv));
418 assertHasClass(problemDiv, 'error');
406 assertTrue(continueButton.disabled); 419 assertTrue(continueButton.disabled);
stevenjb 2017/01/03 18:35:13 We should also test that a shorter pin is valid wh
sammiequon 2017/01/03 22:15:07 Done.
407 }); 420 });
408 421
409 // If the PIN is weak a warning problem is shown. 422 // If the PIN is weak a warning problem is shown.
410 test('WarningShownForWeakPins', function() { 423 test('WarningShownForWeakPins', function() {
411 pinKeyboard.value = '111111'; 424 pinKeyboard.value = '1111';
412 425
413 assertTrue(isVisible(problemDiv)); 426 assertTrue(isVisible(problemDiv));
414 assertHasClass(problemDiv, 'warning'); 427 assertHasClass(problemDiv, 'warning');
415 }); 428 });
416 429
417 // If the confirm PIN does not match the initial PIN a warning is shown. 430 // 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. 431 // If the user tries to submit the PIN, the warning changes to an error.
419 test('WarningThenErrorShownForMismatchedPins', function() { 432 test('WarningThenErrorShownForMismatchedPins', function() {
420 pinKeyboard.value = '1118'; 433 pinKeyboard.value = '1118';
421 MockInteractions.tap(continueButton); 434 MockInteractions.tap(continueButton);
422 435
423 // Entering a mismatched PIN shows a warning. 436 // Entering a mismatched PIN shows a warning.
424 pinKeyboard.value = '1119'; 437 pinKeyboard.value = '1119';
425 assertTrue(isVisible(problemDiv)); 438 assertTrue(isVisible(problemDiv));
426 assertHasClass(problemDiv, 'warning'); 439 assertHasClass(problemDiv, 'warning');
427 440
428 // Submitting a mistmatched PIN shows an error. 441 // Submitting a mistmatched PIN shows an error. Directly call the button
429 MockInteractions.tap(continueButton); 442 // event since a tap on the disabled button does nothing.
443 element.onPinSubmit_();
430 assertHasClass(problemDiv, 'error'); 444 assertHasClass(problemDiv, 'error');
431 445
432 // Changing the PIN changes the error to a warning. 446 // Changing the PIN changes the error to a warning.
433 pinKeyboard.value = '111'; 447 pinKeyboard.value = '111';
434 assertHasClass(problemDiv, 'warning'); 448 assertHasClass(problemDiv, 'warning');
435 }); 449 });
436 450
437 // Hitting cancel at the setup step dismisses the dialog. 451 // Hitting cancel at the setup step dismisses the dialog.
438 test('HittingBackButtonResetsState', function() { 452 test('HittingBackButtonResetsState', function() {
439 MockInteractions.tap(backButton); 453 MockInteractions.tap(backButton);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 }); 493 });
480 }); 494 });
481 } 495 }
482 496
483 return { 497 return {
484 registerAuthenticateTests: registerAuthenticateTests, 498 registerAuthenticateTests: registerAuthenticateTests,
485 registerLockScreenTests: registerLockScreenTests, 499 registerLockScreenTests: registerLockScreenTests,
486 registerSetupPinDialogTests: registerSetupPinDialogTests 500 registerSetupPinDialogTests: registerSetupPinDialogTests
487 }; 501 };
488 }); 502 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698