-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The important checks are the ones done with the invertX&Y apply. The isJoystickFlagged checks are sanity checks, you could replace those with whatever you use for flag testing next @csmartdalton. Note that the flag value is loaded via core (auto-generated) as a raw uint32_t: https://github.com/rive-app/rive/blob/eef7de3b1a5b34a3deb3591781ab9ca2d6e15f0d/packages/runtime/include/rive/generated/joystick_base.hpp#L170 Diffs= 7bbf083ce Add some joystick flag tests. (#5921) Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
- Loading branch information
1 parent
23be2fe
commit f65d21c
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
d35df04272e659d8244c776e9c4f558452888501 | ||
7bbf083ce32d92ba240dbf08b852d2702fac18ca |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "rive/joystick.hpp" | ||
#include "rive/shapes/shape.hpp" | ||
#include "rive_file_reader.hpp" | ||
#include "rive_testing.hpp" | ||
|
||
TEST_CASE("joystick flags load as expected", "[file]") | ||
{ | ||
auto file = ReadRiveFile("../../test/assets/joystick_flag_test.riv"); | ||
auto artboard = file->artboard(); | ||
|
||
auto invertX = artboard->find<rive::Joystick>("Invert X Joystick"); | ||
REQUIRE(invertX->isJoystickFlagged(rive::JoystickFlags::invertX)); | ||
REQUIRE(!invertX->isJoystickFlagged(rive::JoystickFlags::invertY)); | ||
REQUIRE(!invertX->isJoystickFlagged(rive::JoystickFlags::worldSpace)); | ||
|
||
invertX->x(0.0f); | ||
invertX->apply(artboard); | ||
REQUIRE(artboard->find<rive::Shape>("invert_x_rect")->x() == 350.0f); | ||
|
||
invertX->x(1.0f); | ||
invertX->apply(artboard); | ||
REQUIRE(artboard->find<rive::Shape>("invert_x_rect")->x() == 300.0f); | ||
|
||
invertX->x(-1.0f); | ||
invertX->apply(artboard); | ||
REQUIRE(artboard->find<rive::Shape>("invert_x_rect")->x() == 400.0f); | ||
|
||
auto invertY = artboard->find<rive::Joystick>("Invert Y Joystick"); | ||
REQUIRE(!invertY->isJoystickFlagged(rive::JoystickFlags::invertX)); | ||
REQUIRE(invertY->isJoystickFlagged(rive::JoystickFlags::invertY)); | ||
REQUIRE(!invertY->isJoystickFlagged(rive::JoystickFlags::worldSpace)); | ||
|
||
invertY->y(0.0f); | ||
invertY->apply(artboard); | ||
REQUIRE(artboard->find<rive::Shape>("invert_y_ellipse")->x() == 425.0f); | ||
|
||
invertY->y(1.0f); | ||
invertY->apply(artboard); | ||
REQUIRE(artboard->find<rive::Shape>("invert_y_ellipse")->x() == 400.0f); | ||
|
||
invertY->y(-1.0f); | ||
invertY->apply(artboard); | ||
REQUIRE(artboard->find<rive::Shape>("invert_y_ellipse")->x() == 450.0f); | ||
|
||
auto world = artboard->find<rive::Joystick>("World Joystick"); | ||
REQUIRE(!world->isJoystickFlagged(rive::JoystickFlags::invertX)); | ||
REQUIRE(!world->isJoystickFlagged(rive::JoystickFlags::invertY)); | ||
REQUIRE(world->isJoystickFlagged(rive::JoystickFlags::worldSpace)); | ||
|
||
auto normal = artboard->find<rive::Joystick>("Normal Joystick"); | ||
REQUIRE(!normal->isJoystickFlagged(rive::JoystickFlags::invertX)); | ||
REQUIRE(!normal->isJoystickFlagged(rive::JoystickFlags::invertY)); | ||
REQUIRE(!normal->isJoystickFlagged(rive::JoystickFlags::worldSpace)); | ||
} |