| 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 'mojo/public/js/router', | 11 'mojo/public/js/bindings', |
| 12 ]).then(mojo => { | 12 ]).then(mojo => { |
| 13 let [ presentationService, router ] = mojo.modules; | 13 let [ presentationService, bindings ] = mojo.modules; |
| 14 | 14 |
| 15 class PresentationServiceMock { | 15 class PresentationServiceMock { |
| 16 constructor(interfaceProvider) { | 16 constructor(interfaceProvider) { |
| 17 interfaceProvider.addInterfaceOverrideForTesting( | 17 interfaceProvider.addInterfaceOverrideForTesting( |
| 18 presentationService.PresentationService.name, | 18 presentationService.PresentationService.name, |
| 19 handle => this.connectPresentationService_(handle)); | 19 handle => this.bindingSet_.addBinding(this, handle)); |
| 20 this.interfaceProvider_ = interfaceProvider; | 20 this.interfaceProvider_ = interfaceProvider; |
| 21 this.pendingResponse_ = null; | 21 this.pendingResponse_ = null; |
| 22 } | 22 this.bindingSet_ = new bindings.BindingSet( |
| 23 | 23 presentationService.PresentationService); |
| 24 connectPresentationService_(handle) { | |
| 25 this.presentationServiceStub_ = new presentationService.PresentationSe
rvice.stubClass(this); | |
| 26 this.presentationServiceRouter_ = new router.Router(handle); | |
| 27 this.presentationServiceRouter_.setIncomingReceiver(this.presentationS
erviceStub_); | |
| 28 } | 24 } |
| 29 | 25 |
| 30 startSession(urls) { | 26 startSession(urls) { |
| 31 return Promise.resolve({ | 27 return Promise.resolve({ |
| 32 sessionInfo: { url: urls[0], id: 'fakesession' }, | 28 sessionInfo: { url: urls[0], id: 'fakesession' }, |
| 33 error: null, | 29 error: null, |
| 34 }); | 30 }); |
| 35 } | 31 } |
| 36 } | 32 } |
| 37 | 33 |
| 38 return new PresentationServiceMock(mojo.frameInterfaces); | 34 return new PresentationServiceMock(mojo.frameInterfaces); |
| 39 }); | 35 }); |
| OLD | NEW |