fix(EA): list index can be compared to numbers (#11194) e2f7d6cde1

Co-authored-by: hernan <hernan@rive.app>
This commit is contained in:
bodymovin
2025-12-02 17:51:22 +00:00
parent 8a06f22185
commit 09bed0f410
6 changed files with 51 additions and 6 deletions

Binary file not shown.

View File

@@ -17,8 +17,11 @@
#include <rive/shapes/shape.hpp>
#include "catch.hpp"
#include "rive_file_reader.hpp"
#include "utils/serializing_factory.hpp"
#include <cstdio>
using namespace rive;
TEST_CASE("file with state machine be read", "[file]")
{
auto file = ReadRiveFile("assets/rocket.riv");
@@ -502,3 +505,26 @@ TEST_CASE("Triggers will only be used on allowed state changes.", "[file]")
delete stateMachineInstance;
}
TEST_CASE("Transition with list index can be compared to a number", "[silver]")
{
SerializingFactory silver;
auto file = ReadRiveFile("assets/transition_index_condition.riv", &silver);
auto artboard = file->artboardDefault();
silver.frameSize(artboard->width(), artboard->height());
auto stateMachine = artboard->stateMachineAt(0);
int viewModelId = artboard.get()->viewModelId();
auto vmi = viewModelId == -1
? file->createViewModelInstance(artboard.get())
: file->createViewModelInstance(viewModelId, 0);
stateMachine->bindViewModelInstance(vmi);
stateMachine->advanceAndApply(0.0f);
auto renderer = silver.makeRenderer();
artboard->draw(renderer.get());
CHECK(silver.matches("transition_index_condition"));
}