OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Fake implementation of chrome.quickUnlockPrivate for testing. |
| 7 */ |
| 8 cr.define('settings', function() { |
| 9 /** |
| 10 * Fake of the chrome.quickUnlockPrivate API. |
| 11 * @constructor |
| 12 * @implements {QuickUnlockPrivate} |
| 13 */ |
| 14 function FakeQuickUnlockPrivate() { |
| 15 /** @type {!Array<!chrome.quickUnlockPrivate.QuickUnlockMode>} */ |
| 16 this.availableModes = [chrome.quickUnlockPrivate.QuickUnlockMode.PIN]; |
| 17 /** @type {!Array<!chrome.quickUnlockPrivate.QuickUnlockMode>} */ |
| 18 this.activeModes = []; |
| 19 /** @type {!Array<string>} */ this.credentials = []; |
| 20 /** @type {string} */ this.accountPassword = ''; |
| 21 } |
| 22 |
| 23 FakeQuickUnlockPrivate.prototype = { |
| 24 // Public testing methods. |
| 25 /** |
| 26 * @override |
| 27 * @param {function( |
| 28 * !Array<!chrome.quickUnlockPrivate.QuickUnlockMode>):void} onComplete |
| 29 */ |
| 30 getAvailableModes: function(onComplete) { |
| 31 onComplete(this.availableModes); |
| 32 }, |
| 33 |
| 34 /** |
| 35 * @override |
| 36 * @param {function( |
| 37 * !Array<!chrome.quickUnlockPrivate.QuickUnlockMode>):void} onComplete |
| 38 */ |
| 39 getActiveModes: function(onComplete) { |
| 40 onComplete(this.activeModes); |
| 41 }, |
| 42 |
| 43 /** |
| 44 * @override |
| 45 * @param {string} accountPassword |
| 46 * @param {!Array<!chrome.quickUnlockPrivate.QuickUnlockMode>} modes |
| 47 * @param {!Array<string>} credentials |
| 48 * @param {function(boolean):void} onComplete |
| 49 */ |
| 50 setModes: function(accountPassword, modes, credentials, onComplete) { |
| 51 // Even if the account password is wrong we still update activeModes and |
| 52 // credentials so that the mock owner has a chance to see what was given |
| 53 // to the API. |
| 54 this.activeModes = modes; |
| 55 this.credentials = credentials; |
| 56 onComplete(this.accountPassword == accountPassword); |
| 57 } |
| 58 }; |
| 59 |
| 60 /** @type {!ChromeEvent} */ |
| 61 FakeQuickUnlockPrivate.prototype.onActiveModesChanged = new FakeChromeEvent(); |
| 62 |
| 63 return {FakeQuickUnlockPrivate: FakeQuickUnlockPrivate}; |
| 64 }); |
OLD | NEW |