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

Unified Diff: chrome/test/data/webui/settings/fake_quick_unlock_private.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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/settings/fake_quick_unlock_private.js
diff --git a/chrome/test/data/webui/settings/fake_quick_unlock_private.js b/chrome/test/data/webui/settings/fake_quick_unlock_private.js
index 0852d671316e1ef2bc85220a1aa7ffecc252cc46..e0e43d4a68ba274b615a7503c6f9c31a645cba1d 100644
--- a/chrome/test/data/webui/settings/fake_quick_unlock_private.js
+++ b/chrome/test/data/webui/settings/fake_quick_unlock_private.js
@@ -5,6 +5,13 @@
/**
* @fileoverview Fake implementation of chrome.quickUnlockPrivate for testing.
*/
+
+/**
+ * A couple weak pins to use for testing.
+ * @const
+ */
+var TEST_WEAK_PINS = ['1111', '1234', '1313', '2001', '1010'];
+
cr.define('settings', function() {
/**
* Fake of the chrome.quickUnlockPrivate API.
@@ -54,7 +61,47 @@ cr.define('settings', function() {
this.activeModes = modes;
this.credentials = credentials;
onComplete(this.accountPassword == accountPassword);
- }
+ },
+
+ /**
+ * @override
+ * @param {!chrome.quickUnlockPrivate.QuickUnlockMode} mode
+ * @param {string} credential
+ * @param {function(
+ * !chrome.quickUnlockPrivate.CredentialCheck):void} onComplete
+ */
+ checkCredential: function(mode, credential, onComplete) {
+ var message = {};
+ var errors = [];
+ var warnings = [];
+
+ // For testing we will use a min length of 4.
+ if (!!credential && credential.length < 4)
+ errors.push(chrome.quickUnlockPrivate.CredentialProblem.TOO_SHORT);
+
+ if (!!credential && TEST_WEAK_PINS.includes(credential))
+ warnings.push(chrome.quickUnlockPrivate.CredentialProblem.TOO_WEAK);
+
+ message.errors = errors;
+ message.warnings = warnings;
+ onComplete(message);
+ },
+
+ /**
+ * @override.
+ * @param {!chrome.quickUnlockPrivate.QuickUnlockMode} mode
+ * @param {function(
+ * !chrome.quickUnlockPrivate.CredentialRequirements):void onComplete
+ */
+ getCredentialRequirements: function(mode, onComplete) {
+ var fakeCredentials = {};
+
+ // For testing we will use a min length of 4 and a max length of 0 (no max
+ // length).
+ fakeCredentials.minLength = 4;
+ fakeCredentials.maxLength = 0;
+ onComplete(fakeCredentials);
+ },
};
/** @type {!ChromeEvent} */

Powered by Google App Engine
This is Rietveld 408576698