OLD | NEW |
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 Display: 'display', | 8 Display: 'display', |
9 Keyboard: 'keyboard', | 9 Keyboard: 'keyboard', |
10 Touchpad: 'touchpad', | 10 Touchpad: 'touchpad', |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 | 304 |
305 var displayPage; | 305 var displayPage; |
306 return Promise.all([ | 306 return Promise.all([ |
307 // Get the display sub-page. | 307 // Get the display sub-page. |
308 showAndGetDeviceSubpage('display').then(function(page) { | 308 showAndGetDeviceSubpage('display').then(function(page) { |
309 displayPage = page; | 309 displayPage = page; |
310 }), | 310 }), |
311 // Wait for the initial call to getInfo. | 311 // Wait for the initial call to getInfo. |
312 fakeSystemDisplay.getInfoCalled.promise, | 312 fakeSystemDisplay.getInfoCalled.promise, |
313 ]).then(function() { | 313 ]).then(function() { |
314 expectTrue(!!displayPage.displays); | |
315 expectEquals(0, displayPage.displays.length); | |
316 | |
317 // Add a display. | 314 // Add a display. |
318 addDisplay(1); | 315 addDisplay(1); |
319 fakeSystemDisplay.onDisplayChanged.callListeners(); | 316 fakeSystemDisplay.onDisplayChanged.callListeners(); |
320 | 317 |
321 return new Promise(function(resolve, reject) { | 318 return Promise.all([ |
322 setTimeout(resolve); | 319 fakeSystemDisplay.getInfoCalled.promise, |
323 }); | 320 fakeSystemDisplay.getLayoutCalled.promise, |
| 321 new Promise(function(resolve, reject) { setTimeout(resolve); }) |
| 322 ]); |
324 }).then(function() { | 323 }).then(function() { |
325 // There should be a single display which should be primary and | 324 // There should be a single display which should be primary and |
326 // selected. Mirroring should be disabled. | 325 // selected. Mirroring should be disabled. |
327 expectEquals(1, displayPage.displays.length); | 326 expectEquals(1, displayPage.displays.length); |
328 expectEquals( | 327 expectEquals( |
329 displayPage.displays[0].id, displayPage.selectedDisplay.id); | 328 displayPage.displays[0].id, displayPage.selectedDisplay.id); |
330 expectEquals( | 329 expectEquals( |
331 displayPage.displays[0].id, displayPage.primaryDisplayId); | 330 displayPage.displays[0].id, displayPage.primaryDisplayId); |
332 expectFalse(displayPage.showMirror_(displayPage.displays)); | 331 expectFalse(displayPage.showMirror_(displayPage.displays)); |
333 expectFalse(displayPage.isMirrored_(displayPage.displays)); | 332 expectFalse(displayPage.isMirrored_(displayPage.displays)); |
334 | 333 |
335 // Add a second display. | 334 // Add a second display. |
336 addDisplay(2); | 335 addDisplay(2); |
337 fakeSystemDisplay.onDisplayChanged.callListeners(); | 336 fakeSystemDisplay.onDisplayChanged.callListeners(); |
338 | 337 |
339 return new Promise(function(resolve, reject) { | 338 return Promise.all([ |
340 setTimeout(resolve); | 339 fakeSystemDisplay.getInfoCalled.promise, |
341 }); | 340 fakeSystemDisplay.getLayoutCalled.promise, |
| 341 new Promise(function(resolve, reject) { setTimeout(resolve); }) |
| 342 ]); |
342 }).then(function() { | 343 }).then(function() { |
343 // There should be two displays, the first should be primary and | 344 // There should be two displays, the first should be primary and |
344 // selected. Mirroring should be enabled but set to false. | 345 // selected. Mirroring should be enabled but set to false. |
345 expectEquals(2, displayPage.displays.length); | 346 expectEquals(2, displayPage.displays.length); |
346 expectEquals( | 347 expectEquals( |
347 displayPage.displays[0].id, displayPage.selectedDisplay.id); | 348 displayPage.displays[0].id, displayPage.selectedDisplay.id); |
348 expectEquals(displayPage.displays[0].id, displayPage.primaryDisplayId); | 349 expectEquals(displayPage.displays[0].id, displayPage.primaryDisplayId); |
349 expectTrue(displayPage.showMirror_(displayPage.displays)); | 350 expectTrue(displayPage.showMirror_(displayPage.displays)); |
350 expectFalse(displayPage.isMirrored_(displayPage.displays)); | 351 expectFalse(displayPage.isMirrored_(displayPage.displays)); |
351 | 352 |
352 // Select the second display and make it primary. Also change the | 353 // Select the second display and make it primary. Also change the |
353 // orientation of the second display. | 354 // orientation of the second display. |
354 MockInteractions.tap(displayPage.$$('#fakeDisplayId2')); | 355 var displayLayout = displayPage.$$('#displayLayout'); |
| 356 assertTrue(!!displayLayout); |
| 357 var displayDiv = displayLayout.$$('#_fakeDisplayId2'); |
| 358 assertTrue(!!displayDiv); |
| 359 MockInteractions.tap(displayDiv); |
355 expectEquals( | 360 expectEquals( |
356 displayPage.displays[1].id, displayPage.selectedDisplay.id); | 361 displayPage.displays[1].id, displayPage.selectedDisplay.id); |
357 | 362 |
358 displayPage.onMakePrimaryTap_(); | 363 displayPage.onMakePrimaryTap_(); |
359 displayPage.onSetOrientation_({detail: {selected: '90'}}); | 364 displayPage.onSetOrientation_({detail: {selected: '90'}}); |
360 fakeSystemDisplay.onDisplayChanged.callListeners(); | 365 fakeSystemDisplay.onDisplayChanged.callListeners(); |
361 | 366 |
362 return new Promise(function(resolve, reject) { | 367 return Promise.all([ |
363 setTimeout(resolve); | 368 fakeSystemDisplay.getInfoCalled.promise, |
364 }); | 369 fakeSystemDisplay.getLayoutCalled.promise, |
| 370 new Promise(function(resolve, reject) { setTimeout(resolve); }) |
| 371 ]); |
365 }).then(function() { | 372 }).then(function() { |
366 // Confirm that the second display is selected, primary, and rotated. | 373 // Confirm that the second display is selected, primary, and rotated. |
367 expectEquals(2, displayPage.displays.length); | 374 expectEquals(2, displayPage.displays.length); |
368 expectEquals( | 375 expectEquals( |
369 displayPage.displays[1].id, displayPage.selectedDisplay.id); | 376 displayPage.displays[1].id, displayPage.selectedDisplay.id); |
370 expectTrue(displayPage.displays[1].isPrimary); | 377 expectTrue(displayPage.displays[1].isPrimary); |
371 expectEquals(displayPage.displays[1].id, displayPage.primaryDisplayId); | 378 expectEquals(displayPage.displays[1].id, displayPage.primaryDisplayId); |
372 expectEquals(90, displayPage.displays[1].rotation); | 379 expectEquals(90, displayPage.displays[1].rotation); |
373 | 380 |
374 // Mirror the displays. | 381 // Mirror the displays. |
375 displayPage.onMirroredTap_(); | 382 displayPage.onMirroredTap_(); |
376 fakeSystemDisplay.onDisplayChanged.callListeners(); | 383 fakeSystemDisplay.onDisplayChanged.callListeners(); |
377 | 384 |
378 return new Promise(function(resolve, reject) { | 385 return Promise.all([ |
379 setTimeout(resolve); | 386 fakeSystemDisplay.getInfoCalled.promise, |
380 }); | 387 fakeSystemDisplay.getLayoutCalled.promise, |
| 388 new Promise(function(resolve, reject) { setTimeout(resolve); }) |
| 389 ]); |
381 }).then(function() { | 390 }).then(function() { |
382 // Confirm that there is now only one display and that it is primary | 391 // Confirm that there is now only one display and that it is primary |
383 // and mirroring is enabled. | 392 // and mirroring is enabled. |
384 expectEquals(1, displayPage.displays.length); | 393 expectEquals(1, displayPage.displays.length); |
385 expectEquals( | 394 expectEquals( |
386 displayPage.displays[0].id, displayPage.selectedDisplay.id); | 395 displayPage.displays[0].id, displayPage.selectedDisplay.id); |
387 expectTrue(displayPage.displays[0].isPrimary); | 396 expectTrue(displayPage.displays[0].isPrimary); |
388 expectTrue(displayPage.showMirror_(displayPage.displays)); | 397 expectTrue(displayPage.showMirror_(displayPage.displays)); |
389 expectTrue(displayPage.isMirrored_(displayPage.displays)); | 398 expectTrue(displayPage.isMirrored_(displayPage.displays)); |
390 }); | 399 }); |
391 }); | 400 }); |
392 }); | 401 }); |
393 | 402 |
394 return { | 403 return { |
395 TestNames: TestNames | 404 TestNames: TestNames |
396 }; | 405 }; |
397 }); | 406 }); |
OLD | NEW |