##// END OF EJS Templates
Setups test (4)...
Alexandre Leroux -
r716:c3e161f3c70a
parent child
Show More
@@ -6,12 +6,16
6 #include <Data/DataProviderParameters.h>
6 #include <Data/DataProviderParameters.h>
7 #include <Data/IDataProvider.h>
7 #include <Data/IDataProvider.h>
8 #include <Data/ScalarSeries.h>
8 #include <Data/ScalarSeries.h>
9 #include <Time/TimeController.h>
9 #include <Variable/Variable.h>
10 #include <Variable/Variable.h>
10 #include <Variable/VariableController.h>
11 #include <Variable/VariableController.h>
11 #include <Variable/VariableModel.h>
12 #include <Variable/VariableModel.h>
12
13
13 namespace {
14 namespace {
14
15
16 /// Delay after each operation on the variable before validating it (in ms)
17 const auto OPERATION_DELAY = 100;
18
15 /**
19 /**
16 * Generates values according to a range. The value generated for a time t is the number of seconds
20 * Generates values according to a range. The value generated for a time t is the number of seconds
17 * of difference between t and a reference value (which is midnight -> 00:00:00)
21 * of difference between t and a reference value (which is midnight -> 00:00:00)
@@ -173,7 +177,9 void TestVariableSync::testSync_data()
173 // Test structure //
177 // Test structure //
174 // ////////////// //
178 // ////////////// //
175
179
176 /// @todo
180 QTest::addColumn<QUuid>("syncId");
181 QTest::addColumn<SqpRange>("initialRange");
182 QTest::addColumn<Iterations>("iterations");
177
183
178 // ////////// //
184 // ////////// //
179 // Test cases //
185 // Test cases //
@@ -184,7 +190,50 void TestVariableSync::testSync_data()
184
190
185 void TestVariableSync::testSync()
191 void TestVariableSync::testSync()
186 {
192 {
187 /// @todo
193 // Inits controllers
194 TimeController timeController{};
195 VariableController variableController{};
196 variableController.setTimeController(&timeController);
197
198 QFETCH(QUuid, syncId);
199 QFETCH(SqpRange, initialRange);
200 timeController.onTimeToUpdate(initialRange);
201
202 // Synchronization group used
203 variableController.onAddSynchronizationGroupId(syncId);
204
205 // For each iteration:
206 // - execute operation
207 // - compare the variables' state to the expected states
208 QFETCH(Iterations, iterations);
209 for (const auto &iteration : iterations) {
210 iteration.m_Operation->exec(variableController);
211 QTest::qWait(OPERATION_DELAY);
212
213 for (const auto &expectedRangeEntry : iteration.m_ExpectedRanges) {
214 auto variableIndex = expectedRangeEntry.first;
215 auto expectedRange = expectedRangeEntry.second;
216
217 // Gets the variable in the controller
218 auto variable = variableController.variableModel()->variable(variableIndex);
219
220 // Compares variable's range to the expected range
221 QVERIFY(variable != nullptr);
222 auto range = variable->range();
223 QCOMPARE(range, expectedRange);
224
225 // Compares variable's data with values expected for its range
226 auto dataSeries = variable->dataSeries();
227 QVERIFY(dataSeries != nullptr);
228
229 auto it = dataSeries->xAxisRange(range.m_TStart, range.m_TEnd);
230 auto expectedValues = values(range);
231 QVERIFY(std::equal(it.first, it.second, expectedValues.cbegin(), expectedValues.cend(),
232 [](const auto &dataSeriesIt, const auto &expectedValue) {
233 return dataSeriesIt.value() == expectedValue;
234 }));
235 }
236 }
188 }
237 }
189
238
190 QTEST_MAIN(TestVariableSync)
239 QTEST_MAIN(TestVariableSync)
General Comments 0
You need to be logged in to leave comments. Login now