@@ -35,7 +35,7 struct CreateOperation : public IFuzzingOperation { | |||
|
35 | 35 | |
|
36 | 36 | auto variableName = QString{"Var_%1"}.arg(QUuid::createUuid().toString()); |
|
37 | 37 | qCInfo(LOG_FuzzingOperations()).noquote() |
|
38 | << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")"; | |
|
38 | << "Creating variable" << variableName << "(metadata:" << variableMetadata << ")..."; | |
|
39 | 39 | |
|
40 | 40 | auto newVariable |
|
41 | 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 | 72 | * Defines a move operation through a range. |
|
51 | 73 | * |
@@ -147,6 +169,8 std::unique_ptr<IFuzzingOperation> FuzzingOperationFactory::create(FuzzingOperat | |||
|
147 | 169 | switch (type) { |
|
148 | 170 | case FuzzingOperationType::CREATE: |
|
149 | 171 | return std::make_unique<CreateOperation>(); |
|
172 | case FuzzingOperationType::DELETE: | |
|
173 | return std::make_unique<DeleteOperation>(); | |
|
150 | 174 | case FuzzingOperationType::PAN_LEFT: |
|
151 | 175 | return std::make_unique<MoveOperation>( |
|
152 | 176 | std::minus<double>(), std::minus<double>(), |
@@ -16,7 +16,7 class VariableController; | |||
|
16 | 16 | /** |
|
17 | 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 | 21 | /// Interface that represents an operation that can be executed during a fuzzing test |
|
22 | 22 | struct IFuzzingOperation { |
@@ -42,8 +42,9 using VariablesPool = std::map<VariableId, VariableState>; | |||
|
42 | 42 | // Defaults values used when the associated properties have not been set for the test |
|
43 | 43 | const auto NB_MAX_OPERATIONS_DEFAULT_VALUE = 100; |
|
44 | 44 | const auto NB_MAX_VARIABLES_DEFAULT_VALUE = 1; |
|
45 | const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE | |
|
46 |
|
|
|
45 | const auto AVAILABLE_OPERATIONS_DEFAULT_VALUE = QVariant::fromValue(WeightedOperationsTypes{ | |
|
46 | {FuzzingOperationType::CREATE, 1.}, | |
|
47 | {FuzzingOperationType::DELETE, 0.1}, // Delete operation is less frequent | |
|
47 | 48 |
|
|
48 | 49 |
|
|
49 | 50 |
|
@@ -138,7 +139,6 public: | |||
|
138 | 139 | |
|
139 | 140 | fuzzingOperation->execute(variableState, m_VariableController, m_Properties); |
|
140 | 141 | QTest::qWait(operationDelay()); |
|
141 | ||
|
142 | 142 | } |
|
143 | 143 | else { |
|
144 | 144 | qCInfo(LOG_TestAmdaFuzzing()).noquote() |
General Comments 0
You need to be logged in to leave comments.
Login now