##// END OF EJS Templates
All the codebase is modified to build with new Variable Controller...
All the codebase is modified to build with new Variable Controller it only builds now there won't be any data update most of the code is broken now ¯\_(ツ)_/¯ Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1348:ea7d1a66f4ab
r1348:ea7d1a66f4ab
Show More
TestCosinusAcquisition.cpp
195 lines | 7.7 KiB | text/x-c | CppLexer
/ plugins / mockplugin / tests / TestCosinusAcquisition.cpp
Alexandre Leroux
Inits unit test
r742 #include "CosinusProvider.h"
Alexandre Leroux
Changes plugin products to integrate parametric frequencies
r783 #include "MockDefs.h"
Alexandre Leroux
Inits unit test
r742
Alexandre Leroux
Implements unit test (2)...
r744 #include <Data/DataProviderParameters.h>
Alexandre Leroux
Implements unit test (1)...
r743 #include <Data/ScalarSeries.h>
Alexandre Leroux
Inits unit test
r742 #include <SqpApplication.h>
Alexandre Leroux
Implements unit test (2)...
r744 #include <Time/TimeController.h>
#include <Variable/Variable.h>
All the codebase is modified to build with new Variable Controller...
r1348 #include <Variable/VariableController2.h>
Alexandre Leroux
Inits unit test
r742
#include <QObject>
#include <QtTest>
Alexandre Leroux
Implements unit test (1)...
r743 #include <cmath>
#include <memory>
Alexandre Leroux
Inits unit test
r742 namespace {
/// Path for the tests
const auto TESTS_RESOURCES_PATH = QFileInfo{
QString{MOCKPLUGIN_TESTS_RESOURCES_DIR},
"TestCosinusAcquisition"}.absoluteFilePath();
Alexandre Leroux
Implements unit test (1)...
r743 /// Format of dates in data files
const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz");
Alexandre Leroux
Implements unit test (3)...
r745 /**
* Verifies that the data in the candidate series are identical to the data in the reference series
* in a specific range
* @param candidate the candidate data series
* @param range the range to check
* @param reference the reference data series
* @return true if the data of the candidate series and the reference series are identical in the
* range, false otherwise
*/
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 bool checkDataSeries(std::shared_ptr<IDataSeries> candidate, const DateTimeRange &range,
Alexandre Leroux
Implements unit test (3)...
r745 std::shared_ptr<IDataSeries> reference)
{
if (candidate == nullptr || reference == nullptr) {
return candidate == reference;
}
auto referenceIt = reference->xAxisRange(range.m_TStart, range.m_TEnd);
Improve cosinus tests with:...
r808 qInfo() << "candidateSize" << std::distance(candidate->cbegin(), candidate->cend());
qInfo() << "refSize" << std::distance(referenceIt.first, referenceIt.second);
Alexandre Leroux
Implements unit test (3)...
r745 return std::equal(candidate->cbegin(), candidate->cend(), referenceIt.first, referenceIt.second,
[](const auto &it1, const auto &it2) {
// - milliseconds precision for time
// - 1e-6 precision for value
return std::abs(it1.x() - it2.x()) < 1e-3
&& std::abs(it1.value() - it2.value()) < 1e-6;
});
}
Alexandre Leroux
Inits unit test
r742 } // namespace
/**
* @brief The TestCosinusAcquisition class tests acquisition in SciQlop (operations like zooms in,
* zooms out, pans) of data from CosinusProvider
* @sa CosinusProvider
*/
class TestCosinusAcquisition : public QObject {
Q_OBJECT
private slots:
/// Input data for @sa testAcquisition()
void testAcquisition_data();
void testAcquisition();
};
void TestCosinusAcquisition::testAcquisition_data()
{
Alexandre Leroux
Implements unit test (1)...
r743 // ////////////// //
// Test structure //
// ////////////// //
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 QTest::addColumn<DateTimeRange>("referenceRange"); // Range for generating reference series
QTest::addColumn<DateTimeRange>("initialRange"); // First acquisition
Improve cosinus tests with:...
r808 QTest::addColumn<int>("operationDelay"); // Acquisitions to make
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 QTest::addColumn<std::vector<DateTimeRange> >("operations"); // Acquisitions to make
Alexandre Leroux
Adds test case
r746
// ////////// //
// Test cases //
// ////////// //
auto dateTime = [](int year, int month, int day, int hours, int minutes, int seconds) {
return DateUtils::secondsSinceEpoch(
QDateTime{{year, month, day}, {hours, minutes, seconds}, Qt::UTC});
};
QTest::newRow("cosinus")
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 << DateTimeRange{dateTime(2017, 1, 1, 12, 0, 0), dateTime(2017, 1, 1, 13, 0, 0)}
<< DateTimeRange{dateTime(2017, 1, 1, 12, 30, 0), dateTime(2017, 1, 1, 12, 35, 1)} << 250
<< std::vector<DateTimeRange>{
Alexandre Leroux
Adds test case
r746 // Pan (jump) left
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 12, 45, 0), dateTime(2017, 1, 1, 12, 50, 0)},
Alexandre Leroux
Adds test case
r746 // Pan (jump) right
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 12, 15, 0), dateTime(2017, 1, 1, 12, 20, 0)},
Alexandre Leroux
Adds test case
r746 // Pan (overlay) right
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 12, 14, 0), dateTime(2017, 1, 1, 12, 19, 0)},
Alexandre Leroux
Adds test case
r746 // Pan (overlay) left
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 12, 15, 0), dateTime(2017, 1, 1, 12, 20, 0)},
Alexandre Leroux
Adds test case
r746 // Pan (overlay) left
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 12, 16, 0), dateTime(2017, 1, 1, 12, 21, 0)},
Alexandre Leroux
Adds test case
r746 // Zoom in
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 12, 17, 30), dateTime(2017, 1, 1, 12, 19, 30)},
Alexandre Leroux
Adds test case
r746 // Zoom out
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 12, 12, 30), dateTime(2017, 1, 1, 12, 24, 30)}};
Improve cosinus tests with:...
r808
QTest::newRow("cosinus_big")
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 << DateTimeRange{dateTime(2017, 1, 1, 1, 0, 0), dateTime(2017, 1, 5, 13, 0, 0)}
<< DateTimeRange{dateTime(2017, 1, 2, 6, 30, 0), dateTime(2017, 1, 2, 18, 30, 0)} << 5000
<< std::vector<DateTimeRange>{
Improve cosinus tests with:...
r808 // Pan (jump) left
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 13, 30, 0), dateTime(2017, 1, 1, 18, 30, 0)},
Improve cosinus tests with:...
r808 // Pan (jump) right
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 3, 4, 30, 0), dateTime(2017, 1, 3, 10, 30, 0)},
Improve cosinus tests with:...
r808 // Pan (overlay) right
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 3, 8, 30, 0), dateTime(2017, 1, 3, 12, 30, 0)},
Improve cosinus tests with:...
r808 // Pan (overlay) left
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 2, 8, 30, 0), dateTime(2017, 1, 3, 10, 30, 0)},
Improve cosinus tests with:...
r808 // Pan (overlay) left
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 12, 30, 0), dateTime(2017, 1, 3, 5, 30, 0)},
Improve cosinus tests with:...
r808 // Zoom in
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 2, 2, 30, 0), dateTime(2017, 1, 2, 8, 30, 0)},
Improve cosinus tests with:...
r808 // Zoom out
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 DateTimeRange{dateTime(2017, 1, 1, 14, 30, 0), dateTime(2017, 1, 3, 12, 30, 0)}};
Alexandre Leroux
Inits unit test
r742 }
void TestCosinusAcquisition::testAcquisition()
{
Improve cosinus tests with:...
r808 // Retrieves reference range
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 QFETCH(DateTimeRange, referenceRange);
Improve cosinus tests with:...
r808 CosinusProvider referenceProvider{};
auto dataSeries = referenceProvider.provideDataSeries(
Modification of the testCosinusAcquisition to test with 2Millions point...
r1073 referenceRange, {{COSINUS_TYPE_KEY, "scalar"}, {COSINUS_FREQUENCY_KEY, 10.}});
Improve cosinus tests with:...
r808
auto end = dataSeries->cend() - 1;
qInfo() << dataSeries->nbPoints() << dataSeries->cbegin()->x() << end->x();
/// Lambda used to validate a variable at each step
auto validateVariable
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 = [dataSeries](std::shared_ptr<Variable> variable, const DateTimeRange &range) {
Improve cosinus tests with:...
r808 // Checks that the variable's range has changed
Modification of the test for the new vc request kernel
r826 qInfo() << "range vs expected range" << variable->range() << range;
Improve cosinus tests with:...
r808 QCOMPARE(variable->range(), range);
// Checks the variable's data series
QVERIFY(checkDataSeries(variable->dataSeries(), variable->cacheRange(), dataSeries));
};
// Creates variable
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 QFETCH(DateTimeRange, initialRange);
Some WIP refactoring, trying to remove TimeController object...
r1345 sqpApp->timeController().setDateTimeRange(initialRange);
Improve cosinus tests with:...
r808 auto provider = std::make_shared<CosinusProvider>();
auto variable = sqpApp->variableController().createVariable(
Some WIP refactoring, trying to remove TimeController object...
r1345 "MMS", {{COSINUS_TYPE_KEY, "scalar"}, {COSINUS_FREQUENCY_KEY, 10.}}, provider, initialRange);
Improve cosinus tests with:...
r808
Modification of the test for the new vc request kernel
r826
Improve cosinus tests with:...
r808 QFETCH(int, operationDelay);
QTest::qWait(operationDelay);
validateVariable(variable, initialRange);
Modification of the test for the new vc request kernel
r826 QTest::qWait(operationDelay);
Improve cosinus tests with:...
r808 // Makes operations on the variable
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 QFETCH(std::vector<DateTimeRange>, operations);
Improve cosinus tests with:...
r808 for (const auto &operation : operations) {
// Asks request on the variable and waits during its execution
All the codebase is modified to build with new Variable Controller...
r1348 sqpApp->variableController().changeRange(variable, operation);
Improve cosinus tests with:...
r808
QTest::qWait(operationDelay);
validateVariable(variable, operation);
Alexandre Leroux
Implements unit test (1)...
r743 }
Improve cosinus tests with:...
r808
for (const auto &operation : operations) {
// Asks request on the variable and waits during its execution
All the codebase is modified to build with new Variable Controller...
r1348 sqpApp->variableController().changeRange(variable, operation);
Alexandre Leroux
Implements unit test (1)...
r743 }
Improve cosinus tests with:...
r808 QTest::qWait(operationDelay);
validateVariable(variable, operations.back());
Alexandre Leroux
Inits unit test
r742 }
int main(int argc, char *argv[])
{
SqpApplication app{argc, argv};
app.setAttribute(Qt::AA_Use96Dpi, true);
TestCosinusAcquisition testObject{};
QTEST_SET_MAIN_SOURCE_PATH
return QTest::qExec(&testObject, argc, argv);
}
#include "TestCosinusAcquisition.moc"