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

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

Issue 2413623004: MD Settings: allow changing to GTK+ theme on Linux (Closed)
Patch Set: rejigger tests Created 4 years, 2 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 /** @fileoverview Runs polymer appearance font settings elements. */ 5 /** @fileoverview Runs polymer appearance font settings elements. */
6 6
7 cr.define('settings_appearance', function() { 7 cr.define('settings_appearance', function() {
8 /** 8 /**
9 * A test version of AppearanceBrowserProxy. 9 * A test version of AppearanceBrowserProxy.
10 * 10 *
11 * @constructor 11 * @constructor
12 * @implements {settings.AppearanceBrowserProxy} 12 * @implements {settings.AppearanceBrowserProxy}
13 * @extends {settings.TestBrowserProxy} 13 * @extends {settings.TestBrowserProxy}
14 */ 14 */
15 var TestAppearanceBrowserProxy = function() { 15 var TestAppearanceBrowserProxy = function() {
16 settings.TestBrowserProxy.call(this, [ 16 settings.TestBrowserProxy.call(this, [
17 'getResetThemeEnabled', 17 'getThemeInfo',
18 'openWallpaperManager', 18 'openWallpaperManager',
19 'resetTheme', 19 'useDefaultTheme',
20 'useSystemTheme',
20 ]); 21 ]);
21
22 /**
23 * @type {boolean}
24 * @private
25 */
26 this.allowResetTheme_ = false;
27 }; 22 };
28 23
29 TestAppearanceBrowserProxy.prototype = { 24 TestAppearanceBrowserProxy.prototype = {
30 __proto__: settings.TestBrowserProxy.prototype, 25 __proto__: settings.TestBrowserProxy.prototype,
31 26
32 /** @override */ 27 /** @override */
33 getResetThemeEnabled: function() { 28 getThemeInfo: function(themeId) {
34 this.methodCalled('getResetThemeEnabled'); 29 this.methodCalled('getThemeInfo', themeId);
35 return Promise.resolve(this.allowResetTheme_); 30 return Promise.resolve({name: 'Sports car red'});
36 }, 31 },
37 32
38 /** @override */ 33 /** @override */
39 openWallpaperManager: function() { 34 openWallpaperManager: function() {
40 this.methodCalled('openWallpaperManager'); 35 this.methodCalled('openWallpaperManager');
41 }, 36 },
42 37
43 /** @override */ 38 /** @override */
44 resetTheme: function() { 39 useDefaultTheme: function() {
45 this.methodCalled('resetTheme'); 40 this.methodCalled('useDefaultTheme');
46 }, 41 },
47 42
48 /** 43 /** @override */
49 * @param {boolean} isEnabled Whether the user reset the theme. 44 useSystemTheme: function() {
50 */ 45 this.methodCalled('useSystemTheme');
51 setAllowResetTheme: function(isEnabled) { 46 },
52 this.allowResetTheme_ = isEnabled;
53 cr.webUIListenerCallback('reset-theme-enabled-changed', isEnabled);
54 Polymer.dom.flush();
55 }
56 }; 47 };
57 48
58 /** 49 /**
59 * A test version of FontsBrowserProxy. 50 * A test version of FontsBrowserProxy.
60 * 51 *
61 * @constructor 52 * @constructor
62 * @implements {settings.FontsBrowserProxy} 53 * @implements {settings.FontsBrowserProxy}
63 * @extends {settings.TestBrowserProxy} 54 * @extends {settings.TestBrowserProxy}
64 */ 55 */
65 var TestFontsBrowserProxy = function() { 56 var TestFontsBrowserProxy = function() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 var appearanceBrowserProxy = null; 94 var appearanceBrowserProxy = null;
104 95
105 suite('AppearanceHandler', function() { 96 suite('AppearanceHandler', function() {
106 setup(function() { 97 setup(function() {
107 appearanceBrowserProxy = new TestAppearanceBrowserProxy(); 98 appearanceBrowserProxy = new TestAppearanceBrowserProxy();
108 settings.AppearanceBrowserProxyImpl.instance_ = appearanceBrowserProxy; 99 settings.AppearanceBrowserProxyImpl.instance_ = appearanceBrowserProxy;
109 100
110 PolymerTest.clearBody(); 101 PolymerTest.clearBody();
111 102
112 appearancePage = document.createElement('settings-appearance-page'); 103 appearancePage = document.createElement('settings-appearance-page');
104 appearancePage.set('prefs', {
105 extensions: {
106 theme: {
107 id: {
108 value: 'asdf',
109 },
110 use_system: {
111 value: false,
112 },
113 },
114 },
115 });
113 document.body.appendChild(appearancePage); 116 document.body.appendChild(appearancePage);
117 Polymer.dom.flush();
114 }); 118 });
115 119
116 teardown(function() { appearancePage.remove(); }); 120 teardown(function() { appearancePage.remove(); });
117 121
118 if (cr.isChromeOS) { 122 if (cr.isChromeOS) {
119 test('wallpaperManager', function() { 123 test('wallpaperManager', function() {
120 var button = appearancePage.$.wallpaperButton; 124 var button = appearancePage.$.wallpaperButton;
121 assertTrue(!!button); 125 assertTrue(!!button);
122 MockInteractions.tap(button); 126 MockInteractions.tap(button);
123 return appearanceBrowserProxy.whenCalled('openWallpaperManager'); 127 return appearanceBrowserProxy.whenCalled('openWallpaperManager');
124 }); 128 });
125 } else { 129 } else {
126 test('noWallpaperManager', function() { 130 test('noWallpaperManager', function() {
127 // The wallpaper button should not be present. 131 // The wallpaper button should not be present.
128 var button = appearancePage.$.wallpaperButton; 132 var button = appearancePage.$.wallpaperButton;
129 assertFalse(!!button); 133 assertFalse(!!button);
130 }); 134 });
131 } 135 }
132 136
133 test('resetTheme', function() { 137 test('useDefaultTheme', function() {
134 appearanceBrowserProxy.setAllowResetTheme(true); 138 var button = appearancePage.$$('#useDefault');
135 var button = appearancePage.$$('#resetTheme');
136 assertTrue(!!button); 139 assertTrue(!!button);
137 MockInteractions.tap(button); 140 MockInteractions.tap(button);
138 return appearanceBrowserProxy.whenCalled('resetTheme'); 141 return appearanceBrowserProxy.whenCalled('useDefaultTheme');
139 }); 142 });
143
144 if (cr.isLinux && !cr.isChromeOS) {
145 test('useSystemTheme', function() {
146 Polymer.dom.flush();
147
148 var button = appearancePage.$$('#useSystem');
149 assertTrue(!!button);
150 MockInteractions.tap(button);
151 return appearanceBrowserProxy.whenCalled('useSystemTheme');
152 });
153 }
140 }); 154 });
141 } 155 }
142 156
143 function registerAppearanceFontSettingsBrowserTest() { 157 function registerAppearanceFontSettingsBrowserTest() {
144 var fontsPage = null; 158 var fontsPage = null;
145 159
146 /** @type {?TestFontsBrowserProxy} */ 160 /** @type {?TestFontsBrowserProxy} */
147 var fontsBrowserProxy = null; 161 var fontsBrowserProxy = null;
148 162
149 suite('AppearanceFontHandler', function() { 163 suite('AppearanceFontHandler', function() {
(...skipping 24 matching lines...) Expand all
174 }); 188 });
175 } 189 }
176 190
177 return { 191 return {
178 registerTests: function() { 192 registerTests: function() {
179 registerAppearanceFontSettingsBrowserTest(); 193 registerAppearanceFontSettingsBrowserTest();
180 registerAppearanceSettingsBrowserTest(); 194 registerAppearanceSettingsBrowserTest();
181 }, 195 },
182 }; 196 };
183 }); 197 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698