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

Side by Side Diff: chrome/test/data/webui/settings/test_site_settings_prefs_browser_proxy.js

Issue 2480843003: change site-settings -> usb-device to use cr-action-menu instead of paper-menu (Closed)
Patch Set: move helper function out of test function scope Created 4 years, 1 month 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 /** 5 /**
6 * An example empty pref. 6 * An example empty pref.
7 * @type {SiteSettingsPref} 7 * @type {SiteSettingsPref}
8 */ 8 */
9 var prefsEmpty = { 9 var prefsEmpty = {
10 defaults: { 10 defaults: {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 * A test version of SiteSettingsPrefsBrowserProxy. Provides helper methods 43 * A test version of SiteSettingsPrefsBrowserProxy. Provides helper methods
44 * for allowing tests to know when a method was called, as well as 44 * for allowing tests to know when a method was called, as well as
45 * specifying mock responses. 45 * specifying mock responses.
46 * 46 *
47 * @constructor 47 * @constructor
48 * @implements {settings.SiteSettingsPrefsBrowserProxy} 48 * @implements {settings.SiteSettingsPrefsBrowserProxy}
49 * @extends {settings.TestBrowserProxy} 49 * @extends {settings.TestBrowserProxy}
50 */ 50 */
51 var TestSiteSettingsPrefsBrowserProxy = function() { 51 var TestSiteSettingsPrefsBrowserProxy = function() {
52 settings.TestBrowserProxy.call(this, [ 52 settings.TestBrowserProxy.call(this, [
53 'fetchUsbDevices',
53 'fetchZoomLevels', 54 'fetchZoomLevels',
54 'getDefaultValueForContentType', 55 'getDefaultValueForContentType',
55 'getExceptionList', 56 'getExceptionList',
57 'removeUsbDevice',
56 'removeZoomLevel', 58 'removeZoomLevel',
57 'resetCategoryPermissionForOrigin', 59 'resetCategoryPermissionForOrigin',
58 'setCategoryPermissionForOrigin', 60 'setCategoryPermissionForOrigin',
59 'setDefaultValueForContentType', 61 'setDefaultValueForContentType',
60 ]); 62 ]);
61 63
62 /** @private {!SiteSettingsPref} */ 64 /** @private {!SiteSettingsPref} */
63 this.prefs_ = prefsEmpty; 65 this.prefs_ = prefsEmpty;
64 66
65 /** @private {!Array<ZoomLevelEntry>} */ 67 /** @private {!Array<ZoomLevelEntry>} */
66 this.zoomList_ = []; 68 this.zoomList_ = [];
69
70 /** @private {!Array<UsbDeviceEntry>} */
71 this.usbDevices_ = [];
67 }; 72 };
68 73
69 TestSiteSettingsPrefsBrowserProxy.prototype = { 74 TestSiteSettingsPrefsBrowserProxy.prototype = {
70 __proto__: settings.TestBrowserProxy.prototype, 75 __proto__: settings.TestBrowserProxy.prototype,
71 76
72 /** 77 /**
73 * Sets the prefs to use when testing. 78 * Sets the prefs to use when testing.
74 * @param {!SiteSettingsPref} prefs The prefs to set. 79 * @param {!SiteSettingsPref} prefs The prefs to set.
75 */ 80 */
76 setPrefs: function(prefs) { 81 setPrefs: function(prefs) {
77 this.prefs_ = prefs; 82 this.prefs_ = prefs;
78 83
79 // Notify all listeners that their data may be out of date. 84 // Notify all listeners that their data may be out of date.
80 for (var type in settings.ContentSettingsTypes) { 85 for (var type in settings.ContentSettingsTypes) {
81 cr.webUIListenerCallback( 86 cr.webUIListenerCallback(
82 'contentSettingSitePermissionChanged', 87 'contentSettingSitePermissionChanged',
83 settings.ContentSettingsTypes[type], 88 settings.ContentSettingsTypes[type],
84 ''); 89 '');
85 } 90 }
86 }, 91 },
87 92
88 /** 93 /**
89 * Sets the prefs to use when testing. 94 * Sets the prefs to use when testing.
90 * @param !Array<ZoomLevelEntry> list The zoom list to set. 95 * @param {!Array<ZoomLevelEntry>} list The zoom list to set.
91 */ 96 */
92 setZoomList: function(list) { 97 setZoomList: function(list) {
93 this.zoomList_ = list; 98 this.zoomList_ = list;
94 }, 99 },
95 100
101 /**
102 * Sets the prefs to use when testing.
103 * @param {!Array<UsbDeviceEntry>} list The usb device entry list to set.
104 */
105 setUsbDevices: function(list) {
106 // Shallow copy of the passed-in array so mutation won't impact the source
107 this.usbDevices_ = list.slice();
108 },
109
96 /** @override */ 110 /** @override */
97 setDefaultValueForContentType: function(contentType, defaultValue) { 111 setDefaultValueForContentType: function(contentType, defaultValue) {
98 this.methodCalled( 112 this.methodCalled(
99 'setDefaultValueForContentType', [contentType, defaultValue]); 113 'setDefaultValueForContentType', [contentType, defaultValue]);
100 }, 114 },
101 115
102 /** @override */ 116 /** @override */
103 getDefaultValueForContentType: function(contentType) { 117 getDefaultValueForContentType: function(contentType) {
104 this.methodCalled('getDefaultValueForContentType', contentType); 118 this.methodCalled('getDefaultValueForContentType', contentType);
105 119
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 /** @override */ 214 /** @override */
201 fetchZoomLevels: function() { 215 fetchZoomLevels: function() {
202 cr.webUIListenerCallback('onZoomLevelsChanged', this.zoomList_); 216 cr.webUIListenerCallback('onZoomLevelsChanged', this.zoomList_);
203 this.methodCalled('fetchZoomLevels'); 217 this.methodCalled('fetchZoomLevels');
204 }, 218 },
205 219
206 /** @override */ 220 /** @override */
207 removeZoomLevel: function(host) { 221 removeZoomLevel: function(host) {
208 this.methodCalled('removeZoomLevel', [host]); 222 this.methodCalled('removeZoomLevel', [host]);
209 }, 223 },
224
225 /** @override */
226 fetchUsbDevices: function() {
227 this.methodCalled('fetchUsbDevices');
228 return Promise.resolve(this.usbDevices_);
229 },
230
231 /** @override */
232 removeUsbDevice: function() {
233 this.methodCalled('removeUsbDevice', arguments);
234 }
210 }; 235 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698