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

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

Issue 2754563002: MD Settings: Lazy load the contents of the "advanced" settings. (Closed)
Patch Set: Simplify, remove unnecessary file. Created 3 years, 9 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
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 Prototype for Settings page tests. */ 5 /** @fileoverview Prototype for Settings page tests. */
6 6
7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */
8 var ROOT_PATH = '../../../../../'; 8 var ROOT_PATH = '../../../../../';
9 9
10 // Polymer BrowserTest fixture. 10 // Polymer BrowserTest fixture.
(...skipping 14 matching lines...) Expand all
25 25
26 /** @override */ 26 /** @override */
27 extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([ 27 extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([
28 '../fake_chrome_event.js', 28 '../fake_chrome_event.js',
29 'fake_settings_private.js', 29 'fake_settings_private.js',
30 ]), 30 ]),
31 31
32 /** @override */ 32 /** @override */
33 runAccessibilityChecks: false, 33 runAccessibilityChecks: false,
34 34
35 /** @type {?SettingsBasicPageElement} */
36 page: null,
37
35 /** @override */ 38 /** @override */
36 setUp: function() { 39 setUp: function() {
37 PolymerTest.prototype.setUp.call(this); 40 PolymerTest.prototype.setUp.call(this);
38 suiteSetup(function() { 41 suiteSetup(function() {
39 return CrSettingsPrefs.initialized; 42 return CrSettingsPrefs.initialized;
40 }); 43 });
44
45 suiteSetup(function() {
46 return this.getPage('basic').then(function(basicPage) {
47 this.page = basicPage;
48 }.bind(this));
49 }.bind(this));
41 }, 50 },
42 51
43 /** 52 /**
44 * Toggles the Advanced sections. 53 * Toggles the Advanced sections.
45 */ 54 */
46 toggleAdvanced: function() { 55 toggleAdvanced: function() {
47 var settingsMain = document.querySelector('* /deep/ settings-main'); 56 var settingsMain = document.querySelector('* /deep/ settings-main');
48 assert(!!settingsMain); 57 assert(!!settingsMain);
49 settingsMain.advancedToggleExpanded = !settingsMain.advancedToggleExpanded; 58 settingsMain.advancedToggleExpanded = !settingsMain.advancedToggleExpanded;
50 Polymer.dom.flush(); 59 Polymer.dom.flush();
51 }, 60 },
52 61
53 /** 62 /**
54 * @param {string} type The settings page type, e.g. 'about' or 'basic'. 63 * @param {string} type The settings page type, e.g. 'about' or 'basic'.
55 * @return {!PolymerElement} The PolymerElement for the page. 64 * @return {!PolymerElement} The PolymerElement for the page.
Dan Beam 2017/03/16 20:52:22 !Promise<!PolymerElement>
56 */ 65 */
57 getPage: function(type) { 66 getPage: function(type) {
58 var settingsUi = document.querySelector('settings-ui'); 67 var settingsUi = document.querySelector('settings-ui');
59 assertTrue(!!settingsUi); 68 assertTrue(!!settingsUi);
60 var settingsMain = settingsUi.$$('settings-main'); 69 var settingsMain = settingsUi.$$('settings-main');
61 assertTrue(!!settingsMain); 70 assertTrue(!!settingsMain);
62 var pageType = 'settings-' + type + '-page'; 71 var pageType = 'settings-' + type + '-page';
63 var page = settingsMain.$$(pageType); 72 var page = settingsMain.$$(pageType);
64 assertTrue(!!page); 73 assertTrue(!!page);
65 var idleRender = page.$$('template[is=settings-idle-render]'); 74
66 if (idleRender) { 75 var idleRender = page.$$('template[is=settings-idle-load]');
67 idleRender.get(); 76 if (!idleRender)
68 Polymer.dom.flush(); 77 return Promise.resolve(page);
69 } 78
70 return page; 79 return idleRender.get().then(function() {
80 return page;
81 });
71 }, 82 },
72 83
73 /** 84 /**
74 * @param {!PolymerElement} page The PolymerElement for the page containing 85 * @param {!PolymerElement} page The PolymerElement for the page containing
75 * |section|. 86 * |section|.
76 * @param {string} section The settings page section, e.g. 'appearance'. 87 * @param {string} section The settings page section, e.g. 'appearance'.
77 * @return {Node|undefined} The DOM node for the section. 88 * @return {Node|undefined} The DOM node for the section.
78 */ 89 */
79 getSection: function(page, section) { 90 getSection: function(page, section) {
80 var sections = page.shadowRoot.querySelectorAll('settings-section'); 91 var sections = page.shadowRoot.querySelectorAll('settings-section');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // Any other stamped subpages should not be visible. 125 // Any other stamped subpages should not be visible.
115 var subpages = stampedChildren.filter(function(element) { 126 var subpages = stampedChildren.filter(function(element) {
116 return element.getAttribute('route-path') != 'default'; 127 return element.getAttribute('route-path') != 'default';
117 }); 128 });
118 for (var subpage of subpages) { 129 for (var subpage of subpages) {
119 assertEquals(subpage.offsetHeight, 0, 'Expected subpage #' + subpage.id + 130 assertEquals(subpage.offsetHeight, 0, 'Expected subpage #' + subpage.id +
120 ' in ' + section.section + ' not to be visible.'); 131 ' in ' + section.section + ' not to be visible.');
121 } 132 }
122 }, 133 },
123 }; 134 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698