| Index: device/gamepad/public/interfaces/gamepad_struct_traits_unittest.cc
|
| diff --git a/device/gamepad/public/interfaces/gamepad_struct_traits_unittest.cc b/device/gamepad/public/interfaces/gamepad_struct_traits_unittest.cc
|
| index e3b59f10f78e670f2e158ca7fae98a14256efab1..a00e070f42490ac73953f089b0abd0aa2f71a85c 100644
|
| --- a/device/gamepad/public/interfaces/gamepad_struct_traits_unittest.cc
|
| +++ b/device/gamepad/public/interfaces/gamepad_struct_traits_unittest.cc
|
| @@ -4,11 +4,11 @@
|
|
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/run_loop.h"
|
| +#include "device/gamepad/public/cpp/gamepad.h"
|
| #include "device/gamepad/public/interfaces/gamepad_struct_traits_test.mojom.h"
|
| #include "mojo/public/cpp/bindings/binding.h"
|
| #include "mojo/public/cpp/bindings/interface_request.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| -#include "third_party/WebKit/public/platform/WebGamepad.h"
|
|
|
| namespace device {
|
|
|
| @@ -21,21 +21,21 @@ enum GamepadTestDataType {
|
| GamepadPose_Null = 3,
|
| };
|
|
|
| -blink::WebGamepad GetWebGamepadInstance(GamepadTestDataType type) {
|
| - blink::WebGamepadButton wgb(true, false, 1.0f);
|
| +Gamepad GetWebGamepadInstance(GamepadTestDataType type) {
|
| + GamepadButton wgb(true, false, 1.0f);
|
|
|
| - blink::WebGamepadVector wgv;
|
| - memset(&wgv, 0, sizeof(blink::WebGamepadVector));
|
| + GamepadVector wgv;
|
| + memset(&wgv, 0, sizeof(GamepadVector));
|
| wgv.not_null = true;
|
| wgv.x = wgv.y = wgv.z = 1.0f;
|
|
|
| - blink::WebGamepadQuaternion wgq;
|
| - memset(&wgq, 0, sizeof(blink::WebGamepadQuaternion));
|
| + GamepadQuaternion wgq;
|
| + memset(&wgq, 0, sizeof(GamepadQuaternion));
|
| wgq.not_null = true;
|
| wgq.x = wgq.y = wgq.z = wgq.w = 2.0f;
|
|
|
| - blink::WebGamepadPose wgp;
|
| - memset(&wgp, 0, sizeof(blink::WebGamepadPose));
|
| + GamepadPose wgp;
|
| + memset(&wgp, 0, sizeof(GamepadPose));
|
| if (type == GamepadPose_Null) {
|
| wgp.not_null = false;
|
| } else if (type == GamepadCommon) {
|
| @@ -55,57 +55,56 @@ blink::WebGamepad GetWebGamepadInstance(GamepadTestDataType type) {
|
| wgp.angular_acceleration = wgv;
|
| }
|
|
|
| - blink::WebUChar wch[blink::WebGamepad::kMappingLengthCap] = {
|
| + UChar wch[Gamepad::kMappingLengthCap] = {
|
| 1, 8, 9, 127, 128, 1024, 1025, 1949,
|
| 2047, 2048, 16383, 16384, 20000, 32767, 32768, 65535};
|
|
|
| - blink::WebGamepad send;
|
| - memset(&send, 0, sizeof(blink::WebGamepad));
|
| + Gamepad send;
|
| + memset(&send, 0, sizeof(Gamepad));
|
|
|
| send.connected = true;
|
| - for (size_t i = 0; i < blink::WebGamepad::kMappingLengthCap; i++) {
|
| + for (size_t i = 0; i < Gamepad::kMappingLengthCap; i++) {
|
| send.id[i] = send.mapping[i] = wch[i];
|
| }
|
| send.timestamp = 1234567890123456789ULL;
|
| send.axes_length = 0U;
|
| - for (size_t i = 0; i < blink::WebGamepad::kAxesLengthCap; i++) {
|
| + for (size_t i = 0; i < Gamepad::kAxesLengthCap; i++) {
|
| send.axes_length++;
|
| send.axes[i] = 1.0;
|
| }
|
| send.buttons_length = 0U;
|
| - for (size_t i = 0; i < blink::WebGamepad::kButtonsLengthCap; i++) {
|
| + for (size_t i = 0; i < Gamepad::kButtonsLengthCap; i++) {
|
| send.buttons_length++;
|
| send.buttons[i] = wgb;
|
| }
|
| send.pose = wgp;
|
| - send.hand = blink::WebGamepadHand::kGamepadHandRight;
|
| + send.hand = GamepadHand::kGamepadHandRight;
|
| send.display_id = static_cast<unsigned short>(16);
|
|
|
| return send;
|
| }
|
|
|
| -bool isWebGamepadButtonEqual(const blink::WebGamepadButton& lhs,
|
| - const blink::WebGamepadButton& rhs) {
|
| +bool isWebGamepadButtonEqual(const GamepadButton& lhs,
|
| + const GamepadButton& rhs) {
|
| return (lhs.pressed == rhs.pressed && lhs.touched == rhs.touched &&
|
| lhs.value == rhs.value);
|
| }
|
|
|
| -bool isWebGamepadVectorEqual(const blink::WebGamepadVector& lhs,
|
| - const blink::WebGamepadVector& rhs) {
|
| +bool isWebGamepadVectorEqual(const GamepadVector& lhs,
|
| + const GamepadVector& rhs) {
|
| return ((lhs.not_null == false && rhs.not_null == false) ||
|
| (lhs.not_null == rhs.not_null && lhs.x == rhs.x && lhs.y == rhs.y &&
|
| lhs.z == rhs.z));
|
| }
|
|
|
| -bool isWebGamepadQuaternionEqual(const blink::WebGamepadQuaternion& lhs,
|
| - const blink::WebGamepadQuaternion& rhs) {
|
| +bool isWebGamepadQuaternionEqual(const GamepadQuaternion& lhs,
|
| + const GamepadQuaternion& rhs) {
|
| return ((lhs.not_null == false && rhs.not_null == false) ||
|
| (lhs.not_null == rhs.not_null && lhs.x == rhs.x && lhs.y == rhs.y &&
|
| lhs.z == rhs.z && lhs.w == rhs.w));
|
| }
|
|
|
| -bool isWebGamepadPoseEqual(const blink::WebGamepadPose& lhs,
|
| - const blink::WebGamepadPose& rhs) {
|
| +bool isWebGamepadPoseEqual(const GamepadPose& lhs, const GamepadPose& rhs) {
|
| if (lhs.not_null == false && rhs.not_null == false) {
|
| return true;
|
| }
|
| @@ -131,8 +130,7 @@ bool isWebGamepadPoseEqual(const blink::WebGamepadPose& lhs,
|
| return true;
|
| }
|
|
|
| -bool isWebGamepadEqual(const blink::WebGamepad& send,
|
| - const blink::WebGamepad& echo) {
|
| +bool isWebGamepadEqual(const Gamepad& send, const Gamepad& echo) {
|
| if (send.connected != echo.connected || send.timestamp != echo.timestamp ||
|
| send.axes_length != echo.axes_length ||
|
| send.buttons_length != echo.buttons_length ||
|
| @@ -140,22 +138,22 @@ bool isWebGamepadEqual(const blink::WebGamepad& send,
|
| send.display_id != echo.display_id) {
|
| return false;
|
| }
|
| - for (size_t i = 0; i < blink::WebGamepad::kIdLengthCap; i++) {
|
| + for (size_t i = 0; i < Gamepad::kIdLengthCap; i++) {
|
| if (send.id[i] != echo.id[i]) {
|
| return false;
|
| }
|
| }
|
| - for (size_t i = 0; i < blink::WebGamepad::kAxesLengthCap; i++) {
|
| + for (size_t i = 0; i < Gamepad::kAxesLengthCap; i++) {
|
| if (send.axes[i] != echo.axes[i]) {
|
| return false;
|
| }
|
| }
|
| - for (size_t i = 0; i < blink::WebGamepad::kButtonsLengthCap; i++) {
|
| + for (size_t i = 0; i < Gamepad::kButtonsLengthCap; i++) {
|
| if (!isWebGamepadButtonEqual(send.buttons[i], echo.buttons[i])) {
|
| return false;
|
| }
|
| }
|
| - for (size_t i = 0; i < blink::WebGamepad::kMappingLengthCap; i++) {
|
| + for (size_t i = 0; i < Gamepad::kMappingLengthCap; i++) {
|
| if (send.mapping[i] != echo.mapping[i]) {
|
| return false;
|
| }
|
| @@ -163,9 +161,9 @@ bool isWebGamepadEqual(const blink::WebGamepad& send,
|
| return true;
|
| }
|
|
|
| -void ExpectWebGamepad(const blink::WebGamepad& send,
|
| +void ExpectWebGamepad(const Gamepad& send,
|
| const base::Closure& closure,
|
| - const blink::WebGamepad& echo) {
|
| + const Gamepad& echo) {
|
| EXPECT_EQ(true, isWebGamepadEqual(send, echo));
|
| closure.Run();
|
| }
|
| @@ -173,61 +171,57 @@ void ExpectWebGamepad(const blink::WebGamepad& send,
|
| } // namespace
|
|
|
| class GamepadStructTraitsTest : public testing::Test,
|
| - public device::mojom::GamepadStructTraitsTest {
|
| + public mojom::GamepadStructTraitsTest {
|
| protected:
|
| GamepadStructTraitsTest() : binding_(this) {}
|
|
|
| - void PassGamepad(const blink::WebGamepad& send,
|
| + void PassGamepad(const Gamepad& send,
|
| const PassGamepadCallback& callback) override {
|
| callback.Run(send);
|
| }
|
|
|
| - device::mojom::GamepadStructTraitsTestPtr GetGamepadStructTraitsTestProxy() {
|
| + mojom::GamepadStructTraitsTestPtr GetGamepadStructTraitsTestProxy() {
|
| return binding_.CreateInterfacePtrAndBind();
|
| }
|
|
|
| private:
|
| base::MessageLoop message_loop_;
|
| - mojo::Binding<device::mojom::GamepadStructTraitsTest> binding_;
|
| + mojo::Binding<mojom::GamepadStructTraitsTest> binding_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(GamepadStructTraitsTest);
|
| };
|
|
|
| TEST_F(GamepadStructTraitsTest, GamepadCommon) {
|
| - blink::WebGamepad send = GetWebGamepadInstance(GamepadCommon);
|
| + Gamepad send = GetWebGamepadInstance(GamepadCommon);
|
| base::RunLoop loop;
|
| - device::mojom::GamepadStructTraitsTestPtr proxy =
|
| - GetGamepadStructTraitsTestProxy();
|
| + mojom::GamepadStructTraitsTestPtr proxy = GetGamepadStructTraitsTestProxy();
|
| proxy->PassGamepad(send,
|
| base::Bind(&ExpectWebGamepad, send, loop.QuitClosure()));
|
| loop.Run();
|
| }
|
|
|
| TEST_F(GamepadStructTraitsTest, GamepadPose_HasOrientation) {
|
| - blink::WebGamepad send = GetWebGamepadInstance(GamepadPose_HasOrientation);
|
| + Gamepad send = GetWebGamepadInstance(GamepadPose_HasOrientation);
|
| base::RunLoop loop;
|
| - device::mojom::GamepadStructTraitsTestPtr proxy =
|
| - GetGamepadStructTraitsTestProxy();
|
| + mojom::GamepadStructTraitsTestPtr proxy = GetGamepadStructTraitsTestProxy();
|
| proxy->PassGamepad(send,
|
| base::Bind(&ExpectWebGamepad, send, loop.QuitClosure()));
|
| loop.Run();
|
| }
|
|
|
| TEST_F(GamepadStructTraitsTest, GamepadPose_HasPosition) {
|
| - blink::WebGamepad send = GetWebGamepadInstance(GamepadPose_HasPosition);
|
| + Gamepad send = GetWebGamepadInstance(GamepadPose_HasPosition);
|
| base::RunLoop loop;
|
| - device::mojom::GamepadStructTraitsTestPtr proxy =
|
| - GetGamepadStructTraitsTestProxy();
|
| + mojom::GamepadStructTraitsTestPtr proxy = GetGamepadStructTraitsTestProxy();
|
| proxy->PassGamepad(send,
|
| base::Bind(&ExpectWebGamepad, send, loop.QuitClosure()));
|
| loop.Run();
|
| }
|
|
|
| TEST_F(GamepadStructTraitsTest, GamepadPose_Null) {
|
| - blink::WebGamepad send = GetWebGamepadInstance(GamepadPose_Null);
|
| + Gamepad send = GetWebGamepadInstance(GamepadPose_Null);
|
| base::RunLoop loop;
|
| - device::mojom::GamepadStructTraitsTestPtr proxy =
|
| - GetGamepadStructTraitsTestProxy();
|
| + mojom::GamepadStructTraitsTestPtr proxy = GetGamepadStructTraitsTestProxy();
|
| proxy->PassGamepad(send,
|
| base::Bind(&ExpectWebGamepad, send, loop.QuitClosure()));
|
| loop.Run();
|
|
|