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

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

Issue 2932933002: [Media Router] Increment the media's current_time in the WebUI route controller (Closed)
Patch Set: Check that we can increment in onRouteStatusChange_() 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
« no previous file with comments | « chrome/common/media_router/mojo/media_status_struct_traits.cc ('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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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-controls. */ 5 /** @fileoverview Suite of tests for route-controls. */
6 cr.define('route_controls', function() { 6 cr.define('route_controls', function() {
7 function registerTests() { 7 function registerTests() {
8 suite('RouteControls', function() { 8 suite('RouteControls', function() {
9 /** 9 /**
10 * Route Controls created before each test. 10 * Route Controls created before each test.
(...skipping 29 matching lines...) Expand all
40 assertFalse(isElementShown(elementId)); 40 assertFalse(isElementShown(elementId));
41 }; 41 };
42 42
43 // Creates an instance of RouteStatus with the given parameters. If a 43 // Creates an instance of RouteStatus with the given parameters. If a
44 // parameter is not set, it defaults to an empty string, zero, or false. 44 // parameter is not set, it defaults to an empty string, zero, or false.
45 var createRouteStatus = function(params = {}) { 45 var createRouteStatus = function(params = {}) {
46 return new media_router.RouteStatus( 46 return new media_router.RouteStatus(
47 params.title ? params.title : '', 47 params.title ? params.title : '',
48 params.status ? params.status : '', !!params.canPlayPause, 48 params.status ? params.status : '', !!params.canPlayPause,
49 !!params.canMute, !!params.canSetVolume, !!params.canSeek, 49 !!params.canMute, !!params.canSetVolume, !!params.canSeek,
50 params.playState ? params.playState :
51 media_router.PlayState.PLAYING,
50 !!params.isPaused, !!params.isMuted, 52 !!params.isPaused, !!params.isMuted,
51 params.volume ? params.volume : 0, 53 params.volume ? params.volume : 0,
52 params.duration ? params.duration : 0, 54 params.duration ? params.duration : 0,
53 params.currentTime ? params.currentTime : 0); 55 params.currentTime ? params.currentTime : 0);
54 }; 56 };
55 57
56 // Import route_controls.html before running suite. 58 // Import route_controls.html before running suite.
57 suiteSetup(function() { 59 suiteSetup(function() {
58 return PolymerTest.importHtml( 60 return PolymerTest.importHtml(
59 'chrome://media-router/elements/route_controls/' + 61 'chrome://media-router/elements/route_controls/' +
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 assertElementShown('route-volume-button'); 133 assertElementShown('route-volume-button');
132 assertElementShown('route-volume-slider'); 134 assertElementShown('route-volume-slider');
133 }); 135 });
134 136
135 // Tests that the play button sends a command to the browser API. 137 // Tests that the play button sends a command to the browser API.
136 test('send play command', function(done) { 138 test('send play command', function(done) {
137 document.addEventListener('mock-play-current-media', function(data) { 139 document.addEventListener('mock-play-current-media', function(data) {
138 done(); 140 done();
139 }); 141 });
140 142
141 controls.routeStatus = 143 controls.routeStatus = createRouteStatus(
142 createRouteStatus({canPlayPause: true, isPaused: true}); 144 {canPlayPause: true, playState: media_router.PlayState.PAUSED});
143 MockInteractions.tap(controls.$$('#route-play-pause-button')); 145 MockInteractions.tap(controls.$$('#route-play-pause-button'));
144 }); 146 });
145 147
146 // Tests that the pause button sends a command to the browser API. 148 // Tests that the pause button sends a command to the browser API.
147 test('send pause command', function(done) { 149 test('send pause command', function(done) {
148 document.addEventListener('mock-pause-current-media', function(data) { 150 document.addEventListener('mock-pause-current-media', function(data) {
149 done(); 151 done();
150 }); 152 });
151 153
152 controls.routeStatus = 154 controls.routeStatus = createRouteStatus(
153 createRouteStatus({canPlayPause: true, isPaused: false}); 155 {canPlayPause: true, playState: media_router.PlayState.PLAYING});
154 MockInteractions.tap(controls.$$('#route-play-pause-button')); 156 MockInteractions.tap(controls.$$('#route-play-pause-button'));
155 }); 157 });
156 158
157 // Tests that the mute button sends a command to the browser API. 159 // Tests that the mute button sends a command to the browser API.
158 test('send mute command', function(done) { 160 test('send mute command', function(done) {
159 function waitForMuteEvent(data) { 161 function waitForMuteEvent(data) {
160 // Remove the event listener to avoid interfering with other tests. 162 // Remove the event listener to avoid interfering with other tests.
161 document.removeEventListener( 163 document.removeEventListener(
162 'mock-set-current-media-mute', waitForMuteEvent); 164 'mock-set-current-media-mute', waitForMuteEvent);
163 if (data.detail.mute) { 165 if (data.detail.mute) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 233 }
232 }); 234 });
233 235
234 controls.routeStatus = createRouteStatus({canSetVolume: true}); 236 controls.routeStatus = createRouteStatus({canSetVolume: true});
235 237
236 // In actual usage, the change event gets fired when the user interacts 238 // In actual usage, the change event gets fired when the user interacts
237 // with the slider. 239 // with the slider.
238 controls.$$('#route-volume-slider').value = volume; 240 controls.$$('#route-volume-slider').value = volume;
239 controls.$$('#route-volume-slider').fire('change'); 241 controls.$$('#route-volume-slider').fire('change');
240 }); 242 });
243
244 test('increment current time while playing', function(done) {
245 var initialTime = 50;
246 controls.routeStatus = createRouteStatus({
247 canSeek: true,
248 playState: media_router.PlayState.PLAYING,
249 duration: 100,
250 currentTime: initialTime,
251 });
252
253 // Check that the current time has been incremented after a second.
254 setTimeout(function() {
255 controls.routeStatus.playState = media_router.PlayState.PAUSED;
256 var pausedTime = controls.routeStatus.currentTime;
257 assertTrue(pausedTime > initialTime);
258
259 // Check that the current time stayed the same after a second, now
260 // that the media is paused.
261 setTimeout(function() {
262 assertEquals(pausedTime, controls.routeStatus.currentTime);
263 done();
264 }, 1000);
265 }, 1000);
266 });
241 }); 267 });
242 } 268 }
243 269
244 return { 270 return {
245 registerTests: registerTests, 271 registerTests: registerTests,
246 }; 272 };
247 }); 273 });
OLDNEW
« no previous file with comments | « chrome/common/media_router/mojo/media_status_struct_traits.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698