| 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() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 setDefaultZoom: function(defaultZoom) { | 68 setDefaultZoom: function(defaultZoom) { |
| 69 this.defaultZoom_ = defaultZoom; | 69 this.defaultZoom_ = defaultZoom; |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 /** @param {boolean} Whether the user is supervised */ | 72 /** @param {boolean} Whether the user is supervised */ |
| 73 setIsSupervised: function(isSupervised) { | 73 setIsSupervised: function(isSupervised) { |
| 74 this.isSupervised_ = isSupervised; | 74 this.isSupervised_ = isSupervised; |
| 75 }, | 75 }, |
| 76 | 76 |
| 77 /** @override */ | 77 /** @override */ |
| 78 validateStartupPage: function(value) { | 78 validateStartupPage: function(url) { |
| 79 this.methodCalled('validateStartupPage'); | 79 this.methodCalled('validateStartupPage', url); |
| 80 return Promise.resolve(this.isHomeUrlValid_); | 80 return Promise.resolve(this.isHomeUrlValid_); |
| 81 }, | 81 }, |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * @param {boolean} isValid | 84 * @param {boolean} isValid |
| 85 */ | 85 */ |
| 86 setValidStartupPageResponse: function(isValid) { | 86 setValidStartupPageResponse: function(isValid) { |
| 87 this.isHomeUrlValid_ = isValid; | 87 this.isHomeUrlValid_ = isValid; |
| 88 } | 88 } |
| 89 }; | 89 }; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 }); | 243 }); |
| 244 | 244 |
| 245 test('show home button toggling', function() { | 245 test('show home button toggling', function() { |
| 246 assertFalse(!!appearancePage.$$('.list-frame')); | 246 assertFalse(!!appearancePage.$$('.list-frame')); |
| 247 appearancePage.set('prefs', {browser: {show_home_button: {value: true}}}); | 247 appearancePage.set('prefs', {browser: {show_home_button: {value: true}}}); |
| 248 | 248 |
| 249 Polymer.dom.flush(); | 249 Polymer.dom.flush(); |
| 250 | 250 |
| 251 assertTrue(!!appearancePage.$$('.list-frame')); | 251 assertTrue(!!appearancePage.$$('.list-frame')); |
| 252 }); | 252 }); |
| 253 }); |
| 254 |
| 255 suite('HomeUrlInput', function() { |
| 256 var homeUrlInput; |
| 257 |
| 258 setup(function() { |
| 259 appearanceBrowserProxy = new TestAppearanceBrowserProxy(); |
| 260 settings.AppearanceBrowserProxyImpl.instance_ = appearanceBrowserProxy; |
| 261 PolymerTest.clearBody(); |
| 262 |
| 263 homeUrlInput = document.createElement('home-url-input'); |
| 264 homeUrlInput.set( |
| 265 'pref', {type: chrome.settingsPrivate.PrefType.URL, value: 'test'}); |
| 266 |
| 267 document.body.appendChild(homeUrlInput); |
| 268 Polymer.dom.flush(); |
| 269 }); |
| 253 | 270 |
| 254 test('home button urls', function() { | 271 test('home button urls', function() { |
| 255 appearancePage.set('prefs', { | 272 assertFalse(homeUrlInput.invalid); |
| 256 browser: {show_home_button: {value: true}}, | 273 assertEquals(homeUrlInput.value, 'test'); |
| 257 homepage: {type: chrome.settingsPrivate.PrefType.URL, value: 'test'} | |
| 258 }); | |
| 259 | 274 |
| 260 Polymer.dom.flush(); | 275 homeUrlInput.value = '@@@'; |
| 261 | |
| 262 var input = appearancePage.$$('#customHomePage'); | |
| 263 assertTrue(!!input); | |
| 264 assertFalse(input.invalid); | |
| 265 assertEquals(input.value, 'test'); | |
| 266 | |
| 267 input.value = '@@@'; | |
| 268 appearanceBrowserProxy.setValidStartupPageResponse(false); | 276 appearanceBrowserProxy.setValidStartupPageResponse(false); |
| 269 input.fire('input'); | 277 homeUrlInput.$.input.fire('input'); |
| 270 | 278 |
| 271 return appearanceBrowserProxy.whenCalled('validateStartupPage') | 279 return appearanceBrowserProxy.whenCalled('validateStartupPage') |
| 272 .then(function() { | 280 .then(function(url) { |
| 281 assertEquals(homeUrlInput.value, url); |
| 273 Polymer.dom.flush(); | 282 Polymer.dom.flush(); |
| 274 assertEquals(input.value, '@@@'); | 283 assertEquals(homeUrlInput.value, '@@@'); // Value hasn't changed. |
| 275 assertTrue(input.invalid); | 284 assertTrue(homeUrlInput.invalid); |
| 276 | 285 |
| 277 // Should reset to default value on change event. | 286 // Should reset to default value on change event. |
| 278 input.$$('paper-input').fire('change'); | 287 homeUrlInput.$.input.fire('change'); |
| 279 Polymer.dom.flush(); | 288 Polymer.dom.flush(); |
| 280 assertEquals(input.value, 'test'); | 289 assertEquals(homeUrlInput.value, 'test'); |
| 281 }); | 290 }); |
| 282 }); | 291 }); |
| 283 }); | 292 }); |
| OLD | NEW |