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 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 var sections = page.shadowRoot.querySelectorAll('settings-section'); | 67 var sections = page.shadowRoot.querySelectorAll('settings-section'); |
68 assertTrue(!!sections); | 68 assertTrue(!!sections); |
69 for (var i = 0; i < sections.length; ++i) { | 69 for (var i = 0; i < sections.length; ++i) { |
70 var s = sections[i]; | 70 var s = sections[i]; |
71 if (s.section == section) | 71 if (s.section == section) |
72 return s; | 72 return s; |
73 } | 73 } |
74 return undefined; | 74 return undefined; |
75 }, | 75 }, |
76 | 76 |
77 /** @return {!SettingsRouterElement} The <settings-router> for the page. */ | |
78 getRouter: function() { | |
79 var router = document.querySelector('cr-settings').$$('settings-ui') | |
80 .$$('settings-router'); | |
81 assert(!!router); | |
82 return router; | |
83 }, | |
84 | |
85 /** | |
86 * @return {boolean} True if the router's state is a root page, e.g. Basic. | |
87 */ | |
88 isAtRoot: function() { | |
89 var router = this.getRouter(); | |
90 return router.section == '' && router.subpage.length == 0; | |
91 }, | |
92 | |
93 /** Navigates to the current root page, e.g. Basic. */ | |
94 backToRoot: function() { | |
95 var router = document.querySelector('cr-settings').$$('settings-ui') | |
96 .$$('settings-router'); | |
97 router.currentRoute = { | |
98 page: router.currentRoute.page, | |
99 section: '', | |
100 subpage: [], | |
101 }; | |
102 }, | |
103 | |
104 /** | 77 /** |
105 * Verifies the section has a visible #main element and that any possible | 78 * Verifies the section has a visible #main element and that any possible |
106 * sub-pages are hidden. | 79 * sub-pages are hidden. |
107 * @param {!Node} The DOM node for the section. | 80 * @param {!Node} The DOM node for the section. |
108 */ | 81 */ |
109 verifySubpagesHidden: function(section) { | 82 verifySubpagesHidden: function(section) { |
110 // Check if there are sub-pages to verify. | 83 // Check if there are sub-pages to verify. |
111 var pages = section.querySelector('* /deep/ settings-animated-pages'); | 84 var pages = section.querySelector('* /deep/ settings-animated-pages'); |
112 if (!pages) | 85 if (!pages) |
113 return; | 86 return; |
(...skipping 14 matching lines...) Expand all Loading... |
128 // Any other stamped subpages should not be visible. | 101 // Any other stamped subpages should not be visible. |
129 var subpages = stampedChildren.filter(function(element) { | 102 var subpages = stampedChildren.filter(function(element) { |
130 return element.id != 'main'; | 103 return element.id != 'main'; |
131 }); | 104 }); |
132 for (var subpage of subpages) { | 105 for (var subpage of subpages) { |
133 assertEquals(subpage.offsetHeight, 0, 'Expected subpage #' + subpage.id + | 106 assertEquals(subpage.offsetHeight, 0, 'Expected subpage #' + subpage.id + |
134 ' in ' + section.section + ' not to be visible.'); | 107 ' in ' + section.section + ' not to be visible.'); |
135 } | 108 } |
136 }, | 109 }, |
137 }; | 110 }; |
OLD | NEW |