Chromium Code Reviews| Index: chrome/test/data/webui/settings/appearance_browsertest.js |
| diff --git a/chrome/test/data/webui/settings/appearance_browsertest.js b/chrome/test/data/webui/settings/appearance_browsertest.js |
| index 3c3e17a34fee8d5c3ba76a202f894fc4d3b529f9..8050c00fa019d818a445bbc9fe8e556ece65d0c2 100644 |
| --- a/chrome/test/data/webui/settings/appearance_browsertest.js |
| +++ b/chrome/test/data/webui/settings/appearance_browsertest.js |
| @@ -2,73 +2,66 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -/** @fileoverview Runs Polymer Appearance Settings elements. */ |
| +/** @fileoverview Runs polymer appearance font settings elements. */ |
| -GEN_INCLUDE(['settings_page_browsertest.js']); |
| +cr.define('settings_appearance', function() { |
| + /** |
| + * A test version of FontsBrowserProxy. |
| + * |
| + * @constructor |
| + * @implements {settings.FontsBrowserProxy} |
| + * @extends {settings.TestBrowserProxy} |
| + */ |
| + var TestFontsBrowserProxy = function() { |
| + settings.TestBrowserProxy.call(this, [ |
| + 'fetchFontsData', |
| + ]); |
| -/** |
| - * Test Polymer Appearance Settings elements. |
| - * @constructor |
| - * @extends {SettingsPageBrowserTest} |
| -*/ |
| -function AppearanceSettingsBrowserTest() {} |
| + /** @private {!FontData} */ |
|
dpapad
2016/04/07 21:24:26
Typo? s/FontData/FontsData
dschuyler
2016/04/07 21:30:49
Done.
|
| + this.fontsData_ = { |
| + 'fontList': [['font name', 'alternate', 'ltr']], |
| + 'encodingList': [['encoding name', 'alternate', 'ltr']], |
| + }; |
| + }; |
| -AppearanceSettingsBrowserTest.prototype = { |
| - __proto__: SettingsPageBrowserTest.prototype, |
| + TestFontsBrowserProxy.prototype = { |
| + __proto__: settings.TestBrowserProxy.prototype, |
| - /** @return {string} */ |
| - appearancePage: function(selector) { |
| - var section = this.getSection(this.getPage('basic'), 'appearance'); |
| - assertTrue(!!section); |
| - var appearance = section.querySelector('settings-appearance-page'); |
| - assertTrue(!!appearance); |
| - var result = appearance.$$(selector); |
| - assertTrue(!!result); |
| - return result; |
| - }, |
| -}; |
| + /** @override */ |
| + fetchFontsData: function() { |
| + this.methodCalled('fetchFontsData'); |
| + return Promise.resolve(this.fontsData_); |
| + }, |
| + }; |
| -TEST_F('AppearanceSettingsBrowserTest', 'uiTests', function() { |
| - /** |
| - * The prefs API that will get a fake implementation. |
| - * @type {!SettingsPrivate} |
| - */ |
| - var settingsPrefs; |
| - var self = this; |
| + function registerAppearanceFontSettingsBrowserTest() { |
| + var fontsPage = null; |
| - var fontSize = function() { |
| - return self.appearancePage( |
| - '#defaultFontSize').$$('[class=iron-selected]').textContent.trim(); |
| - }; |
| + /** @type {?TestFontsBrowserProxy} */ |
| + var fontsBrowserProxy = null; |
| - suite('AppearanceHandler', function() { |
| - suiteSetup(function() { |
| - settingsPrefs = document.querySelector( |
| - 'cr-settings').$$('settings-prefs'); |
| - assertTrue(!!settingsPrefs); |
| - return CrSettingsPrefs.initialized; |
| - }); |
| + suite('AppearanceFontHandler', function() { |
| + setup(function() { |
| + fontsBrowserProxy = new TestFontsBrowserProxy(); |
| + settings.FontsBrowserProxyImpl.instance_ = fontsBrowserProxy; |
| - test('very small font', function() { |
| - settingsPrefs.set('prefs.webkit.webprefs.default_font_size.value', 9); |
| - assertEquals('Very small', fontSize()); |
| - }); |
| + PolymerTest.clearBody(); |
| - test('large font', function() { |
| - settingsPrefs.set('prefs.webkit.webprefs.default_font_size.value', 20); |
| - assertEquals('Large', fontSize()); |
| - }); |
| + fontsPage = document.createElement('settings-appearance-fonts-page'); |
| + document.body.appendChild(fontsPage); |
| + }); |
| - /** |
| - * If the font size is not one of the preset options (e.g. 16, 20, etc.) |
| - * then the menu label will be 'Custom' (rather than 'Medium', 'Large', |
| - * etc.). |
| - */ |
| - test('custom font size', function() { |
| - settingsPrefs.set( |
| - 'prefs.webkit.webprefs.default_font_size.value', 19); |
| - assertEquals('Custom', fontSize()); |
| + teardown(function() { fontsPage.remove(); }); |
| + |
| + test('fetchFontsData', function() { |
| + return fontsBrowserProxy.whenCalled('fetchFontsData'); |
| + }); |
| }); |
| - }); |
| - mocha.run(); |
| + } |
| + |
| + return { |
| + registerTests: function() { |
| + registerAppearanceFontSettingsBrowserTest(); |
| + }, |
| + }; |
| }); |