diff --git a/plugins/amda/tests/FuzzingDefs.cpp b/plugins/amda/tests/FuzzingDefs.cpp index cf0add9..03b7b72 100644 --- a/plugins/amda/tests/FuzzingDefs.cpp +++ b/plugins/amda/tests/FuzzingDefs.cpp @@ -81,7 +81,8 @@ void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId sync return; } - // Unregisters variable from sync group: if there is no more variable in the group, resets the range + // Unregisters variable from sync group: if there is no more variable in the group, resets the + // range auto &syncGroup = m_SyncGroupsPool.at(syncGroupId); syncGroup.m_Variables.erase(variableId); if (syncGroup.m_Variables.empty()) { @@ -89,3 +90,18 @@ void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId sync } } +void FuzzingState::updateRanges(VariableId variableId, const SqpRange &newRange) +{ + auto syncGroupId = this->syncGroupId(variableId); + + // Retrieves the variables to update: + // - if the variable is synchronized to others, updates all synchronized variables + // - otherwise, updates only the variable + auto variablesToUpdate = syncGroupId.isNull() ? std::set{variableId} + : m_SyncGroupsPool.at(syncGroupId).m_Variables; + + // Sets new range + for (const auto &variableId : variablesToUpdate) { + m_VariablesPool.at(variableId).m_Range = newRange; + } +} diff --git a/plugins/amda/tests/FuzzingDefs.h b/plugins/amda/tests/FuzzingDefs.h index 0afef83..1fa585b 100644 --- a/plugins/amda/tests/FuzzingDefs.h +++ b/plugins/amda/tests/FuzzingDefs.h @@ -110,6 +110,10 @@ struct FuzzingState { /// @param syncGroupId the synchronization group from which to remove the variable void desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId); + /// Updates the range of a variable and all variables to which it is synchronized + /// @param the variable for which to affect the range + /// @param the range to affect + void updateRanges(VariableId variableId, const SqpRange &newRange); VariablesPool m_VariablesPool; SyncGroupsPool m_SyncGroupsPool; diff --git a/plugins/amda/tests/FuzzingOperations.cpp b/plugins/amda/tests/FuzzingOperations.cpp index a61dfa6..bba178c 100644 --- a/plugins/amda/tests/FuzzingOperations.cpp +++ b/plugins/amda/tests/FuzzingOperations.cpp @@ -136,15 +136,16 @@ struct MoveOperation : public IFuzzingOperation { auto delta = RandomGenerator::instance().generateDouble(0, deltaMax); // Moves variable to its new range + auto isSynchronized = !fuzzingState.syncGroupId(variableId).isNull(); auto newVariableRange = SqpRange{m_RangeStartMoveFun(variableRange.m_TStart, delta), m_RangeEndMoveFun(variableRange.m_TEnd, delta)}; qCInfo(LOG_FuzzingOperations()).noquote() << "Performing" << m_Label << "on" << variable->name() << "(from" << variableRange << "to" << newVariableRange << ")..."; - variableController.onRequestDataLoading({variable}, newVariableRange, false); + variableController.onRequestDataLoading({variable}, newVariableRange, isSynchronized); - // Updates variable's state - variableState.m_Range = newVariableRange; + // Updates state + fuzzingState.updateRanges(variableId, newVariableRange); } MoveFunction m_RangeStartMoveFun;