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 Suite of tests for the Settings basic page. */ | 5 /** @fileoverview Suite of tests for the Settings basic page. */ |
6 | 6 |
7 GEN_INCLUDE(['settings_page_browsertest.js']); | 7 GEN_INCLUDE(['settings_page_browsertest.js']); |
8 | 8 |
9 /** | 9 /** |
10 * @constructor | 10 * @constructor |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 for (var i = 0; i < sections.length; i++) { | 89 for (var i = 0; i < sections.length; i++) { |
90 var section = self.getSection(page, sections[i]); | 90 var section = self.getSection(page, sections[i]); |
91 expectTrue(!!section); | 91 expectTrue(!!section); |
92 self.verifySubpagesHidden(section); | 92 self.verifySubpagesHidden(section); |
93 } | 93 } |
94 }); | 94 }); |
95 | 95 |
96 test('scroll to section', function() { | 96 test('scroll to section', function() { |
97 var page = self.basicPage; | 97 var page = self.basicPage; |
98 // Setting the page and section will cause a scrollToSection_. | 98 // Setting the page and section will cause a scrollToSection_. |
99 settings.navigateTo(settings.Route.ON_STARTUP); | 99 settings.navigateTo(settings.routes.ON_STARTUP); |
100 | 100 |
101 return new Promise(function(resolve, reject) { | 101 return new Promise(function(resolve, reject) { |
102 // This test checks for a regression that occurred with scrollToSection_ | 102 // This test checks for a regression that occurred with scrollToSection_ |
103 // failing to find its host element. | 103 // failing to find its host element. |
104 var intervalId = window.setInterval(function() { | 104 var intervalId = window.setInterval(function() { |
105 if (self.getSection(page, settings.getCurrentRoute().section)) { | 105 if (self.getSection(page, settings.getCurrentRoute().section)) { |
106 window.clearInterval(intervalId); | 106 window.clearInterval(intervalId); |
107 resolve(); | 107 resolve(); |
108 } | 108 } |
109 }, 55); | 109 }, 55); |
(...skipping 17 matching lines...) Expand all Loading... |
127 // Should scroll when navigating forwards from the BASIC page. | 127 // Should scroll when navigating forwards from the BASIC page. |
128 assertNotEquals(0, page.scroller.scrollTop); | 128 assertNotEquals(0, page.scroller.scrollTop); |
129 }); | 129 }); |
130 }); | 130 }); |
131 | 131 |
132 test('scroll to section after exiting search', function() { | 132 test('scroll to section after exiting search', function() { |
133 var page = self.basicPage; | 133 var page = self.basicPage; |
134 var searchManager = new TestSearchManager(); | 134 var searchManager = new TestSearchManager(); |
135 settings.setSearchManagerForTesting(searchManager); | 135 settings.setSearchManagerForTesting(searchManager); |
136 | 136 |
137 settings.navigateTo(settings.Route.BASIC, | 137 settings.navigateTo(settings.routes.BASIC, |
138 new URLSearchParams(`search=foobar`), | 138 new URLSearchParams(`search=foobar`), |
139 /* removeSearch */ false); | 139 /* removeSearch */ false); |
140 return searchManager.whenCalled('search').then(function() { | 140 return searchManager.whenCalled('search').then(function() { |
141 return new Promise(function(resolve) { | 141 return new Promise(function(resolve) { |
142 settings.navigateTo(settings.Route.ON_STARTUP, | 142 settings.navigateTo(settings.routes.ON_STARTUP, |
143 /* dynamicParams */ null, | 143 /* dynamicParams */ null, |
144 /* removeSearch */ true); | 144 /* removeSearch */ true); |
145 | 145 |
146 assertTrue(!!page); | 146 assertTrue(!!page); |
147 | 147 |
148 // Should (after some time) be scrolled to the On Startup section. | 148 // Should (after some time) be scrolled to the On Startup section. |
149 var intervalId = window.setInterval(function() { | 149 var intervalId = window.setInterval(function() { |
150 if (page.scroller.scrollTop != 0) { | 150 if (page.scroller.scrollTop != 0) { |
151 window.clearInterval(intervalId); | 151 window.clearInterval(intervalId); |
152 resolve(); | 152 resolve(); |
153 } | 153 } |
154 }, 55); | 154 }, 55); |
155 }); | 155 }); |
156 }); | 156 }); |
157 }); | 157 }); |
158 | 158 |
159 test('scroll to top before navigating to about', function() { | 159 test('scroll to top before navigating to about', function() { |
160 var page = self.basicPage; | 160 var page = self.basicPage; |
161 // Set the viewport small to force the scrollbar to appear on ABOUT. | 161 // Set the viewport small to force the scrollbar to appear on ABOUT. |
162 Polymer.dom().querySelector('settings-ui').style.height = '200px'; | 162 Polymer.dom().querySelector('settings-ui').style.height = '200px'; |
163 | 163 |
164 settings.navigateTo(settings.Route.ON_STARTUP); | 164 settings.navigateTo(settings.routes.ON_STARTUP); |
165 assertNotEquals(0, page.scroller.scrollTop); | 165 assertNotEquals(0, page.scroller.scrollTop); |
166 | 166 |
167 settings.navigateTo(settings.Route.ABOUT); | 167 settings.navigateTo(settings.routes.ABOUT); |
168 assertEquals(0, page.scroller.scrollTop); | 168 assertEquals(0, page.scroller.scrollTop); |
169 }); | 169 }); |
170 }); | 170 }); |
171 | 171 |
172 // Run all registered tests. | 172 // Run all registered tests. |
173 mocha.run(); | 173 mocha.run(); |
174 }); | 174 }); |
OLD | NEW |