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

Side by Side Diff: chrome/test/data/webui/settings/settings_subpage_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 /** 5 /**
6 * @fileoverview Suite of tests to ensure that settings subpages exist and 6 * @fileoverview Suite of tests to ensure that settings subpages exist and
7 * load without errors. Also outputs approximate load times for each subpage. 7 * load without errors. Also outputs approximate load times for each subpage.
8 */ 8 */
9 9
10 GEN_INCLUDE(['settings_page_browsertest.js']); 10 GEN_INCLUDE(['settings_page_browsertest.js']);
11 11
12 /** 12 /**
13 * @constructor 13 * @constructor
14 * @extends {SettingsPageBrowserTest} 14 * @extends {SettingsPageBrowserTest}
15 *
16 * @param {string} pageId Just 'basic'. TODO(michaelpg): Add 'about' if we want
17 * to, but that requires wrapping its sole <settings-section> in a dom-if.
18 */ 15 */
19 function SettingsSubPageBrowserTest(pageId) { 16 function SettingsSubPageBrowserTest() {
20 /** @type {string} */
21 this.pageId = pageId;
22
23 /** @type {!Array<string>} */ 17 /** @type {!Array<string>} */
24 this.subPages = []; 18 this.subPages = [];
25 } 19 }
26 20
27 SettingsSubPageBrowserTest.prototype = { 21 SettingsSubPageBrowserTest.prototype = {
28 __proto__: SettingsPageBrowserTest.prototype, 22 __proto__: SettingsPageBrowserTest.prototype,
29 23
30 /** @override */ 24 /** @override */
31 preLoad: function() { 25 preLoad: function() {
32 SettingsPageBrowserTest.prototype.preLoad.call(this); 26 SettingsPageBrowserTest.prototype.preLoad.call(this);
33 // This will cause all subpages to initially be hidden via dom-if. 27 // This will cause all subpages to initially be hidden via dom-if.
34 // This allows us to test loading each subpage independently without other 28 // This allows us to test loading each subpage independently without other
35 // subpages affecting load times, etc. 29 // subpages affecting load times, etc.
36 settingsHidePagesByDefaultForTest = true; 30 settingsHidePagesByDefaultForTest = true;
37 }, 31 },
38 32
39 /** @override */
40 setUp: function() {
41 SettingsPageBrowserTest.prototype.setUp.call(this);
42 this.verifySubPagesHidden_();
43 },
44
45 /* 33 /*
46 * Checks all subpages are hidden first. 34 * Checks all subpages are hidden first.
47 * @private 35 * @private
48 */ 36 */
49 verifySubPagesHidden_: function() { 37 verifySubPagesHidden_: function() {
50 var page = this.getPage(this.pageId); 38 var page = this.page;
51 assertEquals(0, Object.keys(page.pageVisibility).length); 39 assertEquals(0, Object.keys(page.pageVisibility).length);
52 40
53 // Ensure all pages are still hidden after the dom-ifs compute their |if|. 41 // Ensure all pages are still hidden after the dom-ifs compute their |if|.
54 Polymer.dom.flush(); 42 Polymer.dom.flush();
55 var sections = page.shadowRoot.querySelectorAll('settings-section'); 43 var sections = page.shadowRoot.querySelectorAll('settings-section');
56 assertTrue(!!sections); 44 assertTrue(!!sections);
57 assertEquals(0, sections.length); 45 assertEquals(0, sections.length);
58 }, 46 },
59 47
60 /** 48 /**
(...skipping 11 matching lines...) Expand all
72 Polymer.dom.flush(); 60 Polymer.dom.flush();
73 var dtime = window.performance.now() - startTime; 61 var dtime = window.performance.now() - startTime;
74 console.log('Page: ' + subPage + ' Load time: ' + dtime.toFixed(0) + ' ms'); 62 console.log('Page: ' + subPage + ' Load time: ' + dtime.toFixed(0) + ' ms');
75 assertTrue(!!this.getSection(page, subPage)); 63 assertTrue(!!this.getSection(page, subPage));
76 // Hide the page so that it doesn't interfere with other subPages. 64 // Hide the page so that it doesn't interfere with other subPages.
77 page.set('pageVisibility.' + subPage, false); 65 page.set('pageVisibility.' + subPage, false);
78 Polymer.dom.flush(); 66 Polymer.dom.flush();
79 }, 67 },
80 68
81 testSubPages: function() { 69 testSubPages: function() {
82 var page = this.getPage(this.pageId);
83 this.subPages.forEach(function(subPage) { 70 this.subPages.forEach(function(subPage) {
84 test(subPage, this.testSubPage.bind(this, page, subPage)); 71 test(subPage, function() {
72 this.verifySubPagesHidden_();
73 this.testSubPage.bind(this, this.page, subPage);
Dan Beam 2017/03/16 20:52:22 this is not the same. did you mean this.testSubP
dpapad 2017/03/17 00:08:09 Good catch. Yes, I meant what you wrote above. I'l
74 }.bind(this));
85 }.bind(this)); 75 }.bind(this));
86 }, 76 },
87 }; 77 };
88 78
89 /** @constructor @extends {SettingsSubPageBrowserTest} */ 79 /** @constructor @extends {SettingsSubPageBrowserTest} */
90 function SettingsBasicSubPageBrowserTest() { 80 function SettingsBasicSubPageBrowserTest() {
91 SettingsSubPageBrowserTest.call(this, 'basic'); 81 SettingsSubPageBrowserTest.call(this, 'basic');
92 82
93 /** @override */ 83 /** @override */
94 this.subPages = [ 84 this.subPages = [
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 setUp: function() { 130 setUp: function() {
141 this.toggleAdvanced(); 131 this.toggleAdvanced();
142 SettingsSubPageBrowserTest.prototype.setUp.call(this); 132 SettingsSubPageBrowserTest.prototype.setUp.call(this);
143 }, 133 },
144 }; 134 };
145 135
146 TEST_F('SettingsAdvancedSubPageBrowserTest', 'SubPages', function() { 136 TEST_F('SettingsAdvancedSubPageBrowserTest', 'SubPages', function() {
147 suite('Advanced', this.testSubPages.bind(this)); 137 suite('Advanced', this.testSubPages.bind(this));
148 mocha.run(); 138 mocha.run();
149 }); 139 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698