Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: chrome/test/data/webui/media_router/media_router_container_route_tests.js

Issue 1880283004: [Media Router WebUI] Put sink list in conditional template. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 setTimeout(done); 102 setTimeout(done);
103 }); 103 });
104 104
105 // Tests for 'create-route' event firing when a sink with no associated 105 // Tests for 'create-route' event firing when a sink with no associated
106 // route is clicked. 106 // route is clicked.
107 test('select sink without a route', function(done) { 107 test('select sink without a route', function(done) {
108 container.allSinks = fakeSinkList; 108 container.allSinks = fakeSinkList;
109 109
110 setTimeout(function() { 110 setTimeout(function() {
111 var sinkList = 111 var sinkList =
112 container.$['sink-list'].querySelectorAll('paper-item'); 112 container.shadowRoot.getElementById('sink-list')
113 .querySelectorAll('paper-item');
113 container.addEventListener('create-route', function(data) { 114 container.addEventListener('create-route', function(data) {
114 // Container is initially in auto mode since a cast mode has not 115 // Container is initially in auto mode since a cast mode has not
115 // been selected. 116 // been selected.
116 assertEquals(media_router.CastModeType.AUTO, 117 assertEquals(media_router.CastModeType.AUTO,
117 container.shownCastModeValue_); 118 container.shownCastModeValue_);
118 assertEquals(fakeSinkList[2].id, data.detail.sinkId); 119 assertEquals(fakeSinkList[2].id, data.detail.sinkId);
119 120
120 // The preferred compatible cast mode on the sink is used, since 121 // The preferred compatible cast mode on the sink is used, since
121 // the we did not choose a cast mode on the container. 122 // the we did not choose a cast mode on the container.
122 assertEquals(0x2, data.detail.selectedCastModeValue); 123 assertEquals(0x2, data.detail.selectedCastModeValue);
123 done(); 124 done();
124 }); 125 });
125 // Tap on a sink without a route, which should fire a 'create-route' 126 // Tap on a sink without a route, which should fire a 'create-route'
126 // event. 127 // event.
127 assertEquals(fakeSinkList.length, sinkList.length); 128 assertEquals(fakeSinkList.length, sinkList.length);
128 MockInteractions.tap(sinkList[2]); 129 MockInteractions.tap(sinkList[2]);
129 }); 130 });
130 }); 131 });
131 132
132 // Tests that selecting a sink with an associated route will make the 133 // Tests that selecting a sink with an associated route will make the
133 // |container| switch to ROUTE_DETAILS view. 134 // |container| switch to ROUTE_DETAILS view.
134 test('select sink with a route', function(done) { 135 test('select sink with a route', function(done) {
135 container.allSinks = fakeSinkList; 136 container.allSinks = fakeSinkList;
136 container.routeList = fakeRouteList; 137 container.routeList = fakeRouteList;
137 138
138 setTimeout(function() { 139 setTimeout(function() {
139 var sinkList = 140 var sinkList =
140 container.$['sink-list'].querySelectorAll('paper-item'); 141 container.shadowRoot.getElementById('sink-list')
142 .querySelectorAll('paper-item');
141 143
142 // Start from the SINK_LIST view. 144 // Start from the SINK_LIST view.
143 container.showSinkList_(); 145 container.showSinkList_();
144 checkCurrentView(media_router.MediaRouterView.SINK_LIST); 146 checkCurrentView(media_router.MediaRouterView.SINK_LIST);
145 MockInteractions.tap(sinkList[0]); 147 MockInteractions.tap(sinkList[0]);
146 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS); 148 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS);
147 done(); 149 done();
148 }); 150 });
149 }); 151 });
150 152
(...skipping 20 matching lines...) Expand all
171 media_router.SinkStatus.PENDING, [1, 2, 3]) 173 media_router.SinkStatus.PENDING, [1, 2, 3])
172 ]; 174 ];
173 175
174 container.routeList = [ 176 container.routeList = [
175 new media_router.Route('id 3', 'sink id 3', 'Title 3', 0, true), 177 new media_router.Route('id 3', 'sink id 3', 'Title 3', 0, true),
176 new media_router.Route('id 4', 'sink id 4', 'Title 4', 1, false), 178 new media_router.Route('id 4', 'sink id 4', 'Title 4', 1, false),
177 ]; 179 ];
178 180
179 setTimeout(function() { 181 setTimeout(function() {
180 var sinkSubtextList = 182 var sinkSubtextList =
181 container.$['sink-list'].querySelectorAll('.sink-subtext'); 183 container.shadowRoot.getElementById('sink-list')
184 .querySelectorAll('.sink-subtext');
182 185
183 // There will only be 3 sink subtext entries, because Sink 1 does not 186 // There will only be 3 sink subtext entries, because Sink 1 does not
184 // have any subtext. 187 // have any subtext.
185 assertEquals(3, sinkSubtextList.length); 188 assertEquals(3, sinkSubtextList.length);
186 189
187 checkElementText(container.allSinks[1].description, 190 checkElementText(container.allSinks[1].description,
188 sinkSubtextList[0]); 191 sinkSubtextList[0]);
189 192
190 // Route description overrides sink description for subtext. 193 // Route description overrides sink description for subtext.
191 checkElementText(container.routeList[0].description, 194 checkElementText(container.routeList[0].description,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 MockInteractions.tap(container.$['container-header']. 315 MockInteractions.tap(container.$['container-header'].
313 $['arrow-drop-icon']); 316 $['arrow-drop-icon']);
314 setTimeout(function() { 317 setTimeout(function() {
315 // Select cast mode 2. 318 // Select cast mode 2.
316 var castModeList = 319 var castModeList =
317 container.$$('#cast-mode-list').querySelectorAll('paper-item'); 320 container.$$('#cast-mode-list').querySelectorAll('paper-item');
318 MockInteractions.tap(castModeList[1]); 321 MockInteractions.tap(castModeList[1]);
319 assertEquals(fakeCastModeList[1].description, container.headerText); 322 assertEquals(fakeCastModeList[1].description, container.headerText);
320 setTimeout(function() { 323 setTimeout(function() {
321 var sinkList = 324 var sinkList =
322 container.$['sink-list'].querySelectorAll('paper-item'); 325 container.shadowRoot.getElementById('sink-list')
326 .querySelectorAll('paper-item');
323 container.addEventListener('create-route', function(data) { 327 container.addEventListener('create-route', function(data) {
324 assertEquals(fakeSinkList[2].id, data.detail.sinkId); 328 assertEquals(fakeSinkList[2].id, data.detail.sinkId);
325 // Cast mode 2 is used, since we selected it explicitly. 329 // Cast mode 2 is used, since we selected it explicitly.
326 assertEquals(fakeCastModeList[1].type, 330 assertEquals(fakeCastModeList[1].type,
327 data.detail.selectedCastModeValue); 331 data.detail.selectedCastModeValue);
328 done(); 332 done();
329 }); 333 });
330 // All sinks are compatible with cast mode 2. 334 // All sinks are compatible with cast mode 2.
331 assertEquals(fakeSinkList.length, sinkList.length); 335 assertEquals(fakeSinkList.length, sinkList.length);
332 // Tap on a sink without a route, which should fire a 'create-route' 336 // Tap on a sink without a route, which should fire a 'create-route'
333 // event. 337 // event.
334 MockInteractions.tap(sinkList[2]); 338 MockInteractions.tap(sinkList[2]);
335 }); 339 });
336 }); 340 });
337 }); 341 });
338 }); 342 });
339 } 343 }
340 344
341 return { 345 return {
342 registerTests: registerTests, 346 registerTests: registerTests,
343 }; 347 };
344 }); 348 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698