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

Side by Side Diff: third_party/WebKit/LayoutTests/presentation/resources/presentation-service-mock.js

Issue 2643473002: [Presentation API] Allow PresentationConnection state change to "Connecting" (Closed)
Patch Set: Address Mark and Bin's comments Created 3 years, 10 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 /* 1 /*
2 * Mock implementation of mojo PresentationService. 2 * Mock implementation of mojo PresentationService.
3 */ 3 */
4 4
5 "use strict"; 5 "use strict";
6 6
7 let presentationServiceMock = loadMojoModules( 7 const presentationServiceMock =
8 'presentationServiceMock', 8 loadMojoModules('presentationServiceMock', [
9 [
10 'third_party/WebKit/public/platform/modules/presentation/presentation.mojo m', 9 'third_party/WebKit/public/platform/modules/presentation/presentation.mojo m',
11 'mojo/public/js/bindings', 10 'mojo/public/js/bindings',
12 ]).then(mojo => { 11 ]).then(mojo => {
13 let [ presentationService, bindings ] = mojo.modules; 12 const [presentationService, bindings] = mojo.modules;
14 13
15 class PresentationServiceMock { 14 class PresentationServiceMock {
16 constructor(interfaceProvider) { 15 constructor(interfaceProvider) {
17 interfaceProvider.addInterfaceOverrideForTesting( 16 interfaceProvider.addInterfaceOverrideForTesting(
18 presentationService.PresentationService.name, 17 presentationService.PresentationService.name,
19 handle => this.bindingSet_.addBinding(this, handle)); 18 handle => this.bindingSet_.addBinding(this, handle));
20 this.interfaceProvider_ = interfaceProvider; 19 this.interfaceProvider_ = interfaceProvider;
21 this.pendingResponse_ = null; 20 this.pendingResponse_ = null;
22 this.bindingSet_ = new bindings.BindingSet( 21 this.bindingSet_ = new bindings.BindingSet(
23 presentationService.PresentationService); 22 presentationService.PresentationService);
24 } 23 }
25 24
25 setClient(client) { this.client_ = client; }
26
26 startSession(urls) { 27 startSession(urls) {
27 return Promise.resolve({ 28 return Promise.resolve({
28 sessionInfo: { url: urls[0], id: 'fakesession' }, 29 sessionInfo: { url: urls[0], id: 'fakesession' },
29 error: null, 30 error: null,
30 }); 31 });
31 } 32 }
32 33
33 joinSession(urls) { 34 joinSession(urls) {
34 return Promise.resolve({ 35 return Promise.resolve({
35 sessionInfo: { url: urls[0], id: 'fakeSessionId' }, 36 sessionInfo: { url: urls[0], id: 'fakeSessionId' },
36 error: null, 37 error: null,
37 }); 38 });
38 } 39 }
40
41 closeConnection(url, id) {
42 this.client_.onConnectionClosed(
43 {url: url, id: id},
44 presentationService.PresentationConnectionCloseReason.CLOSED, '');
45 }
39 } 46 }
40 47
41 return new PresentationServiceMock(mojo.frameInterfaces); 48 return new PresentationServiceMock(mojo.frameInterfaces);
42 }); 49 });
43 50
44 function waitForClick(callback, button) { 51 function waitForClick(callback, button) {
45 button.addEventListener('click', callback, { once: true }); 52 button.addEventListener('click', callback, { once: true });
46 53
47 if (!('eventSender' in window)) 54 if (!('eventSender' in window))
48 return; 55 return;
49 56
50 var boundingRect = button.getBoundingClientRect(); 57 const boundingRect = button.getBoundingClientRect();
51 var x = boundingRect.left + boundingRect.width / 2; 58 const x = boundingRect.left + boundingRect.width / 2;
52 var y = boundingRect.top + boundingRect.height / 2; 59 const y = boundingRect.top + boundingRect.height / 2;
53 60
54 eventSender.mouseMoveTo(x, y); 61 eventSender.mouseMoveTo(x, y);
55 eventSender.mouseDown(); 62 eventSender.mouseDown();
56 eventSender.mouseUp(); 63 eventSender.mouseUp();
57 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698