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

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