##// END OF EJS Templates
Setups test (2)...
Alexandre Leroux -
r714:6790f5fb3952
parent child
Show More
@@ -1,8 +1,12
1 1 #include <QObject>
2 2 #include <QtTest>
3 3
4 #include <memory>
5
4 6 #include <Variable/Variable.h>
5 7 #include <Variable/VariableController.h>
8 #include <Variable/VariableModel.h>
9
6 10 namespace {
7 11
8 12 /**
@@ -17,6 +21,69 struct IOperation {
17 21 };
18 22
19 23 /**
24 *Variable creation operation in the controller
25 */
26 struct Create : public IOperation {
27 explicit Create(int index) : m_Index{index} {}
28
29 void exec(VariableController &variableController) const override
30 {
31 auto variable = variableController.createVariable(QString::number(m_Index), {},
32 std::make_unique<TestProvider>());
33 }
34
35 int m_Index; ///< The index of the variable to create in the controller
36 };
37
38 /**
39 * Variable move/shift operation in the controller
40 */
41 struct Move : public IOperation {
42 explicit Move(int index, const SqpRange &newRange, bool shift = false)
43 : m_Index{index}, m_NewRange{newRange}, m_Shift{shift}
44 {
45 }
46
47 void exec(VariableController &variableController) const override
48 {
49 if (auto variable = variableController.variableModel()->variable(m_Index)) {
50 variableController.onRequestDataLoading({variable}, m_NewRange, variable->range(),
51 !m_Shift);
52 }
53 }
54
55 int m_Index; ///< The index of the variable to move
56 SqpRange m_NewRange; ///< The new range of the variable
57 bool m_Shift; ///< Performs a shift (
58 };
59
60 /**
61 * Variable synchronization/desynchronization operation in the controller
62 */
63 struct Synchronize : public IOperation {
64 explicit Synchronize(int index, QUuid syncId, bool synchronize = true)
65 : m_Index{index}, m_SyncId{syncId}, m_Synchronize{synchronize}
66 {
67 }
68
69 void exec(VariableController &variableController) const override
70 {
71 if (auto variable = variableController.variableModel()->variable(m_Index)) {
72 if (m_Synchronize) {
73 variableController.onAddSynchronized(variable, m_SyncId);
74 }
75 else {
76 variableController.desynchronize(variable, m_SyncId);
77 }
78 }
79 }
80
81 int m_Index; ///< The index of the variable to sync/desync
82 QUuid m_SyncId; ///< The synchronization group of the variable
83 bool m_Synchronize; ///< Performs sync or desync operation
84 };
85
86 /**
20 87 * Test Iteration
21 88 *
22 89 * A test iteration includes an operation to be performed, and a set of expected ranges after each
General Comments 0
You need to be logged in to leave comments. Login now