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

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

Issue 2068593002: [Media Router] Assign each route a current cast mode if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
« no previous file with comments | « chrome/test/data/webui/media_router/media_router_container_test_base.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 route-details. */ 5 /** @fileoverview Suite of tests for route-details. */
6 cr.define('route_details', function() { 6 cr.define('route_details', function() {
7 function registerTests() { 7 function registerTests() {
8 suite('RouteDetails', function() { 8 suite('RouteDetails', function() {
9 /** 9 /**
10 * Route Details created before each test. 10 * Route Details created before each test.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 assertTrue(details.$['route-information'].hasAttribute('hidden')); 54 assertTrue(details.$['route-information'].hasAttribute('hidden'));
55 assertFalse(details.$['custom-controller'].hasAttribute('hidden')); 55 assertFalse(details.$['custom-controller'].hasAttribute('hidden'));
56 }; 56 };
57 57
58 // Checks whether |expected| and the text in the |elementId| element 58 // Checks whether |expected| and the text in the |elementId| element
59 // are equal given an id. 59 // are equal given an id.
60 var checkElementTextWithId = function(expected, elementId) { 60 var checkElementTextWithId = function(expected, elementId) {
61 assertEquals(expected, details.$[elementId].innerText); 61 assertEquals(expected, details.$[elementId].innerText);
62 }; 62 };
63 63
64 /**
65 * Fake sink that corresponds to |fakeRouteOne|.
66 * @type {media_router.Sink}
67 */
68 var fakeSinkOne;
69
64 // Import route_details.html before running suite. 70 // Import route_details.html before running suite.
65 suiteSetup(function() { 71 suiteSetup(function() {
66 return PolymerTest.importHtml( 72 return PolymerTest.importHtml(
67 'chrome://media-router/elements/route_details/' + 73 'chrome://media-router/elements/route_details/' +
68 'route_details.html'); 74 'route_details.html');
69 }); 75 });
70 76
71 // Initialize a route-details before each test. 77 // Initialize a route-details before each test.
72 setup(function(done) { 78 setup(function(done) {
73 PolymerTest.clearBody(); 79 PolymerTest.clearBody();
74 details = document.createElement('route-details'); 80 details = document.createElement('route-details');
75 document.body.appendChild(details); 81 document.body.appendChild(details);
76 82
77 // Initialize routes and sinks. 83 // Initialize routes and sinks.
78 fakeRouteOne = new media_router.Route('route id 1', 'sink id 1', 84 fakeRouteOne = new media_router.Route('route id 1', 'sink id 1',
79 'Video 1', 1, true, false, 85 'Video 1', 1, true, false,
80 'chrome-extension://123/custom_view.html'); 86 'chrome-extension://123/custom_view.html');
81 fakeRouteTwo = new media_router.Route('route id 2', 'sink id 2', 87 fakeRouteTwo = new media_router.Route('route id 2', 'sink id 2',
82 'Video 2', 2, false, true); 88 'Video 2', 2, false, true);
89 fakeSinkOne = new media_router.Sink(
90 'sink id 1', 'sink 1', 'description', null,
91 media_router.SinkIconType.CAST, media_router.SinkStatus.ACTIVE,
92 2 | 4);
83 93
84 // Allow for the route details to be created and attached. 94 // Allow for the route details to be created and attached.
85 setTimeout(done); 95 setTimeout(done);
86 }); 96 });
87 97
88 // Tests that the cast button is shown under the correct circumstances and 98 // Tests that the cast button is shown under the correct circumstances and
89 // that updating |replaceRouteAvailable| updates the cast button 99 // that updating |replaceRouteAvailable| updates the cast button
90 // visibility. 100 // visibility.
91 test('cast button visibility', function() { 101 test('cast button visibility', function() {
92 details.route = fakeRouteTwo; 102 details.route = fakeRouteTwo;
93 checkStartCastButtonIsShown(); 103 checkStartCastButtonIsShown();
94 104
95 details.availableCastModes = 1;
96 details.replaceRouteAvailable = false;
97 details.route = fakeRouteOne; 105 details.route = fakeRouteOne;
98 checkStartCastButtonIsNotShown(); 106 checkStartCastButtonIsNotShown();
99 107
100 details.replaceRouteAvailable = true; 108 details.sink = fakeSinkOne;
109 checkStartCastButtonIsShown();
110
111 // Retrigger observer because it's not necessary for it to watch
112 // |route.currentCastMode| in general.
113 fakeRouteOne.currentCastMode = 2;
114 details.route = null;
115 details.route = fakeRouteOne;
116 checkStartCastButtonIsNotShown();
117
118 // Simulate user changing cast modes to be compatible or incompatible
119 // with the route's sink.
120 details.shownCastModeValue = 4;
121 checkStartCastButtonIsShown();
122
123 details.shownCastModeValue = 1;
124 checkStartCastButtonIsNotShown();
125
126 details.shownCastModeValue = 4;
127 checkStartCastButtonIsShown();
128
129 // Cast button should be hidden while another sink is launching.
130 details.isAnySinkCurrentlyLaunching = true;
131 checkStartCastButtonIsNotShown();
132
133 details.isAnySinkCurrentlyLaunching = false;
101 checkStartCastButtonIsShown(); 134 checkStartCastButtonIsShown();
102 }); 135 });
103 136
104 // Tests for 'close-route-click' event firing when the 137 // Tests for 'close-route-click' event firing when the
105 // 'close-route-button' button is clicked. 138 // 'close-route-button' button is clicked.
106 test('close route button click', function(done) { 139 test('close route button click', function(done) {
107 details.addEventListener('close-route', function() { 140 details.addEventListener('close-route', function() {
108 done(); 141 done();
109 }); 142 });
110 MockInteractions.tap(details.$['close-route-button']); 143 MockInteractions.tap(details.$['close-route-button']);
(...skipping 27 matching lines...) Expand all
138 checkSpanText( 171 checkSpanText(
139 loadTimeData.getString('startCastingButtonText').toUpperCase(), 172 loadTimeData.getString('startCastingButtonText').toUpperCase(),
140 'start-casting-to-route-button'); 173 'start-casting-to-route-button');
141 checkSpanText('', 'route-information'); 174 checkSpanText('', 'route-information');
142 }); 175 });
143 176
144 // Tests when |route| is undefined or set. 177 // Tests when |route| is undefined or set.
145 test('route is undefined or set', function() { 178 test('route is undefined or set', function() {
146 // |route| is initially undefined. 179 // |route| is initially undefined.
147 assertEquals(undefined, details.route); 180 assertEquals(undefined, details.route);
148 assertEquals(0, details.availableCastModes);
149 checkDefaultViewIsShown(); 181 checkDefaultViewIsShown();
150 182
151 // Set |route|. 183 // Set |route|.
152 details.route = fakeRouteOne; 184 details.route = fakeRouteOne;
153 assertEquals(fakeRouteOne, details.route); 185 assertEquals(fakeRouteOne, details.route);
154 checkSpanText(loadTimeData.getStringF('castingActivityStatus', 186 checkSpanText(loadTimeData.getStringF('castingActivityStatus',
155 fakeRouteOne.description), 'route-information'); 187 fakeRouteOne.description), 'route-information');
156 checkDefaultViewIsShown(); 188 checkDefaultViewIsShown();
157 checkStartCastButtonIsNotShown(); 189 checkStartCastButtonIsNotShown();
158 190
159 // Set |route| to a different route. 191 // Set |route| to a different route.
160 details.route = fakeRouteTwo; 192 details.route = fakeRouteTwo;
161 assertEquals(fakeRouteTwo, details.route); 193 assertEquals(fakeRouteTwo, details.route);
162 checkSpanText(loadTimeData.getStringF('castingActivityStatus', 194 checkSpanText(loadTimeData.getStringF('castingActivityStatus',
163 fakeRouteTwo.description), 'route-information'); 195 fakeRouteTwo.description), 'route-information');
164 checkDefaultViewIsShown(); 196 checkDefaultViewIsShown();
165 checkStartCastButtonIsShown(); 197 checkStartCastButtonIsShown();
166 }); 198 });
167 199
168 // Tests when |availableCastModes| is undefined or set.
169 test('route available cast modes undefined or set', function() {
170 details.route = fakeRouteOne;
171 assertEquals(0, details.availableCastModes);
172 assertFalse(details.route.canJoin);
173 checkStartCastButtonIsNotShown();
174
175 details.availableCastModes = 1;
176 checkStartCastButtonIsShown();
177
178 details.availableCastModes = 2;
179 checkStartCastButtonIsShown();
180
181 details.availableCastModes = 3;
182 checkStartCastButtonIsShown();
183 });
184
185 // Tests when |route| exists, has a custom controller, and it loads. 200 // Tests when |route| exists, has a custom controller, and it loads.
186 test('route has custom controller and loading succeeds', function(done) { 201 test('route has custom controller and loading succeeds', function(done) {
187 var loadInvoked = false; 202 var loadInvoked = false;
188 details.$['custom-controller'].load = function(url) { 203 details.$['custom-controller'].load = function(url) {
189 loadInvoked = true; 204 loadInvoked = true;
190 assertEquals('chrome-extension://123/custom_view.html', url); 205 assertEquals('chrome-extension://123/custom_view.html', url);
191 return Promise.resolve(); 206 return Promise.resolve();
192 }; 207 };
193 208
194 details.route = fakeRouteOne; 209 details.route = fakeRouteOne;
(...skipping 19 matching lines...) Expand all
214 done(); 229 done();
215 }); 230 });
216 }); 231 });
217 }); 232 });
218 } 233 }
219 234
220 return { 235 return {
221 registerTests: registerTests, 236 registerTests: registerTests,
222 }; 237 };
223 }); 238 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/media_router/media_router_container_test_base.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698