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

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

Issue 2198203002: MD Settings: Test for section expand/collapse navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@RefactorSettingsAnimatedPages
Patch Set: switch expect and actual Created 4 years, 4 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 assertTrue(!!settingsUi); 51 assertTrue(!!settingsUi);
52 var settingsMain = settingsUi.$$('settings-main'); 52 var settingsMain = settingsUi.$$('settings-main');
53 assertTrue(!!settingsMain); 53 assertTrue(!!settingsMain);
54 var pageType = 'settings-' + type + '-page'; 54 var pageType = 'settings-' + type + '-page';
55 var page = settingsMain.$$(pageType); 55 var page = settingsMain.$$(pageType);
56 assertTrue(!!page); 56 assertTrue(!!page);
57 return page; 57 return page;
58 }, 58 },
59 59
60 /** 60 /**
61 * @param {!PolymerElement} page The PolymerElement for the page containing 61 * @param {!MainPageBehavior} page The page containing the sections to return.
62 * |section|. 62 * @return {!Array<!SettingsSectionElement>} The page's <settings-section>s.
63 * @param {string} section The settings page section, e.g. 'appearance'.
64 * @return {Node|undefined} The DOM node for the section.
65 */ 63 */
66 getSection: function(page, section) { 64 getSections: function(page) {
67 var sections = page.shadowRoot.querySelectorAll('settings-section'); 65 return Array.from(page.shadowRoot.querySelectorAll('settings-section'));
68 assertTrue(!!sections); 66 },
69 for (var i = 0; i < sections.length; ++i) { 67
70 var s = sections[i]; 68 /**
71 if (s.section == section) 69 * @param {!MainPageBehavior} page The page containing |section|.
72 return s; 70 * @param {string} sectionId The settings page section, e.g. 'appearance'.
73 } 71 * @return {?SettingsSectionElement} The settings-section element, or null.
74 return undefined; 72 */
73 getSection: function(page, sectionId) {
74 return page.$$(`settings-section[section="${sectionId}"]`);
75 },
76
77 /*
78 * Returns all stamped subpages of a section. This excludes the main
79 * animatable (the default initial view of the closed section).
80 * @param {!SettingsSectionElement} section
81 * @return {!Map<string, !SettingsSubpageElement>} Map of subpages by id.
82 */
83 getSectionSubpages: function(section) {
84 var subpages = new Map();
85 var pages = section.querySelector('* /deep/ settings-animated-pages');
86 if (!pages)
87 return subpages;
88
89 pages.getContentChildren().forEach(function(element) {
90 if (element.tagName == 'SETTINGS-SUBPAGE')
91 subpages.set(element.id, element);
92 });
93 return subpages;
94 },
95
96 /*
97 * Returns the main animatable of a section (the default initial view of the
98 * closed section).
99 * @param {!SettingsSectionElement} section
100 * @return {?NeonAnimatableElement>}
101 */
102 getSectionMainAnimatable: function(section) {
103 var pages = section.querySelector('* /deep/ settings-animated-pages');
104 if (!pages)
105 return null;
106 return pages.querySelector('#main');
75 }, 107 },
76 108
77 /** 109 /**
78 * Verifies the section has a visible #main element and that any possible 110 * Verifies the section has a visible #main element and that any possible
79 * sub-pages are hidden. 111 * sub-pages are hidden.
80 * @param {!Node} The DOM node for the section. 112 * @param {!SettingsSectionElement} section
81 */ 113 */
82 verifySubpagesHidden: function(section) { 114 verifySubpagesHidden: function(section) {
83 // Check if there are sub-pages to verify. 115 // Check if there are sub-pages to verify.
84 var pages = section.querySelector('* /deep/ settings-animated-pages'); 116 var pages = section.querySelector('* /deep/ settings-animated-pages');
85 if (!pages) 117 if (!pages)
86 return; 118 return;
87 119
88 var children = pages.getContentChildren(); 120 var children = pages.getContentChildren();
89 var stampedChildren = children.filter(function(element) { 121 var stampedChildren = children.filter(function(element) {
90 return element.tagName != 'TEMPLATE'; 122 return element.tagName != 'TEMPLATE';
(...skipping 10 matching lines...) Expand all
101 // Any other stamped subpages should not be visible. 133 // Any other stamped subpages should not be visible.
102 var subpages = stampedChildren.filter(function(element) { 134 var subpages = stampedChildren.filter(function(element) {
103 return element.id != 'main'; 135 return element.id != 'main';
104 }); 136 });
105 for (var subpage of subpages) { 137 for (var subpage of subpages) {
106 assertEquals(subpage.offsetHeight, 0, 'Expected subpage #' + subpage.id + 138 assertEquals(subpage.offsetHeight, 0, 'Expected subpage #' + subpage.id +
107 ' in ' + section.section + ' not to be visible.'); 139 ' in ' + section.section + ' not to be visible.');
108 } 140 }
109 }, 141 },
110 }; 142 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698