@@ -1,1 +1,1 | |||
|
1 | Subproject commit 54e194b00c35fb5f769eda61234c1b4dd6de3a43 | |
|
1 | Subproject commit 79fb0ced05d752f6e9260afddb38cc0d50e80c6d |
@@ -1,101 +1,109 | |||
|
1 | 1 | #include <QtTest> |
|
2 | 2 | #include <QObject> |
|
3 | 3 | #include <QString> |
|
4 | 4 | #include <QScreen> |
|
5 | 5 | #include <QMainWindow> |
|
6 | 6 | #include <QWheelEvent> |
|
7 | 7 | |
|
8 | 8 | #include <qcustomplot.h> |
|
9 | 9 | |
|
10 | 10 | #include <SqpApplication.h> |
|
11 | 11 | #include <Variable/VariableController2.h> |
|
12 | 12 | #include <Common/cpp_utils.h> |
|
13 | 13 | |
|
14 | 14 | #include <Visualization/VisualizationZoneWidget.h> |
|
15 | 15 | #include <Visualization/VisualizationGraphWidget.h> |
|
16 | 16 | #include <TestProviders.h> |
|
17 | 17 | #include <GUITestUtils.h> |
|
18 | 18 | |
|
19 | 19 | template <int GraphCount=2> |
|
20 | 20 | std::tuple< std::unique_ptr<VisualizationZoneWidget>, |
|
21 | 21 | std::vector<std::shared_ptr<Variable>>, |
|
22 |
std::vector<VisualizationGraphWidget*> |
|
|
22 | std::vector<VisualizationGraphWidget*>, | |
|
23 | DateTimeRange> | |
|
23 | 24 | build_multi_graph_test() |
|
24 | 25 | { |
|
25 | 26 | auto w = std::make_unique<VisualizationZoneWidget>(); |
|
26 | 27 | auto provider = std::make_shared<SimpleRange<10> >(); |
|
27 | 28 | auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),QTime(16, 00)); |
|
28 | 29 | std::vector<std::shared_ptr<Variable>> variables; |
|
29 | 30 | std::vector<VisualizationGraphWidget*> graphs; |
|
30 | 31 | for(auto i=0;i<GraphCount;i++) |
|
31 | 32 | { |
|
32 | 33 | auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable( |
|
33 | 34 | QString("V%1").arg(i), {{"", "scalar"}}, provider, range); |
|
34 | 35 | auto graph = new VisualizationGraphWidget(); |
|
35 | 36 | graph->addVariable(var, range); |
|
36 | 37 | while (!isReady(var)) |
|
37 | 38 | QCoreApplication::processEvents(); |
|
38 | 39 | variables.push_back(var); |
|
39 | 40 | graphs.push_back(graph); |
|
40 | 41 | w->addGraph(graph); |
|
41 | 42 | } |
|
42 | auto cent = center(w.get()); | |
|
43 | return {std::move(w), variables, graphs}; | |
|
43 | return {std::move(w), variables, graphs, range}; | |
|
44 | 44 | } |
|
45 | 45 | |
|
46 | 46 | |
|
47 | 47 | class A_MultipleSyncGraphs : public QObject { |
|
48 | 48 | Q_OBJECT |
|
49 | 49 | public: |
|
50 | 50 | explicit A_MultipleSyncGraphs(QObject *parent = Q_NULLPTR) : QObject(parent) {} |
|
51 | 51 | |
|
52 | 52 | private slots: |
|
53 | 53 | void scrolls_left_with_mouse() |
|
54 | 54 | { |
|
55 | auto [w, variables, graphs] = build_multi_graph_test<3>(); | |
|
55 | auto [w, variables, graphs, range] = build_multi_graph_test<3>(); | |
|
56 | auto var = variables.front(); | |
|
57 | auto graph = graphs.front(); | |
|
56 | 58 | QVERIFY(prepare_gui_test(w.get())); |
|
59 | for (auto i = 0; i < 100; i++) { | |
|
60 | scroll_graph(graph, -200); | |
|
61 | waitForVar(var); | |
|
62 | } | |
|
63 | auto r = variables.back()->range(); | |
|
57 | 64 | |
|
58 | 65 | /* |
|
59 | 66 | * Scrolling to the left implies going back in time |
|
60 | 67 | * Scroll only implies keeping the same delta T -> shit only transformation |
|
61 | 68 | */ |
|
62 |
|
|
|
63 |
|
|
|
69 | QVERIFY(r.m_TEnd < range.m_TEnd); | |
|
70 | QVERIFY(SciQLop::numeric::almost_equal<double>(r.delta(),range.delta(),1)); | |
|
64 | 71 | } |
|
65 | 72 | |
|
66 | 73 | void scrolls_right_with_mouse() |
|
67 | 74 | { |
|
68 | auto [w, variables, graphs] = build_multi_graph_test<3>(); | |
|
75 | auto [w, variables, graphs, range] = build_multi_graph_test<3>(); | |
|
76 | auto var = variables.front(); | |
|
77 | auto graph = graphs.front(); | |
|
69 | 78 | QVERIFY(prepare_gui_test(w.get())); |
|
70 | // w->show(); | |
|
71 | // for(int i=0;i<10000;i++) | |
|
72 | // { | |
|
73 | // QThread::usleep(1000); | |
|
74 | // qApp->processEvents(); | |
|
75 | // } | |
|
79 | for (auto i = 0; i < 100; i++) { | |
|
80 | scroll_graph(graph, 200); | |
|
81 | waitForVar(var); | |
|
82 | } | |
|
83 | auto r = variables.back()->range(); | |
|
76 | 84 | |
|
77 | 85 | /* |
|
78 | 86 | * Scrolling to the right implies going forward in time |
|
79 | 87 | * Scroll only implies keeping the same delta T -> shit only transformation |
|
80 | 88 | */ |
|
81 |
|
|
|
82 |
|
|
|
89 | QVERIFY(r.m_TEnd > range.m_TEnd); | |
|
90 | QVERIFY(SciQLop::numeric::almost_equal<double>(r.delta(),range.delta(),1)); | |
|
83 | 91 | } |
|
84 | 92 | }; |
|
85 | 93 | |
|
86 | 94 | |
|
87 | 95 | QT_BEGIN_NAMESPACE |
|
88 | 96 | QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS |
|
89 | 97 | QT_END_NAMESPACE |
|
90 | 98 | int main(int argc, char *argv[]) |
|
91 | 99 | { |
|
92 | 100 | SqpApplication app{argc, argv}; |
|
93 | 101 | app.setAttribute(Qt::AA_Use96Dpi, true); |
|
94 | 102 | QTEST_DISABLE_KEYPAD_NAVIGATION; |
|
95 | 103 | QTEST_ADD_GPU_BLACKLIST_SUPPORT; |
|
96 | 104 | A_MultipleSyncGraphs tc; |
|
97 | 105 | QTEST_SET_MAIN_SOURCE_PATH; |
|
98 | 106 | return QTest::qExec(&tc, argc, argv); |
|
99 | 107 | } |
|
100 | 108 | |
|
101 | 109 | #include "main.moc" |
@@ -1,91 +1,90 | |||
|
1 | 1 | #include <QtTest> |
|
2 | 2 | #include <QObject> |
|
3 | 3 | #include <QString> |
|
4 | 4 | #include <QScreen> |
|
5 | 5 | #include <QMainWindow> |
|
6 | 6 | #include <QWheelEvent> |
|
7 | 7 | |
|
8 | 8 | #include <qcustomplot.h> |
|
9 | 9 | |
|
10 | 10 | #include <SqpApplication.h> |
|
11 | 11 | #include <Variable/VariableController2.h> |
|
12 | 12 | #include <Common/cpp_utils.h> |
|
13 | 13 | |
|
14 | 14 | #include <Visualization/VisualizationGraphWidget.h> |
|
15 | 15 | #include <TestProviders.h> |
|
16 | 16 | #include <GUITestUtils.h> |
|
17 | 17 | #include <Variable/Variable.h> |
|
18 | 18 | |
|
19 | 19 | std::tuple< std::unique_ptr<VisualizationGraphWidget>, |
|
20 | 20 | std::shared_ptr<Variable>, |
|
21 | 21 | DateTimeRange > |
|
22 | 22 | build_simple_graph_test() |
|
23 | 23 | { |
|
24 | 24 | auto w = std::make_unique<VisualizationGraphWidget>(); |
|
25 | 25 | auto provider = std::make_shared<SimpleRange<10> >(); |
|
26 | 26 | auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),QTime(16, 00)); |
|
27 | 27 | auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable("V1", {{"", "scalar"}}, provider, range); |
|
28 | 28 | while (!isReady(var)) QCoreApplication::processEvents(); |
|
29 | 29 | w->addVariable(var, range); |
|
30 | 30 | while (!isReady(var)) QCoreApplication::processEvents(); |
|
31 | auto cent = center(w.get()); | |
|
32 | 31 | return {std::move(w), var, range}; |
|
33 | 32 | } |
|
34 | 33 | |
|
35 | 34 | |
|
36 | 35 | class A_SimpleGraph : public QObject { |
|
37 | 36 | Q_OBJECT |
|
38 | 37 | public: |
|
39 | 38 | explicit A_SimpleGraph(QObject *parent = Q_NULLPTR) : QObject(parent) {} |
|
40 | 39 | |
|
41 | 40 | private slots: |
|
42 | 41 | void scrolls_left_with_mouse() |
|
43 | 42 | { |
|
44 | 43 | auto [w, var, range] = build_simple_graph_test(); |
|
45 | 44 | QVERIFY(prepare_gui_test(w.get())); |
|
46 | 45 | for (auto i = 0; i < 100; i++) { |
|
47 | 46 | scroll_graph(w.get(), 200); |
|
48 | 47 | waitForVar(var); |
|
49 | 48 | } |
|
50 | 49 | auto r = var->range(); |
|
51 | 50 | /* |
|
52 | 51 | * Scrolling to the left implies going back in time |
|
53 | 52 | * Scroll only implies keeping the same delta T -> shit only transformation |
|
54 | 53 | */ |
|
55 | 54 | QVERIFY(r.m_TEnd < range.m_TEnd); |
|
56 | 55 | QVERIFY(SciQLop::numeric::almost_equal<double>(r.delta(),range.delta(),1)); |
|
57 | 56 | } |
|
58 | 57 | |
|
59 | 58 | void scrolls_right_with_mouse() |
|
60 | 59 | { |
|
61 | 60 | auto [w, var, range] = build_simple_graph_test(); |
|
62 | 61 | QVERIFY(prepare_gui_test(w.get())); |
|
63 | 62 | for (auto i = 0; i < 100; i++) { |
|
64 | 63 | scroll_graph(w.get(), -200); |
|
65 | 64 | waitForVar(var); |
|
66 | 65 | } |
|
67 | 66 | auto r = var->range(); |
|
68 | 67 | /* |
|
69 | 68 | * Scrolling to the right implies going forward in time |
|
70 | 69 | * Scroll only implies keeping the same delta T -> shit only transformation |
|
71 | 70 | */ |
|
72 | 71 | QVERIFY(r.m_TEnd > range.m_TEnd); |
|
73 | 72 | QVERIFY(SciQLop::numeric::almost_equal<double>(r.delta(),range.delta(),1)); |
|
74 | 73 | } |
|
75 | 74 | }; |
|
76 | 75 | |
|
77 | 76 | QT_BEGIN_NAMESPACE |
|
78 | 77 | QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS |
|
79 | 78 | QT_END_NAMESPACE |
|
80 | 79 | int main(int argc, char *argv[]) |
|
81 | 80 | { |
|
82 | 81 | SqpApplication app{argc, argv}; |
|
83 | 82 | app.setAttribute(Qt::AA_Use96Dpi, true); |
|
84 | 83 | QTEST_DISABLE_KEYPAD_NAVIGATION; |
|
85 | 84 | QTEST_ADD_GPU_BLACKLIST_SUPPORT; |
|
86 | 85 | A_SimpleGraph tc; |
|
87 | 86 | QTEST_SET_MAIN_SOURCE_PATH; |
|
88 | 87 | return QTest::qExec(&tc, argc, argv); |
|
89 | 88 | } |
|
90 | 89 | |
|
91 | 90 | #include "main.moc" |
General Comments 0
You need to be logged in to leave comments.
Login now