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

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

Issue 2210933004: Settings Router Refactor: Kill settings-router. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 cr.define('device_page_tests', function() { 5 cr.define('device_page_tests', function() {
6 /** @enum {string} */ 6 /** @enum {string} */
7 var TestNames = { 7 var TestNames = {
8 DevicePage: 'device page', 8 DevicePage: 'device page',
9 Display: 'display', 9 Display: 'display',
10 Keyboard: 'keyboard', 10 Keyboard: 'keyboard',
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 suite('SettingsDevicePage', function() { 135 suite('SettingsDevicePage', function() {
136 /** @type {!SettingsDevicePage|undefined} */ 136 /** @type {!SettingsDevicePage|undefined} */
137 var devicePage; 137 var devicePage;
138 138
139 /** @type {!FakeSystemDisplay|undefined} */ 139 /** @type {!FakeSystemDisplay|undefined} */
140 var fakeSystemDisplay; 140 var fakeSystemDisplay;
141 141
142 suiteSetup(function() { 142 suiteSetup(function() {
143 // Disable animations so sub-pages open within one event loop. 143 // Disable animations so sub-pages open within one event loop.
144 testing.Test.disableAnimationsAndTransitions(); 144 testing.Test.disableAnimationsAndTransitions();
145
146 // Update the device page route for navigations.
147 // TODO(tommycli): Remove once settings.navigateTo is no longer a stub.
148 settings.navigateTo = function(route) {
149 devicePage.currentRoute = route;
150 };
151 }); 145 });
152 146
153 setup(function(done) { 147 setup(function(done) {
154 fakeSystemDisplay = new settings.FakeSystemDisplay(); 148 fakeSystemDisplay = new settings.FakeSystemDisplay();
155 settings.display.systemDisplayApi = fakeSystemDisplay; 149 settings.display.systemDisplayApi = fakeSystemDisplay;
156 150
157 PolymerTest.clearBody(); 151 PolymerTest.clearBody();
158 devicePage = document.createElement('settings-device-page'); 152 devicePage = document.createElement('settings-device-page');
159 devicePage.currentRoute = settings.Route.BASIC;
160 devicePage.prefs = getFakePrefs(); 153 devicePage.prefs = getFakePrefs();
161 settings.DevicePageBrowserProxyImpl.instance_ = 154 settings.DevicePageBrowserProxyImpl.instance_ =
162 new TestDevicePageBrowserProxy(); 155 new TestDevicePageBrowserProxy();
163 156
164 // settings-animated-pages expects a parent with data-page set. 157 // settings-animated-pages expects a parent with data-page set.
165 var basicPage = document.createElement('div'); 158 var basicPage = document.createElement('div');
166 basicPage.dataset.page = 'basic'; 159 basicPage.dataset.page = 'basic';
167 basicPage.appendChild(devicePage); 160 basicPage.appendChild(devicePage);
168 document.body.appendChild(basicPage); 161 document.body.appendChild(basicPage);
169 162
170 // Allow the light DOM to be distributed to settings-animated-pages. 163 // Allow the light DOM to be distributed to settings-animated-pages.
171 setTimeout(done); 164 setTimeout(done);
172 }); 165 });
173 166
174 /** @return {!Promise<!HTMLElement>} */ 167 /** @return {!Promise<!HTMLElement>} */
175 function showAndGetDeviceSubpage(subpage) { 168 function showAndGetDeviceSubpage(subpage) {
176 return new Promise(function(resolve, reject) { 169 return new Promise(function(resolve, reject) {
177 var row = assert(devicePage.$$('#main #' + subpage + 'Row')); 170 var row = assert(devicePage.$$('#main #' + subpage + 'Row'));
178 devicePage.$.pages.addEventListener('neon-animation-finish', resolve); 171 devicePage.$.pages.addEventListener('neon-animation-finish', resolve);
179 MockInteractions.tap(row); 172 MockInteractions.tap(row);
180 }).then(function() { 173 }).then(function() {
181 assertEquals('device', devicePage.currentRoute.section); 174 assertEquals('device', settings.getCurrentRoute().section);
182 assertEquals(subpage, devicePage.currentRoute.subpage[0]); 175 assertEquals(subpage, settings.getCurrentRoute().subpage[0]);
183 var page = devicePage.$$('#' + subpage + ' settings-' + subpage); 176 var page = devicePage.$$('#' + subpage + ' settings-' + subpage);
184 return assert(page); 177 return assert(page);
185 }); 178 });
186 }; 179 };
187 180
188 /** 181 /**
189 * @param {!HTMLElement} pointersPage 182 * @param {!HTMLElement} pointersPage
190 * @param {Boolean} expected 183 * @param {Boolean} expected
191 */ 184 */
192 function expectNaturalScrollValue(pointersPage, expected) { 185 function expectNaturalScrollValue(pointersPage, expected) {
(...skipping 26 matching lines...) Expand all
219 suite(assert(TestNames.Pointers), function() { 212 suite(assert(TestNames.Pointers), function() {
220 var pointersPage; 213 var pointersPage;
221 214
222 setup(function() { 215 setup(function() {
223 return showAndGetDeviceSubpage('pointers').then(function(page) { 216 return showAndGetDeviceSubpage('pointers').then(function(page) {
224 pointersPage = page; 217 pointersPage = page;
225 }); 218 });
226 }); 219 });
227 220
228 test('subpage responds to pointer attach/detach', function() { 221 test('subpage responds to pointer attach/detach', function() {
229 assertEquals('pointers', devicePage.currentRoute.subpage[0]); 222 assertEquals('pointers', settings.getCurrentRoute().subpage[0]);
230 assertTrue(devicePage.currentRoute == settings.Route.POINTERS); 223 assertTrue(settings.getCurrentRoute() == settings.Route.POINTERS);
231 assertLT(0, pointersPage.$.mouse.offsetHeight); 224 assertLT(0, pointersPage.$.mouse.offsetHeight);
232 assertLT(0, pointersPage.$.touchpad.offsetHeight); 225 assertLT(0, pointersPage.$.touchpad.offsetHeight);
233 assertLT(0, pointersPage.$$('#mouse h2').offsetHeight); 226 assertLT(0, pointersPage.$$('#mouse h2').offsetHeight);
234 assertLT(0, pointersPage.$$('#touchpad h2').offsetHeight); 227 assertLT(0, pointersPage.$$('#touchpad h2').offsetHeight);
235 228
236 cr.webUIListenerCallback('has-touchpad-changed', false); 229 cr.webUIListenerCallback('has-touchpad-changed', false);
237 assertEquals('pointers', devicePage.currentRoute.subpage[0]); 230 assertEquals('pointers', settings.getCurrentRoute().subpage[0]);
238 assertLT(0, pointersPage.$.mouse.offsetHeight); 231 assertLT(0, pointersPage.$.mouse.offsetHeight);
239 assertEquals(0, pointersPage.$.touchpad.offsetHeight); 232 assertEquals(0, pointersPage.$.touchpad.offsetHeight);
240 assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight); 233 assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
241 assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight); 234 assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
242 235
243 // Wait for the transition back to the main page. 236 // Wait for the transition back to the main page.
244 return new Promise(function(resolve, reject) { 237 return new Promise(function(resolve, reject) {
245 devicePage.$.pages.addEventListener('neon-animation-finish', resolve); 238 devicePage.$.pages.addEventListener('neon-animation-finish', resolve);
246 239
247 cr.webUIListenerCallback('has-mouse-changed', false); 240 cr.webUIListenerCallback('has-mouse-changed', false);
248 }).then(function() { 241 }).then(function() {
249 assertEquals(0, devicePage.currentRoute.subpage.length); 242 assertEquals(0, settings.getCurrentRoute().subpage.length);
250 assertEquals(0, devicePage.$$('#main #pointersRow').offsetHeight); 243 assertEquals(0, devicePage.$$('#main #pointersRow').offsetHeight);
251 244
252 cr.webUIListenerCallback('has-touchpad-changed', true); 245 cr.webUIListenerCallback('has-touchpad-changed', true);
253 assertLT(0, devicePage.$$('#main #pointersRow').offsetHeight); 246 assertLT(0, devicePage.$$('#main #pointersRow').offsetHeight);
254 return showAndGetDeviceSubpage('pointers'); 247 return showAndGetDeviceSubpage('pointers');
255 }).then(function(page) { 248 }).then(function(page) {
256 assertEquals(0, pointersPage.$.mouse.offsetHeight); 249 assertEquals(0, pointersPage.$.mouse.offsetHeight);
257 assertLT(0, pointersPage.$.touchpad.offsetHeight); 250 assertLT(0, pointersPage.$.touchpad.offsetHeight);
258 assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight); 251 assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
259 assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight); 252 assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
260 253
261 cr.webUIListenerCallback('has-mouse-changed', true); 254 cr.webUIListenerCallback('has-mouse-changed', true);
262 assertEquals('pointers', devicePage.currentRoute.subpage[0]); 255 assertEquals('pointers', settings.getCurrentRoute().subpage[0]);
263 assertLT(0, pointersPage.$.mouse.offsetHeight); 256 assertLT(0, pointersPage.$.mouse.offsetHeight);
264 assertLT(0, pointersPage.$.touchpad.offsetHeight); 257 assertLT(0, pointersPage.$.touchpad.offsetHeight);
265 assertLT(0, pointersPage.$$('#mouse h2').offsetHeight); 258 assertLT(0, pointersPage.$$('#mouse h2').offsetHeight);
266 assertLT(0, pointersPage.$$('#touchpad h2').offsetHeight); 259 assertLT(0, pointersPage.$$('#touchpad h2').offsetHeight);
267 }); 260 });
268 }); 261 });
269 262
270 test('mouse', function() { 263 test('mouse', function() {
271 expectLT(0, pointersPage.$.mouse.offsetHeight); 264 expectLT(0, pointersPage.$.mouse.offsetHeight);
272 265
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 expectTrue(displayPage.showMirror_(displayPage.displays)); 511 expectTrue(displayPage.showMirror_(displayPage.displays));
519 expectTrue(displayPage.isMirrored_(displayPage.displays)); 512 expectTrue(displayPage.isMirrored_(displayPage.displays));
520 }); 513 });
521 }); 514 });
522 }); 515 });
523 516
524 return { 517 return {
525 TestNames: TestNames 518 TestNames: TestNames
526 }; 519 };
527 }); 520 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698