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} */ |