main.cpp
90 lines
| 2.8 KiB
| text/x-c
|
CppLexer
r1359 | #include <QtTest> | |||
#include <QObject> | ||||
#include <QString> | ||||
#include <QScreen> | ||||
#include <QMainWindow> | ||||
r1360 | #include <QWheelEvent> | |||
r1359 | ||||
r1360 | #include <qcustomplot.h> | |||
r1359 | ||||
#include <SqpApplication.h> | ||||
#include <Variable/VariableController2.h> | ||||
r1361 | #include <Common/cpp_utils.h> | |||
r1359 | ||||
#include <Visualization/VisualizationGraphWidget.h> | ||||
#include <TestProviders.h> | ||||
r1360 | #include <GUITestUtils.h> | |||
r1370 | #include <Variable/Variable.h> | |||
r1361 | ||||
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); | ||||
r1370 | while (!isReady(var)) QCoreApplication::processEvents(); | |||
r1369 | w->addVariable(var, range); | |||
r1370 | while (!isReady(var)) QCoreApplication::processEvents(); | |||
r1369 | return {std::move(w), var, range}; | |||
} | ||||
r1361 | ||||
r1359 | class A_SimpleGraph : public QObject { | |||
Q_OBJECT | ||||
public: | ||||
r1361 | explicit A_SimpleGraph(QObject *parent = Q_NULLPTR) : QObject(parent) {} | |||
r1359 | ||||
private slots: | ||||
r1363 | void scrolls_left_with_mouse() | |||
r1359 | { | |||
r1369 | auto [w, var, range] = build_simple_graph_test(); | |||
QVERIFY(prepare_gui_test(w.get())); | ||||
r1363 | for (auto i = 0; i < 100; i++) { | |||
r1370 | scroll_graph(w.get(), 200); | |||
waitForVar(var); | ||||
r1360 | } | |||
r1361 | auto r = var->range(); | |||
r1362 | /* | |||
* Scrolling to the left implies going back in time | ||||
* Scroll only implies keeping the same delta T -> shit only transformation | ||||
*/ | ||||
r1361 | QVERIFY(r.m_TEnd < range.m_TEnd); | |||
QVERIFY(SciQLop::numeric::almost_equal<double>(r.delta(),range.delta(),1)); | ||||
r1359 | } | |||
r1363 | ||||
void scrolls_right_with_mouse() | ||||
{ | ||||
r1369 | auto [w, var, range] = build_simple_graph_test(); | |||
QVERIFY(prepare_gui_test(w.get())); | ||||
r1363 | for (auto i = 0; i < 100; i++) { | |||
r1370 | scroll_graph(w.get(), -200); | |||
waitForVar(var); | ||||
r1363 | } | |||
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)); | ||||
} | ||||
r1359 | }; | |||
QT_BEGIN_NAMESPACE | ||||
QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS | ||||
r1361 | QT_END_NAMESPACE | |||
r1359 | int main(int argc, char *argv[]) | |||
{ | ||||
SqpApplication app{argc, argv}; | ||||
app.setAttribute(Qt::AA_Use96Dpi, true); | ||||
r1363 | QTEST_DISABLE_KEYPAD_NAVIGATION; | |||
QTEST_ADD_GPU_BLACKLIST_SUPPORT; | ||||
r1359 | A_SimpleGraph tc; | |||
r1363 | QTEST_SET_MAIN_SOURCE_PATH; | |||
r1359 | return QTest::qExec(&tc, argc, argv); | |||
} | ||||
#include "main.moc" | ||||