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

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

Issue 2957153003: MD Settings: remove unsupported routes from guest-mode. (Closed)
Patch Set: fix tests Created 3 years, 5 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 suiteSetup(function() { 239 suiteSetup(function() {
240 // Disable animations so sub-pages open within one event loop. 240 // Disable animations so sub-pages open within one event loop.
241 testing.Test.disableAnimationsAndTransitions(); 241 testing.Test.disableAnimationsAndTransitions();
242 }); 242 });
243 243
244 setup(function(done) { 244 setup(function(done) {
245 fakeSystemDisplay = new settings.FakeSystemDisplay(); 245 fakeSystemDisplay = new settings.FakeSystemDisplay();
246 settings.display.systemDisplayApi = fakeSystemDisplay; 246 settings.display.systemDisplayApi = fakeSystemDisplay;
247 247
248 PolymerTest.clearBody(); 248 PolymerTest.clearBody();
249 settings.navigateTo(settings.Route.BASIC); 249 settings.navigateTo(settings.routes.BASIC);
250 250
251 devicePage = document.createElement('settings-device-page'); 251 devicePage = document.createElement('settings-device-page');
252 devicePage.prefs = getFakePrefs(); 252 devicePage.prefs = getFakePrefs();
253 settings.DevicePageBrowserProxyImpl.instance_ = 253 settings.DevicePageBrowserProxyImpl.instance_ =
254 new TestDevicePageBrowserProxy(); 254 new TestDevicePageBrowserProxy();
255 255
256 // settings-animated-pages expects a parent with data-page set. 256 // settings-animated-pages expects a parent with data-page set.
257 var basicPage = document.createElement('div'); 257 var basicPage = document.createElement('div');
258 basicPage.dataset.page = 'basic'; 258 basicPage.dataset.page = 'basic';
259 basicPage.appendChild(devicePage); 259 basicPage.appendChild(devicePage);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 expectEquals(0, devicePage.$$('#pointersRow').offsetHeight); 338 expectEquals(0, devicePage.$$('#pointersRow').offsetHeight);
339 cr.webUIListenerCallback('has-mouse-changed', true); 339 cr.webUIListenerCallback('has-mouse-changed', true);
340 expectLT(0, devicePage.$$('#pointersRow').offsetHeight); 340 expectLT(0, devicePage.$$('#pointersRow').offsetHeight);
341 }); 341 });
342 342
343 suite(assert(TestNames.Pointers), function() { 343 suite(assert(TestNames.Pointers), function() {
344 var pointersPage; 344 var pointersPage;
345 345
346 setup(function() { 346 setup(function() {
347 return showAndGetDeviceSubpage( 347 return showAndGetDeviceSubpage(
348 'pointers', settings.Route.POINTERS).then(function(page) { 348 'pointers', settings.routes.POINTERS).then(function(page) {
349 pointersPage = page; 349 pointersPage = page;
350 }); 350 });
351 }); 351 });
352 352
353 test('subpage responds to pointer attach/detach', function() { 353 test('subpage responds to pointer attach/detach', function() {
354 assertEquals(settings.Route.POINTERS, settings.getCurrentRoute()); 354 assertEquals(settings.routes.POINTERS, settings.getCurrentRoute());
355 assertLT(0, pointersPage.$$('#mouse').offsetHeight); 355 assertLT(0, pointersPage.$$('#mouse').offsetHeight);
356 assertLT(0, pointersPage.$$('#touchpad').offsetHeight); 356 assertLT(0, pointersPage.$$('#touchpad').offsetHeight);
357 assertLT(0, pointersPage.$$('#mouse h2').offsetHeight); 357 assertLT(0, pointersPage.$$('#mouse h2').offsetHeight);
358 assertLT(0, pointersPage.$$('#touchpad h2').offsetHeight); 358 assertLT(0, pointersPage.$$('#touchpad h2').offsetHeight);
359 359
360 cr.webUIListenerCallback('has-touchpad-changed', false); 360 cr.webUIListenerCallback('has-touchpad-changed', false);
361 assertEquals(settings.Route.POINTERS, settings.getCurrentRoute()); 361 assertEquals(settings.routes.POINTERS, settings.getCurrentRoute());
362 assertLT(0, pointersPage.$$('#mouse').offsetHeight); 362 assertLT(0, pointersPage.$$('#mouse').offsetHeight);
363 assertEquals(0, pointersPage.$$('#touchpad').offsetHeight); 363 assertEquals(0, pointersPage.$$('#touchpad').offsetHeight);
364 assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight); 364 assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
365 assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight); 365 assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
366 366
367 // Wait for the transition back to the main page. 367 // Wait for the transition back to the main page.
368 return new Promise(function(resolve, reject) { 368 return new Promise(function(resolve, reject) {
369 devicePage.$$('#pages').addEventListener( 369 devicePage.$$('#pages').addEventListener(
370 'neon-animation-finish', resolve); 370 'neon-animation-finish', resolve);
371 371
372 cr.webUIListenerCallback('has-mouse-changed', false); 372 cr.webUIListenerCallback('has-mouse-changed', false);
373 }).then(function() { 373 }).then(function() {
374 assertEquals(settings.Route.DEVICE, settings.getCurrentRoute()); 374 assertEquals(settings.routes.DEVICE, settings.getCurrentRoute());
375 assertEquals(0, devicePage.$$('#main #pointersRow').offsetHeight); 375 assertEquals(0, devicePage.$$('#main #pointersRow').offsetHeight);
376 376
377 cr.webUIListenerCallback('has-touchpad-changed', true); 377 cr.webUIListenerCallback('has-touchpad-changed', true);
378 assertLT(0, devicePage.$$('#main #pointersRow').offsetHeight); 378 assertLT(0, devicePage.$$('#main #pointersRow').offsetHeight);
379 return showAndGetDeviceSubpage('pointers', settings.Route.POINTERS); 379 return showAndGetDeviceSubpage('pointers', settings.routes.POINTERS);
380 }).then(function(page) { 380 }).then(function(page) {
381 assertEquals(0, pointersPage.$$('#mouse').offsetHeight); 381 assertEquals(0, pointersPage.$$('#mouse').offsetHeight);
382 assertLT(0, pointersPage.$$('#touchpad').offsetHeight); 382 assertLT(0, pointersPage.$$('#touchpad').offsetHeight);
383 assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight); 383 assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
384 assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight); 384 assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
385 385
386 cr.webUIListenerCallback('has-mouse-changed', true); 386 cr.webUIListenerCallback('has-mouse-changed', true);
387 assertEquals(settings.Route.POINTERS, settings.getCurrentRoute()); 387 assertEquals(settings.routes.POINTERS, settings.getCurrentRoute());
388 assertLT(0, pointersPage.$$('#mouse').offsetHeight); 388 assertLT(0, pointersPage.$$('#mouse').offsetHeight);
389 assertLT(0, pointersPage.$$('#touchpad').offsetHeight); 389 assertLT(0, pointersPage.$$('#touchpad').offsetHeight);
390 assertLT(0, pointersPage.$$('#mouse h2').offsetHeight); 390 assertLT(0, pointersPage.$$('#mouse h2').offsetHeight);
391 assertLT(0, pointersPage.$$('#touchpad h2').offsetHeight); 391 assertLT(0, pointersPage.$$('#touchpad h2').offsetHeight);
392 }); 392 });
393 }); 393 });
394 394
395 test('mouse', function() { 395 test('mouse', function() {
396 expectLT(0, pointersPage.$$('#mouse').offsetHeight); 396 expectLT(0, pointersPage.$$('#mouse').offsetHeight);
397 397
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 expectNaturalScrollValue(pointersPage, true); 453 expectNaturalScrollValue(pointersPage, true);
454 done(); 454 done();
455 }, 1); 455 }, 1);
456 }, 1); 456 }, 1);
457 }); 457 });
458 }); 458 });
459 459
460 test(assert(TestNames.Keyboard), function() { 460 test(assert(TestNames.Keyboard), function() {
461 // Open the keyboard subpage. 461 // Open the keyboard subpage.
462 return showAndGetDeviceSubpage( 462 return showAndGetDeviceSubpage(
463 'keyboard', settings.Route.KEYBOARD).then(function(keyboardPage) { 463 'keyboard', settings.routes.KEYBOARD).then(function(keyboardPage) {
464 // Initially, the optional keys are hidden. 464 // Initially, the optional keys are hidden.
465 expectFalse(!!keyboardPage.$$('#capsLockKey')); 465 expectFalse(!!keyboardPage.$$('#capsLockKey'));
466 expectFalse(!!keyboardPage.$$('#diamondKey')); 466 expectFalse(!!keyboardPage.$$('#diamondKey'));
467 467
468 // Pretend the diamond key is available. 468 // Pretend the diamond key is available.
469 var showCapsLock = false; 469 var showCapsLock = false;
470 var showDiamondKey = true; 470 var showDiamondKey = true;
471 cr.webUIListenerCallback( 471 cr.webUIListenerCallback(
472 'show-keys-changed', showCapsLock, showDiamondKey); 472 'show-keys-changed', showCapsLock, showDiamondKey);
473 Polymer.dom.flush(); 473 Polymer.dom.flush();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 height: 1080, 545 height: 1080,
546 }, 546 },
547 }; 547 };
548 fakeSystemDisplay.addDisplayForTest(display); 548 fakeSystemDisplay.addDisplayForTest(display);
549 }; 549 };
550 550
551 var displayPage; 551 var displayPage;
552 return Promise.all([ 552 return Promise.all([
553 // Get the display sub-page. 553 // Get the display sub-page.
554 showAndGetDeviceSubpage( 554 showAndGetDeviceSubpage(
555 'display', settings.Route.DISPLAY).then(function(page) { 555 'display', settings.routes.DISPLAY).then(function(page) {
556 displayPage = page; 556 displayPage = page;
557 }), 557 }),
558 // Wait for the initial call to getInfo. 558 // Wait for the initial call to getInfo.
559 fakeSystemDisplay.getInfoCalled.promise, 559 fakeSystemDisplay.getInfoCalled.promise,
560 ]).then(function() { 560 ]).then(function() {
561 // Add a display. 561 // Add a display.
562 addDisplay(1); 562 addDisplay(1);
563 fakeSystemDisplay.onDisplayChanged.callListeners(); 563 fakeSystemDisplay.onDisplayChanged.callListeners();
564 564
565 return Promise.all([ 565 return Promise.all([
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 var lidClosedToggle; 685 var lidClosedToggle;
686 686
687 suiteSetup(function() { 687 suiteSetup(function() {
688 // Always show power settings. 688 // Always show power settings.
689 loadTimeData.overrideValues({ 689 loadTimeData.overrideValues({
690 enablePowerSettings: true, 690 enablePowerSettings: true,
691 }); 691 });
692 }); 692 });
693 693
694 setup(function() { 694 setup(function() {
695 return showAndGetDeviceSubpage('power', settings.Route.POWER) 695 return showAndGetDeviceSubpage('power', settings.routes.POWER)
696 .then(function(page) { 696 .then(function(page) {
697 powerPage = page; 697 powerPage = page;
698 powerSourceRow = assert(powerPage.$$('#powerSourceRow')); 698 powerSourceRow = assert(powerPage.$$('#powerSourceRow'));
699 powerSourceWrapper = 699 powerSourceWrapper =
700 assert(powerSourceRow.querySelector('.md-select-wrapper')); 700 assert(powerSourceRow.querySelector('.md-select-wrapper'));
701 powerSourceSelect = assert(powerPage.$$('#powerSource')); 701 powerSourceSelect = assert(powerPage.$$('#powerSource'));
702 assertEquals( 702 assertEquals(
703 1, 703 1,
704 settings.DevicePageBrowserProxyImpl.getInstance() 704 settings.DevicePageBrowserProxyImpl.getInstance()
705 .updatePowerStatusCalled_); 705 .updatePowerStatusCalled_);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 926
927 927
928 suiteSetup(function() { 928 suiteSetup(function() {
929 // Always show stylus settings. 929 // Always show stylus settings.
930 loadTimeData.overrideValues({ 930 loadTimeData.overrideValues({
931 stylusAllowed: true, 931 stylusAllowed: true,
932 }); 932 });
933 }); 933 });
934 934
935 setup(function() { 935 setup(function() {
936 return showAndGetDeviceSubpage('stylus', settings.Route.STYLUS).then( 936 return showAndGetDeviceSubpage('stylus', settings.routes.STYLUS).then(
937 function(page) { 937 function(page) {
938 stylusPage = page; 938 stylusPage = page;
939 browserProxy = settings.DevicePageBrowserProxyImpl.getInstance(); 939 browserProxy = settings.DevicePageBrowserProxyImpl.getInstance();
940 appSelector = assert(page.$$('#menu')); 940 appSelector = assert(page.$$('#menu'));
941 noAppsDiv = assert(page.$$('#no-apps')); 941 noAppsDiv = assert(page.$$('#no-apps'));
942 waitingDiv = assert(page.$$('#waiting')); 942 waitingDiv = assert(page.$$('#waiting'));
943 selectAppDiv = assert(page.$$('#select-app')); 943 selectAppDiv = assert(page.$$('#select-app'));
944 944
945 assertEquals(1, browserProxy.requestNoteTakingApps_); 945 assertEquals(1, browserProxy.requestNoteTakingApps_);
946 assertEquals('', browserProxy.setPreferredNoteTakingApp_); 946 assertEquals('', browserProxy.setPreferredNoteTakingApp_);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 .value); 1190 .value);
1191 }); 1191 });
1192 }); 1192 });
1193 }); 1193 });
1194 }); 1194 });
1195 1195
1196 return { 1196 return {
1197 TestNames: TestNames 1197 TestNames: TestNames
1198 }; 1198 };
1199 }); 1199 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698