| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/input/input_event.h" |
| 34 |
#include "tests/test_macros.h" |
| 35 |
|
| 36 |
namespace TestInputEventMouse { |
| 37 |
|
| 38 |
TEST_CASE("[InputEventMouse] Mouse button mask is set correctly") { |
| 39 |
InputEventMouse mousekey; |
| 40 |
|
| 41 |
mousekey.set_button_mask(MouseButtonMask::LEFT); |
| 42 |
CHECK(mousekey.get_button_mask().has_flag(MouseButtonMask::LEFT)); |
| 43 |
|
| 44 |
mousekey.set_button_mask(MouseButtonMask::MB_XBUTTON1); |
| 45 |
CHECK(mousekey.get_button_mask().has_flag(MouseButtonMask::MB_XBUTTON1)); |
| 46 |
|
| 47 |
mousekey.set_button_mask(MouseButtonMask::MB_XBUTTON2); |
| 48 |
CHECK(mousekey.get_button_mask().has_flag(MouseButtonMask::MB_XBUTTON2)); |
| 49 |
|
| 50 |
mousekey.set_button_mask(MouseButtonMask::MIDDLE); |
| 51 |
CHECK(mousekey.get_button_mask().has_flag(MouseButtonMask::MIDDLE)); |
| 52 |
|
| 53 |
mousekey.set_button_mask(MouseButtonMask::RIGHT); |
| 54 |
CHECK(mousekey.get_button_mask().has_flag(MouseButtonMask::RIGHT)); |
| 55 |
} |
| 56 |
|
| 57 |
TEST_CASE("[InputEventMouse] Setting the mouse position works correctly") { |
| 58 |
InputEventMouse mousekey; |
| 59 |
|
| 60 |
mousekey.set_position(Vector2{ 10, 10 }); |
| 61 |
CHECK(mousekey.get_position() == Vector2{ 10, 10 }); |
| 62 |
|
| 63 |
mousekey.set_position(Vector2{ -1, -1 }); |
| 64 |
CHECK(mousekey.get_position() == Vector2{ -1, -1 }); |
| 65 |
} |
| 66 |
|
| 67 |
TEST_CASE("[InputEventMouse] Setting the global mouse position works correctly") { |
| 68 |
InputEventMouse mousekey; |
| 69 |
|
| 70 |
mousekey.set_global_position(Vector2{ 10, 10 }); |
| 71 |
CHECK(mousekey.get_global_position() == Vector2{ 10, 10 }); |
| 72 |
CHECK(mousekey.get_global_position() != Vector2{ 1, 1 }); |
| 73 |
|
| 74 |
mousekey.set_global_position(Vector2{ -1, -1 }); |
| 75 |
CHECK(mousekey.get_global_position() == Vector2{ -1, -1 }); |
| 76 |
CHECK(mousekey.get_global_position() != Vector2{ 1, 1 }); |
| 77 |
} |
| 78 |
} |