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

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

Issue 1754713005: [Media Router] Animate transition between sink list and filter views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for apacible's perf change Created 4 years, 7 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_filter_tests.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 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() {
11 /**
12 * Wrapper that lets a function |f| run after the container animation
13 * promise completes but also lets any UI logic run before setting up the
14 * call. This is important because |container.animationPromise_| may not
15 * exist until the UI logic runs or it may be updated to a new Promise.
16 * This wrapper also carries assertion errors (and any other exceptions)
17 * outside of the promise back into the test since throwing in a then() or
18 * catch() doesn't stop the test.
19 *
20 * @param {function()} f
21 */
22 var chainOnAnimationPromise = function(f) {
23 setTimeout(function() {
24 container.animationPromise_.then(f).catch(function(err) {
25 setTimeout(function() { throw err; });
26 });
27 });
28 };
11 29
12 /** 30 /**
13 * Checks whether |view| matches the current view of |container|. 31 * Checks whether |view| matches the current view of |container|.
14 * 32 *
15 * @param {!media_router.MediaRouterView} view Expected view type. 33 * @param {!media_router.MediaRouterView} view Expected view type.
16 */ 34 */
17 var checkCurrentView; 35 var checkCurrentView;
18 36
19 /** 37 /**
20 * Checks whether an element is visible. An element is visible if it 38 * Checks whether an element is visible. An element is visible if it
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 var checkNoCreateRoute = function() { 358 var checkNoCreateRoute = function() {
341 assertTrue(false); 359 assertTrue(false);
342 }; 360 };
343 var route = new media_router.Route( 361 var route = new media_router.Route(
344 'id 1', foundSink.id, 'Title 1', 0, true, false); 362 'id 1', foundSink.id, 'Title 1', 0, true, false);
345 container.allSinks = fakeSinkListWithPseudoSink; 363 container.allSinks = fakeSinkListWithPseudoSink;
346 container.addEventListener('create-route', checkNoCreateRoute); 364 container.addEventListener('create-route', checkNoCreateRoute);
347 365
348 var searchInput = container.$['sink-search-input']; 366 var searchInput = container.$['sink-search-input'];
349 searchInput.value = foundSink.name; 367 searchInput.value = foundSink.name;
350 setTimeout(function() { 368 chainOnAnimationPromise(function() {
351 var searchResults = 369 var searchResults =
352 container.$$('#search-results').querySelectorAll('paper-item'); 370 container.$$('#search-results').querySelectorAll('paper-item');
353 MockInteractions.tap(searchResults[0]); 371 MockInteractions.tap(searchResults[0]);
354 MockInteractions.tap( 372 MockInteractions.tap(
355 container.$['container-header'].$$('#back-button')); 373 container.$['container-header'].$$('#back-button'));
356 setTimeout(function() { 374 chainOnAnimationPromise(function() {
357 var sinkList = 375 var sinkList =
358 container.$$('#sink-list').querySelectorAll('paper-item'); 376 container.$$('#sink-list').querySelectorAll('paper-item');
359 sinkList = [...sinkList]; 377 sinkList = [...sinkList];
360 var sink = sinkList.find(function(sink) { 378 var sink = sinkList.find(function(sink) {
361 var item = container.$$('#sinkList').itemForElement(sink); 379 var item = container.$$('#sinkList').itemForElement(sink);
362 return fakeSinkList[0].id == item.id; 380 return fakeSinkList[0].id == item.id;
363 }); 381 });
364 MockInteractions.tap(sink); 382 MockInteractions.tap(sink);
365 container.allSinks = fakeSinkListWithPseudoSink.concat([foundSink]); 383 container.allSinks = fakeSinkListWithPseudoSink.concat([foundSink]);
366 setTimeout(function() { 384 chainOnAnimationPromise(function() {
367 container.onReceiveSearchResult(foundSink.id); 385 container.onReceiveSearchResult(foundSink.id);
368 MockInteractions.tap(sink); 386 MockInteractions.tap(sink);
369 container.onCreateRouteResponseReceived( 387 container.onCreateRouteResponseReceived(
370 pseudoSink.id, route, true); 388 pseudoSink.id, route, true);
371 setTimeout(function() { 389 chainOnAnimationPromise(function() {
372 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS); 390 checkCurrentView(media_router.MediaRouterView.ROUTE_DETAILS);
373 MockInteractions.tap( 391 MockInteractions.tap(
374 container.$['container-header'].$$('#back-button')); 392 container.$['container-header'].$$('#back-button'));
375 container.removeEventListener( 393 container.removeEventListener(
376 'create-route', checkNoCreateRoute); 394 'create-route', checkNoCreateRoute);
377 container.addEventListener('create-route', checkCreateRoute); 395 container.addEventListener('create-route', checkCreateRoute);
378 setTimeout(function() { 396 chainOnAnimationPromise(function() {
379 checkCurrentView(media_router.MediaRouterView.SINK_LIST); 397 checkCurrentView(media_router.MediaRouterView.SINK_LIST);
380 MockInteractions.tap(sink); 398 MockInteractions.tap(sink);
381 }); 399 });
382 }); 400 });
383 }); 401 });
384 }); 402 });
385 }); 403 });
386 }); 404 });
387 405
388 test('route creation failure clears spinner and search', function(done) { 406 test('route creation failure clears spinner and search', function(done) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 assertEquals(someId, searchState.mapRouteSinkId(someId)); 471 assertEquals(someId, searchState.mapRouteSinkId(someId));
454 assertEquals(foundSink.id, searchState.mapRouteSinkId(pseudoSink.id)); 472 assertEquals(foundSink.id, searchState.mapRouteSinkId(pseudoSink.id));
455 }); 473 });
456 }); 474 });
457 } 475 }
458 476
459 return { 477 return {
460 registerTests: registerTests, 478 registerTests: registerTests,
461 }; 479 };
462 }); 480 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/media_router/media_router_container_filter_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698