| OLD | NEW |
| 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 let presentationServiceMock = loadMojoModules( |
| 8 'presentationServiceMock', | 8 'presentationServiceMock', |
| 9 [ | 9 [ |
| 10 'third_party/WebKit/public/platform/modules/presentation/presentation.mojo
m', | 10 'third_party/WebKit/public/platform/modules/presentation/presentation.mojo
m', |
| 11 'url/mojo/url.mojom', | 11 'url/mojo/url.mojom', |
| 12 'mojo/public/js/bindings', | 12 'mojo/public/js/bindings', |
| 13 ]).then(mojo => { | 13 ]).then(mojo => { |
| 14 let [ presentationService, url, bindings ] = mojo.modules; | 14 let [ presentationService, url, bindings ] = mojo.modules; |
| 15 | 15 |
| 16 class MockPresentationConnection { | 16 class MockPresentationConnection { |
| 17 }; | 17 }; |
| 18 | 18 |
| 19 class PresentationServiceMock { | 19 class PresentationServiceMock { |
| 20 constructor(interfaceProvider) { | 20 constructor(interfaceProvider) { |
| 21 interfaceProvider.addInterfaceOverrideForTesting( | 21 interfaceProvider.addInterfaceOverrideForTesting( |
| 22 presentationService.PresentationService.name, | 22 presentationService.PresentationService.name, |
| 23 handle => this.bindingSet_.addBinding(this, handle)); | 23 handle => this.bindingSet_.addBinding(this, handle)); |
| 24 this.interfaceProvider_ = interfaceProvider; | 24 this.interfaceProvider_ = interfaceProvider; |
| 25 this.pendingResponse_ = null; | 25 this.pendingResponse_ = null; |
| 26 this.bindingSet_ = new bindings.BindingSet( | 26 this.bindingSet_ = new bindings.BindingSet( |
| 27 presentationService.PresentationService); | 27 presentationService.PresentationService); |
| 28 |
| 29 this.onSetClient = null; |
| 28 } | 30 } |
| 29 | 31 |
| 30 setClient(client) { | 32 setClient(client) { |
| 31 this.client_ = client; | 33 this.client_ = client; |
| 34 |
| 35 if (this.onSetClient) |
| 36 this.onSetClient(); |
| 32 } | 37 } |
| 33 | 38 |
| 34 startSession(urls) { | 39 startSession(urls) { |
| 35 return Promise.resolve({ | 40 return Promise.resolve({ |
| 36 sessionInfo: { url: urls[0], id: 'fakesession' }, | 41 sessionInfo: { url: urls[0], id: 'fakesession' }, |
| 37 error: null, | 42 error: null, |
| 38 }); | 43 }); |
| 39 } | 44 } |
| 40 | 45 |
| 41 joinSession(urls) { | 46 joinSession(urls) { |
| 42 return Promise.resolve({ | 47 return Promise.resolve({ |
| 43 sessionInfo: { url: urls[0], id: 'fakeSessionId' }, | 48 sessionInfo: { url: urls[0], id: 'fakeSessionId' }, |
| 44 error: null, | 49 error: null, |
| 45 }); | 50 }); |
| 46 } | 51 } |
| 47 | 52 |
| 53 terminate(presentationUrl, presentationId) { |
| 54 this.client_.onConnectionStateChanged( |
| 55 { url: presentationUrl, id: presentationId }, |
| 56 presentationService.PresentationConnectionState.TERMINATED); |
| 57 } |
| 58 |
| 59 setPresentationConnection( |
| 60 seesionInfo, controllerConnectionPtr, receiverConnectionRequest) { |
| 61 this.client_.onConnectionStateChanged( |
| 62 seesionInfo, |
| 63 presentationService.PresentationConnectionState.CONNECTED); |
| 64 } |
| 65 |
| 48 onReceiverConnectionAvailable(strUrl, id) { | 66 onReceiverConnectionAvailable(strUrl, id) { |
| 49 const mojoUrl = new url.Url(); | 67 const mojoUrl = new url.Url(); |
| 50 mojoUrl.url = strUrl; | 68 mojoUrl.url = strUrl; |
| 51 const controllerConnectionPtr = new presentationService.PresentationCo
nnectionPtr(); | 69 const controllerConnectionPtr = new presentationService.PresentationCo
nnectionPtr(); |
| 52 const connectionBinding = new bindings.Binding( | 70 const connectionBinding = new bindings.Binding( |
| 53 presentationService.PresentationConnection, | 71 presentationService.PresentationConnection, |
| 54 new MockPresentationConnection(), | 72 new MockPresentationConnection(), |
| 55 bindings.makeRequest(controllerConnectionPtr)); | 73 bindings.makeRequest(controllerConnectionPtr)); |
| 56 const receiverConnectionPtr = new presentationService.PresentationConn
ectionPtr(); | 74 const receiverConnectionPtr = new presentationService.PresentationConn
ectionPtr(); |
| 57 | 75 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 72 return; | 90 return; |
| 73 | 91 |
| 74 const boundingRect = button.getBoundingClientRect(); | 92 const boundingRect = button.getBoundingClientRect(); |
| 75 const x = boundingRect.left + boundingRect.width / 2; | 93 const x = boundingRect.left + boundingRect.width / 2; |
| 76 const y = boundingRect.top + boundingRect.height / 2; | 94 const y = boundingRect.top + boundingRect.height / 2; |
| 77 | 95 |
| 78 eventSender.mouseMoveTo(x, y); | 96 eventSender.mouseMoveTo(x, y); |
| 79 eventSender.mouseDown(); | 97 eventSender.mouseDown(); |
| 80 eventSender.mouseUp(); | 98 eventSender.mouseUp(); |
| 81 } | 99 } |
| OLD | NEW |