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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 * @type {?media_router.Issue} | 62 * @type {?media_router.Issue} |
63 */ | 63 */ |
64 var fakeNonBlockingIssue; | 64 var fakeNonBlockingIssue; |
65 | 65 |
66 /** | 66 /** |
67 * The list of available sinks. | 67 * The list of available sinks. |
68 * @type {!Array<!media_router.Sink>} | 68 * @type {!Array<!media_router.Sink>} |
69 */ | 69 */ |
70 var fakeSinkList = []; | 70 var fakeSinkList = []; |
71 | 71 |
| 72 // Mock the browser API. |
| 73 var overrideBrowserApi = function() { |
| 74 cr.define('media_router.browserApi', function() { |
| 75 'use strict'; |
| 76 |
| 77 function onMediaControllerClosed() { |
| 78 container.fire('mock-media-controller-closed'); |
| 79 } |
| 80 |
| 81 function onMediaControllerAvailable(routeId) { |
| 82 container.fire('mock-media-controller-available', |
| 83 {routeId: routeId}); |
| 84 } |
| 85 |
| 86 return { |
| 87 onMediaControllerClosed: onMediaControllerClosed, |
| 88 onMediaControllerAvailable: onMediaControllerAvailable, |
| 89 }; |
| 90 }); |
| 91 } |
| 92 |
72 // Import media_router_container.html before running suite. | 93 // Import media_router_container.html before running suite. |
73 suiteSetup(function() { | 94 suiteSetup(function() { |
74 return PolymerTest.importHtml( | 95 return PolymerTest.importHtml( |
75 'chrome://media-router/elements/media_router_container/' + | 96 'chrome://media-router/elements/media_router_container/' + |
76 'media_router_container.html'); | 97 'media_router_container.html'); |
77 }); | 98 }); |
78 | 99 |
79 setup(function(done) { | 100 setup(function(done) { |
80 PolymerTest.clearBody(); | 101 PolymerTest.clearBody(); |
81 // Initialize a media-router-container before each test. | 102 // Initialize a media-router-container before each test. |
82 container = document.createElement('media-router-container'); | 103 container = document.createElement('media-router-container'); |
83 document.body.appendChild(container); | 104 document.body.appendChild(container); |
| 105 overrideBrowserApi(); |
84 | 106 |
85 // Get common functions and variables. | 107 // Get common functions and variables. |
86 var test_base = media_router_container_test_base.init(container); | 108 var test_base = media_router_container_test_base.init(container); |
87 | 109 |
88 checkCurrentView = test_base.checkCurrentView; | 110 checkCurrentView = test_base.checkCurrentView; |
89 checkElementsVisibleWithId = test_base.checkElementsVisibleWithId; | 111 checkElementsVisibleWithId = test_base.checkElementsVisibleWithId; |
90 checkElementText = test_base.checkElementText; | 112 checkElementText = test_base.checkElementText; |
91 fakeBlockingIssue = test_base.fakeBlockingIssue; | 113 fakeBlockingIssue = test_base.fakeBlockingIssue; |
92 fakeCastModeList = test_base.fakeCastModeList; | 114 fakeCastModeList = test_base.fakeCastModeList; |
93 fakeCastModeListWithNonDefaultModesOnly = | 115 fakeCastModeListWithNonDefaultModesOnly = |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 }); | 470 }); |
449 }); | 471 }); |
450 }); | 472 }); |
451 }); | 473 }); |
452 } | 474 } |
453 | 475 |
454 return { | 476 return { |
455 registerTests: registerTests, | 477 registerTests: registerTests, |
456 }; | 478 }; |
457 }); | 479 }); |
OLD | NEW |