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_browsertest.js

Issue 1864713003: [MD settings] appearance browser tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup 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/chrome_tests.gypi ('k') | chrome/test/data/webui/settings/cr_settings_browsertest.js » ('j') | 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 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 /**
10 * Test Polymer Appearance Settings elements.
11 * @constructor
12 * @extends {SettingsPageBrowserTest}
13 */
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 /** 8 /**
33 * The prefs API that will get a fake implementation. 9 * A test version of FontsBrowserProxy.
34 * @type {!SettingsPrivate} 10 *
11 * @constructor
12 * @implements {settings.FontsBrowserProxy}
13 * @extends {settings.TestBrowserProxy}
35 */ 14 */
36 var settingsPrefs; 15 var TestFontsBrowserProxy = function() {
37 var self = this; 16 settings.TestBrowserProxy.call(this, [
38 17 'fetchFontsData',
39 var fontSize = function() { 18 ]);
40 return self.appearancePage(
41 '#defaultFontSize').$$('[class=iron-selected]').textContent.trim();
42 }; 19 };
43 20
44 suite('AppearanceHandler', function() { 21 TestFontsBrowserProxy.prototype = {
45 suiteSetup(function() { 22 __proto__: settings.TestBrowserProxy.prototype,
46 settingsPrefs = document.querySelector(
47 'cr-settings').$$('settings-prefs');
48 assertTrue(!!settingsPrefs);
49 return CrSettingsPrefs.initialized;
50 });
51 23
52 test('very small font', function() { 24 fontsData: {
dpapad 2016/04/06 17:14:55 Since fontsData is not a function, it makes more s
dschuyler 2016/04/07 20:47:42 Done.
53 settingsPrefs.set('prefs.webkit.webprefs.default_font_size.value', 9); 25 'fontList': [['font name', 'alternate', 'ltr']],
54 assertEquals('Very small', fontSize()); 26 'encodingList': [['encoding name', 'alternate', 'ltr']],
55 }); 27 },
56
57 test('large font', function() {
58 settingsPrefs.set('prefs.webkit.webprefs.default_font_size.value', 20);
59 assertEquals('Large', fontSize());
60 });
61 28
62 /** 29 /**
dpapad 2016/04/06 17:14:55 /** @override */
dschuyler 2016/04/07 20:47:42 Done.
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 */ 30 */
67 test('custom font size', function() { 31 fetchFontsData: function() {
68 settingsPrefs.set( 32 this.methodCalled('fetchFontsData');
69 'prefs.webkit.webprefs.default_font_size.value', 19); 33 return Promise.resolve(this.fontsData);
70 assertEquals('Custom', fontSize()); 34 },
35 };
36
37 function registerAppearanceFontSettingsBrowserTest() {
38 var fontsEntry = null;
dpapad 2016/04/06 17:14:55 Nit: s/fontsEntry/fontsPage or simply page?
dschuyler 2016/04/07 20:47:42 Done.
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 fontsEntry = document.createElement('settings-appearance-fonts-page');
51 document.body.appendChild(fontsEntry);
52 });
53
54 teardown(function() { fontsEntry.remove(); });
55
56 test('fetchFontsData', function() {
57 var fetchPromise = fontsBrowserProxy.whenCalled('fetchFontsData');
58 var responsePromise = fontsBrowserProxy.fetchFontsData().then(
dpapad 2016/04/06 17:14:55 |fetchPromise| tests that the actual production co
dschuyler 2016/04/07 20:47:42 Done.
59 function(response) {
60 assertGT(response.fontList.length, 0);
61 assertGT(response.encodingList.length, 0);
62 return true;
63 });
64 return Promise.all([fetchPromise, responsePromise]);
65 });
71 }); 66 });
72 }); 67 }
73 mocha.run(); 68
69 return {
70 registerTests: function() {
71 registerAppearanceFontSettingsBrowserTest();
72 },
73 };
74 }); 74 });
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/data/webui/settings/cr_settings_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698