| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @fileoverview Fake implementation of chrome.settingsPrivate for testing. */ | 5 /** @fileoverview Fake implementation of chrome.settingsPrivate for testing. */ |
| 6 cr.define('settings', function() { | 6 cr.define('settings', function() { |
| 7 /** | 7 /** |
| 8 * Creates a deep copy of the object. | 8 * Creates a deep copy of the object. |
| 9 * @param {!Object} obj | 9 * @param {!Object} obj |
| 10 * @return {!Object} | 10 * @return {!Object} |
| 11 */ | 11 */ |
| 12 function deepCopy(obj) { | 12 function deepCopy(obj) { |
| 13 return JSON.parse(JSON.stringify(obj)); | 13 return JSON.parse(JSON.stringify(obj)); |
| 14 } | 14 } |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * Fake of chrome.settingsPrivate API. Use by setting | 17 * Fake of chrome.settingsPrivate API. Use by setting |
| 18 * CrSettingsPrefs.deferInitialization to true, then passing a | 18 * CrSettingsPrefs.deferInitialization to true, then passing a |
| 19 * FakeSettingsPrivate to SettingsPrefs.initializeForTesting. | 19 * FakeSettingsPrivate to settings-prefs#initialize(). |
| 20 * @constructor | 20 * @constructor |
| 21 * @param {Array<!settings.FakeSettingsPrivate.Pref>=} opt_initialPrefs | 21 * @param {Array<!settings.FakeSettingsPrivate.Pref>=} opt_initialPrefs |
| 22 * @implements {SettingsPrivate} | 22 * @implements {SettingsPrivate} |
| 23 */ | 23 */ |
| 24 function FakeSettingsPrivate(opt_initialPrefs) { | 24 function FakeSettingsPrivate(opt_initialPrefs) { |
| 25 this.prefs = {}; | 25 this.prefs = {}; |
| 26 | 26 |
| 27 if (!opt_initialPrefs) | 27 if (!opt_initialPrefs) |
| 28 return; | 28 return; |
| 29 for (var pref of opt_initialPrefs) | 29 for (var pref of opt_initialPrefs) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 return {FakeSettingsPrivate: FakeSettingsPrivate}; | 123 return {FakeSettingsPrivate: FakeSettingsPrivate}; |
| 124 }); | 124 }); |
| 125 | 125 |
| 126 /** | 126 /** |
| 127 * @type {Array<{key: string, | 127 * @type {Array<{key: string, |
| 128 * type: chrome.settingsPrivate.PrefType, | 128 * type: chrome.settingsPrivate.PrefType, |
| 129 * values: !Array<*>}>} | 129 * values: !Array<*>}>} |
| 130 */ | 130 */ |
| 131 settings.FakeSettingsPrivate.Pref; | 131 settings.FakeSettingsPrivate.Pref; |
| OLD | NEW |