@@ -11,6 +11,9 | |||||
11 |
|
11 | |||
12 | #include <qcustomplot.h> |
|
12 | #include <qcustomplot.h> | |
13 |
|
13 | |||
|
14 | #include <SqpApplication.h> | |||
|
15 | #include <Variable/Variable.h> | |||
|
16 | ||||
14 | template <typename T> |
|
17 | template <typename T> | |
15 | QPoint center(T* widget) |
|
18 | QPoint center(T* widget) | |
16 | { |
|
19 | { | |
@@ -133,6 +136,23 void dragnDropItem(T1* sourceWidget, T2* destWidget, T3* item, T4* destItem=Q_NU | |||||
133 | mouseMove(sourceWidget,itemCenterPos,Qt::LeftButton); |
|
136 | mouseMove(sourceWidget,itemCenterPos,Qt::LeftButton); | |
134 | } |
|
137 | } | |
135 |
|
138 | |||
|
139 | template <typename T> | |||
|
140 | void scroll_graph(T* w, int dx) | |||
|
141 | { | |||
|
142 | auto cent = center(w); | |||
|
143 | QTest::mousePress(w, Qt::LeftButton, Qt::NoModifier, cent, 1); | |||
|
144 | mouseMove(w, {cent.x() + dx, cent.y()}, Qt::LeftButton); | |||
|
145 | QTest::mouseRelease(w, Qt::LeftButton); | |||
|
146 | } | |||
|
147 | ||||
|
148 | ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableController().isReady) | |||
|
149 | ||||
|
150 | void waitForVar(std::shared_ptr<Variable> var) | |||
|
151 | { | |||
|
152 | while (!isReady(var)) | |||
|
153 | QCoreApplication::processEvents(); | |||
|
154 | } | |||
|
155 | ||||
136 | template<typename T> |
|
156 | template<typename T> | |
137 | bool prepare_gui_test(T* w) |
|
157 | bool prepare_gui_test(T* w) | |
138 | { |
|
158 | { |
@@ -16,9 +16,6 | |||||
16 | #include <TestProviders.h> |
|
16 | #include <TestProviders.h> | |
17 | #include <GUITestUtils.h> |
|
17 | #include <GUITestUtils.h> | |
18 |
|
18 | |||
19 |
|
||||
20 | ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableController().isReady) |
|
|||
21 |
|
||||
22 | template <int GraphCount=2> |
|
19 | template <int GraphCount=2> | |
23 | std::tuple< std::unique_ptr<VisualizationZoneWidget>, |
|
20 | std::tuple< std::unique_ptr<VisualizationZoneWidget>, | |
24 | std::vector<std::shared_ptr<Variable>>, |
|
21 | std::vector<std::shared_ptr<Variable>>, | |
@@ -70,12 +67,12 private slots: | |||||
70 | { |
|
67 | { | |
71 | auto [w, variables, graphs] = build_multi_graph_test<3>(); |
|
68 | auto [w, variables, graphs] = build_multi_graph_test<3>(); | |
72 | QVERIFY(prepare_gui_test(w.get())); |
|
69 | QVERIFY(prepare_gui_test(w.get())); | |
73 | w->show(); |
|
70 | // w->show(); | |
74 | for(int i=0;i<10000;i++) |
|
71 | // for(int i=0;i<10000;i++) | |
75 | { |
|
72 | // { | |
76 | QThread::usleep(1000); |
|
73 | // QThread::usleep(1000); | |
77 | qApp->processEvents(); |
|
74 | // qApp->processEvents(); | |
78 | } |
|
75 | // } | |
79 |
|
76 | |||
80 | /* |
|
77 | /* | |
81 | * Scrolling to the right implies going forward in time |
|
78 | * Scrolling to the right implies going forward in time |
@@ -14,9 +14,7 | |||||
14 | #include <Visualization/VisualizationGraphWidget.h> |
|
14 | #include <Visualization/VisualizationGraphWidget.h> | |
15 | #include <TestProviders.h> |
|
15 | #include <TestProviders.h> | |
16 | #include <GUITestUtils.h> |
|
16 | #include <GUITestUtils.h> | |
17 |
|
17 | #include <Variable/Variable.h> | ||
18 |
|
||||
19 | ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableController().isReady) |
|
|||
20 |
|
18 | |||
21 | std::tuple< std::unique_ptr<VisualizationGraphWidget>, |
|
19 | std::tuple< std::unique_ptr<VisualizationGraphWidget>, | |
22 | std::shared_ptr<Variable>, |
|
20 | std::shared_ptr<Variable>, | |
@@ -27,9 +25,9 build_simple_graph_test() | |||||
27 | auto provider = std::make_shared<SimpleRange<10> >(); |
|
25 | auto provider = std::make_shared<SimpleRange<10> >(); | |
28 | auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),QTime(16, 00)); |
|
26 | auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),QTime(16, 00)); | |
29 | auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable("V1", {{"", "scalar"}}, provider, range); |
|
27 | auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable("V1", {{"", "scalar"}}, provider, range); | |
|
28 | while (!isReady(var)) QCoreApplication::processEvents(); | |||
30 | w->addVariable(var, range); |
|
29 | w->addVariable(var, range); | |
31 | while (!isReady(var)) |
|
30 | while (!isReady(var)) QCoreApplication::processEvents(); | |
32 | QCoreApplication::processEvents(); |
|
|||
33 | auto cent = center(w.get()); |
|
31 | auto cent = center(w.get()); | |
34 | return {std::move(w), var, range}; |
|
32 | return {std::move(w), var, range}; | |
35 | } |
|
33 | } | |
@@ -45,17 +43,10 private slots: | |||||
45 | { |
|
43 | { | |
46 | auto [w, var, range] = build_simple_graph_test(); |
|
44 | auto [w, var, range] = build_simple_graph_test(); | |
47 | QVERIFY(prepare_gui_test(w.get())); |
|
45 | QVERIFY(prepare_gui_test(w.get())); | |
48 | auto cent = center(w.get()); |
|
|||
49 |
|
||||
50 | for (auto i = 0; i < 100; i++) { |
|
46 | for (auto i = 0; i < 100; i++) { | |
51 | QTest::mousePress(w.get(), Qt::LeftButton, Qt::NoModifier, cent, 1); |
|
47 | scroll_graph(w.get(), 200); | |
52 | mouseMove(w.get(), {cent.x() + 200, cent.y()}, Qt::LeftButton); |
|
48 | waitForVar(var); | |
53 | QTest::mouseRelease(w.get(), Qt::LeftButton); |
|
|||
54 | while (!isReady(var)) |
|
|||
55 | QCoreApplication::processEvents(); |
|
|||
56 | } |
|
49 | } | |
57 | while (!isReady(var)) |
|
|||
58 | QCoreApplication::processEvents(); |
|
|||
59 | auto r = var->range(); |
|
50 | auto r = var->range(); | |
60 | /* |
|
51 | /* | |
61 | * Scrolling to the left implies going back in time |
|
52 | * Scrolling to the left implies going back in time | |
@@ -69,17 +60,10 private slots: | |||||
69 | { |
|
60 | { | |
70 | auto [w, var, range] = build_simple_graph_test(); |
|
61 | auto [w, var, range] = build_simple_graph_test(); | |
71 | QVERIFY(prepare_gui_test(w.get())); |
|
62 | QVERIFY(prepare_gui_test(w.get())); | |
72 | auto cent = center(w.get()); |
|
|||
73 |
|
||||
74 | for (auto i = 0; i < 100; i++) { |
|
63 | for (auto i = 0; i < 100; i++) { | |
75 | QTest::mousePress(w.get(), Qt::LeftButton, Qt::NoModifier, cent, 1); |
|
64 | scroll_graph(w.get(), -200); | |
76 | mouseMove(w.get(), {cent.x() - 200, cent.y()}, Qt::LeftButton); |
|
65 | waitForVar(var); | |
77 | QTest::mouseRelease(w.get(), Qt::LeftButton); |
|
|||
78 | while (!isReady(var)) |
|
|||
79 | QCoreApplication::processEvents(); |
|
|||
80 | } |
|
66 | } | |
81 | while (!isReady(var)) |
|
|||
82 | QCoreApplication::processEvents(); |
|
|||
83 | auto r = var->range(); |
|
67 | auto r = var->range(); | |
84 | /* |
|
68 | /* | |
85 | * Scrolling to the right implies going forward in time |
|
69 | * Scrolling to the right implies going forward in time |
General Comments 0
You need to be logged in to leave comments.
Login now