| 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 | 5 /** @fileoverview Suite of tests for media-router-container that focus on |
| 6 * routes. | 6 * routes. |
| 7 */ | 7 */ |
| 8 cr.define('media_router_container_route', function() { | 8 cr.define('media_router_container_route', function() { |
| 9 function registerTests() { | 9 function registerTests() { |
| 10 suite('MediaRouterContainerRoute', function() { | 10 suite('MediaRouterContainerRoute', function() { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 fakeBlockingIssue = test_base.fakeBlockingIssue; | 91 fakeBlockingIssue = test_base.fakeBlockingIssue; |
| 92 fakeCastModeList = test_base.fakeCastModeList; | 92 fakeCastModeList = test_base.fakeCastModeList; |
| 93 fakeNonBlockingIssue = test_base.fakeNonBlockingIssue; | 93 fakeNonBlockingIssue = test_base.fakeNonBlockingIssue; |
| 94 fakeRouteList = test_base.fakeRouteList; | 94 fakeRouteList = test_base.fakeRouteList; |
| 95 fakeRouteListWithLocalRoutesOnly = | 95 fakeRouteListWithLocalRoutesOnly = |
| 96 test_base.fakeRouteListWithLocalRoutesOnly; | 96 test_base.fakeRouteListWithLocalRoutesOnly; |
| 97 fakeSinkList = test_base.fakeSinkList; | 97 fakeSinkList = test_base.fakeSinkList; |
| 98 | 98 |
| 99 container.castModeList = test_base.fakeCastModeList; | 99 container.castModeList = test_base.fakeCastModeList; |
| 100 | 100 |
| 101 // Allow for the media router container to be created and attached. | 101 // Allow for the media router container to be created, attached, and |
| 102 setTimeout(done); | 102 // listeners registered in an afterNextRender() call. |
| 103 Polymer.RenderStatus.afterNextRender(this, done); |
| 103 }); | 104 }); |
| 104 | 105 |
| 105 // Tests for 'create-route' event firing when a sink with no associated | 106 // Tests for 'create-route' event firing when a sink with no associated |
| 106 // route is clicked. | 107 // route is clicked. |
| 107 test('select sink without a route', function(done) { | 108 test('select sink without a route', function(done) { |
| 108 container.allSinks = fakeSinkList; | 109 container.allSinks = fakeSinkList; |
| 109 | 110 |
| 110 setTimeout(function() { | 111 setTimeout(function() { |
| 111 var sinkList = | 112 var sinkList = |
| 112 container.shadowRoot.getElementById('sink-list') | 113 container.shadowRoot.getElementById('sink-list') |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 container.issue = fakeBlockingIssue; | 305 container.issue = fakeBlockingIssue; |
| 305 setTimeout(function() { | 306 setTimeout(function() { |
| 306 checkElementsVisibleWithId(['container-header', | 307 checkElementsVisibleWithId(['container-header', |
| 307 'device-missing', | 308 'device-missing', |
| 308 'issue-banner']); | 309 'issue-banner']); |
| 309 done(); | 310 done(); |
| 310 }); | 311 }); |
| 311 }); | 312 }); |
| 312 | 313 |
| 313 test('creating route with selected cast mode', function(done) { | 314 test('creating route with selected cast mode', function(done) { |
| 315 container.allSinks = fakeSinkList; |
| 316 MockInteractions.tap(container.$['container-header']. |
| 317 $['arrow-drop-icon']); |
| 314 setTimeout(function() { | 318 setTimeout(function() { |
| 315 container.allSinks = fakeSinkList; | 319 // Select cast mode 2. |
| 316 MockInteractions.tap(container.$['container-header']. | 320 var castModeList = |
| 317 $['arrow-drop-icon']); | 321 container.$$('#cast-mode-list').querySelectorAll('paper-item'); |
| 322 MockInteractions.tap(castModeList[1]); |
| 323 assertEquals(fakeCastModeList[1].description, container.headerText); |
| 318 setTimeout(function() { | 324 setTimeout(function() { |
| 319 // Select cast mode 2. | 325 var sinkList = |
| 320 var castModeList = | 326 container.shadowRoot.getElementById('sink-list') |
| 321 container.$$('#cast-mode-list').querySelectorAll('paper-item'); | 327 .querySelectorAll('paper-item'); |
| 322 MockInteractions.tap(castModeList[1]); | 328 container.addEventListener('create-route', function(data) { |
| 323 assertEquals(fakeCastModeList[1].description, container.headerText); | 329 assertEquals(fakeSinkList[2].id, data.detail.sinkId); |
| 324 setTimeout(function() { | 330 // Cast mode 2 is used, since we selected it explicitly. |
| 325 var sinkList = | 331 assertEquals(fakeCastModeList[1].type, |
| 326 container.shadowRoot.getElementById('sink-list') | 332 data.detail.selectedCastModeValue); |
| 327 .querySelectorAll('paper-item'); | 333 done(); |
| 328 container.addEventListener('create-route', function(data) { | |
| 329 assertEquals(fakeSinkList[2].id, data.detail.sinkId); | |
| 330 // Cast mode 2 is used, since we selected it explicitly. | |
| 331 assertEquals(fakeCastModeList[1].type, | |
| 332 data.detail.selectedCastModeValue); | |
| 333 done(); | |
| 334 }); | |
| 335 // All sinks are compatible with cast mode 2. | |
| 336 assertEquals(fakeSinkList.length, sinkList.length); | |
| 337 // Tap on a sink without a route, which should fire a | |
| 338 // 'create-route' event. | |
| 339 MockInteractions.tap(sinkList[2]); | |
| 340 }); | 334 }); |
| 335 // All sinks are compatible with cast mode 2. |
| 336 assertEquals(fakeSinkList.length, sinkList.length); |
| 337 // Tap on a sink without a route, which should fire a |
| 338 // 'create-route' event. |
| 339 MockInteractions.tap(sinkList[2]); |
| 341 }); | 340 }); |
| 342 }); | 341 }); |
| 343 }); | 342 }); |
| 344 }); | 343 }); |
| 345 } | 344 } |
| 346 | 345 |
| 347 return { | 346 return { |
| 348 registerTests: registerTests, | 347 registerTests: registerTests, |
| 349 }; | 348 }; |
| 350 }); | 349 }); |
| OLD | NEW |