[CodeHealth] Spanify WebXR test code
Bug: 351564777 Change-Id: Ib298fe5406c9d1e8dff25e9e87515532dbd5cb29 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6130368 Auto-Submit: Alexander Cooper <alcooper@chromium.org> Commit-Queue: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Cr-Commit-Position: refs/heads/main@{#1401551}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
136fa2c404
commit
dd576ab923
chrome/browser/vr
components/webxr
device/vr/test
@ -2,11 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "chrome/browser/vr/test/mock_xr_device_hook_base.h"
|
||||
|
||||
#include "content/public/test/xr_test_utils.h"
|
||||
@ -227,8 +222,7 @@ device::ControllerFrameData MockXRDeviceHookBase::CreateValidController(
|
||||
device::ControllerFrameData ret;
|
||||
// Because why shouldn't a 64 button controller exist?
|
||||
ret.supported_buttons = UINT64_MAX;
|
||||
memset(ret.axis_data, 0,
|
||||
sizeof(device::ControllerAxisData) * device::kMaxNumAxes);
|
||||
std::ranges::fill(ret.axis_data, device::ControllerAxisData{});
|
||||
ret.role = role;
|
||||
ret.is_valid = true;
|
||||
// Identity matrix.
|
||||
|
@ -63,8 +63,8 @@ class MockXRDeviceHookBase : public device_test::mojom::XRTestHook {
|
||||
void SetCanCreateSession(bool can_create_session);
|
||||
|
||||
protected:
|
||||
device_test::mojom::TrackedDeviceClass
|
||||
tracked_classes_[device::kMaxTrackedDevices];
|
||||
std::array<device_test::mojom::TrackedDeviceClass, device::kMaxTrackedDevices>
|
||||
tracked_classes_;
|
||||
base::flat_map<unsigned int, device::ControllerFrameData>
|
||||
controller_data_map_;
|
||||
std::queue<device_test::mojom::EventData> event_data_queue_;
|
||||
|
@ -2,11 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
@ -175,7 +170,8 @@ class WebXrControllerInputMock : public MockXRDeviceHookBase {
|
||||
bool is_valid) {
|
||||
auto controller_data = GetCurrentControllerData(index);
|
||||
controller_data.pose_data.is_valid = is_valid;
|
||||
device_to_origin.GetColMajorF(controller_data.pose_data.device_to_origin);
|
||||
device_to_origin.GetColMajorF(
|
||||
controller_data.pose_data.device_to_origin.data());
|
||||
UpdateControllerAndWait(index, controller_data);
|
||||
}
|
||||
|
||||
@ -840,11 +836,11 @@ WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(TestControllerInputRegistered) {
|
||||
}
|
||||
|
||||
std::string TransformToColMajorString(const gfx::Transform& t) {
|
||||
float array[16];
|
||||
t.GetColMajorF(array);
|
||||
std::array<float, 16> array;
|
||||
t.GetColMajorF(array.data());
|
||||
std::string array_string = "[";
|
||||
for (int i = 0; i < 16; i++) {
|
||||
array_string += base::NumberToString(array[i]) + ",";
|
||||
for (const auto& val : array) {
|
||||
array_string += base::NumberToString(val) + ",";
|
||||
}
|
||||
array_string.pop_back();
|
||||
array_string.push_back(']');
|
||||
|
@ -2,11 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(crbug.com/342213636): Remove this and spanify to fix the errors.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "components/webxr/xr_test_hook_wrapper.h"
|
||||
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
@ -36,7 +31,7 @@ device::PoseFrameData MojoToDevicePoseFrameData(
|
||||
device::PoseFrameData ret = {};
|
||||
ret.is_valid = !!pose->device_to_origin;
|
||||
if (ret.is_valid) {
|
||||
pose->device_to_origin->GetColMajorF(ret.device_to_origin);
|
||||
pose->device_to_origin->GetColMajorF(ret.device_to_origin.data());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -2,11 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#ifndef DEVICE_VR_TEST_TEST_HOOK_H_
|
||||
#define DEVICE_VR_TEST_TEST_HOOK_H_
|
||||
|
||||
@ -89,14 +84,16 @@ struct ViewData {
|
||||
};
|
||||
|
||||
struct PoseFrameData {
|
||||
float device_to_origin[16];
|
||||
std::array<float, 16> device_to_origin;
|
||||
bool is_valid;
|
||||
};
|
||||
|
||||
struct DeviceConfig {
|
||||
float interpupillary_distance;
|
||||
float viewport_left[4]; // raw projection left {left, right, top, bottom}
|
||||
float viewport_right[4]; // raw projection right {left, right, top, bottom}
|
||||
std::array<float, 4>
|
||||
viewport_left; // raw projection left {left, right, top, bottom}
|
||||
std::array<float, 4>
|
||||
viewport_right; // raw projection right {left, right, top, bottom}
|
||||
};
|
||||
|
||||
struct ControllerAxisData {
|
||||
@ -140,10 +137,10 @@ struct COMPONENT_EXPORT(VR_TEST_HOOK) ControllerFrameData {
|
||||
uint64_t buttons_pressed = 0;
|
||||
uint64_t buttons_touched = 0;
|
||||
uint64_t supported_buttons = 0;
|
||||
ControllerAxisData axis_data[kMaxNumAxes];
|
||||
std::array<ControllerAxisData, kMaxNumAxes> axis_data;
|
||||
PoseFrameData pose_data = {};
|
||||
ControllerRole role = kControllerRoleInvalid;
|
||||
XRHandJointData hand_data[kNumJointsForTest];
|
||||
std::array<XRHandJointData, kNumJointsForTest> hand_data;
|
||||
bool has_hand_data = false;
|
||||
bool is_valid = false;
|
||||
|
||||
@ -159,7 +156,7 @@ inline gfx::Transform PoseFrameDataToTransform(PoseFrameData data) {
|
||||
// we're given data in column-major order. Construct in column-major order and
|
||||
// transpose since it looks cleaner than manually transposing the arguments
|
||||
// passed to the constructor.
|
||||
float* t = data.device_to_origin;
|
||||
auto& t = data.device_to_origin;
|
||||
return gfx::Transform::ColMajor(t[0], t[1], t[2], t[3], t[4], t[5], t[6],
|
||||
t[7], t[8], t[9], t[10], t[11], t[12], t[13],
|
||||
t[14], t[15]);
|
||||
|
Reference in New Issue
Block a user