##// END OF EJS Templates
Adds delete operation
Alexandre Leroux -
r1225:96867eb9a6ed
parent child
Show More
@@ -35,7 +35,7 struct CreateOperation : public IFuzzingOperation {
35
35
36 auto variableName = QString{"Var_%1"}.arg(QUuid::createUuid().toString());
36 auto variableName = QString{"Var_%1"}.arg(QUuid::createUuid().toString());
37 qCInfo(LOG_FuzzingOperations()).noquote()
37 qCInfo(LOG_FuzzingOperations()).noquote()
38 << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")";
38 << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")...";
39
39
40 auto newVariable
40 auto newVariable
41 = variableController.createVariable(variableName, variableMetadata, variableProvider);
41 = variableController.createVariable(variableName, variableMetadata, variableProvider);
@@ -46,6 +46,28 struct CreateOperation : public IFuzzingOperation {
46 }
46 }
47 };
47 };
48
48
49 struct DeleteOperation : public IFuzzingOperation {
50 bool canExecute(const VariableState &variableState) const override
51 {
52 // A variable can be delete only if it exists
53 return variableState.m_Variable != nullptr;
54 }
55
56 void execute(VariableState &variableState, VariableController &variableController,
57 const Properties &properties) const override
58 {
59 Q_UNUSED(properties);
60
61 qCInfo(LOG_FuzzingOperations()).noquote()
62 << "Deleting variable" << variableState.m_Variable->name() << "...";
63 variableController.deleteVariable(variableState.m_Variable);
64
65 // Updates variable's state
66 variableState.m_Range = INVALID_RANGE;
67 variableState.m_Variable = nullptr;
68 }
69 };
70
49 /**
71 /**
50 * Defines a move operation through a range.
72 * Defines a move operation through a range.
51 *
73 *
@@ -147,6 +169,8 std::unique_ptr<IFuzzingOperation> FuzzingOperationFactory::create(FuzzingOperat
147 switch (type) {
169 switch (type) {
148 case FuzzingOperationType::CREATE:
170 case FuzzingOperationType::CREATE:
149 return std::make_unique<CreateOperation>();
171 return std::make_unique<CreateOperation>();
172 case FuzzingOperationType::DELETE:
173 return std::make_unique<DeleteOperation>();
150 case FuzzingOperationType::PAN_LEFT:
174 case FuzzingOperationType::PAN_LEFT:
151 return std::make_unique<MoveOperation>(
175 return std::make_unique<MoveOperation>(
152 std::minus<double>(), std::minus<double>(),
176 std::minus<double>(), std::minus<double>(),
@@ -16,7 +16,7 class VariableController;
16 /**
16 /**
17 * Enumeration of types of existing fuzzing operations
17 * Enumeration of types of existing fuzzing operations
18 */
18 */
19 enum class FuzzingOperationType { CREATE, PAN_LEFT, PAN_RIGHT, ZOOM_IN, ZOOM_OUT };
19 enum class FuzzingOperationType { CREATE, DELETE, PAN_LEFT, PAN_RIGHT, ZOOM_IN, ZOOM_OUT };
20
20
21 /// Interface that represents an operation that can be executed during a fuzzing test
21 /// Interface that represents an operation that can be executed during a fuzzing test
22 struct IFuzzingOperation {
22 struct IFuzzingOperation {
@@ -42,12 +42,13 using VariablesPool = std::map<VariableId, VariableState>;
42 // Defaults values used when the associated properties have not been set for the test
42 // Defaults values used when the associated properties have not been set for the test
43 const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100;
43 const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100;
44 const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1;
44 const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1;
45 const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE
45 const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE = QVariant::fromValue(WeightedOperationsTypes{
46 = QVariant::fromValue(WeightedOperationsTypes{{FuzzingOperationType::CREATE, 1.},
46 {FuzzingOperationType::CREATE, 1.},
47 {FuzzingOperationType::PAN_LEFT, 1.},
47 {FuzzingOperationType::DELETE, 0.1}, // Delete operation is less frequent
48 {FuzzingOperationType::PAN_RIGHT, 1.},
48 {FuzzingOperationType::PAN_LEFT, 1.},
49 {FuzzingOperationType::ZOOM_IN, 1.},
49 {FuzzingOperationType::PAN_RIGHT, 1.},
50 {FuzzingOperationType::ZOOM_OUT, 1.}});
50 {FuzzingOperationType::ZOOM_IN, 1.},
51 {FuzzingOperationType::ZOOM_OUT, 1.}});
51 const auto CACHE_TOLERANCE_DEFAULT_VALUE = 0.2;
52 const auto CACHE_TOLERANCE_DEFAULT_VALUE = 0.2;
52
53
53 /// Delay between each operation (in ms)
54 /// Delay between each operation (in ms)
@@ -138,7 +139,6 public:
138
139
139 fuzzingOperation->execute(variableState, m_VariableController, m_Properties);
140 fuzzingOperation->execute(variableState, m_VariableController, m_Properties);
140 QTest::qWait(operationDelay());
141 QTest::qWait(operationDelay());
141
142 }
142 }
143 else {
143 else {
144 qCInfo(LOG_TestAmdaFuzzing()).noquote()
144 qCInfo(LOG_TestAmdaFuzzing()).noquote()
General Comments 0
You need to be logged in to leave comments. Login now