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

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

Issue 1896283003: [MD settings] appearance theme and wallpaper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 8 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
« no previous file with comments | « chrome/browser/ui/webui/settings/appearance_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
10 *
11 * @constructor
12 * @implements {settings.AppearanceBrowserProxy}
13 * @extends {settings.TestBrowserProxy}
14 */
15 var TestAppearanceBrowserProxy = function() {
16 settings.TestBrowserProxy.call(this, [
17 'getResetThemeEnabled',
18 'openWallpaperManager',
19 'resetTheme',
20 ]);
21
22 /** @type {boolean} */
dpapad 2016/04/20 19:23:08 @private
23 this.allowResetTheme_ = false;
24 };
25
26 TestAppearanceBrowserProxy.prototype = {
27 __proto__: settings.TestBrowserProxy.prototype,
28
29 /** @override */
30 getResetThemeEnabled: function() {
31 this.methodCalled('getResetThemeEnabled');
32 return Promise.resolve(this.allowResetTheme_);
33 },
34
35 /** @override */
36 openWallpaperManager: function() {
37 this.methodCalled('openWallpaperManager');
38 },
39
40 /** @override */
41 resetTheme: function() {
42 this.methodCalled('resetTheme');
43 },
44
45 /**
46 * @param {boolean} isEnabled Whether the user reset the theme.
47 */
48 setAllowResetTheme: function(isEnabled) {
49 this.allowResetTheme_ = isEnabled;
50 cr.webUIListenerCallback('reset-theme-enabled-changed', isEnabled);
51 Polymer.dom.flush();
52 }
53 };
54
55 /**
9 * A test version of FontsBrowserProxy. 56 * A test version of FontsBrowserProxy.
10 * 57 *
11 * @constructor 58 * @constructor
12 * @implements {settings.FontsBrowserProxy} 59 * @implements {settings.FontsBrowserProxy}
13 * @extends {settings.TestBrowserProxy} 60 * @extends {settings.TestBrowserProxy}
14 */ 61 */
15 var TestFontsBrowserProxy = function() { 62 var TestFontsBrowserProxy = function() {
16 settings.TestBrowserProxy.call(this, [ 63 settings.TestBrowserProxy.call(this, [
17 'fetchFontsData', 64 'fetchFontsData',
18 'observeAdvancedFontExtensionAvailable', 65 'observeAdvancedFontExtensionAvailable',
66 'openAdvancedFontSettings',
19 ]); 67 ]);
20 68
21 /** @private {!FontsData} */ 69 /** @private {!FontsData} */
22 this.fontsData_ = { 70 this.fontsData_ = {
23 'fontList': [['font name', 'alternate', 'ltr']], 71 'fontList': [['font name', 'alternate', 'ltr']],
24 'encodingList': [['encoding name', 'alternate', 'ltr']], 72 'encodingList': [['encoding name', 'alternate', 'ltr']],
25 }; 73 };
26 }; 74 };
27 75
28 TestFontsBrowserProxy.prototype = { 76 TestFontsBrowserProxy.prototype = {
29 __proto__: settings.TestBrowserProxy.prototype, 77 __proto__: settings.TestBrowserProxy.prototype,
30 78
31 /** @override */ 79 /** @override */
32 fetchFontsData: function() { 80 fetchFontsData: function() {
33 this.methodCalled('fetchFontsData'); 81 this.methodCalled('fetchFontsData');
34 return Promise.resolve(this.fontsData_); 82 return Promise.resolve(this.fontsData_);
35 }, 83 },
36 84
37 /** @override */ 85 /** @override */
38 observeAdvancedFontExtensionAvailable: function() { 86 observeAdvancedFontExtensionAvailable: function() {
39 this.methodCalled('observeAdvancedFontExtensionAvailable'); 87 this.methodCalled('observeAdvancedFontExtensionAvailable');
40 }, 88 },
89
90 /** @override */
91 openAdvancedFontSettings: function() {
92 this.methodCalled('openAdvancedFontSettings');
93 },
41 }; 94 };
42 95
96 function registerAppearanceSettingsBrowserTest() {
97 var appearancePage = null;
98
99 /** @type {?TestAppearanceBrowserProxy} */
100 var appearanceBrowserProxy = null;
101
102 suite('AppearanceHandler', function() {
103 setup(function() {
104 appearanceBrowserProxy = new TestAppearanceBrowserProxy();
105 settings.AppearanceBrowserProxyImpl.instance_ = appearanceBrowserProxy;
106
107 PolymerTest.clearBody();
108
109 appearancePage = document.createElement('settings-appearance-page');
110 document.body.appendChild(appearancePage);
111 });
112
113 teardown(function() { appearancePage.remove(); });
114
115 if (cr.isChromeOS) {
116 test('wallpaperManager', function() {
117 var button = appearancePage.$.wallpaperButton;
118 assertTrue(!!button);
119 MockInteractions.tap(button);
120 return appearanceBrowserProxy.whenCalled('openWallpaperManager');
121 });
122 } else {
123 test('noWallpaperManager', function() {
124 // The wallpaper button should not be present.
125 var button = appearancePage.$.wallpaperButton;
126 assertFalse(!!button);
127 });
128 }
129
130 test('resetTheme', function() {
131 appearanceBrowserProxy.setAllowResetTheme(true);
132 var button = appearancePage.$$('#resetTheme');
133 assertTrue(!!button);
134 MockInteractions.tap(button);
135 return appearanceBrowserProxy.whenCalled('resetTheme');
136 });
137 });
138 }
139
43 function registerAppearanceFontSettingsBrowserTest() { 140 function registerAppearanceFontSettingsBrowserTest() {
44 var fontsPage = null; 141 var fontsPage = null;
45 142
46 /** @type {?TestFontsBrowserProxy} */ 143 /** @type {?TestFontsBrowserProxy} */
47 var fontsBrowserProxy = null; 144 var fontsBrowserProxy = null;
48 145
49 suite('AppearanceFontHandler', function() { 146 suite('AppearanceFontHandler', function() {
50 setup(function() { 147 setup(function() {
51 fontsBrowserProxy = new TestFontsBrowserProxy(); 148 fontsBrowserProxy = new TestFontsBrowserProxy();
52 settings.FontsBrowserProxyImpl.instance_ = fontsBrowserProxy; 149 settings.FontsBrowserProxyImpl.instance_ = fontsBrowserProxy;
53 150
54 PolymerTest.clearBody(); 151 PolymerTest.clearBody();
55 152
56 fontsPage = document.createElement('settings-appearance-fonts-page'); 153 fontsPage = document.createElement('settings-appearance-fonts-page');
57 document.body.appendChild(fontsPage); 154 document.body.appendChild(fontsPage);
58 }); 155 });
59 156
60 teardown(function() { fontsPage.remove(); }); 157 teardown(function() { fontsPage.remove(); });
61 158
62 test('fetchFontsData', function() { 159 test('fetchFontsData', function() {
63 return fontsBrowserProxy.whenCalled('fetchFontsData'); 160 return fontsBrowserProxy.whenCalled('fetchFontsData');
64 }); 161 });
162
163 test('openAdvancedFontSettings', function() {
164 cr.webUIListenerCallback('advanced-font-settings-installed', [true]);
165 Polymer.dom.flush();
166 var button = fontsPage.$$('#advancedButton');
167 assert(!!button);
168 MockInteractions.tap(button);
169 return fontsBrowserProxy.whenCalled('openAdvancedFontSettings');
170 });
65 }); 171 });
66 } 172 }
67 173
68 return { 174 return {
69 registerTests: function() { 175 registerTests: function() {
70 registerAppearanceFontSettingsBrowserTest(); 176 registerAppearanceFontSettingsBrowserTest();
177 registerAppearanceSettingsBrowserTest();
71 }, 178 },
72 }; 179 };
73 }); 180 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/appearance_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698