| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 sinkSubtextList[2]); | 210 sinkSubtextList[2]); |
| 211 done(); | 211 done(); |
| 212 }); | 212 }); |
| 213 }); | 213 }); |
| 214 | 214 |
| 215 // Tests the expected view when there is only one local active route and | 215 // Tests the expected view when there is only one local active route and |
| 216 // media_router_container is created for the first time. | 216 // media_router_container is created for the first time. |
| 217 test('initial view with one local route', function() { | 217 test('initial view with one local route', function() { |
| 218 container.allSinks = fakeSinkList; | 218 container.allSinks = fakeSinkList; |
| 219 container.routeList = fakeRouteList; | 219 container.routeList = fakeRouteList; |
| 220 container.maybeShowRouteDetailsOnOpen(); | 220 container.showInitialView(); |
| 221 | 221 |
| 222 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS); | 222 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS); |
| 223 }); | 223 }); |
| 224 | 224 |
| 225 // Tests the expected view when there are multiple local active routes | 225 // Tests the expected view when there are multiple local active routes |
| 226 // and media_router_container is created for the first time. | 226 // and media_router_container is created for the first time. |
| 227 test('initial view with multiple local routes', function() { | 227 test('initial view with multiple local routes', function() { |
| 228 container.allSinks = fakeSinkList; | 228 container.allSinks = fakeSinkList; |
| 229 container.routeList = fakeRouteListWithLocalRoutesOnly; | 229 container.routeList = fakeRouteListWithLocalRoutesOnly; |
| 230 | 230 |
| 231 checkCurrentView(media_router.MediaRouterView.SINK_LIST); | 231 checkCurrentView(media_router.MediaRouterView.SINK_LIST); |
| 232 }); | 232 }); |
| 233 | 233 |
| 234 // Tests the expected view when there are no local active routes and | 234 // Tests the expected view when there are no local active routes and |
| 235 // media_router_container is created for the first time. | 235 // media_router_container is created for the first time. |
| 236 test('initial view with no local route', function() { | 236 test('initial view with no local route', function() { |
| 237 container.allSinks = fakeSinkList; | 237 container.allSinks = fakeSinkList; |
| 238 container.routeList = []; | 238 container.routeList = []; |
| 239 | 239 |
| 240 checkCurrentView(media_router.MediaRouterView.SINK_LIST); | 240 checkCurrentView(media_router.MediaRouterView.SINK_LIST); |
| 241 }); | 241 }); |
| 242 | 242 |
| 243 // Tests the expected view when there are no local active routes and | 243 // Tests the expected view when there are no local active routes and |
| 244 // media_router_container is created for the first time. | 244 // media_router_container is created for the first time. |
| 245 test('view after route is closed remotely', function() { | 245 test('view after route is closed remotely', function() { |
| 246 container.allSinks = fakeSinkList; | 246 container.allSinks = fakeSinkList; |
| 247 container.routeList = fakeRouteList; | 247 container.routeList = fakeRouteList; |
| 248 container.maybeShowRouteDetailsOnOpen(); | 248 container.showInitialView(); |
| 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 setTimeout(function() { | 258 setTimeout(function() { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 // Tests that the route details cast button is shown when the user has | 408 // Tests that the route details cast button is shown when the user has |
| 409 // selected a cast mode that is different from the current cast mode of | 409 // selected a cast mode that is different from the current cast mode of |
| 410 // the route. | 410 // the route. |
| 411 test('cast button when selected cast mode differs', function(done) { | 411 test('cast button when selected cast mode differs', function(done) { |
| 412 container.allSinks = fakeSinkList; | 412 container.allSinks = fakeSinkList; |
| 413 container.routeList = fakeRouteList; | 413 container.routeList = fakeRouteList; |
| 414 container.castModeList = fakeCastModeList; | 414 container.castModeList = fakeCastModeList; |
| 415 for (var i = 0; i < fakeRouteList.length; ++i) { | 415 for (var i = 0; i < fakeRouteList.length; ++i) { |
| 416 fakeRouteList[i].currentCastMode = 2; | 416 fakeRouteList[i].currentCastMode = 2; |
| 417 } | 417 } |
| 418 container.showSinkList_(); |
| 418 MockInteractions.tap( | 419 MockInteractions.tap( |
| 419 container.$['container-header'].$['arrow-drop-icon']); | 420 container.$['container-header'].$['arrow-drop-icon']); |
| 420 setTimeout(function() { | 421 setTimeout(function() { |
| 421 MockInteractions.tap(container.$$('#cast-mode-list') | 422 MockInteractions.tap(container.$$('#cast-mode-list') |
| 422 .querySelectorAll('paper-item')[2]); | 423 .querySelectorAll('paper-item')[2]); |
| 423 setTimeout(function() { | 424 setTimeout(function() { |
| 424 assertTrue(container.shownCastModeValue_ != 2); | 425 assertTrue(container.shownCastModeValue_ != 2); |
| 425 MockInteractions.tap( | 426 MockInteractions.tap( |
| 426 container.$$('#sink-list').querySelectorAll('paper-item')[0]); | 427 container.$$('#sink-list').querySelectorAll('paper-item')[0]); |
| 427 setTimeout(function() { | 428 setTimeout(function() { |
| 428 checkElementVisible( | 429 checkElementVisible( |
| 429 true, container.$$('#route-details') | 430 true, container.$$('#route-details') |
| 430 .$$('#start-casting-to-route-button'), | 431 .$$('#start-casting-to-route-button'), |
| 431 'start-casting-to-route-button'); | 432 'start-casting-to-route-button'); |
| 432 done(); | 433 done(); |
| 433 }); | 434 }); |
| 434 }); | 435 }); |
| 435 }); | 436 }); |
| 436 }); | 437 }); |
| 437 | 438 |
| 438 // Tests that the route details cast button is not shown when the user has | 439 // 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. | 440 // 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) { | 441 test('no cast button when selected cast mode same', function(done) { |
| 441 container.allSinks = fakeSinkList; | 442 container.allSinks = fakeSinkList; |
| 442 container.routeList = fakeRouteList; | 443 container.routeList = fakeRouteList; |
| 443 container.castModeList = fakeCastModeList; | 444 container.castModeList = fakeCastModeList; |
| 444 for (var i = 0; i < fakeRouteList.length; ++i) { | 445 for (var i = 0; i < fakeRouteList.length; ++i) { |
| 445 fakeRouteList[i].currentCastMode = 2; | 446 fakeRouteList[i].currentCastMode = 2; |
| 446 } | 447 } |
| 448 container.showSinkList_(); |
| 447 MockInteractions.tap( | 449 MockInteractions.tap( |
| 448 container.$['container-header'].$['arrow-drop-icon']); | 450 container.$['container-header'].$['arrow-drop-icon']); |
| 449 setTimeout(function() { | 451 setTimeout(function() { |
| 450 MockInteractions.tap(container.$$('#cast-mode-list') | 452 MockInteractions.tap(container.$$('#cast-mode-list') |
| 451 .querySelectorAll('paper-item')[1]); | 453 .querySelectorAll('paper-item')[1]); |
| 452 setTimeout(function() { | 454 setTimeout(function() { |
| 453 assertEquals(2, container.shownCastModeValue_); | 455 assertEquals(2, container.shownCastModeValue_); |
| 454 MockInteractions.tap( | 456 MockInteractions.tap( |
| 455 container.$$('#sink-list').querySelectorAll('paper-item')[0]); | 457 container.$$('#sink-list').querySelectorAll('paper-item')[0]); |
| 456 setTimeout(function() { | 458 setTimeout(function() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // container's sink list. | 504 // container's sink list. |
| 503 container.showRouteDetails_(fakeRouteList[0]); | 505 container.showRouteDetails_(fakeRouteList[0]); |
| 504 setTimeout(function() { | 506 setTimeout(function() { |
| 505 checkElementVisible( | 507 checkElementVisible( |
| 506 false, container.$$('#route-details') | 508 false, container.$$('#route-details') |
| 507 .$$('#start-casting-to-route-button'), | 509 .$$('#start-casting-to-route-button'), |
| 508 'start-casting-to-route-button'); | 510 'start-casting-to-route-button'); |
| 509 done(); | 511 done(); |
| 510 }); | 512 }); |
| 511 }); | 513 }); |
| 514 |
| 515 // Tests that if the route list contains one local route the first time |
| 516 // it's updated, we show the route details view. |
| 517 test('default to details view for one local route', function(done) { |
| 518 container.routeList = fakeRouteList; |
| 519 setTimeout(function() { |
| 520 checkElementVisible(true, container.$$('#route-details')); |
| 521 checkElementVisible(false, container.$$('#sink-list-view')); |
| 522 done(); |
| 523 }); |
| 524 }); |
| 525 |
| 526 // Tests that if the route list contains no local routes the first time |
| 527 // it's updated, we show the sink list view. |
| 528 test('default to sink list for no local routes', function(done) { |
| 529 container.routeList = []; |
| 530 setTimeout(function() { |
| 531 checkElementVisible(false, container.$$('#route-details')); |
| 532 checkElementVisible(true, container.$$('#sink-list-view')); |
| 533 done(); |
| 534 }); |
| 535 }); |
| 536 |
| 537 // Tests that if the route list contains multiple local routes the first |
| 538 // time it's updated, we show the sink list view. |
| 539 test('default to sink list for multiple local routes', function(done) { |
| 540 container.routeList = fakeRouteListWithLocalRoutesOnly; |
| 541 setTimeout(function() { |
| 542 checkElementVisible(false, container.$$('#route-details')); |
| 543 checkElementVisible(true, container.$$('#sink-list-view')); |
| 544 done(); |
| 545 }); |
| 546 }); |
| 512 }); | 547 }); |
| 513 } | 548 } |
| 514 | 549 |
| 515 return { | 550 return { |
| 516 registerTests: registerTests, | 551 registerTests: registerTests, |
| 517 }; | 552 }; |
| 518 }); | 553 }); |
| OLD | NEW |