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

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

Issue 2915983002: [Media Router] Add UMA metrics to record the load time for route controls (Closed)
Patch Set: Fix a test failure Created 3 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
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.
11 * @type {RouteDetails} 11 * @type {RouteDetails}
12 */ 12 */
13 var details; 13 var details;
14 14
15 /** 15 /**
16 * First fake route created before each test. 16 * First fake route created before each test.
17 * @type {media_router.Route} 17 * @type {media_router.Route}
18 */ 18 */
19 var fakeRouteOne; 19 var fakeRouteOne;
20 20
21 /** 21 /**
22 * The custom controller path for |fakeRouteOne|.
23 * @const @type {string}
24 */
25 var fakeRouteOneControllerPath =
26 'chrome-extension://123/custom_view.html';
27
28 /**
22 * Second fake route created before each test. 29 * Second fake route created before each test.
23 * @type {media_router.Route} 30 * @type {media_router.Route}
24 */ 31 */
25 var fakeRouteTwo; 32 var fakeRouteTwo;
26 33
27 /** 34 /**
28 * Fake sink that corresponds to |fakeRouteOne|. 35 * Fake sink that corresponds to |fakeRouteOne|.
29 * @type {media_router.Sink} 36 * @type {media_router.Sink}
30 */ 37 */
31 var fakeSinkOne; 38 var fakeSinkOne;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 }); 84 });
78 85
79 // Initialize a route-details before each test. 86 // Initialize a route-details before each test.
80 setup(function(done) { 87 setup(function(done) {
81 PolymerTest.clearBody(); 88 PolymerTest.clearBody();
82 details = document.createElement('route-details'); 89 details = document.createElement('route-details');
83 details.useWebUiRouteControls = false; 90 details.useWebUiRouteControls = false;
84 document.body.appendChild(details); 91 document.body.appendChild(details);
85 92
86 // Initialize routes and sinks. 93 // Initialize routes and sinks.
87 fakeRouteOne = new media_router.Route('route id 1', 'sink id 1', 94 fakeRouteOne = new media_router.Route(
88 'Video 1', 1, true, false, 95 'route id 1', 'sink id 1', 'Video 1', 1, true, false,
89 'chrome-extension://123/custom_view.html'); 96 fakeRouteOneControllerPath);
90 fakeRouteTwo = new media_router.Route('route id 2', 'sink id 2', 97 fakeRouteTwo = new media_router.Route('route id 2', 'sink id 2',
91 'Video 2', 2, false, true); 98 'Video 2', 2, false, true);
92 fakeSinkOne = new media_router.Sink( 99 fakeSinkOne = new media_router.Sink(
93 'sink id 1', 'sink 1', 'description', null, 100 'sink id 1', 'sink 1', 'description', null,
94 media_router.SinkIconType.CAST, media_router.SinkStatus.ACTIVE, 101 media_router.SinkIconType.CAST, media_router.SinkStatus.ACTIVE,
95 2 | 4); 102 2 | 4);
96 103
97 // Allow for the route details to be created and attached. 104 // Allow for the route details to be created and attached.
98 setTimeout(done); 105 setTimeout(done);
99 }); 106 });
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 fakeRouteTwo.description), 'route-information'); 205 fakeRouteTwo.description), 'route-information');
199 checkDefaultViewIsShown(); 206 checkDefaultViewIsShown();
200 checkStartCastButtonIsShown(); 207 checkStartCastButtonIsShown();
201 }); 208 });
202 209
203 // Tests when |route| exists, has a custom controller, and it loads. 210 // Tests when |route| exists, has a custom controller, and it loads.
204 test('route has custom controller and loading succeeds', function(done) { 211 test('route has custom controller and loading succeeds', function(done) {
205 details.$$('extension-view-wrapper').$$('#custom-controller').load = 212 details.$$('extension-view-wrapper').$$('#custom-controller').load =
206 function(url) { 213 function(url) {
207 setTimeout(function() { 214 setTimeout(function() {
208 assertEquals('chrome-extension://123/custom_view.html', url); 215 assertEquals(
216 fakeRouteOneControllerPath,
217 url.substring(0, fakeRouteOneControllerPath.length));
209 checkCustomControllerIsShown(); 218 checkCustomControllerIsShown();
210 done(); 219 done();
211 }); 220 });
212 return Promise.resolve(); 221 return Promise.resolve();
213 }; 222 };
214 223
215 details.route = fakeRouteOne; 224 details.route = fakeRouteOne;
216 }); 225 });
217 226
218 // Tests when |route| exists, has a custom controller, but fails to load. 227 // Tests when |route| exists, has a custom controller, but fails to load.
219 test('route has custom controller but loading fails', function(done) { 228 test('route has custom controller but loading fails', function(done) {
220 details.$$('extension-view-wrapper').$$('#custom-controller').load = 229 details.$$('extension-view-wrapper').$$('#custom-controller').load =
221 function(url) { 230 function(url) {
222 setTimeout(function() { 231 setTimeout(function() {
223 checkDefaultViewIsShown(); 232 checkDefaultViewIsShown();
224 done(); 233 done();
225 }); 234 });
226 return Promise.reject(); 235 return Promise.reject();
227 }; 236 };
228 237
229 details.route = fakeRouteOne; 238 details.route = fakeRouteOne;
230 }); 239 });
231 }); 240 });
232 } 241 }
233 242
234 return { 243 return {
235 registerTests: registerTests, 244 registerTests: registerTests,
236 }; 245 };
237 }); 246 });
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/media_router/media_router_webui_message_handler.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698