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();
|
||||
|
||||
@@ -278,6 +278,14 @@ void TestRuntimeCoordinatorPersistenceEvents()
|
||||
expectAcceptedPersistence(coordinator.UpdateLayerParameter(alphaLayerId, "gain", JsonValue(0.75)), "UpdateLayerParameter",
|
||||
"parameter changes are accepted");
|
||||
|
||||
RuntimeCoordinatorResult resetResult = coordinator.ResetLayerParameters(alphaLayerId);
|
||||
std::vector<RuntimeEvent> resetEvents = dispatchAndClear();
|
||||
Expect(resetResult.accepted, "parameter reset is accepted");
|
||||
Expect(resetResult.transientOscInvalidation == RuntimeCoordinatorTransientOscInvalidation::Layer,
|
||||
"parameter reset requests layer-scoped transient OSC invalidation");
|
||||
Expect(resetResult.transientOscLayerKey == alphaLayerId, "parameter reset invalidates the target layer overlays");
|
||||
Expect(countEvents(resetEvents, RuntimeEventType::RuntimeMutationAccepted) == 1, "parameter reset publishes accepted fact");
|
||||
|
||||
expectAcceptedPersistence(coordinator.AddLayer("beta"), "AddLayer", "stack edits are accepted");
|
||||
layers = store.CopyLayerStates();
|
||||
Expect(layers.size() == 2, "stack edit creates a second layer");
|
||||
|
||||
Reference in New Issue
Block a user