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

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

Issue 2754563002: MD Settings: Lazy load the contents of the "advanced" settings. (Closed)
Patch Set: Address comments. 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 /** @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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }, 79 },
80 }; 80 };
81 81
82 // Register mocha tests. 82 // Register mocha tests.
83 suite('SettingsPage', function() { 83 suite('SettingsPage', function() {
84 test('load page', function() { 84 test('load page', function() {
85 // This will fail if there are any asserts or errors in the Settings page. 85 // This will fail if there are any asserts or errors in the Settings page.
86 }); 86 });
87 87
88 test('basic pages', function() { 88 test('basic pages', function() {
89 var page = self.getPage('basic'); 89 var page = self.basicPage;
90 var sections = ['appearance', 'onStartup', 'people', 'search']; 90 var sections = ['appearance', 'onStartup', 'people', 'search'];
91 expectTrue(!!self.getSection(page, 'appearance')); 91 expectTrue(!!self.getSection(page, 'appearance'));
92 if (!cr.isChromeOS) 92 if (!cr.isChromeOS)
93 sections.push('defaultBrowser'); 93 sections.push('defaultBrowser');
94 else 94 else
95 sections = sections.concat(['internet', 'bluetooth', 'device']); 95 sections = sections.concat(['internet', 'bluetooth', 'device']);
96 96
97 for (var i = 0; i < sections.length; i++) { 97 for (var i = 0; i < sections.length; i++) {
98 var section = self.getSection(page, sections[i]); 98 var section = self.getSection(page, sections[i]);
99 expectTrue(!!section); 99 expectTrue(!!section);
100 self.verifySubpagesHidden(section); 100 self.verifySubpagesHidden(section);
101 } 101 }
102 }); 102 });
103 103
104 test('scroll to section', function() { 104 test('scroll to section', function() {
105 var page = self.basicPage;
105 // Setting the page and section will cause a scrollToSection_. 106 // Setting the page and section will cause a scrollToSection_.
106 settings.navigateTo(settings.Route.ON_STARTUP); 107 settings.navigateTo(settings.Route.ON_STARTUP);
107 108
108 var page = self.getPage('basic');
109
110 return new Promise(function(resolve, reject) { 109 return new Promise(function(resolve, reject) {
111 // This test checks for a regression that occurred with scrollToSection_ 110 // This test checks for a regression that occurred with scrollToSection_
112 // failing to find its host element. 111 // failing to find its host element.
113 var intervalId = window.setInterval(function() { 112 var intervalId = window.setInterval(function() {
114 var page = self.getPage('basic');
115 if (self.getSection(page, settings.getCurrentRoute().section)) { 113 if (self.getSection(page, settings.getCurrentRoute().section)) {
116 window.clearInterval(intervalId); 114 window.clearInterval(intervalId);
117 resolve(); 115 resolve();
118 } 116 }
119 }, 55); 117 }, 55);
120 }.bind(self)).then(function() { 118 }.bind(self)).then(function() {
121 // Should be scrolled to the On Startup section. 119 // Should be scrolled to the On Startup section.
122 assertNotEquals(0, page.scroller.scrollTop); 120 assertNotEquals(0, page.scroller.scrollTop);
123 121
124 return new Promise(function(resolve) { 122 return new Promise(function(resolve) {
125 listenOnce(window, 'popstate', resolve); 123 listenOnce(window, 'popstate', resolve);
126 settings.navigateToPreviousRoute(); 124 settings.navigateToPreviousRoute();
127 }); 125 });
128 }).then(function() { 126 }).then(function() {
129 // Should be at the top of the page after going Back from the section. 127 // Should be at the top of the page after going Back from the section.
130 assertEquals(0, page.scroller.scrollTop); 128 assertEquals(0, page.scroller.scrollTop);
131 129
132 return new Promise(function(resolve) { 130 return new Promise(function(resolve) {
133 listenOnce(window, 'popstate', resolve); 131 listenOnce(window, 'popstate', resolve);
134 window.history.forward(); 132 window.history.forward();
135 }); 133 });
136 }).then(function() { 134 }).then(function() {
137 // Should scroll when navigating forwards from the BASIC page. 135 // Should scroll when navigating forwards from the BASIC page.
138 assertNotEquals(0, page.scroller.scrollTop); 136 assertNotEquals(0, page.scroller.scrollTop);
139 }); 137 });
140 }); 138 });
141 139
142 test('scroll to section after exiting search', function() { 140 test('scroll to section after exiting search', function() {
141 var page = self.basicPage;
143 var searchManager = new TestSearchManager(); 142 var searchManager = new TestSearchManager();
144 settings.setSearchManagerForTesting(searchManager); 143 settings.setSearchManagerForTesting(searchManager);
145 144
146 settings.navigateTo(settings.Route.BASIC, 145 settings.navigateTo(settings.Route.BASIC,
147 new URLSearchParams(`search=foobar`), 146 new URLSearchParams(`search=foobar`),
148 /* removeSearch */ false); 147 /* removeSearch */ false);
149 return searchManager.whenCalled('search').then(function() { 148 return searchManager.whenCalled('search').then(function() {
150 return new Promise(function(resolve) { 149 return new Promise(function(resolve) {
151 settings.navigateTo(settings.Route.ON_STARTUP, 150 settings.navigateTo(settings.Route.ON_STARTUP,
152 /* dynamicParams */ null, 151 /* dynamicParams */ null,
153 /* removeSearch */ true); 152 /* removeSearch */ true);
154 153
155 var page = self.getPage('basic');
156 assertTrue(!!page); 154 assertTrue(!!page);
157 155
158 // Should (after some time) be scrolled to the On Startup section. 156 // Should (after some time) be scrolled to the On Startup section.
159 var intervalId = window.setInterval(function() { 157 var intervalId = window.setInterval(function() {
160 if (page.scroller.scrollTop != 0) { 158 if (page.scroller.scrollTop != 0) {
161 window.clearInterval(intervalId); 159 window.clearInterval(intervalId);
162 resolve(); 160 resolve();
163 } 161 }
164 }, 55); 162 }, 55);
165 }); 163 });
166 }); 164 });
167 }); 165 });
168 166
169 test('scroll to top before navigating to about', function() { 167 test('scroll to top before navigating to about', function() {
170 var page = self.getPage('basic'); 168 var page = self.basicPage;
171 // Set the viewport small to force the scrollbar to appear on ABOUT. 169 // Set the viewport small to force the scrollbar to appear on ABOUT.
172 Polymer.dom().querySelector('settings-ui').style.height = '200px'; 170 Polymer.dom().querySelector('settings-ui').style.height = '200px';
173 171
174 settings.navigateTo(settings.Route.ON_STARTUP); 172 settings.navigateTo(settings.Route.ON_STARTUP);
175 assertNotEquals(0, page.scroller.scrollTop); 173 assertNotEquals(0, page.scroller.scrollTop);
176 174
177 settings.navigateTo(settings.Route.ABOUT); 175 settings.navigateTo(settings.Route.ABOUT);
178 assertEquals(0, page.scroller.scrollTop); 176 assertEquals(0, page.scroller.scrollTop);
179 }); 177 });
180 }); 178 });
181 179
182 // Run all registered tests. 180 // Run all registered tests.
183 mocha.run(); 181 mocha.run();
184 }); 182 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698