Chromium Code Reviews| 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 /** @fileoverview Suite of tests for media-router-container that focus on the | 5 /** @fileoverview Suite of tests for media-router-container that focus on the |
| 6 * cast mode list. | 6 * cast mode list. |
| 7 */ | 7 */ |
| 8 cr.define('media_router_container_cast_mode_list', function() { | 8 cr.define('media_router_container_cast_mode_list', function() { |
| 9 function registerTests() { | 9 function registerTests() { |
| 10 suite('MediaRouterContainerCastModeList', function() { | 10 suite('MediaRouterContainerCastModeList', function() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 */ | 51 */ |
| 52 var fakeCastModeList = []; | 52 var fakeCastModeList = []; |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * The list of CastModes to show with non-default modes only. | 55 * The list of CastModes to show with non-default modes only. |
| 56 * @type {!Array<!media_router.CastMode>} | 56 * @type {!Array<!media_router.CastMode>} |
| 57 */ | 57 */ |
| 58 var fakeCastModeListWithNonDefaultModesOnly = []; | 58 var fakeCastModeListWithNonDefaultModesOnly = []; |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * The list of CastModes to show with default mode forced. | |
| 62 * @type {!Array<!media_router.CastMode>} | |
| 63 */ | |
| 64 var fakeCastModeListWithDefaultModeForced = []; | |
| 65 | |
| 66 /** | |
| 61 * The blocking issue to show. | 67 * The blocking issue to show. |
| 62 * @type {?media_router.Issue} | 68 * @type {?media_router.Issue} |
| 63 */ | 69 */ |
| 64 var fakeNonBlockingIssue; | 70 var fakeNonBlockingIssue; |
| 65 | 71 |
| 66 /** | 72 /** |
| 67 * The list of available sinks. | 73 * The list of available sinks. |
| 68 * @type {!Array<!media_router.Sink>} | 74 * @type {!Array<!media_router.Sink>} |
| 69 */ | 75 */ |
| 70 var fakeSinkList = []; | 76 var fakeSinkList = []; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 85 // Get common functions and variables. | 91 // Get common functions and variables. |
| 86 var test_base = media_router_container_test_base.init(container); | 92 var test_base = media_router_container_test_base.init(container); |
| 87 | 93 |
| 88 checkCurrentView = test_base.checkCurrentView; | 94 checkCurrentView = test_base.checkCurrentView; |
| 89 checkElementsVisibleWithId = test_base.checkElementsVisibleWithId; | 95 checkElementsVisibleWithId = test_base.checkElementsVisibleWithId; |
| 90 checkElementText = test_base.checkElementText; | 96 checkElementText = test_base.checkElementText; |
| 91 fakeBlockingIssue = test_base.fakeBlockingIssue; | 97 fakeBlockingIssue = test_base.fakeBlockingIssue; |
| 92 fakeCastModeList = test_base.fakeCastModeList; | 98 fakeCastModeList = test_base.fakeCastModeList; |
| 93 fakeCastModeListWithNonDefaultModesOnly = | 99 fakeCastModeListWithNonDefaultModesOnly = |
| 94 test_base.fakeCastModeListWithNonDefaultModesOnly; | 100 test_base.fakeCastModeListWithNonDefaultModesOnly; |
| 101 fakeCastModeListWithDefaultModeForced = | |
| 102 test_base.fakeCastModeListWithDefaultModeForced; | |
| 95 fakeNonBlockingIssue = test_base.fakeNonBlockingIssue; | 103 fakeNonBlockingIssue = test_base.fakeNonBlockingIssue; |
| 96 fakeSinkList = test_base.fakeSinkList; | 104 fakeSinkList = test_base.fakeSinkList; |
| 97 | 105 |
| 98 container.castModeList = test_base.fakeCastModeList; | 106 container.castModeList = test_base.fakeCastModeList; |
| 99 | 107 |
| 100 // Allow for the media router container to be created, attached, and | 108 // Allow for the media router container to be created, attached, and |
| 101 // listeners registered in an afterNextRender() call. | 109 // listeners registered in an afterNextRender() call. |
| 102 Polymer.RenderStatus.afterNextRender(this, done); | 110 Polymer.RenderStatus.afterNextRender(this, done); |
| 103 }); | 111 }); |
| 104 | 112 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 var sinkList = | 323 var sinkList = |
| 316 container.shadowRoot.getElementById('sink-list') | 324 container.shadowRoot.getElementById('sink-list') |
| 317 .querySelectorAll('paper-item'); | 325 .querySelectorAll('paper-item'); |
| 318 assertEquals(3, sinkList.length); | 326 assertEquals(3, sinkList.length); |
| 319 done(); | 327 done(); |
| 320 }); | 328 }); |
| 321 }); | 329 }); |
| 322 }); | 330 }); |
| 323 }); | 331 }); |
| 324 | 332 |
| 333 // When a forced cast mode it set, it is used. | |
| 334 test('cast mode list respects forced mode', function(done) { | |
| 335 container.allSinks = [ | |
| 336 new media_router.Sink('sink id 1', 'Sink 1', null, null, | |
| 337 media_router.SinkIconType.CAST, | |
| 338 media_router.SinkStatus.ACTIVE, 0x1), | |
| 339 new media_router.Sink('sink id 2', 'Sink 2', null, null, | |
| 340 media_router.SinkIconType.CAST, | |
| 341 media_router.SinkStatus.ACTIVE, 0x1 | 0x2), | |
| 342 new media_router.Sink('sink id 3', 'Sink 3', null, null, | |
| 343 media_router.SinkIconType.CAST, | |
| 344 media_router.SinkStatus.ACTIVE, 0x2) | |
| 345 ]; | |
| 346 container.castModeList = fakeCastModeListWithDefaultModeForced; | |
| 347 MockInteractions.tap(container.$['container-header']. | |
| 348 $['arrow-drop-icon']); | |
| 349 setTimeout(function() { | |
| 350 assertEquals(media_router.CastModeType.DEFAULT, | |
| 351 container.shownCastModeValue_); | |
| 352 assertEquals('Cast google.com', container.headerText); | |
| 353 assertFalse(container.userHasSelectedCastMode_); | |
| 354 | |
| 355 var sinkList = | |
| 356 container.shadowRoot.getElementById('sink-list') | |
| 357 .querySelectorAll('paper-item'); | |
| 358 | |
| 359 // The sink list contains only sinks compatible with DEFAULT mode | |
|
apacible
2017/05/19 14:54:37
nit: period.
mark a. foltz
2017/05/19 18:30:32
Done.
| |
| 360 assertEquals(2, sinkList.length); | |
| 361 checkElementText('Sink 1', sinkList[0]); | |
| 362 checkElementText('Sink 2', sinkList[1]); | |
| 363 done(); | |
| 364 }); | |
| 365 }); | |
| 366 | |
| 325 // Tests that the sink list does not contain any sinks that are not | 367 // Tests that the sink list does not contain any sinks that are not |
| 326 // compatible with the selected cast mode and are not associated with a | 368 // compatible with the selected cast mode and are not associated with a |
| 327 // route. | 369 // route. |
| 328 test('sink list in user selected cast mode', function(done) { | 370 test('sink list in user selected cast mode', function(done) { |
| 329 var newSinks = [ | 371 var newSinks = [ |
| 330 new media_router.Sink('sink id 10', 'Sink 10', null, null, | 372 new media_router.Sink('sink id 10', 'Sink 10', null, null, |
| 331 media_router.SinkIconType.CAST, | 373 media_router.SinkIconType.CAST, |
| 332 media_router.SinkStatus.ACTIVE, 0x4 | 0x8), | 374 media_router.SinkStatus.ACTIVE, 0x4 | 0x8), |
| 333 new media_router.Sink('sink id 20', 'Sink 20', null, null, | 375 new media_router.Sink('sink id 20', 'Sink 20', null, null, |
| 334 media_router.SinkIconType.CAST, | 376 media_router.SinkIconType.CAST, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 }); | 490 }); |
| 449 }); | 491 }); |
| 450 }); | 492 }); |
| 451 }); | 493 }); |
| 452 } | 494 } |
| 453 | 495 |
| 454 return { | 496 return { |
| 455 registerTests: registerTests, | 497 registerTests: registerTests, |
| 456 }; | 498 }; |
| 457 }); | 499 }); |
| OLD | NEW |