Index: content/browser/vr/vr_test_helpers.cc |
diff --git a/content/browser/vr/vr_test_helpers.cc b/content/browser/vr/vr_test_helpers.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..819d9375cf0e4856bca57c3958420f65a6d64eeb |
--- /dev/null |
+++ b/content/browser/vr/vr_test_helpers.cc |
@@ -0,0 +1,93 @@ |
+// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/vr/vr_test_helpers.h" |
+ |
+namespace content { |
+ |
+MockVRDevice::MockVRDevice(VRDeviceProvider* provider) |
+ : VRDevice(provider) { |
+} |
+ |
+MockVRDevice::~MockVRDevice() { |
+ |
+} |
+ |
+void MockVRDevice::SetVRDevice(const blink::WebVRDevice& device) { |
+ device_ = device; |
+} |
+ |
+void MockVRDevice::SetHMDSensorState(const blink::WebHMDSensorState& state) { |
+ state_ = state; |
+} |
+ |
+void MockVRDevice::SetRenderTargetSize( |
+ unsigned int width, |
+ unsigned int height) { |
+ width_ = width; |
+ height_ = height; |
+} |
+ |
+void MockVRDevice::GetVRDevice(blink::WebVRDevice* device) { |
+ *device = device_; |
+} |
+ |
+void MockVRDevice::GetHMDSensorState(blink::WebHMDSensorState* state) { |
+ *state = state_; |
+} |
+void MockVRDevice::GetRenderTargetRects( |
+ blink::WebVRFieldOfView leftFov, |
+ blink::WebVRFieldOfView rightFov, |
+ blink::WebVRVector4* leftRect, |
+ blink::WebVRVector4* rightRect) { |
+ leftRect->x = 0; |
+ leftRect->y = 0; |
+ leftRect->z = width_ / 2.0; |
+ leftRect->w = height_; |
+ |
+ rightRect->x = width_ / 2.0; |
+ rightRect->y = 0; |
+ rightRect->z = width_ / 2.0; |
+ rightRect->w = height_; |
+} |
+ |
+MockVRDeviceProvider::MockVRDeviceProvider() : VRDeviceProvider() { |
+ initialized_ = false; |
+} |
+ |
+MockVRDeviceProvider::~MockVRDeviceProvider() { |
+} |
+ |
+void MockVRDeviceProvider::AddDevice(VRDevice* device) { |
+ devices_.push_back(device); |
+} |
+ |
+void MockVRDeviceProvider::RemoveDevice(VRDevice* device) { |
+ std::vector<VRDevice*>::iterator iter = devices_.begin(); |
+ while (iter != devices_.end()) { |
+ if (device == *iter) { |
+ iter = devices_.erase(iter); |
+ } else { |
+ ++iter; |
+ } |
+ } |
+} |
+ |
+void MockVRDeviceProvider::GetDevices(std::vector<VRDevice*>& devices) { |
+ std::vector<VRDevice*>::iterator iter; |
+ |
+ for(iter = devices_.begin(); iter != devices_.end(); ++iter) { |
+ devices.push_back(*iter); |
+ } |
+} |
+ |
+void MockVRDeviceProvider::Initialize() { |
+ initialized_ = true; |
+} |
+ |
+void MockVRDeviceProvider::Shutdown() { |
+ initialized_ = false; |
+} |
+ |
+} // namespace content |