| 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 'getThemeInfo', | 13 'getThemeInfo', |
| 13 'isSupervised', | 14 'isSupervised', |
| 14 'openWallpaperManager', | 15 'openWallpaperManager', |
| 15 'useDefaultTheme', | 16 'useDefaultTheme', |
| 16 'useSystemTheme', | 17 'useSystemTheme', |
| 17 ]); | 18 ]); |
| 19 |
| 20 /** @private */ |
| 21 this.defaultZoom_ = 1; |
| 22 |
| 23 /** @private */ |
| 24 this.isSupervised_ = false; |
| 18 }; | 25 }; |
| 19 | 26 |
| 20 TestAppearanceBrowserProxy.prototype = { | 27 TestAppearanceBrowserProxy.prototype = { |
| 21 __proto__: settings.TestBrowserProxy.prototype, | 28 __proto__: settings.TestBrowserProxy.prototype, |
| 22 | 29 |
| 23 /** @private */ | 30 /** @override */ |
| 24 isSupervised_: false, | 31 getDefaultZoom: function() { |
| 32 this.methodCalled('getDefaultZoom'); |
| 33 return Promise.resolve(this.defaultZoom_); |
| 34 }, |
| 25 | 35 |
| 26 /** @override */ | 36 /** @override */ |
| 27 getThemeInfo: function(themeId) { | 37 getThemeInfo: function(themeId) { |
| 28 this.methodCalled('getThemeInfo', themeId); | 38 this.methodCalled('getThemeInfo', themeId); |
| 29 return Promise.resolve({name: 'Sports car red'}); | 39 return Promise.resolve({name: 'Sports car red'}); |
| 30 }, | 40 }, |
| 31 | 41 |
| 32 /** @override */ | 42 /** @override */ |
| 33 isSupervised: function() { | 43 isSupervised: function() { |
| 34 this.methodCalled('isSupervised'); | 44 this.methodCalled('isSupervised'); |
| 35 return this.isSupervised_; | 45 return this.isSupervised_; |
| 36 }, | 46 }, |
| 37 | 47 |
| 38 /** @override */ | 48 /** @override */ |
| 39 openWallpaperManager: function() { | 49 openWallpaperManager: function() { |
| 40 this.methodCalled('openWallpaperManager'); | 50 this.methodCalled('openWallpaperManager'); |
| 41 }, | 51 }, |
| 42 | 52 |
| 43 /** @override */ | 53 /** @override */ |
| 44 useDefaultTheme: function() { | 54 useDefaultTheme: function() { |
| 45 this.methodCalled('useDefaultTheme'); | 55 this.methodCalled('useDefaultTheme'); |
| 46 }, | 56 }, |
| 47 | 57 |
| 48 /** @override */ | 58 /** @override */ |
| 49 useSystemTheme: function() { | 59 useSystemTheme: function() { |
| 50 this.methodCalled('useSystemTheme'); | 60 this.methodCalled('useSystemTheme'); |
| 51 }, | 61 }, |
| 52 | 62 |
| 63 /** @param {number} defaultZoom */ |
| 64 setDefaultZoom: function(defaultZoom) { |
| 65 this.defaultZoom_ = defaultZoom; |
| 66 }, |
| 67 |
| 53 /** @param {boolean} Whether the user is supervised */ | 68 /** @param {boolean} Whether the user is supervised */ |
| 54 setIsSupervised: function(isSupervised) { | 69 setIsSupervised: function(isSupervised) { |
| 55 this.isSupervised_ = isSupervised; | 70 this.isSupervised_ = isSupervised; |
| 56 }, | 71 }, |
| 57 }; | 72 }; |
| 58 | 73 |
| 59 var appearancePage = null; | 74 var appearancePage = null; |
| 60 | 75 |
| 61 /** @type {?TestAppearanceBrowserProxy} */ | 76 /** @type {?TestAppearanceBrowserProxy} */ |
| 62 var appearanceBrowserProxy = null; | 77 var appearanceBrowserProxy = null; |
| 63 | 78 |
| 79 function createAppearancePage() { |
| 80 appearanceBrowserProxy.reset(); |
| 81 PolymerTest.clearBody(); |
| 82 |
| 83 appearancePage = document.createElement('settings-appearance-page'); |
| 84 appearancePage.set('prefs', { |
| 85 extensions: { |
| 86 theme: { |
| 87 id: { |
| 88 value: '', |
| 89 }, |
| 90 use_system: { |
| 91 value: false, |
| 92 }, |
| 93 }, |
| 94 }, |
| 95 }); |
| 96 |
| 97 document.body.appendChild(appearancePage); |
| 98 Polymer.dom.flush(); |
| 99 } |
| 100 |
| 64 suite('AppearanceHandler', function() { | 101 suite('AppearanceHandler', function() { |
| 65 setup(function() { | 102 setup(function() { |
| 66 appearanceBrowserProxy = new TestAppearanceBrowserProxy(); | 103 appearanceBrowserProxy = new TestAppearanceBrowserProxy(); |
| 67 settings.AppearanceBrowserProxyImpl.instance_ = appearanceBrowserProxy; | 104 settings.AppearanceBrowserProxyImpl.instance_ = appearanceBrowserProxy; |
| 68 | 105 createAppearancePage(); |
| 69 PolymerTest.clearBody(); | |
| 70 | |
| 71 appearancePage = document.createElement('settings-appearance-page'); | |
| 72 appearancePage.set('prefs', { | |
| 73 extensions: { | |
| 74 theme: { | |
| 75 id: { | |
| 76 value: '', | |
| 77 }, | |
| 78 use_system: { | |
| 79 value: false, | |
| 80 }, | |
| 81 }, | |
| 82 }, | |
| 83 }); | |
| 84 document.body.appendChild(appearancePage); | |
| 85 Polymer.dom.flush(); | |
| 86 }); | 106 }); |
| 87 | 107 |
| 88 teardown(function() { appearancePage.remove(); }); | 108 teardown(function() { appearancePage.remove(); }); |
| 89 | 109 |
| 90 if (cr.isChromeOS) { | 110 if (cr.isChromeOS) { |
| 91 test('wallpaperManager', function() { | 111 test('wallpaperManager', function() { |
| 92 var button = appearancePage.$.wallpaperButton; | 112 var button = appearancePage.$.wallpaperButton; |
| 93 assertTrue(!!button); | 113 assertTrue(!!button); |
| 94 MockInteractions.tap(button); | 114 MockInteractions.tap(button); |
| 95 return appearanceBrowserProxy.whenCalled('openWallpaperManager'); | 115 return appearanceBrowserProxy.whenCalled('openWallpaperManager'); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 Polymer.dom.flush(); | 188 Polymer.dom.flush(); |
| 169 | 189 |
| 170 // With a custom theme installed, "RESET TO DEFAULT" should show. | 190 // With a custom theme installed, "RESET TO DEFAULT" should show. |
| 171 var button = appearancePage.$$('#useDefault'); | 191 var button = appearancePage.$$('#useDefault'); |
| 172 assertTrue(!!button); | 192 assertTrue(!!button); |
| 173 | 193 |
| 174 MockInteractions.tap(button); | 194 MockInteractions.tap(button); |
| 175 return appearanceBrowserProxy.whenCalled('useDefaultTheme'); | 195 return appearanceBrowserProxy.whenCalled('useDefaultTheme'); |
| 176 }); | 196 }); |
| 177 } | 197 } |
| 198 |
| 199 test('default zoom handling', function() { |
| 200 function getDefaultZoomText() { |
| 201 var zoomLevel = appearancePage.$.zoomLevel; |
| 202 return zoomLevel.options[zoomLevel.selectedIndex].textContent.trim(); |
| 203 } |
| 204 |
| 205 return appearanceBrowserProxy.whenCalled('getDefaultZoom').then(function() { |
| 206 assertEquals('100%', getDefaultZoomText()); |
| 207 |
| 208 appearanceBrowserProxy.setDefaultZoom(2 / 3); |
| 209 createAppearancePage(); |
| 210 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); |
| 211 }).then(function() { |
| 212 assertEquals('67%', getDefaultZoomText()); |
| 213 |
| 214 appearanceBrowserProxy.setDefaultZoom(11 / 10); |
| 215 createAppearancePage(); |
| 216 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); |
| 217 }).then(function() { |
| 218 assertEquals('110%', getDefaultZoomText()); |
| 219 |
| 220 appearanceBrowserProxy.setDefaultZoom(1.7499999999999); |
| 221 createAppearancePage(); |
| 222 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); |
| 223 }).then(function() { |
| 224 assertEquals('175%', getDefaultZoomText()); |
| 225 }); |
| 226 }); |
| 178 }); | 227 }); |
| OLD | NEW |