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

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: Added a comment. Created 4 years 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 9
10 /** 10 /**
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 setup(function() { 316 setup(function() {
317 PolymerTest.clearBody(); 317 PolymerTest.clearBody();
318 318
319 quickUnlockPrivateApi = new settings.FakeQuickUnlockPrivate(); 319 quickUnlockPrivateApi = new settings.FakeQuickUnlockPrivate();
320 320
321 // Create setup-pin element. 321 // Create setup-pin element.
322 element = document.createElement('settings-setup-pin-dialog'); 322 element = document.createElement('settings-setup-pin-dialog');
323 element.setModes = 323 element.setModes =
324 quickUnlockPrivateApi.setModes.bind(quickUnlockPrivateApi, ''); 324 quickUnlockPrivateApi.setModes.bind(quickUnlockPrivateApi, '');
325 element.checkCredential_ =
326 quickUnlockPrivateApi.checkCredential.bind(quickUnlockPrivateApi);
327 element.getCredentialRequirements_ =
328 quickUnlockPrivateApi.getCredentialRequirements.bind(
329 quickUnlockPrivateApi);
325 330
326 document.body.appendChild(element); 331 document.body.appendChild(element);
327 Polymer.dom.flush(); 332 Polymer.dom.flush();
328 333
329 element.open(); 334 element.open();
330 335
331 titleDiv = getFromElement('div[class="title"]'); 336 titleDiv = getFromElement('div[class="title"]');
332 problemDiv = getFromElement('#problemDiv'); 337 problemDiv = getFromElement('#problemDiv');
333 pinKeyboard = getFromElement('pin-keyboard'); 338 pinKeyboard = getFromElement('pin-keyboard');
334 backButton = getFromElement('paper-button[class="cancel-button"]'); 339 backButton = getFromElement('paper-button[class="cancel-button"]');
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 382
378 pinKeyboard.value = ''; 383 pinKeyboard.value = '';
379 assertTrue(isVisible(problemDiv)); 384 assertTrue(isVisible(problemDiv));
380 }); 385 });
381 386
382 // If the PIN is too short an error problem is shown. 387 // If the PIN is too short an error problem is shown.
383 test('WarningShownForShortPins', function() { 388 test('WarningShownForShortPins', function() {
384 pinKeyboard.value = '11'; 389 pinKeyboard.value = '11';
385 390
386 assertTrue(isVisible(problemDiv)); 391 assertTrue(isVisible(problemDiv));
387 assertHasClass(problemDiv, 'warning'); 392 assertHasClass(problemDiv, 'error');
388 assertTrue(continueButton.disabled); 393 assertTrue(continueButton.disabled);
389 }); 394 });
390 395
391 // If the PIN is weak a warning problem is shown. 396 // If the PIN is weak a warning problem is shown.
392 test('WarningShownForWeakPins', function() { 397 test('WarningShownForWeakPins', function() {
393 pinKeyboard.value = '111111'; 398 pinKeyboard.value = '1111';
394 399
395 assertTrue(isVisible(problemDiv)); 400 assertTrue(isVisible(problemDiv));
396 assertHasClass(problemDiv, 'warning'); 401 assertHasClass(problemDiv, 'warning');
397 }); 402 });
398 403
399 // If the confirm PIN does not match the initial PIN a warning is shown. 404 // If the confirm PIN does not match the initial PIN a warning is shown.
400 // If the user tries to submit the PIN, the warning changes to an error. 405 // If the user tries to submit the PIN, the warning changes to an error.
401 test('WarningThenErrorShownForMismatchedPins', function() { 406 test('WarningThenErrorShownForMismatchedPins', function() {
402 pinKeyboard.value = '1118'; 407 pinKeyboard.value = '1118';
403 MockInteractions.tap(continueButton); 408 MockInteractions.tap(continueButton);
404 409
405 // Entering a mismatched PIN shows a warning. 410 // Entering a mismatched PIN shows a warning.
406 pinKeyboard.value = '1119'; 411 pinKeyboard.value = '1119';
407 assertTrue(isVisible(problemDiv)); 412 assertTrue(isVisible(problemDiv));
408 assertHasClass(problemDiv, 'warning'); 413 assertHasClass(problemDiv, 'warning');
409 414
410 // Submitting a mistmatched PIN shows an error. 415 // Submitting a mistmatched PIN shows an error. Directly call the button
411 MockInteractions.tap(continueButton); 416 // event since a tap on the disabled button does nothing.
417 element.onPinSubmit_();
412 assertHasClass(problemDiv, 'error'); 418 assertHasClass(problemDiv, 'error');
413 419
414 // Changing the PIN changes the error to a warning. 420 // Changing the PIN changes the error to a warning.
415 pinKeyboard.value = '111'; 421 pinKeyboard.value = '111';
416 assertHasClass(problemDiv, 'warning'); 422 assertHasClass(problemDiv, 'warning');
417 }); 423 });
418 424
419 // Hitting cancel at the setup step dismisses the dialog. 425 // Hitting cancel at the setup step dismisses the dialog.
420 test('HittingBackButtonResetsState', function() { 426 test('HittingBackButtonResetsState', function() {
421 MockInteractions.tap(backButton); 427 MockInteractions.tap(backButton);
(...skipping 29 matching lines...) Expand all
451 }); 457 });
452 }); 458 });
453 } 459 }
454 460
455 return { 461 return {
456 registerAuthenticateTests: registerAuthenticateTests, 462 registerAuthenticateTests: registerAuthenticateTests,
457 registerLockScreenTests: registerLockScreenTests, 463 registerLockScreenTests: registerLockScreenTests,
458 registerSetupPinDialogTests: registerSetupPinDialogTests 464 registerSetupPinDialogTests: registerSetupPinDialogTests
459 }; 465 };
460 }); 466 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698