| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 'media_router_container.html'); | 86 'media_router_container.html'); |
| 87 }); | 87 }); |
| 88 | 88 |
| 89 setup(function(done) { | 89 setup(function(done) { |
| 90 PolymerTest.clearBody(); | 90 PolymerTest.clearBody(); |
| 91 // Initialize a media-router-container before each test. | 91 // Initialize a media-router-container before each test. |
| 92 container = document.createElement('media-router-container'); | 92 container = document.createElement('media-router-container'); |
| 93 document.body.appendChild(container); | 93 document.body.appendChild(container); |
| 94 | 94 |
| 95 // Get common functions and variables. | 95 // Get common functions and variables. |
| 96 var test_base = media_router_container_test_base.init(container); | 96 var testBase = media_router_container_test_base.init(container); |
| 97 | 97 |
| 98 checkCurrentView = test_base.checkCurrentView; | 98 checkCurrentView = testBase.checkCurrentView; |
| 99 checkElementsVisibleWithId = test_base.checkElementsVisibleWithId; | 99 checkElementsVisibleWithId = testBase.checkElementsVisibleWithId; |
| 100 checkElementVisible = test_base.checkElementVisible; | 100 checkElementVisible = testBase.checkElementVisible; |
| 101 checkElementText = test_base.checkElementText; | 101 checkElementText = testBase.checkElementText; |
| 102 fakeBlockingIssue = test_base.fakeBlockingIssue; | 102 fakeBlockingIssue = testBase.fakeBlockingIssue; |
| 103 fakeCastModeList = test_base.fakeCastModeList; | 103 fakeCastModeList = testBase.fakeCastModeList; |
| 104 fakeNonBlockingIssue = test_base.fakeNonBlockingIssue; | 104 fakeNonBlockingIssue = testBase.fakeNonBlockingIssue; |
| 105 fakeRouteList = test_base.fakeRouteList; | 105 fakeRouteList = testBase.fakeRouteList; |
| 106 fakeRouteListWithLocalRoutesOnly = | 106 fakeRouteListWithLocalRoutesOnly = |
| 107 test_base.fakeRouteListWithLocalRoutesOnly; | 107 testBase.fakeRouteListWithLocalRoutesOnly; |
| 108 fakeSinkList = test_base.fakeSinkList; | 108 fakeSinkList = testBase.fakeSinkList; |
| 109 | 109 |
| 110 container.castModeList = test_base.fakeCastModeList; | 110 container.castModeList = testBase.fakeCastModeList; |
| 111 | 111 |
| 112 // Allow for the media router container to be created, attached, and | 112 // Allow for the media router container to be created, attached, and |
| 113 // listeners registered in an afterNextRender() call. | 113 // listeners registered in an afterNextRender() call. |
| 114 Polymer.RenderStatus.afterNextRender(this, done); | 114 Polymer.RenderStatus.afterNextRender(this, done); |
| 115 }); | 115 }); |
| 116 | 116 |
| 117 // Tests for 'create-route' event firing when a sink with no associated | 117 // Tests for 'create-route' event firing when a sink with no associated |
| 118 // route is clicked. | 118 // route is clicked. |
| 119 test('select sink without a route', function(done) { | 119 test('select sink without a route', function(done) { |
| 120 container.allSinks = fakeSinkList; | 120 container.allSinks = fakeSinkList; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 container.routeList = fakeRouteList; | 247 container.routeList = fakeRouteList; |
| 248 container.maybeShowRouteDetailsOnOpen(); | 248 container.maybeShowRouteDetailsOnOpen(); |
| 249 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS); | 249 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS); |
| 250 | 250 |
| 251 container.routeList = []; | 251 container.routeList = []; |
| 252 checkCurrentView(media_router.MediaRouterView.SINK_LIST); | 252 checkCurrentView(media_router.MediaRouterView.SINK_LIST); |
| 253 }); | 253 }); |
| 254 | 254 |
| 255 // Tests for expected visible UI when the view is ROUTE_DETAILS. | 255 // Tests for expected visible UI when the view is ROUTE_DETAILS. |
| 256 test('route details visibility', function(done) { | 256 test('route details visibility', function(done) { |
| 257 container.showRouteDetails_(); | 257 container.showRouteDetails_( |
| 258 new media_router.Route('id 3', 'sink id 3', 'Title 3', 0, true)); |
| 258 setTimeout(function() { | 259 setTimeout(function() { |
| 259 checkElementsVisibleWithId(['container-header', | 260 checkElementsVisibleWithId(['container-header', |
| 260 'device-missing', | 261 'device-missing', |
| 261 'route-details']); | 262 'route-details']); |
| 262 done(); | 263 done(); |
| 263 }); | 264 }); |
| 264 }); | 265 }); |
| 265 | 266 |
| 266 test('updated route in route details', function(done) { | 267 test('updated route in route details', function(done) { |
| 267 container.allSinks = fakeSinkList; | 268 container.allSinks = fakeSinkList; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 287 assertTrue(!!container.currentRoute_); | 288 assertTrue(!!container.currentRoute_); |
| 288 assertEquals(newDescription, container.currentRoute_.description); | 289 assertEquals(newDescription, container.currentRoute_.description); |
| 289 done(); | 290 done(); |
| 290 }); | 291 }); |
| 291 }); | 292 }); |
| 292 }); | 293 }); |
| 293 | 294 |
| 294 // Tests for expected visible UI when the view is ROUTE_DETAILS, and there | 295 // Tests for expected visible UI when the view is ROUTE_DETAILS, and there |
| 295 // is a non-blocking issue. | 296 // is a non-blocking issue. |
| 296 test('route details visibility non blocking issue', function(done) { | 297 test('route details visibility non blocking issue', function(done) { |
| 297 container.showRouteDetails_(); | 298 container.showRouteDetails_( |
| 299 new media_router.Route('id 3', 'sink id 3', 'Title 3', 0, true)); |
| 298 | 300 |
| 299 // Set a non-blocking issue. The issue should be shown. | 301 // Set a non-blocking issue. The issue should be shown. |
| 300 container.issue = fakeNonBlockingIssue; | 302 container.issue = fakeNonBlockingIssue; |
| 301 setTimeout(function() { | 303 setTimeout(function() { |
| 302 checkElementsVisibleWithId(['container-header', | 304 checkElementsVisibleWithId(['container-header', |
| 303 'device-missing', | 305 'device-missing', |
| 304 'route-details']); | 306 'route-details']); |
| 305 done(); | 307 done(); |
| 306 }); | 308 }); |
| 307 }); | 309 }); |
| 308 | 310 |
| 309 // Tests for expected visible UI when the view is ROUTE_DETAILS, and there | 311 // Tests for expected visible UI when the view is ROUTE_DETAILS, and there |
| 310 // is a blocking issue. | 312 // is a blocking issue. |
| 311 test('route details visibility with blocking issue', function(done) { | 313 test('route details visibility with blocking issue', function(done) { |
| 312 container.showRouteDetails_(); | 314 container.showRouteDetails_( |
| 315 new media_router.Route('id 3', 'sink id 3', 'Title 3', 0, true)); |
| 313 | 316 |
| 314 // Set a blocking issue. The issue should be shown, and everything | 317 // Set a blocking issue. The issue should be shown, and everything |
| 315 // else, hidden. | 318 // else, hidden. |
| 316 container.issue = fakeBlockingIssue; | 319 container.issue = fakeBlockingIssue; |
| 317 setTimeout(function() { | 320 setTimeout(function() { |
| 318 checkElementsVisibleWithId(['container-header', | 321 checkElementsVisibleWithId(['container-header', |
| 319 'device-missing', | 322 'device-missing', |
| 320 'issue-banner']); | 323 'issue-banner']); |
| 321 done(); | 324 done(); |
| 322 }); | 325 }); |
| 323 }); | 326 }); |
| 324 | 327 |
| 325 test('creating route with selected cast mode', function(done) { | 328 test('creating route with selected cast mode', function(done) { |
| 326 container.allSinks = fakeSinkList; | 329 container.allSinks = fakeSinkList; |
| 327 MockInteractions.tap(container.$['container-header']. | 330 MockInteractions.tap( |
| 328 $['arrow-drop-icon']); | 331 container.$$('#container-header').$['arrow-drop-icon']); |
| 329 setTimeout(function() { | 332 setTimeout(function() { |
| 330 // Select cast mode 2. | 333 // Select cast mode 2. |
| 331 var castModeList = | 334 var castModeList = |
| 332 container.$$('#cast-mode-list').querySelectorAll('paper-item'); | 335 container.$$('#cast-mode-list').querySelectorAll('paper-item'); |
| 333 MockInteractions.tap(castModeList[1]); | 336 MockInteractions.tap(castModeList[1]); |
| 334 assertEquals(fakeCastModeList[1].description, container.headerText); | 337 assertEquals(fakeCastModeList[1].description, container.headerText); |
| 335 setTimeout(function() { | 338 setTimeout(function() { |
| 336 var sinkList = | 339 var sinkList = |
| 337 container.shadowRoot.getElementById('sink-list') | 340 container.shadowRoot.getElementById('sink-list') |
| 338 .querySelectorAll('paper-item'); | 341 .querySelectorAll('paper-item'); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // selected a cast mode that is different from the current cast mode of | 412 // selected a cast mode that is different from the current cast mode of |
| 410 // the route. | 413 // the route. |
| 411 test('cast button when selected cast mode differs', function(done) { | 414 test('cast button when selected cast mode differs', function(done) { |
| 412 container.allSinks = fakeSinkList; | 415 container.allSinks = fakeSinkList; |
| 413 container.routeList = fakeRouteList; | 416 container.routeList = fakeRouteList; |
| 414 container.castModeList = fakeCastModeList; | 417 container.castModeList = fakeCastModeList; |
| 415 for (var i = 0; i < fakeRouteList.length; ++i) { | 418 for (var i = 0; i < fakeRouteList.length; ++i) { |
| 416 fakeRouteList[i].currentCastMode = 2; | 419 fakeRouteList[i].currentCastMode = 2; |
| 417 } | 420 } |
| 418 MockInteractions.tap( | 421 MockInteractions.tap( |
| 419 container.$['container-header'].$['arrow-drop-icon']); | 422 container.$$('#container-header').$$('#arrow-drop-icon')); |
| 420 setTimeout(function() { | 423 setTimeout(function() { |
| 421 MockInteractions.tap(container.$$('#cast-mode-list') | 424 MockInteractions.tap(container.$$('#cast-mode-list') |
| 422 .querySelectorAll('paper-item')[2]); | 425 .querySelectorAll('paper-item')[2]); |
| 423 setTimeout(function() { | 426 setTimeout(function() { |
| 424 assertTrue(container.shownCastModeValue_ != 2); | 427 assertTrue(container.shownCastModeValue_ != 2); |
| 425 MockInteractions.tap( | 428 MockInteractions.tap( |
| 426 container.$$('#sink-list').querySelectorAll('paper-item')[0]); | 429 container.$$('#sink-list').querySelectorAll('paper-item')[0]); |
| 427 setTimeout(function() { | 430 setTimeout(function() { |
| 428 checkElementVisible( | 431 checkElementVisible( |
| 429 true, container.$$('#route-details') | 432 true, container.$$('#route-details') |
| 430 .$$('#start-casting-to-route-button'), | 433 .$$('#start-casting-to-route-button'), |
| 431 'start-casting-to-route-button'); | 434 'start-casting-to-route-button'); |
| 432 done(); | 435 done(); |
| 433 }); | 436 }); |
| 434 }); | 437 }); |
| 435 }); | 438 }); |
| 436 }); | 439 }); |
| 437 | 440 |
| 438 // Tests that the route details cast button is not shown when the user has | 441 // Tests that the route details cast button is not shown when the user has |
| 439 // selected a the same cast mode as the route's current cast mode. | 442 // selected a the same cast mode as the route's current cast mode. |
| 440 test('no cast button when selected cast mode same', function(done) { | 443 test('no cast button when selected cast mode same', function(done) { |
| 441 container.allSinks = fakeSinkList; | 444 container.allSinks = fakeSinkList; |
| 442 container.routeList = fakeRouteList; | 445 container.routeList = fakeRouteList; |
| 443 container.castModeList = fakeCastModeList; | 446 container.castModeList = fakeCastModeList; |
| 444 for (var i = 0; i < fakeRouteList.length; ++i) { | 447 for (var i = 0; i < fakeRouteList.length; ++i) { |
| 445 fakeRouteList[i].currentCastMode = 2; | 448 fakeRouteList[i].currentCastMode = 2; |
| 446 } | 449 } |
| 447 MockInteractions.tap( | 450 MockInteractions.tap( |
| 448 container.$['container-header'].$['arrow-drop-icon']); | 451 container.$$('#container-header').$$('#arrow-drop-icon')); |
| 449 setTimeout(function() { | 452 setTimeout(function() { |
| 450 MockInteractions.tap(container.$$('#cast-mode-list') | 453 MockInteractions.tap(container.$$('#cast-mode-list') |
| 451 .querySelectorAll('paper-item')[1]); | 454 .querySelectorAll('paper-item')[1]); |
| 452 setTimeout(function() { | 455 setTimeout(function() { |
| 453 assertEquals(2, container.shownCastModeValue_); | 456 assertEquals(2, container.shownCastModeValue_); |
| 454 MockInteractions.tap( | 457 MockInteractions.tap( |
| 455 container.$$('#sink-list').querySelectorAll('paper-item')[0]); | 458 container.$$('#sink-list').querySelectorAll('paper-item')[0]); |
| 456 setTimeout(function() { | 459 setTimeout(function() { |
| 457 checkElementVisible( | 460 checkElementVisible( |
| 458 false, container.$$('#route-details') | 461 false, container.$$('#route-details') |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 done(); | 512 done(); |
| 510 }); | 513 }); |
| 511 }); | 514 }); |
| 512 }); | 515 }); |
| 513 } | 516 } |
| 514 | 517 |
| 515 return { | 518 return { |
| 516 registerTests: registerTests, | 519 registerTests: registerTests, |
| 517 }; | 520 }; |
| 518 }); | 521 }); |
| OLD | NEW |