diff --git a/plugins/amda/tests/FuzzingOperations.cpp b/plugins/amda/tests/FuzzingOperations.cpp index b0c590b..6991c0f 100644 --- a/plugins/amda/tests/FuzzingOperations.cpp +++ b/plugins/amda/tests/FuzzingOperations.cpp @@ -15,13 +15,13 @@ Q_LOGGING_CATEGORY(LOG_FuzzingOperations, "FuzzingOperations") namespace { struct CreateOperation : public IFuzzingOperation { - bool canExecute(std::shared_ptr variable) const override + bool canExecute(const VariableState &variableState) const override { // A variable can be created only if it doesn't exist yet - return variable == nullptr; + return variableState.m_Variable == nullptr; } - void execute(std::shared_ptr &variable, VariableController &variableController, + void execute(VariableState &variableState, VariableController &variableController, const Properties &properties) const override { // Retrieves metadata pool from properties, and choose one of the metadata entries to @@ -39,7 +39,7 @@ struct CreateOperation : public IFuzzingOperation { auto newVariable = variableController.createVariable(variableName, variableMetadata, variableProvider); - std::swap(variable, newVariable); + std::swap(variableState.m_Variable, newVariable); } }; @@ -75,14 +75,16 @@ struct MoveOperation : public IFuzzingOperation { { } - bool canExecute(std::shared_ptr variable) const override + bool canExecute(const VariableState &variableState) const override { - return variable != nullptr; + return variableState.m_Variable != nullptr; } - void execute(std::shared_ptr &variable, VariableController &variableController, + void execute(VariableState &variableState, VariableController &variableController, const Properties &properties) const override { + auto variable = variableState.m_Variable; + // Gets the max range defined auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE)) .value(); @@ -107,6 +109,9 @@ struct MoveOperation : public IFuzzingOperation { << "Performing" << m_Label << "on" << variable->name() << "(from" << variableRange << "to" << newVariableRange << ")..."; variableController.onRequestDataLoading({variable}, newVariableRange, false); + + // Updates variable's state + variableState.m_Range = newVariableRange; } MoveFunction m_RangeStartMoveFun; @@ -116,16 +121,16 @@ struct MoveOperation : public IFuzzingOperation { }; struct UnknownOperation : public IFuzzingOperation { - bool canExecute(std::shared_ptr variable) const override + bool canExecute(const VariableState &variableState) const override { - Q_UNUSED(variable); + Q_UNUSED(variableState); return false; } - void execute(std::shared_ptr &variable, VariableController &variableController, + void execute(VariableState &variableState, VariableController &variableController, const Properties &properties) const override { - Q_UNUSED(variable); + Q_UNUSED(variableState); Q_UNUSED(variableController); Q_UNUSED(properties); // Does nothing diff --git a/plugins/amda/tests/FuzzingOperations.h b/plugins/amda/tests/FuzzingOperations.h index fecd2dc..ce8e134 100644 --- a/plugins/amda/tests/FuzzingOperations.h +++ b/plugins/amda/tests/FuzzingOperations.h @@ -11,7 +11,6 @@ Q_DECLARE_LOGGING_CATEGORY(LOG_FuzzingOperations) -class Variable; class VariableController; /** @@ -23,17 +22,17 @@ enum class FuzzingOperationType { CREATE, PAN_LEFT, PAN_RIGHT, ZOOM_IN, ZOOM_OUT struct IFuzzingOperation { virtual ~IFuzzingOperation() noexcept = default; - /// Checks if the operation can be executed according to the current state of the variable - /// passed in parameter - virtual bool canExecute(std::shared_ptr variable) const = 0; - /// Executes the operation on the variable passed in parameter - /// @param variable the variable on which to execute the operation + /// Checks if the operation can be executed according to the current variable state passed in + /// parameter + virtual bool canExecute(const VariableState &variableState) const = 0; + /// Executes the operation on the variable state passed in parameter + /// @param variableState the variable state on which to execute the operation /// @param variableController the controller associated to the operation /// @param properties properties that can be used to configure the operation - /// @remarks variable is passed as a reference because, according to the operation, it can be + /// @remarks variableState is passed as a reference because, according to the operation, it can + /// be /// modified (in/out parameter) - virtual void execute(std::shared_ptr &variable, - VariableController &variableController, + virtual void execute(VariableState &variableState, VariableController &variableController, const Properties &properties = {}) const = 0; };