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 'getThemeInfo', | 13 'getThemeInfo', |
| 13 'isSupervised', | 14 'isSupervised', |
| 14 'openWallpaperManager', | 15 'openWallpaperManager', |
| 15 'useDefaultTheme', | 16 'useDefaultTheme', |
| 16 'useSystemTheme', | 17 'useSystemTheme', |
| 17 ]); | 18 ]); |
| 18 }; | 19 }; |
| 19 | 20 |
| 20 TestAppearanceBrowserProxy.prototype = { | 21 TestAppearanceBrowserProxy.prototype = { |
| 21 __proto__: settings.TestBrowserProxy.prototype, | 22 __proto__: settings.TestBrowserProxy.prototype, |
| 22 | 23 |
| 23 /** @private */ | 24 /** @private */ |
| 25 defaultZoom_: 1, | |
|
dpapad
2016/11/10 02:38:34
Can me move this within the constructor instead? I
Dan Beam
2016/11/10 02:52:38
Done, but is this request based on a style rule or
dpapad
2016/11/10 17:57:46
Both. https://google.github.io/styleguide/javascri
Dan Beam
2016/11/10 18:54:36
interesting that the style guide calls this out ex
| |
| 26 | |
| 27 /** @private */ | |
| 24 isSupervised_: false, | 28 isSupervised_: false, |
| 25 | 29 |
| 26 /** @override */ | 30 /** @override */ |
| 31 getDefaultZoom: function() { | |
| 32 this.methodCalled('getDefaultZoom'); | |
| 33 return Promise.resolve(this.defaultZoom_); | |
| 34 }, | |
| 35 | |
| 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 PolymerTest.clearBody(); | |
| 81 | |
| 82 appearancePage = document.createElement('settings-appearance-page'); | |
|
dpapad
2016/11/10 02:38:34
Nit(optional): Would "appearancePage.prefs = " als
Dan Beam
2016/11/10 02:52:38
there's a few things I could do to attempt to simu
| |
| 83 appearancePage.set('prefs', { | |
| 84 extensions: { | |
| 85 theme: { | |
| 86 id: { | |
| 87 value: '', | |
| 88 }, | |
| 89 use_system: { | |
| 90 value: false, | |
| 91 }, | |
| 92 }, | |
| 93 }, | |
| 94 }); | |
| 95 | |
| 96 document.body.appendChild(appearancePage); | |
| 97 Polymer.dom.flush(); | |
| 98 } | |
| 99 | |
| 64 suite('AppearanceHandler', function() { | 100 suite('AppearanceHandler', function() { |
| 65 setup(function() { | 101 setup(function() { |
| 66 appearanceBrowserProxy = new TestAppearanceBrowserProxy(); | 102 appearanceBrowserProxy = new TestAppearanceBrowserProxy(); |
| 67 settings.AppearanceBrowserProxyImpl.instance_ = appearanceBrowserProxy; | 103 settings.AppearanceBrowserProxyImpl.instance_ = appearanceBrowserProxy; |
| 68 | 104 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 }); | 105 }); |
| 87 | 106 |
| 88 teardown(function() { appearancePage.remove(); }); | 107 teardown(function() { appearancePage.remove(); }); |
| 89 | 108 |
| 90 if (cr.isChromeOS) { | 109 if (cr.isChromeOS) { |
| 91 test('wallpaperManager', function() { | 110 test('wallpaperManager', function() { |
| 92 var button = appearancePage.$.wallpaperButton; | 111 var button = appearancePage.$.wallpaperButton; |
| 93 assertTrue(!!button); | 112 assertTrue(!!button); |
| 94 MockInteractions.tap(button); | 113 MockInteractions.tap(button); |
| 95 return appearanceBrowserProxy.whenCalled('openWallpaperManager'); | 114 return appearanceBrowserProxy.whenCalled('openWallpaperManager'); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 Polymer.dom.flush(); | 187 Polymer.dom.flush(); |
| 169 | 188 |
| 170 // With a custom theme installed, "RESET TO DEFAULT" should show. | 189 // With a custom theme installed, "RESET TO DEFAULT" should show. |
| 171 var button = appearancePage.$$('#useDefault'); | 190 var button = appearancePage.$$('#useDefault'); |
| 172 assertTrue(!!button); | 191 assertTrue(!!button); |
| 173 | 192 |
| 174 MockInteractions.tap(button); | 193 MockInteractions.tap(button); |
| 175 return appearanceBrowserProxy.whenCalled('useDefaultTheme'); | 194 return appearanceBrowserProxy.whenCalled('useDefaultTheme'); |
| 176 }); | 195 }); |
| 177 } | 196 } |
| 197 | |
| 198 test('default zoom handling', function() { | |
| 199 function getDefaultZoomText() { | |
| 200 var zoomLevel = appearancePage.$.zoomLevel; | |
| 201 return zoomLevel.options[zoomLevel.selectedIndex].textContent.trim(); | |
| 202 } | |
| 203 | |
| 204 return appearanceBrowserProxy.whenCalled('getDefaultZoom').then(function() { | |
| 205 assertEquals('100%', getDefaultZoomText()); | |
| 206 | |
| 207 appearanceBrowserProxy.setDefaultZoom(2 / 3); | |
| 208 appearanceBrowserProxy.reset(); | |
|
dpapad
2016/11/10 02:38:33
Perhaps move that call within createAppearancePage
Dan Beam
2016/11/10 02:52:38
Done.
| |
| 209 createAppearancePage(); | |
| 210 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); | |
| 211 }).then(function() { | |
| 212 assertEquals('67%', getDefaultZoomText()); | |
| 213 | |
| 214 appearanceBrowserProxy.setDefaultZoom(11 / 10); | |
| 215 appearanceBrowserProxy.reset(); | |
| 216 createAppearancePage(); | |
| 217 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); | |
| 218 }).then(function() { | |
| 219 assertEquals('110%', getDefaultZoomText()); | |
| 220 | |
| 221 appearanceBrowserProxy.setDefaultZoom(1.7499999999999); | |
| 222 appearanceBrowserProxy.reset(); | |
| 223 createAppearancePage(); | |
| 224 return appearanceBrowserProxy.whenCalled('getDefaultZoom'); | |
| 225 }).then(function() { | |
| 226 assertEquals('175%', getDefaultZoomText()); | |
| 227 }); | |
| 228 }); | |
| 178 }); | 229 }); |
| OLD | NEW |