##// END OF EJS Templates
Some test refac and prepared synchronized graph test...
Some test refac and prepared synchronized graph test Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1369:8a5759a257ef
r1369:8a5759a257ef
Show More
main.cpp
107 lines | 3.5 KiB | text/x-c | CppLexer
Started UI unit testing...
r1359 #include <QtTest>
#include <QObject>
#include <QString>
#include <QScreen>
#include <QMainWindow>
Added GUI Test Utils lib to share boilerplate code for UI testing...
r1360 #include <QWheelEvent>
Started UI unit testing...
r1359
Added GUI Test Utils lib to share boilerplate code for UI testing...
r1360 #include <qcustomplot.h>
Started UI unit testing...
r1359
#include <SqpApplication.h>
#include <Variable/VariableController2.h>
simple graph unit test: simple scroll implemented...
r1361 #include <Common/cpp_utils.h>
Started UI unit testing...
r1359
#include <Visualization/VisualizationGraphWidget.h>
#include <TestProviders.h>
Added GUI Test Utils lib to share boilerplate code for UI testing...
r1360 #include <GUITestUtils.h>
Started UI unit testing...
r1359
simple graph unit test: simple scroll implemented...
r1361
ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableController().isReady)
Some test refac and prepared synchronized graph test...
r1369 std::tuple< std::unique_ptr<VisualizationGraphWidget>,
std::shared_ptr<Variable>,
DateTimeRange >
build_simple_graph_test()
{
auto w = std::make_unique<VisualizationGraphWidget>();
auto provider = std::make_shared<SimpleRange<10> >();
auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),QTime(16, 00));
auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable("V1", {{"", "scalar"}}, provider, range);
w->addVariable(var, range);
while (!isReady(var))
QCoreApplication::processEvents();
auto cent = center(w.get());
return {std::move(w), var, range};
}
simple graph unit test: simple scroll implemented...
r1361
Started UI unit testing...
r1359 class A_SimpleGraph : public QObject {
Q_OBJECT
public:
simple graph unit test: simple scroll implemented...
r1361 explicit A_SimpleGraph(QObject *parent = Q_NULLPTR) : QObject(parent) {}
Started UI unit testing...
r1359
private slots:
More refactoring and added back plot tooltip...
r1363 void scrolls_left_with_mouse()
Started UI unit testing...
r1359 {
Some test refac and prepared synchronized graph test...
r1369 auto [w, var, range] = build_simple_graph_test();
QVERIFY(prepare_gui_test(w.get()));
auto cent = center(w.get());
simple graph unit test: simple scroll implemented...
r1361
More refactoring and added back plot tooltip...
r1363 for (auto i = 0; i < 100; i++) {
Some test refac and prepared synchronized graph test...
r1369 QTest::mousePress(w.get(), Qt::LeftButton, Qt::NoModifier, cent, 1);
mouseMove(w.get(), {cent.x() + 200, cent.y()}, Qt::LeftButton);
QTest::mouseRelease(w.get(), Qt::LeftButton);
simple graph unit test: simple scroll implemented...
r1361 while (!isReady(var))
QCoreApplication::processEvents();
Added GUI Test Utils lib to share boilerplate code for UI testing...
r1360 }
simple graph unit test: simple scroll implemented...
r1361 while (!isReady(var))
More refactoring and added back plot tooltip...
r1363 QCoreApplication::processEvents();
simple graph unit test: simple scroll implemented...
r1361 auto r = var->range();
Partly reimplemented Graph event handling + bugfix...
r1362 /*
* Scrolling to the left implies going back in time
* Scroll only implies keeping the same delta T -> shit only transformation
*/
simple graph unit test: simple scroll implemented...
r1361 QVERIFY(r.m_TEnd < range.m_TEnd);
QVERIFY(SciQLop::numeric::almost_equal<double>(r.delta(),range.delta(),1));
Started UI unit testing...
r1359 }
More refactoring and added back plot tooltip...
r1363
void scrolls_right_with_mouse()
{
Some test refac and prepared synchronized graph test...
r1369 auto [w, var, range] = build_simple_graph_test();
QVERIFY(prepare_gui_test(w.get()));
auto cent = center(w.get());
More refactoring and added back plot tooltip...
r1363
for (auto i = 0; i < 100; i++) {
Some test refac and prepared synchronized graph test...
r1369 QTest::mousePress(w.get(), Qt::LeftButton, Qt::NoModifier, cent, 1);
mouseMove(w.get(), {cent.x() - 200, cent.y()}, Qt::LeftButton);
QTest::mouseRelease(w.get(), Qt::LeftButton);
More refactoring and added back plot tooltip...
r1363 while (!isReady(var))
QCoreApplication::processEvents();
}
while (!isReady(var))
QCoreApplication::processEvents();
auto r = var->range();
/*
* Scrolling to the right implies going forward in time
* Scroll only implies keeping the same delta T -> shit only transformation
*/
QVERIFY(r.m_TEnd > range.m_TEnd);
QVERIFY(SciQLop::numeric::almost_equal<double>(r.delta(),range.delta(),1));
}
Started UI unit testing...
r1359 };
QT_BEGIN_NAMESPACE
QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
simple graph unit test: simple scroll implemented...
r1361 QT_END_NAMESPACE
Started UI unit testing...
r1359 int main(int argc, char *argv[])
{
SqpApplication app{argc, argv};
app.setAttribute(Qt::AA_Use96Dpi, true);
More refactoring and added back plot tooltip...
r1363 QTEST_DISABLE_KEYPAD_NAVIGATION;
QTEST_ADD_GPU_BLACKLIST_SUPPORT;
Started UI unit testing...
r1359 A_SimpleGraph tc;
More refactoring and added back plot tooltip...
r1363 QTEST_SET_MAIN_SOURCE_PATH;
Started UI unit testing...
r1359 return QTest::qExec(&tc, argc, argv);
}
#include "main.moc"