step 3
This commit is contained in:
@@ -349,6 +349,100 @@ void TestRuntimeLiveStateTriggerOverlayIncrementsAndClears()
|
||||
Expect(liveState.OverlayCount() == 0, "trigger overlay clears after apply");
|
||||
}
|
||||
|
||||
void TestRuntimeLiveStateClearsOverlaysForLayerKey()
|
||||
{
|
||||
RuntimeLiveState liveState;
|
||||
|
||||
RuntimeLiveOscUpdate first;
|
||||
first.routeKey = "layer-one\namount";
|
||||
first.layerKey = "layer-one";
|
||||
first.parameterKey = "amount";
|
||||
first.targetValue = JsonValue(0.5);
|
||||
|
||||
RuntimeLiveOscUpdate second = first;
|
||||
second.routeKey = "layer-two\namount";
|
||||
second.layerKey = "layer-two";
|
||||
second.targetValue = JsonValue(0.75);
|
||||
|
||||
liveState.ApplyOscUpdates({ first, second });
|
||||
liveState.ClearForLayerKey("layer-one");
|
||||
|
||||
Expect(liveState.OverlayCount() == 1, "layer-scoped invalidation only removes matching overlays");
|
||||
|
||||
std::vector<RuntimeRenderState> states = { MakeLayerState() };
|
||||
states[0].layerId = "layer-two";
|
||||
RuntimeLiveStateApplyOptions options;
|
||||
options.smoothing = 0.0;
|
||||
liveState.ApplyToLayerStates(states, options, nullptr);
|
||||
|
||||
const auto valueIt = states[0].parameterValues.find("amount");
|
||||
Expect(valueIt != states[0].parameterValues.end() &&
|
||||
!valueIt->second.numberValues.empty() &&
|
||||
std::fabs(valueIt->second.numberValues[0] - 0.75) < 0.0001,
|
||||
"unmatched layer invalidation preserves unrelated overlay");
|
||||
}
|
||||
|
||||
void TestRuntimeLiveStatePrunesRemovedLayerOverlay()
|
||||
{
|
||||
RuntimeLiveState liveState;
|
||||
|
||||
RuntimeLiveOscUpdate update;
|
||||
update.routeKey = "removed-layer\namount";
|
||||
update.layerKey = "removed-layer";
|
||||
update.parameterKey = "amount";
|
||||
update.targetValue = JsonValue(0.5);
|
||||
liveState.ApplyOscUpdates({ update });
|
||||
|
||||
std::vector<RuntimeRenderState> states = { MakeLayerState() };
|
||||
liveState.PruneIncompatibleOverlays(states);
|
||||
|
||||
Expect(liveState.OverlayCount() == 0, "invalidation policy removes overlays for missing layers");
|
||||
}
|
||||
|
||||
void TestRuntimeLiveStatePrunesIncompatibleParameterOverlay()
|
||||
{
|
||||
RuntimeLiveState liveState;
|
||||
|
||||
RuntimeLiveOscUpdate update;
|
||||
update.routeKey = "layer-one\namount";
|
||||
update.layerKey = "layer-one";
|
||||
update.parameterKey = "amount";
|
||||
update.targetValue = JsonValue(0.5);
|
||||
liveState.ApplyOscUpdates({ update });
|
||||
|
||||
std::vector<RuntimeRenderState> states = { MakeLayerStateWithDefinitions({ FloatDefinition("other", "Other") }) };
|
||||
liveState.PruneIncompatibleOverlays(states);
|
||||
|
||||
Expect(liveState.OverlayCount() == 0, "invalidation policy removes overlays for missing parameters");
|
||||
}
|
||||
|
||||
void TestRuntimeLiveStatePreservesCompatibleOverlayAfterShaderReload()
|
||||
{
|
||||
RuntimeLiveState liveState;
|
||||
|
||||
RuntimeLiveOscUpdate update;
|
||||
update.routeKey = "layer-one\namount";
|
||||
update.layerKey = "layer-one";
|
||||
update.parameterKey = "Amount";
|
||||
update.targetValue = JsonValue(0.5);
|
||||
liveState.ApplyOscUpdates({ update });
|
||||
|
||||
std::vector<RuntimeRenderState> states = { MakeLayerStateWithDefinitions({ FloatDefinition("amount-renamed", "Amount") }) };
|
||||
liveState.PruneIncompatibleOverlays(states);
|
||||
|
||||
Expect(liveState.OverlayCount() == 1, "invalidation policy preserves overlays that still map by control key");
|
||||
|
||||
RuntimeLiveStateApplyOptions options;
|
||||
options.smoothing = 0.0;
|
||||
liveState.ApplyToLayerStates(states, options, nullptr);
|
||||
|
||||
const auto valueIt = states[0].parameterValues.find("amount-renamed");
|
||||
Expect(valueIt != states[0].parameterValues.end() &&
|
||||
!valueIt->second.numberValues.empty() &&
|
||||
std::fabs(valueIt->second.numberValues[0] - 0.5) < 0.0001,
|
||||
"compatible overlay applies to the reloaded parameter id");
|
||||
}
|
||||
|
||||
void TestRenderStateComposerBuildsFrameState()
|
||||
{
|
||||
RuntimeLiveState liveState;
|
||||
@@ -496,6 +590,10 @@ int main()
|
||||
TestRuntimeLiveStateSmoothingPartiallyConverges();
|
||||
TestRuntimeLiveStateSmoothingVectorSizeMismatchUsesTargetShape();
|
||||
TestRuntimeLiveStateTriggerOverlayIncrementsAndClears();
|
||||
TestRuntimeLiveStateClearsOverlaysForLayerKey();
|
||||
TestRuntimeLiveStatePrunesRemovedLayerOverlay();
|
||||
TestRuntimeLiveStatePrunesIncompatibleParameterOverlay();
|
||||
TestRuntimeLiveStatePreservesCompatibleOverlayAfterShaderReload();
|
||||
TestRenderStateComposerBuildsFrameState();
|
||||
TestRenderStateComposerUsesCommittedLayerOverBaseLayer();
|
||||
TestRenderStateComposerUsesBaseLayerWhenCommittedLayerMissing();
|
||||
|
||||
Reference in New Issue
Block a user