#include #include #include #include #include #include #include #include #include #include #include #include #include #include template std::tuple< std::unique_ptr, std::vector>, std::vector, DateTimeRange> build_multi_graph_test() { auto w = std::make_unique(); auto provider = std::make_shared >(); auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),QTime(16, 00)); std::vector> variables; std::vector graphs; for(auto i=0;i(qApp)->variableController().createVariable( QString("V%1").arg(i), {{"", "scalar"}}, provider, range); auto graph = new VisualizationGraphWidget(); graph->addVariable(var, range); while (!isReady(var)) QCoreApplication::processEvents(); variables.push_back(var); graphs.push_back(graph); w->addGraph(graph); } return {std::move(w), variables, graphs, range}; } class A_MultipleSyncGraphs : public QObject { Q_OBJECT public: explicit A_MultipleSyncGraphs(QObject *parent = Q_NULLPTR) : QObject(parent) {} private slots: void scrolls_left_with_mouse() { auto [w, variables, graphs, range] = build_multi_graph_test<3>(); auto var = variables.front(); auto graph = graphs.front(); QVERIFY(prepare_gui_test(w.get())); for (auto i = 0; i < 100; i++) { scroll_graph(graph, -200); waitForVar(var); } auto r = variables.back()->range(); /* * Scrolling to the left implies going back 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(r.delta(),range.delta(),1)); } void scrolls_right_with_mouse() { auto [w, variables, graphs, range] = build_multi_graph_test<3>(); auto var = variables.front(); auto graph = graphs.front(); QVERIFY(prepare_gui_test(w.get())); for (auto i = 0; i < 100; i++) { scroll_graph(graph, 200); waitForVar(var); } auto r = variables.back()->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(r.delta(),range.delta(),1)); } }; QT_BEGIN_NAMESPACE QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS QT_END_NAMESPACE int main(int argc, char *argv[]) { SqpApplication app{argc, argv}; app.setAttribute(Qt::AA_Use96Dpi, true); QTEST_DISABLE_KEYPAD_NAVIGATION; QTEST_ADD_GPU_BLACKLIST_SUPPORT; A_MultipleSyncGraphs tc; QTEST_SET_MAIN_SOURCE_PATH; return QTest::qExec(&tc, argc, argv); } #include "main.moc"