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 /** @fileoverview Runs Polymer Appearance Settings elements. */ | 5 /** @fileoverview Runs polymer appearance font settings elements. */ |
| 6 | 6 |
| 7 GEN_INCLUDE(['settings_page_browsertest.js']); | 7 cr.define('settings_appearance', function() { |
| 8 /** | |
| 9 * A test version of FontsBrowserProxy. | |
| 10 * | |
| 11 * @constructor | |
| 12 * @implements {settings.FontsBrowserProxy} | |
| 13 * @extends {settings.TestBrowserProxy} | |
| 14 */ | |
| 15 var TestFontsBrowserProxy = function() { | |
| 16 settings.TestBrowserProxy.call(this, [ | |
| 17 'fetchFontsData', | |
| 18 ]); | |
| 8 | 19 |
| 9 /** | 20 /** @private {!FontData} */ |
|
dpapad
2016/04/07 21:24:26
Typo? s/FontData/FontsData
dschuyler
2016/04/07 21:30:49
Done.
| |
| 10 * Test Polymer Appearance Settings elements. | 21 this.fontsData_ = { |
| 11 * @constructor | 22 'fontList': [['font name', 'alternate', 'ltr']], |
| 12 * @extends {SettingsPageBrowserTest} | 23 'encodingList': [['encoding name', 'alternate', 'ltr']], |
| 13 */ | 24 }; |
| 14 function AppearanceSettingsBrowserTest() {} | |
| 15 | |
| 16 AppearanceSettingsBrowserTest.prototype = { | |
| 17 __proto__: SettingsPageBrowserTest.prototype, | |
| 18 | |
| 19 /** @return {string} */ | |
| 20 appearancePage: function(selector) { | |
| 21 var section = this.getSection(this.getPage('basic'), 'appearance'); | |
| 22 assertTrue(!!section); | |
| 23 var appearance = section.querySelector('settings-appearance-page'); | |
| 24 assertTrue(!!appearance); | |
| 25 var result = appearance.$$(selector); | |
| 26 assertTrue(!!result); | |
| 27 return result; | |
| 28 }, | |
| 29 }; | |
| 30 | |
| 31 TEST_F('AppearanceSettingsBrowserTest', 'uiTests', function() { | |
| 32 /** | |
| 33 * The prefs API that will get a fake implementation. | |
| 34 * @type {!SettingsPrivate} | |
| 35 */ | |
| 36 var settingsPrefs; | |
| 37 var self = this; | |
| 38 | |
| 39 var fontSize = function() { | |
| 40 return self.appearancePage( | |
| 41 '#defaultFontSize').$$('[class=iron-selected]').textContent.trim(); | |
| 42 }; | 25 }; |
| 43 | 26 |
| 44 suite('AppearanceHandler', function() { | 27 TestFontsBrowserProxy.prototype = { |
| 45 suiteSetup(function() { | 28 __proto__: settings.TestBrowserProxy.prototype, |
| 46 settingsPrefs = document.querySelector( | 29 |
| 47 'cr-settings').$$('settings-prefs'); | 30 /** @override */ |
| 48 assertTrue(!!settingsPrefs); | 31 fetchFontsData: function() { |
| 49 return CrSettingsPrefs.initialized; | 32 this.methodCalled('fetchFontsData'); |
| 33 return Promise.resolve(this.fontsData_); | |
| 34 }, | |
| 35 }; | |
| 36 | |
| 37 function registerAppearanceFontSettingsBrowserTest() { | |
| 38 var fontsPage = null; | |
| 39 | |
| 40 /** @type {?TestFontsBrowserProxy} */ | |
| 41 var fontsBrowserProxy = null; | |
| 42 | |
| 43 suite('AppearanceFontHandler', function() { | |
| 44 setup(function() { | |
| 45 fontsBrowserProxy = new TestFontsBrowserProxy(); | |
| 46 settings.FontsBrowserProxyImpl.instance_ = fontsBrowserProxy; | |
| 47 | |
| 48 PolymerTest.clearBody(); | |
| 49 | |
| 50 fontsPage = document.createElement('settings-appearance-fonts-page'); | |
| 51 document.body.appendChild(fontsPage); | |
| 52 }); | |
| 53 | |
| 54 teardown(function() { fontsPage.remove(); }); | |
| 55 | |
| 56 test('fetchFontsData', function() { | |
| 57 return fontsBrowserProxy.whenCalled('fetchFontsData'); | |
| 58 }); | |
| 50 }); | 59 }); |
| 60 } | |
| 51 | 61 |
| 52 test('very small font', function() { | 62 return { |
| 53 settingsPrefs.set('prefs.webkit.webprefs.default_font_size.value', 9); | 63 registerTests: function() { |
| 54 assertEquals('Very small', fontSize()); | 64 registerAppearanceFontSettingsBrowserTest(); |
| 55 }); | 65 }, |
| 56 | 66 }; |
| 57 test('large font', function() { | |
| 58 settingsPrefs.set('prefs.webkit.webprefs.default_font_size.value', 20); | |
| 59 assertEquals('Large', fontSize()); | |
| 60 }); | |
| 61 | |
| 62 /** | |
| 63 * If the font size is not one of the preset options (e.g. 16, 20, etc.) | |
| 64 * then the menu label will be 'Custom' (rather than 'Medium', 'Large', | |
| 65 * etc.). | |
| 66 */ | |
| 67 test('custom font size', function() { | |
| 68 settingsPrefs.set( | |
| 69 'prefs.webkit.webprefs.default_font_size.value', 19); | |
| 70 assertEquals('Custom', fontSize()); | |
| 71 }); | |
| 72 }); | |
| 73 mocha.run(); | |
| 74 }); | 67 }); |
| OLD | NEW |