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

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 9 errors. 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return Promise.all(urls.map(PolymerTest.importHtml)); 313 return Promise.all(urls.map(PolymerTest.importHtml));
314 }); 314 });
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.quickUnlockPrivate_ = quickUnlockPrivateApi;
323 element.setModes = 324 element.setModes =
324 quickUnlockPrivateApi.setModes.bind(quickUnlockPrivateApi, ''); 325 quickUnlockPrivateApi.setModes.bind(quickUnlockPrivateApi, '');
325 326
326 document.body.appendChild(element); 327 document.body.appendChild(element);
327 Polymer.dom.flush(); 328 Polymer.dom.flush();
328 329
329 element.open(); 330 element.open();
330 331
331 titleDiv = getFromElement('div[class="title"]'); 332 titleDiv = getFromElement('div[class="title"]');
332 problemDiv = getFromElement('#problemDiv'); 333 problemDiv = getFromElement('#problemDiv');
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 378
378 pinKeyboard.value = ''; 379 pinKeyboard.value = '';
379 assertTrue(isVisible(problemDiv)); 380 assertTrue(isVisible(problemDiv));
380 }); 381 });
381 382
382 // If the PIN is too short an error problem is shown. 383 // If the PIN is too short an error problem is shown.
383 test('WarningShownForShortPins', function() { 384 test('WarningShownForShortPins', function() {
384 pinKeyboard.value = '11'; 385 pinKeyboard.value = '11';
385 386
386 assertTrue(isVisible(problemDiv)); 387 assertTrue(isVisible(problemDiv));
387 assertHasClass(problemDiv, 'warning'); 388 assertHasClass(problemDiv, 'error');
388 assertTrue(continueButton.disabled); 389 assertTrue(continueButton.disabled);
389 }); 390 });
390 391
391 // If the PIN is weak a warning problem is shown. 392 // If the PIN is weak a warning problem is shown.
392 test('WarningShownForWeakPins', function() { 393 test('WarningShownForWeakPins', function() {
393 pinKeyboard.value = '111111'; 394 pinKeyboard.value = '1111';
394 395
395 assertTrue(isVisible(problemDiv)); 396 assertTrue(isVisible(problemDiv));
396 assertHasClass(problemDiv, 'warning'); 397 assertHasClass(problemDiv, 'warning');
397 }); 398 });
stevenjb 2016/12/19 19:01:29 Shouldn't we add a too long test?
sammiequon 2016/12/21 07:37:07 Done.
398 399
399 // If the confirm PIN does not match the initial PIN a warning is shown. 400 // 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. 401 // If the user tries to submit the PIN, the warning changes to an error.
401 test('WarningThenErrorShownForMismatchedPins', function() { 402 test('WarningThenErrorShownForMismatchedPins', function() {
402 pinKeyboard.value = '1118'; 403 pinKeyboard.value = '1118';
403 MockInteractions.tap(continueButton); 404 MockInteractions.tap(continueButton);
404 405
405 // Entering a mismatched PIN shows a warning. 406 // Entering a mismatched PIN shows a warning.
406 pinKeyboard.value = '1119'; 407 pinKeyboard.value = '1119';
407 assertTrue(isVisible(problemDiv)); 408 assertTrue(isVisible(problemDiv));
408 assertHasClass(problemDiv, 'warning'); 409 assertHasClass(problemDiv, 'warning');
409 410
410 // Submitting a mistmatched PIN shows an error. 411 // Submitting a mistmatched PIN shows an error. Directly call the button
411 MockInteractions.tap(continueButton); 412 // event since a tap on the disabled button does nothing.
413 element.onPinSubmit_();
412 assertHasClass(problemDiv, 'error'); 414 assertHasClass(problemDiv, 'error');
413 415
414 // Changing the PIN changes the error to a warning. 416 // Changing the PIN changes the error to a warning.
415 pinKeyboard.value = '111'; 417 pinKeyboard.value = '111';
416 assertHasClass(problemDiv, 'warning'); 418 assertHasClass(problemDiv, 'warning');
417 }); 419 });
418 420
419 // Hitting cancel at the setup step dismisses the dialog. 421 // Hitting cancel at the setup step dismisses the dialog.
420 test('HittingBackButtonResetsState', function() { 422 test('HittingBackButtonResetsState', function() {
421 MockInteractions.tap(backButton); 423 MockInteractions.tap(backButton);
(...skipping 29 matching lines...) Expand all
451 }); 453 });
452 }); 454 });
453 } 455 }
454 456
455 return { 457 return {
456 registerAuthenticateTests: registerAuthenticateTests, 458 registerAuthenticateTests: registerAuthenticateTests,
457 registerLockScreenTests: registerLockScreenTests, 459 registerLockScreenTests: registerLockScreenTests,
458 registerSetupPinDialogTests: registerSetupPinDialogTests 460 registerSetupPinDialogTests: registerSetupPinDialogTests
459 }; 461 };
460 }); 462 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698