OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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. */ | 5 /** @fileoverview Suite of tests for media-router-container. */ |
6 cr.define('media_router_container', function() { | 6 cr.define('media_router_container', function() { |
7 function registerTests() { | 7 function registerTests() { |
8 suite('MediaRouterContainer', function() { | 8 suite('MediaRouterContainer', function() { |
9 /** | 9 /** |
10 * Media Router Container created before each test. | 10 * Media Router Container created before each test. |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 container.allSinks = [ | 393 container.allSinks = [ |
394 new media_router.Sink('sink id 1', 'Sink 1', null, null, | 394 new media_router.Sink('sink id 1', 'Sink 1', null, null, |
395 media_router.SinkIconType.HANGOUT, | 395 media_router.SinkIconType.HANGOUT, |
396 media_router.SinkStatus.ACTIVE, [1, 2, 3]), | 396 media_router.SinkStatus.ACTIVE, [1, 2, 3]), |
397 new media_router.Sink('sink id 2', 'Sink 2', | 397 new media_router.Sink('sink id 2', 'Sink 2', |
398 null, 'example.com', | 398 null, 'example.com', |
399 media_router.SinkIconType.HANGOUT, | 399 media_router.SinkIconType.HANGOUT, |
400 media_router.SinkStatus.ACTIVE, [1, 2, 3]), | 400 media_router.SinkStatus.ACTIVE, [1, 2, 3]), |
401 ]; | 401 ]; |
402 | 402 |
| 403 container.showDomain = true; |
| 404 |
403 setTimeout(function() { | 405 setTimeout(function() { |
404 var sinkList = | 406 var sinkList = |
405 container.$['sink-list'].querySelectorAll('paper-item'); | 407 container.$['sink-list'].querySelectorAll('paper-item'); |
406 assertEquals(2, sinkList.length); | 408 assertEquals(2, sinkList.length); |
407 | 409 |
408 // |sinkList[0]| has sink name only. | 410 // |sinkList[0]| has sink name only. |
409 checkElementText(container.allSinks[0].name, sinkList[0]); | 411 checkElementText(container.allSinks[0].name, sinkList[0]); |
410 // |sinkList[1]| contains sink name and domain. | 412 // |sinkList[1]| contains sink name and domain. |
411 assertTrue(sinkList[1].textContent.trim().startsWith( | 413 assertTrue(sinkList[1].textContent.trim().startsWith( |
412 container.allSinks[1].name.trim())); | 414 container.allSinks[1].name.trim())); |
413 assertTrue(sinkList[1].textContent.trim().indexOf( | 415 assertTrue(sinkList[1].textContent.trim().indexOf( |
414 container.allSinks[1].domain.trim()) != -1); | 416 container.allSinks[1].domain.trim()) != -1); |
415 done(); | 417 done(); |
416 }); | 418 }); |
417 }); | 419 }); |
418 | 420 |
| 421 // Tests that domain text is not shown when |showDomain| is false. |
| 422 test('sink with domain text', function(done) { |
| 423 // Sink 1 - sink, no domain -> text = name |
| 424 // Sink 2 - sink, domain -> text = sink + domain |
| 425 container.allSinks = [ |
| 426 new media_router.Sink('sink id 1', 'Sink 1', null, null, |
| 427 media_router.SinkIconType.HANGOUT, |
| 428 media_router.SinkStatus.ACTIVE, [1, 2, 3]), |
| 429 new media_router.Sink('sink id 2', 'Sink 2', |
| 430 null, 'example.com', |
| 431 media_router.SinkIconType.HANGOUT, |
| 432 media_router.SinkStatus.ACTIVE, [1, 2, 3]), |
| 433 ]; |
| 434 |
| 435 container.showDomain = false; |
| 436 |
| 437 setTimeout(function() { |
| 438 var sinkList = |
| 439 container.$['sink-list'].querySelectorAll('paper-item'); |
| 440 assertEquals(2, sinkList.length); |
| 441 |
| 442 // |sinkList[0]| has sink name only. |
| 443 checkElementText(container.allSinks[0].name, sinkList[0]); |
| 444 // |sinkList[1]| has sink name but domain should be hidden. |
| 445 checkElementText(container.allSinks[1].name, sinkList[1]); |
| 446 assertTrue(sinkList[1].textContent.trim().indexOf( |
| 447 container.allSinks[1].domain.trim()) == -1); |
| 448 done(); |
| 449 }); |
| 450 }); |
| 451 |
419 // Tests the text shown for the sink list. | 452 // Tests the text shown for the sink list. |
420 test('initial sink list route text', function(done) { | 453 test('initial sink list route text', function(done) { |
421 // Sink 1 - no sink description, no route -> no subtext | 454 // Sink 1 - no sink description, no route -> no subtext |
422 // Sink 2 - sink description, no route -> subtext = sink description | 455 // Sink 2 - sink description, no route -> subtext = sink description |
423 // Sink 3 - no sink description, route -> subtext = route description | 456 // Sink 3 - no sink description, route -> subtext = route description |
424 // Sink 4 - sink description, route -> subtext = route description | 457 // Sink 4 - sink description, route -> subtext = route description |
425 container.allSinks = [ | 458 container.allSinks = [ |
426 new media_router.Sink('sink id 1', 'Sink 1', null, null, | 459 new media_router.Sink('sink id 1', 'Sink 1', null, null, |
427 media_router.SinkIconType.CAST, | 460 media_router.SinkIconType.CAST, |
428 media_router.SinkStatus.ACTIVE, [1, 2, 3]), | 461 media_router.SinkStatus.ACTIVE, [1, 2, 3]), |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 }); | 539 }); |
507 | 540 |
508 // Tests for expected visible UI when the view is CAST_MODE_LIST. | 541 // Tests for expected visible UI when the view is CAST_MODE_LIST. |
509 test('cast mode list state visibility', function(done) { | 542 test('cast mode list state visibility', function(done) { |
510 container.showCastModeList_(); | 543 container.showCastModeList_(); |
511 setTimeout(function() { | 544 setTimeout(function() { |
512 checkElementsVisibleWithId(['cast-mode-list', | 545 checkElementsVisibleWithId(['cast-mode-list', |
513 'container-header', | 546 'container-header', |
514 'device-missing']); | 547 'device-missing']); |
515 | 548 |
516 // Sc.et a non-blocking issue. The issue should stay hidden. | 549 // Set a non-blocking issue. The issue should stay hidden. |
517 container.issue = fakeNonBlockingIssue; | 550 container.issue = fakeNonBlockingIssue; |
518 setTimeout(function() { | 551 setTimeout(function() { |
519 checkElementsVisibleWithId(['cast-mode-list', | 552 checkElementsVisibleWithId(['cast-mode-list', |
520 'container-header', | 553 'container-header', |
521 'device-missing']); | 554 'device-missing']); |
522 | 555 |
523 // Set a blocking issue. The issue should stay hidden. | 556 // Set a blocking issue. The issue should stay hidden. |
524 container.issue = fakeBlockingIssue; | 557 container.issue = fakeBlockingIssue; |
525 setTimeout(function() { | 558 setTimeout(function() { |
526 checkElementsVisibleWithId(['container-header', | 559 checkElementsVisibleWithId(['container-header', |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 }); | 981 }); |
949 }); | 982 }); |
950 }); | 983 }); |
951 }); | 984 }); |
952 } | 985 } |
953 | 986 |
954 return { | 987 return { |
955 registerTests: registerTests, | 988 registerTests: registerTests, |
956 }; | 989 }; |
957 }); | 990 }); |
OLD | NEW |