Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 'use strict'; | |
| 2 | |
| 3 let mockVRService = loadMojoModules( | |
| 4 'mockVRService', | |
| 5 ['mojo/public/js/bindings', | |
| 6 'mojo/public/js/connection', | |
|
yzshen1
2017/01/03 22:29:05
Please note that "connection" is deprecated and be
bsheedy
2017/01/03 22:39:06
What do you suggest using in its place? Or should
Lei Lei
2017/01/03 22:40:35
With bindings.BindingSet, connection is not needed
| |
| 7 'mojo/public/js/router', | |
| 8 'device/vr/vr_service.mojom', | |
| 9 ]).then(mojo => { | |
| 10 let [bindings, connection, router, vr_service] = mojo.modules; | |
| 11 | |
| 12 class MockVRDisplay extends vr_service.VRDisplay.stubClass { | |
| 13 constructor(interfaceProvider) { | |
| 14 super(); | |
| 15 interfaceProvider.addInterfaceOverrideForTesting( | |
| 16 vr_service.VRDisplay.name, | |
| 17 handle => this.connect_(handle)); | |
| 18 } | |
| 19 | |
| 20 connect_(handle) { | |
| 21 this.router_ = new router.Router(handle); | |
|
yzshen1
2017/01/03 22:29:05
Please don't use router directly, this doesn't do
bsheedy
2017/01/03 22:39:06
I'll look into changing this, then.
Lei Lei
2017/01/03 22:40:35
Thanks for fixing it!
| |
| 22 this.router_.setIncomingReceiver(this); | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 class MockVRService extends vr_service.VRService.stubClass { | |
| 27 constructor(interfaceProvider) { | |
| 28 super(); | |
| 29 interfaceProvider.addInterfaceOverrideForTesting( | |
| 30 vr_service.VRService.name, | |
| 31 handle => this.connect_(handle)); | |
| 32 this.vrDisplays_ = null; | |
| 33 } | |
| 34 | |
| 35 connect_(handle) { | |
| 36 this.router_ = new router.Router(handle); | |
| 37 this.router_.setIncomingReceiver(this); | |
| 38 } | |
| 39 | |
| 40 setVRDisplays(displays) { | |
| 41 this.vrDisplays_ = displays; | |
| 42 } | |
| 43 | |
| 44 setClient(client) { | |
| 45 if (this.vrDisplays_ != null) { | |
| 46 this.vrDisplays_.forEach(display => { | |
| 47 var displayPtr = new vr_service.VRDisplayPtr(); | |
| 48 var request = bindings.makeRequest(displayPtr); | |
| 49 var binding = new bindings.Binding( | |
| 50 vr_service.VRDisplay, | |
| 51 new MockVRDisplay(mojo.frameInterfaces), request); | |
| 52 var client_handle = new bindings.InterfaceRequest( | |
| 53 connection.bindProxy(proxy => {}, vr_service.VRDisplayClient)); | |
| 54 client.onDisplayConnected(displayPtr, client_handle, display); | |
| 55 }); | |
| 56 return Promise.resolve( | |
| 57 {numberOfConnectedDevices: this.vrDisplays_.length}); | |
| 58 } | |
| 59 return Promise.resolve({numberOfConnectedDevices: 0}); | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 return new MockVRService(mojo.frameInterfaces); | |
| 64 }); | |
| 65 | |
| 66 function vr_test(func, vrDisplays, name, properties) { | |
| 67 promise_test(t => mockVRService.then((service) => { | |
| 68 service.setVRDisplays(vrDisplays); | |
| 69 return func(); | |
| 70 }), name, properties); | |
| 71 } | |
| 72 | |
| 73 | |
| OLD | NEW |