Chromium Code Reviews| 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 /** | 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 Loading... | |
| 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() { | |
| 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 /** | |
| 80 * @param {string} value The string represnatation of boolean to return. | |
|
dpapad
2017/03/24 01:39:32
No need for @param when you are using @override.
scottchen
2017/03/24 20:48:54
Done.
| |
| 81 * @override | |
| 82 */ | |
| 83 validateStartupPage: function(value) { | |
| 84 this.methodCalled('validateStartupPage'); | |
| 85 // 'false' is an invalid value for testing purposes. | |
| 86 var returnValue = 'false' ? false : true; // 'false' | |
| 87 return Promise.resolve(returnValue); | |
| 88 }, | |
| 72 }; | 89 }; |
| 73 | 90 |
| 74 var appearancePage = null; | 91 var appearancePage = null; |
| 75 | 92 |
| 76 /** @type {?TestAppearanceBrowserProxy} */ | 93 /** @type {?TestAppearanceBrowserProxy} */ |
| 77 var appearanceBrowserProxy = null; | 94 var appearanceBrowserProxy = null; |
| 78 | 95 |
| 79 function createAppearancePage() { | 96 function createAppearancePage() { |
| 80 appearanceBrowserProxy.reset(); | 97 appearanceBrowserProxy.reset(); |
| 81 PolymerTest.clearBody(); | 98 PolymerTest.clearBody(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 }).then(function() { | 234 }).then(function() { |
| 218 assertEquals('110%', getDefaultZoomText()); | 235 assertEquals('110%', getDefaultZoomText()); |
| 219 | 236 |
| 220 appearanceBrowserProxy.setDefaultZoom(1.7499999999999); | 237 appearanceBrowserProxy.setDefaultZoom(1.7499999999999); |
| 221 createAppearancePage(); | 238 createAppearancePage(); |
| 222 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); | 239 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); |
| 223 }).then(function() { | 240 }).then(function() { |
| 224 assertEquals('175%', getDefaultZoomText()); | 241 assertEquals('175%', getDefaultZoomText()); |
| 225 }); | 242 }); |
| 226 }); | 243 }); |
| 244 | |
| 245 test('show home button toggling', function() { | |
| 246 assertFalse(!!appearancePage.$$('.list-frame')); | |
| 247 appearancePage.set('prefs', {browser: {show_home_button: {value: true}}}); | |
| 248 | |
| 249 Polymer.dom.flush(); | |
| 250 | |
| 251 assertTrue(!!appearancePage.$$('.list-frame')); | |
| 252 }); | |
| 253 | |
| 254 test('home button urls', function() { | |
| 255 appearancePage.set('prefs', { | |
| 256 browser: {show_home_button: {value: true}}, | |
| 257 homepage: {type: chrome.settingsPrivate.PrefType.URL, value: 'test'} | |
| 258 }); | |
| 259 | |
| 260 Polymer.dom.flush(); | |
| 261 | |
| 262 var input = appearancePage.$$('#customHomePage'); | |
| 263 assertTrue(!!input); | |
| 264 assertFalse(input.invalid); | |
| 265 assertEquals(input.value, 'test'); | |
| 266 | |
| 267 input.value = 'false'; // 'false' is an invalid value for testing purposes. | |
| 268 input.fire('input'); | |
| 269 | |
| 270 return appearanceBrowserProxy.whenCalled('validateStartupPage') | |
| 271 .then(function() { | |
| 272 Polymer.dom.flush(); | |
| 273 assertEquals(input.value, 'false'); | |
| 274 assertTrue(input.invalid); | |
| 275 | |
| 276 // Should reset to default value on change event. | |
| 277 input.$$('paper-input').fire('change'); | |
| 278 Polymer.dom.flush(); | |
| 279 assertEquals(input.value, 'test'); | |
| 280 }); | |
| 281 }); | |
| 227 }); | 282 }); |
| OLD | NEW |