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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 * @type {!Array<!media_router.Route>} | 72 * @type {!Array<!media_router.Route>} |
73 */ | 73 */ |
74 var fakeRouteList = []; | 74 var fakeRouteList = []; |
75 | 75 |
76 /** | 76 /** |
77 * The list of available sinks. | 77 * The list of available sinks. |
78 * @type {!Array<!media_router.Sink>} | 78 * @type {!Array<!media_router.Sink>} |
79 */ | 79 */ |
80 var fakeSinkList = []; | 80 var fakeSinkList = []; |
81 | 81 |
| 82 // Mock the browser API. |
| 83 var overrideBrowserApi = function() { |
| 84 cr.define('media_router.browserApi', function() { |
| 85 'use strict'; |
| 86 |
| 87 function onMediaControllerClosed() { |
| 88 container.fire('mock-media-controller-closed'); |
| 89 } |
| 90 |
| 91 function onMediaControllerAvailable(routeId) { |
| 92 container.fire('mock-media-controller-available', |
| 93 {routeId: routeId}); |
| 94 } |
| 95 |
| 96 return { |
| 97 onMediaControllerClosed: onMediaControllerClosed, |
| 98 onMediaControllerAvailable: onMediaControllerAvailable, |
| 99 }; |
| 100 }); |
| 101 } |
| 102 |
82 // Import media_router_container.html before running suite. | 103 // Import media_router_container.html before running suite. |
83 suiteSetup(function() { | 104 suiteSetup(function() { |
84 return PolymerTest.importHtml( | 105 return PolymerTest.importHtml( |
85 'chrome://media-router/elements/media_router_container/' + | 106 'chrome://media-router/elements/media_router_container/' + |
86 'media_router_container.html'); | 107 'media_router_container.html'); |
87 }); | 108 }); |
88 | 109 |
89 setup(function(done) { | 110 setup(function(done) { |
90 PolymerTest.clearBody(); | 111 PolymerTest.clearBody(); |
91 // Initialize a media-router-container before each test. | 112 // Initialize a media-router-container before each test. |
92 container = document.createElement('media-router-container'); | 113 container = document.createElement('media-router-container'); |
93 document.body.appendChild(container); | 114 document.body.appendChild(container); |
| 115 overrideBrowserApi(); |
94 | 116 |
95 // Get common functions and variables. | 117 // Get common functions and variables. |
96 var test_base = media_router_container_test_base.init(container); | 118 var test_base = media_router_container_test_base.init(container); |
97 | 119 |
98 checkCurrentView = test_base.checkCurrentView; | 120 checkCurrentView = test_base.checkCurrentView; |
99 checkElementsVisibleWithId = test_base.checkElementsVisibleWithId; | 121 checkElementsVisibleWithId = test_base.checkElementsVisibleWithId; |
100 checkElementVisible = test_base.checkElementVisible; | 122 checkElementVisible = test_base.checkElementVisible; |
101 checkElementText = test_base.checkElementText; | 123 checkElementText = test_base.checkElementText; |
102 fakeBlockingIssue = test_base.fakeBlockingIssue; | 124 fakeBlockingIssue = test_base.fakeBlockingIssue; |
103 fakeCastModeList = test_base.fakeCastModeList; | 125 fakeCastModeList = test_base.fakeCastModeList; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 container.routeList = fakeRouteList; | 269 container.routeList = fakeRouteList; |
248 container.maybeShowRouteDetailsOnOpen(); | 270 container.maybeShowRouteDetailsOnOpen(); |
249 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS); | 271 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS); |
250 | 272 |
251 container.routeList = []; | 273 container.routeList = []; |
252 checkCurrentView(media_router.MediaRouterView.SINK_LIST); | 274 checkCurrentView(media_router.MediaRouterView.SINK_LIST); |
253 }); | 275 }); |
254 | 276 |
255 // Tests for expected visible UI when the view is ROUTE_DETAILS. | 277 // Tests for expected visible UI when the view is ROUTE_DETAILS. |
256 test('route details visibility', function(done) { | 278 test('route details visibility', function(done) { |
257 container.showRouteDetails_(); | 279 container.showRouteDetails_( |
| 280 new media_router.Route('id 3', 'sink id 3', 'Title 3', 0, true)); |
258 setTimeout(function() { | 281 setTimeout(function() { |
259 checkElementsVisibleWithId(['container-header', | 282 checkElementsVisibleWithId(['container-header', |
260 'device-missing', | 283 'device-missing', |
261 'route-details']); | 284 'route-details']); |
262 done(); | 285 done(); |
263 }); | 286 }); |
264 }); | 287 }); |
265 | 288 |
266 test('updated route in route details', function(done) { | 289 test('updated route in route details', function(done) { |
267 container.allSinks = fakeSinkList; | 290 container.allSinks = fakeSinkList; |
(...skipping 19 matching lines...) Expand all Loading... |
287 assertTrue(!!container.currentRoute_); | 310 assertTrue(!!container.currentRoute_); |
288 assertEquals(newDescription, container.currentRoute_.description); | 311 assertEquals(newDescription, container.currentRoute_.description); |
289 done(); | 312 done(); |
290 }); | 313 }); |
291 }); | 314 }); |
292 }); | 315 }); |
293 | 316 |
294 // Tests for expected visible UI when the view is ROUTE_DETAILS, and there | 317 // Tests for expected visible UI when the view is ROUTE_DETAILS, and there |
295 // is a non-blocking issue. | 318 // is a non-blocking issue. |
296 test('route details visibility non blocking issue', function(done) { | 319 test('route details visibility non blocking issue', function(done) { |
297 container.showRouteDetails_(); | 320 container.showRouteDetails_( |
| 321 new media_router.Route('id 3', 'sink id 3', 'Title 3', 0, true)); |
298 | 322 |
299 // Set a non-blocking issue. The issue should be shown. | 323 // Set a non-blocking issue. The issue should be shown. |
300 container.issue = fakeNonBlockingIssue; | 324 container.issue = fakeNonBlockingIssue; |
301 setTimeout(function() { | 325 setTimeout(function() { |
302 checkElementsVisibleWithId(['container-header', | 326 checkElementsVisibleWithId(['container-header', |
303 'device-missing', | 327 'device-missing', |
304 'route-details']); | 328 'route-details']); |
305 done(); | 329 done(); |
306 }); | 330 }); |
307 }); | 331 }); |
308 | 332 |
309 // Tests for expected visible UI when the view is ROUTE_DETAILS, and there | 333 // Tests for expected visible UI when the view is ROUTE_DETAILS, and there |
310 // is a blocking issue. | 334 // is a blocking issue. |
311 test('route details visibility with blocking issue', function(done) { | 335 test('route details visibility with blocking issue', function(done) { |
312 container.showRouteDetails_(); | 336 container.showRouteDetails_( |
| 337 new media_router.Route('id 3', 'sink id 3', 'Title 3', 0, true)); |
313 | 338 |
314 // Set a blocking issue. The issue should be shown, and everything | 339 // Set a blocking issue. The issue should be shown, and everything |
315 // else, hidden. | 340 // else, hidden. |
316 container.issue = fakeBlockingIssue; | 341 container.issue = fakeBlockingIssue; |
317 setTimeout(function() { | 342 setTimeout(function() { |
318 checkElementsVisibleWithId(['container-header', | 343 checkElementsVisibleWithId(['container-header', |
319 'device-missing', | 344 'device-missing', |
320 'issue-banner']); | 345 'issue-banner']); |
321 done(); | 346 done(); |
322 }); | 347 }); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 done(); | 534 done(); |
510 }); | 535 }); |
511 }); | 536 }); |
512 }); | 537 }); |
513 } | 538 } |
514 | 539 |
515 return { | 540 return { |
516 registerTests: registerTests, | 541 registerTests: registerTests, |
517 }; | 542 }; |
518 }); | 543 }); |
OLD | NEW |