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

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

Issue 2659853006: Add getFrameData and getPose layout tests (Closed)
Patch Set: Add more tests 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/vr/resources/mock-vr-service.js
diff --git a/third_party/WebKit/LayoutTests/vr/resources/mock-vr-service.js b/third_party/WebKit/LayoutTests/vr/resources/mock-vr-service.js
index d40e9e4800fb2b085047b17b718c7d6e1ecbdc10..618b1afce38aa6905621ee22df95f25561c88521 100644
--- a/third_party/WebKit/LayoutTests/vr/resources/mock-vr-service.js
+++ b/third_party/WebKit/LayoutTests/vr/resources/mock-vr-service.js
@@ -28,6 +28,15 @@ let mockVRService = loadMojoModules(
return Promise.resolve({success: true});
}
+ setPose(pose) {
+ if (pose == null) {
+ this.vsync_provider_.pose_ = null;
+ } else {
+ this.vsync_provider_.initPose();
+ this.vsync_provider_.fillPose(pose);
+ }
+ }
+
getVRVSyncProvider(request) { this.vsync_provider_.bind(request); }
forceActivate(reason) {
@@ -50,19 +59,46 @@ let mockVRService = loadMojoModules(
constructor() {
this.timeDelta_ = 0;
this.binding_ = new bindings.Binding(vr_service.VRVSyncProvider, this);
+ this.pose_ = null;
}
bind(request) {
this.binding_.close();
this.binding_.bind(request);
}
getVSync() {
- this.timeDelta_ += 1000.0 / 60.0;
- return Promise.resolve({
- pose: null,
+ if (this.pose_) {
+ this.pose_.timestamp = this.timeDelta_;
+ this.pose_.poseIndex++;
+ }
+
+ let retval = Promise.resolve({
+ pose: this.pose_,
time: {
microseconds: this.timeDelta_,
},
});
+
+ this.timeDelta_ += 1000.0 / 60.0;
+ return retval;
+ }
+ initPose() {
+ this.pose_ = {
+ timestamp: 0,
+ orientation: null,
+ position: null,
+ angularVelocity: null,
+ linearVelocity: null,
+ angularAcceleration: null,
+ linearAcceleration: null,
+ poseIndex: 0
+ };
+ }
+ fillPose(pose) {
+ for (var field in pose) {
+ if (this.pose_.hasOwnProperty(field)) {
+ this.pose_[field] = pose[field];
+ }
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698