Tests
This commit is contained in:
@@ -34,12 +34,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::AddLayer(const std::string& shaderI
|
||||
std::string error;
|
||||
if (!ValidateShaderExists(shaderId, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("AddLayer", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.CreateStoredLayer(shaderId, error), error, true, true);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.CreateStoredLayer(shaderId, error), error, true, true, true);
|
||||
PublishCoordinatorResult("AddLayer", result);
|
||||
return result;
|
||||
}
|
||||
@@ -50,12 +50,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::RemoveLayer(const std::string& laye
|
||||
std::string error;
|
||||
if (!ValidateLayerExists(layerId, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("RemoveLayer", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.DeleteStoredLayer(layerId, error), error, true, true);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.DeleteStoredLayer(layerId, error), error, true, true, true);
|
||||
PublishCoordinatorResult("RemoveLayer", result);
|
||||
return result;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ RuntimeCoordinatorResult RuntimeCoordinator::MoveLayer(const std::string& layerI
|
||||
bool shouldMove = false;
|
||||
if (!ResolveLayerMove(layerId, direction, shouldMove, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("MoveLayer", result);
|
||||
return result;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ RuntimeCoordinatorResult RuntimeCoordinator::MoveLayer(const std::string& layerI
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.MoveStoredLayer(layerId, direction, error), error, true, true);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.MoveStoredLayer(layerId, direction, error), error, true, true, true);
|
||||
PublishCoordinatorResult("MoveLayer", result);
|
||||
return result;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ RuntimeCoordinatorResult RuntimeCoordinator::MoveLayerToIndex(const std::string&
|
||||
bool shouldMove = false;
|
||||
if (!ResolveLayerMoveToIndex(layerId, targetIndex, shouldMove, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("MoveLayerToIndex", result);
|
||||
return result;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ RuntimeCoordinatorResult RuntimeCoordinator::MoveLayerToIndex(const std::string&
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.MoveStoredLayerToIndex(layerId, targetIndex, error), error, true, true);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.MoveStoredLayerToIndex(layerId, targetIndex, error), error, true, true, true);
|
||||
PublishCoordinatorResult("MoveLayerToIndex", result);
|
||||
return result;
|
||||
}
|
||||
@@ -110,12 +110,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::SetLayerBypass(const std::string& l
|
||||
std::string error;
|
||||
if (!ValidateLayerExists(layerId, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("SetLayerBypass", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredLayerBypassState(layerId, bypassed, error), error, true, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredLayerBypassState(layerId, bypassed, error), error, true, false, true);
|
||||
PublishCoordinatorResult("SetLayerBypass", result);
|
||||
return result;
|
||||
}
|
||||
@@ -126,12 +126,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::SetLayerShader(const std::string& l
|
||||
std::string error;
|
||||
if (!ValidateLayerExists(layerId, error) || !ValidateShaderExists(shaderId, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("SetLayerShader", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredLayerShaderSelection(layerId, shaderId, error), error, true, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredLayerShaderSelection(layerId, shaderId, error), error, true, false, true);
|
||||
PublishCoordinatorResult("SetLayerShader", result);
|
||||
return result;
|
||||
}
|
||||
@@ -143,12 +143,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::UpdateLayerParameter(const std::str
|
||||
ResolvedParameterMutation mutation;
|
||||
if (!BuildParameterMutationById(layerId, parameterId, newValue, true, mutation, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("UpdateLayerParameter", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false, mutation.persistState);
|
||||
PublishCoordinatorResult("UpdateLayerParameter", result);
|
||||
return result;
|
||||
}
|
||||
@@ -160,12 +160,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::UpdateLayerParameterByControlKey(co
|
||||
ResolvedParameterMutation mutation;
|
||||
if (!BuildParameterMutationByControlKey(layerKey, parameterKey, newValue, true, mutation, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("UpdateLayerParameterByControlKey", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false, mutation.persistState);
|
||||
PublishCoordinatorResult("UpdateLayerParameterByControlKey", result);
|
||||
return result;
|
||||
}
|
||||
@@ -177,12 +177,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::CommitOscParameterByControlKey(cons
|
||||
ResolvedParameterMutation mutation;
|
||||
if (!BuildParameterMutationByControlKey(layerKey, parameterKey, newValue, false, mutation, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("CommitOscParameterByControlKey", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SetStoredParameterValue(mutation.layerId, mutation.parameterId, mutation.value, mutation.persistState, error), error, false, false, mutation.persistState);
|
||||
PublishCoordinatorResult("CommitOscParameterByControlKey", result);
|
||||
return result;
|
||||
}
|
||||
@@ -193,12 +193,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::ResetLayerParameters(const std::str
|
||||
std::string error;
|
||||
if (!ValidateLayerExists(layerId, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("ResetLayerParameters", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.ResetStoredLayerParameterValues(layerId, error), error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.ResetStoredLayerParameterValues(layerId, error), error, false, false, true);
|
||||
if (!result.accepted)
|
||||
{
|
||||
PublishCoordinatorResult("ResetLayerParameters", result);
|
||||
@@ -217,12 +217,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::SaveStackPreset(const std::string&
|
||||
std::string error;
|
||||
if (!ValidatePresetName(presetName, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("SaveStackPreset", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SaveStackPresetSnapshot(presetName, error), error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.SaveStackPresetSnapshot(presetName, error), error, false, false, true);
|
||||
PublishCoordinatorResult("SaveStackPreset", result);
|
||||
return result;
|
||||
}
|
||||
@@ -233,12 +233,12 @@ RuntimeCoordinatorResult RuntimeCoordinator::LoadStackPreset(const std::string&
|
||||
std::string error;
|
||||
if (!ValidatePresetName(presetName, error))
|
||||
{
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(false, error, false, false, false);
|
||||
PublishCoordinatorResult("LoadStackPreset", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.LoadStackPresetSnapshot(presetName, error), error, true, false);
|
||||
RuntimeCoordinatorResult result = ApplyStoreMutation(mRuntimeStore.LoadStackPresetSnapshot(presetName, error), error, true, false, true);
|
||||
PublishCoordinatorResult("LoadStackPreset", result);
|
||||
return result;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ bool RuntimeCoordinator::ValidatePresetName(const std::string& presetName, std::
|
||||
return false;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult RuntimeCoordinator::ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState)
|
||||
RuntimeCoordinatorResult RuntimeCoordinator::ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState, bool persistenceRequested)
|
||||
{
|
||||
if (!succeeded)
|
||||
{
|
||||
@@ -457,9 +457,15 @@ RuntimeCoordinatorResult RuntimeCoordinator::ApplyStoreMutation(bool succeeded,
|
||||
}
|
||||
|
||||
if (reloadRequired)
|
||||
return BuildQueuedReloadResult(preserveFeedbackState);
|
||||
{
|
||||
RuntimeCoordinatorResult result = BuildQueuedReloadResult(preserveFeedbackState);
|
||||
result.persistenceRequested = persistenceRequested;
|
||||
return result;
|
||||
}
|
||||
|
||||
return BuildAcceptedNoReloadResult();
|
||||
RuntimeCoordinatorResult result = BuildAcceptedNoReloadResult();
|
||||
result.persistenceRequested = persistenceRequested;
|
||||
return result;
|
||||
}
|
||||
|
||||
RuntimeCoordinatorResult RuntimeCoordinator::BuildQueuedReloadResult(bool preserveFeedbackState)
|
||||
@@ -497,6 +503,7 @@ void RuntimeCoordinator::PublishCoordinatorResult(const std::string& action, con
|
||||
mutation.runtimeStateChanged = result.accepted && result.runtimeStateBroadcastRequired;
|
||||
mutation.runtimeStateBroadcastRequired = result.runtimeStateBroadcastRequired;
|
||||
mutation.shaderBuildRequested = result.shaderBuildRequested;
|
||||
mutation.persistenceRequested = result.persistenceRequested;
|
||||
mutation.clearTransientOscState = result.clearTransientOscState;
|
||||
mutation.renderResetScope = ToRuntimeEventRenderResetScope(result.renderResetScope);
|
||||
mutation.errorMessage = result.errorMessage;
|
||||
@@ -521,9 +528,18 @@ void RuntimeCoordinator::PublishCoordinatorFollowUpEvents(const std::string& act
|
||||
RuntimeStateChangedEvent stateChanged;
|
||||
stateChanged.reason = action;
|
||||
stateChanged.renderVisible = result.renderResetScope != RuntimeCoordinatorRenderResetScope::None;
|
||||
stateChanged.persistenceRequested = result.persistenceRequested;
|
||||
mRuntimeEventDispatcher.PublishPayload(stateChanged, "RuntimeCoordinator");
|
||||
}
|
||||
|
||||
if (result.persistenceRequested)
|
||||
{
|
||||
RuntimePersistenceRequestedEvent persistenceRequested;
|
||||
persistenceRequested.reason = action;
|
||||
persistenceRequested.debounceAllowed = true;
|
||||
mRuntimeEventDispatcher.PublishPayload(persistenceRequested, "RuntimeCoordinator");
|
||||
}
|
||||
|
||||
if (result.shaderBuildRequested)
|
||||
{
|
||||
RuntimeReloadRequestedEvent reloadRequested;
|
||||
|
||||
@@ -30,6 +30,7 @@ struct RuntimeCoordinatorResult
|
||||
bool accepted = false;
|
||||
bool runtimeStateBroadcastRequired = false;
|
||||
bool shaderBuildRequested = false;
|
||||
bool persistenceRequested = false;
|
||||
bool clearTransientOscState = false;
|
||||
bool compileStatusChanged = false;
|
||||
bool compileStatusSucceeded = false;
|
||||
@@ -89,7 +90,7 @@ private:
|
||||
bool ResolveLayerMove(const std::string& layerId, int direction, bool& shouldMove, std::string& error) const;
|
||||
bool ResolveLayerMoveToIndex(const std::string& layerId, std::size_t targetIndex, bool& shouldMove, std::string& error) const;
|
||||
bool ValidatePresetName(const std::string& presetName, std::string& error) const;
|
||||
RuntimeCoordinatorResult ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState);
|
||||
RuntimeCoordinatorResult ApplyStoreMutation(bool succeeded, const std::string& errorMessage, bool reloadRequired, bool preserveFeedbackState, bool persistenceRequested);
|
||||
RuntimeCoordinatorResult BuildQueuedReloadResult(bool preserveFeedbackState);
|
||||
RuntimeCoordinatorResult BuildAcceptedNoReloadResult() const;
|
||||
void PublishCoordinatorResult(const std::string& action, const RuntimeCoordinatorResult& result) const;
|
||||
|
||||
Reference in New Issue
Block a user