| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 getSection: function(page, section) { | 68 getSection: function(page, section) { |
| 69 var sections = page.shadowRoot.querySelectorAll('settings-section'); | 69 var sections = page.shadowRoot.querySelectorAll('settings-section'); |
| 70 assertTrue(!!sections); | 70 assertTrue(!!sections); |
| 71 for (var i = 0; i < sections.length; ++i) { | 71 for (var i = 0; i < sections.length; ++i) { |
| 72 var s = sections[i]; | 72 var s = sections[i]; |
| 73 if (s.section == section) | 73 if (s.section == section) |
| 74 return s; | 74 return s; |
| 75 } | 75 } |
| 76 return undefined; | 76 return undefined; |
| 77 }, | 77 }, |
| 78 |
| 79 /** |
| 80 * Verifies the section has a visible #main element and that any possible |
| 81 * sub-pages are hidden. |
| 82 * @param {!Node} The DOM node for the section. |
| 83 */ |
| 84 verifySubpagesHidden: function(section) { |
| 85 // Check if there are sub-pages to verify. |
| 86 var pages = section.querySelector('* /deep/ settings-animated-pages'); |
| 87 if (!pages) |
| 88 return; |
| 89 |
| 90 var children = pages.getContentChildren(); |
| 91 var stampedChildren = children.filter(function(element) { |
| 92 return element.tagName != 'TEMPLATE'; |
| 93 }); |
| 94 |
| 95 // The section's main child should be stamped and visible. |
| 96 var main = stampedChildren.filter(function(element) { |
| 97 return element.id == 'main'; |
| 98 }); |
| 99 assertEquals(main.length, 1, '#main not found for section ' + |
| 100 section.section); |
| 101 assertGT(main[0].offsetHeight, 0); |
| 102 |
| 103 // Any other stamped subpages should not be visible. |
| 104 var subpages = stampedChildren.filter(function(element) { |
| 105 return element.id != 'main'; |
| 106 }); |
| 107 for (var subpage of subpages) { |
| 108 assertEquals(subpage.offsetHeight, 0, 'Expected subpage #' + subpage.id + |
| 109 ' in ' + section.section + ' not to be visible.'); |
| 110 } |
| 111 }, |
| 78 }; | 112 }; |
| OLD | NEW |