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

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

Issue 2624633002: Remove Sync GetPose VRService call, implement VRVSyncProvider (Closed)
Patch Set: oops Created 3 years, 11 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 | « device/vr/vr_service.mojom ('k') | third_party/WebKit/Source/modules/vr/VRDisplay.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 'use strict'; 1 'use strict';
2 2
3 let mockVRService = loadMojoModules( 3 let mockVRService = loadMojoModules(
4 'mockVRService', 4 'mockVRService',
5 ['mojo/public/js/bindings', 5 ['mojo/public/js/bindings',
6 'device/vr/vr_service.mojom', 6 'device/vr/vr_service.mojom',
7 ]).then(mojo => { 7 ]).then(mojo => {
8 let [bindings, vr_service] = mojo.modules; 8 let [bindings, vr_service] = mojo.modules;
9 9
10 class MockVRDisplay { 10 class MockVRDisplay {
11 constructor(interfaceProvider, displayInfo, service) { 11 constructor(interfaceProvider, displayInfo, service) {
12 this.bindingSet_ = new bindings.BindingSet(vr_service.VRDisplay); 12 this.bindingSet_ = new bindings.BindingSet(vr_service.VRDisplay);
13 this.displayClient_ = new vr_service.VRDisplayClientPtr(); 13 this.displayClient_ = new vr_service.VRDisplayClientPtr();
14 this.displayInfo_ = displayInfo; 14 this.displayInfo_ = displayInfo;
15 this.service_ = service; 15 this.service_ = service;
16 this.vsync_provider_ = new MockVRVSyncProvider();
16 17
17 interfaceProvider.addInterfaceOverrideForTesting( 18 interfaceProvider.addInterfaceOverrideForTesting(
18 vr_service.VRDisplay.name, 19 vr_service.VRDisplay.name,
19 handle => this.bindingSet_.addBinding(this, handle)); 20 handle => this.bindingSet_.addBinding(this, handle));
20 21
21 if (service.client_) { 22 if (service.client_) {
22 this.notifyClientOfDisplay(); 23 this.notifyClientOfDisplay();
23 } 24 }
24 } 25 }
25 26
26 requestPresent(secureOrigin) { 27 requestPresent(secureOrigin) {
27 return Promise.resolve({success: true}); 28 return Promise.resolve({success: true});
28 } 29 }
29 30
31 getVRVSyncProvider(request) { this.vsync_provider_.bind(request); }
32
30 forceActivate(reason) { 33 forceActivate(reason) {
31 this.displayClient_.onActivate(reason); 34 this.displayClient_.onActivate(reason);
32 } 35 }
33 36
34 notifyClientOfDisplay() { 37 notifyClientOfDisplay() {
35 let displayPtr = new vr_service.VRDisplayPtr(); 38 let displayPtr = new vr_service.VRDisplayPtr();
36 let request = bindings.makeRequest(displayPtr); 39 let request = bindings.makeRequest(displayPtr);
37 let binding = new bindings.Binding( 40 let binding = new bindings.Binding(
38 vr_service.VRDisplay, 41 vr_service.VRDisplay,
39 this, request); 42 this, request);
40 let clientRequest = bindings.makeRequest(this.displayClient_); 43 let clientRequest = bindings.makeRequest(this.displayClient_);
41 this.service_.client_.onDisplayConnected(displayPtr, clientRequest, 44 this.service_.client_.onDisplayConnected(displayPtr, clientRequest,
42 this.displayInfo_); 45 this.displayInfo_);
43 } 46 }
44 } 47 }
45 48
49 class MockVRVSyncProvider {
50 constructor() {
51 this.timeDelta_ = 0;
52 this.binding_ = new bindings.Binding(vr_service.VRVSyncProvider, this);
53 }
54 bind(request) {
55 this.binding_.close();
56 this.binding_.bind(request);
57 }
58 getVSync() {
59 this.timeDelta_ += 1000.0 / 60.0;
60 return Promise.resolve({
61 pose: null,
62 time: {
63 microseconds: this.timeDelta_,
64 },
65 });
66 }
67 }
68
46 class MockVRService { 69 class MockVRService {
47 constructor(interfaceProvider) { 70 constructor(interfaceProvider) {
48 this.bindingSet_ = new bindings.BindingSet(vr_service.VRService); 71 this.bindingSet_ = new bindings.BindingSet(vr_service.VRService);
49 this.mockVRDisplays_ = []; 72 this.mockVRDisplays_ = [];
50 73
51 interfaceProvider.addInterfaceOverrideForTesting( 74 interfaceProvider.addInterfaceOverrideForTesting(
52 vr_service.VRService.name, 75 vr_service.VRService.name,
53 handle => this.bindingSet_.addBinding(this, handle)); 76 handle => this.bindingSet_.addBinding(this, handle));
54 } 77 }
55 78
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return new MockVRService(mojo.frameInterfaces); 110 return new MockVRService(mojo.frameInterfaces);
88 }); 111 });
89 112
90 function vr_test(func, vrDisplays, name, properties) { 113 function vr_test(func, vrDisplays, name, properties) {
91 mockVRService.then( (service) => { 114 mockVRService.then( (service) => {
92 service.setVRDisplays(vrDisplays); 115 service.setVRDisplays(vrDisplays);
93 let t = async_test(name, properties); 116 let t = async_test(name, properties);
94 func(t, service); 117 func(t, service);
95 }); 118 });
96 } 119 }
OLDNEW
« no previous file with comments | « device/vr/vr_service.mojom ('k') | third_party/WebKit/Source/modules/vr/VRDisplay.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698