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 * the MRPM search feature. | 6 * the MRPM search feature. |
7 */ | 7 */ |
8 cr.define('media_router_container_search', function() { | 8 cr.define('media_router_container_search', function() { |
9 function registerTests() { | 9 function registerTests() { |
10 suite('MediaRouterContainerSearch', function() { | 10 suite('MediaRouterContainerSearch', function() { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 * @type {!Array<!media_router.Sink>} | 112 * @type {!Array<!media_router.Sink>} |
113 */ | 113 */ |
114 var fakeSinkListWithPseudoSink = []; | 114 var fakeSinkListWithPseudoSink = []; |
115 | 115 |
116 /** | 116 /** |
117 * Sink returned by search. | 117 * Sink returned by search. |
118 * @type {media_router.Sink} | 118 * @type {media_router.Sink} |
119 */ | 119 */ |
120 var foundSink = null; | 120 var foundSink = null; |
121 | 121 |
122 // Mock the browser API. | |
123 var overrideBrowserApi = function() { | |
124 cr.define('media_router.browserApi', function() { | |
imcheng
2017/05/05 21:36:41
Can this go in media_router_elements_browsertest.j
takumif
2017/05/09 00:14:57
This methods needs the Polymer method to fire even
| |
125 'use strict'; | |
126 | |
127 function onMediaControllerClosed() { | |
128 container.fire('mock-media-controller-closed'); | |
129 } | |
130 | |
131 function onMediaControllerAvailable(routeId) { | |
132 container.fire('mock-media-controller-available', | |
133 {routeId: routeId}); | |
134 } | |
135 | |
136 return { | |
137 onMediaControllerClosed: onMediaControllerClosed, | |
138 onMediaControllerAvailable: onMediaControllerAvailable, | |
139 }; | |
140 }); | |
141 } | |
142 | |
122 /** | 143 /** |
123 * Example pseudo sink. | 144 * Example pseudo sink. |
124 * @type {media_router.Sink} | 145 * @type {media_router.Sink} |
125 */ | 146 */ |
126 var pseudoSink = null; | 147 var pseudoSink = null; |
127 | 148 |
128 // Import media_router_container.html before running suite. | 149 // Import media_router_container.html before running suite. |
129 suiteSetup(function() { | 150 suiteSetup(function() { |
130 return PolymerTest.importHtml( | 151 return PolymerTest.importHtml( |
131 'chrome://media-router/elements/media_router_container/' + | 152 'chrome://media-router/elements/media_router_container/' + |
132 'media_router_container.html'); | 153 'media_router_container.html'); |
133 }); | 154 }); |
134 | 155 |
135 setup(function(done) { | 156 setup(function(done) { |
136 PolymerTest.clearBody(); | 157 PolymerTest.clearBody(); |
137 // Initialize a media-router-container before each test. | 158 // Initialize a media-router-container before each test. |
138 container = document.createElement('media-router-container'); | 159 container = document.createElement('media-router-container'); |
139 document.body.appendChild(container); | 160 document.body.appendChild(container); |
161 overrideBrowserApi(container); | |
140 | 162 |
141 // Get common functions and variables. | 163 // Get common functions and variables. |
142 var test_base = media_router_container_test_base.init(container); | 164 var test_base = media_router_container_test_base.init(container); |
143 | 165 |
144 checkCurrentView = test_base.checkCurrentView; | 166 checkCurrentView = test_base.checkCurrentView; |
145 fakeSinkList = test_base.fakeSinkList; | 167 fakeSinkList = test_base.fakeSinkList; |
146 | 168 |
147 pseudoSink = new media_router.Sink( | 169 pseudoSink = new media_router.Sink( |
148 'pseudo:test', '', null, 'domain.com', | 170 'pseudo:test', '', null, 'domain.com', |
149 media_router.SinkIconType.CAST, undefined, | 171 media_router.SinkIconType.CAST, undefined, |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 searchState.checkForRealSink(fakeSinkList.concat([foundSink]))); | 469 searchState.checkForRealSink(fakeSinkList.concat([foundSink]))); |
448 assertEquals(foundSink.id, searchState.checkForRealSink(fakeSinkList)); | 470 assertEquals(foundSink.id, searchState.checkForRealSink(fakeSinkList)); |
449 }); | 471 }); |
450 }); | 472 }); |
451 } | 473 } |
452 | 474 |
453 return { | 475 return { |
454 registerTests: registerTests, | 476 registerTests: registerTests, |
455 }; | 477 }; |
456 }); | 478 }); |
OLD | NEW |