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

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

Issue 2766093002: MD Settings: validate home button url input (Closed)
Patch Set: Merge branch 'master' into home-button Created 3 years, 9 months 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 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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @implements {settings.AppearanceBrowserProxy} 7 * @implements {settings.AppearanceBrowserProxy}
8 * @extends {settings.TestBrowserProxy} 8 * @extends {settings.TestBrowserProxy}
9 */ 9 */
10 var TestAppearanceBrowserProxy = function() { 10 var TestAppearanceBrowserProxy = function() {
11 settings.TestBrowserProxy.call(this, [ 11 settings.TestBrowserProxy.call(this, [
12 'getDefaultZoom', 12 'getDefaultZoom',
13 'getThemeInfo', 13 'getThemeInfo',
14 'isSupervised', 14 'isSupervised',
15 'openWallpaperManager', 15 'openWallpaperManager',
16 'useDefaultTheme', 16 'useDefaultTheme',
17 'useSystemTheme', 17 'useSystemTheme',
18 'validateStartupPage',
18 ]); 19 ]);
19 20
20 /** @private */ 21 /** @private */
21 this.defaultZoom_ = 1; 22 this.defaultZoom_ = 1;
22 23
23 /** @private */ 24 /** @private */
24 this.isSupervised_ = false; 25 this.isSupervised_ = false;
25 }; 26 };
26 27
27 TestAppearanceBrowserProxy.prototype = { 28 TestAppearanceBrowserProxy.prototype = {
(...skipping 25 matching lines...) Expand all
53 /** @override */ 54 /** @override */
54 useDefaultTheme: function() { 55 useDefaultTheme: function() {
55 this.methodCalled('useDefaultTheme'); 56 this.methodCalled('useDefaultTheme');
56 }, 57 },
57 58
58 /** @override */ 59 /** @override */
59 useSystemTheme: function() { 60 useSystemTheme: function() {
60 this.methodCalled('useSystemTheme'); 61 this.methodCalled('useSystemTheme');
61 }, 62 },
62 63
64 /** @override */
65 useSystemTheme: function() {
dpapad 2017/03/24 21:47:43 Accidental copy paste?
scottchen 2017/03/24 22:56:31 Done.
66 this.methodCalled('useSystemTheme');
67 },
68
63 /** @param {number} defaultZoom */ 69 /** @param {number} defaultZoom */
64 setDefaultZoom: function(defaultZoom) { 70 setDefaultZoom: function(defaultZoom) {
65 this.defaultZoom_ = defaultZoom; 71 this.defaultZoom_ = defaultZoom;
66 }, 72 },
67 73
68 /** @param {boolean} Whether the user is supervised */ 74 /** @param {boolean} Whether the user is supervised */
69 setIsSupervised: function(isSupervised) { 75 setIsSupervised: function(isSupervised) {
70 this.isSupervised_ = isSupervised; 76 this.isSupervised_ = isSupervised;
71 }, 77 },
78
79 /** @override */
80 validateStartupPage: function(value) {
81 this.methodCalled('validateStartupPage');
82 // 'false' is an invalid value for testing purposes.
83 var returnValue = 'false' ? false : true; // 'false'
dpapad 2017/03/24 21:47:43 Instead of hardcoding an invalid value, how about
scottchen 2017/03/24 22:56:31 Done.
84 return Promise.resolve(returnValue);
85 },
72 }; 86 };
73 87
74 var appearancePage = null; 88 var appearancePage = null;
75 89
76 /** @type {?TestAppearanceBrowserProxy} */ 90 /** @type {?TestAppearanceBrowserProxy} */
77 var appearanceBrowserProxy = null; 91 var appearanceBrowserProxy = null;
78 92
79 function createAppearancePage() { 93 function createAppearancePage() {
80 appearanceBrowserProxy.reset(); 94 appearanceBrowserProxy.reset();
81 PolymerTest.clearBody(); 95 PolymerTest.clearBody();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 }).then(function() { 231 }).then(function() {
218 assertEquals('110%', getDefaultZoomText()); 232 assertEquals('110%', getDefaultZoomText());
219 233
220 appearanceBrowserProxy.setDefaultZoom(1.7499999999999); 234 appearanceBrowserProxy.setDefaultZoom(1.7499999999999);
221 createAppearancePage(); 235 createAppearancePage();
222 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); 236 return appearanceBrowserProxy.whenCalled('getDefaultZoom');
223 }).then(function() { 237 }).then(function() {
224 assertEquals('175%', getDefaultZoomText()); 238 assertEquals('175%', getDefaultZoomText());
225 }); 239 });
226 }); 240 });
241
242 test('show home button toggling', function() {
243 assertFalse(!!appearancePage.$$('.list-frame'));
244 appearancePage.set('prefs', {browser: {show_home_button: {value: true}}});
245
246 Polymer.dom.flush();
247
248 assertTrue(!!appearancePage.$$('.list-frame'));
249 });
250
251 test('home button urls', function() {
252 appearancePage.set('prefs', {
253 browser: {show_home_button: {value: true}},
254 homepage: {type: chrome.settingsPrivate.PrefType.URL, value: 'test'}
255 });
256
257 Polymer.dom.flush();
258
259 var input = appearancePage.$$('#customHomePage');
260 assertTrue(!!input);
261 assertFalse(input.invalid);
262 assertEquals(input.value, 'test');
263
264 input.value = 'false'; // 'false' is an invalid value for testing purposes.
265 input.fire('input');
266
267 return appearanceBrowserProxy.whenCalled('validateStartupPage')
268 .then(function() {
269 Polymer.dom.flush();
270 assertEquals(input.value, 'false');
271 assertTrue(input.invalid);
272
273 // Should reset to default value on change event.
274 input.$$('paper-input').fire('change');
dpapad 2017/03/24 21:47:43 Does the 'change' event have to be fired from pape
scottchen 2017/03/24 22:56:31 settingsInput.onChange_ was attached to <paper-inp
275 Polymer.dom.flush();
276 assertEquals(input.value, 'test');
277 });
278 });
227 }); 279 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698