@@ -1,3 +1,3 | |||||
1 | subdirs(GUITestUtils) |
|
1 | subdirs(GUITestUtils) | |
2 | declare_test(simple_graph simple_graph simple_graph/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test") |
|
2 | declare_test(simple_graph simple_graph simple_graph/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test") | |
3 |
declare_test( |
|
3 | declare_test(multiple_sync_graph multiple_sync_graph multiple_sync_graph/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test") |
@@ -85,11 +85,11 auto getItem(T* widget, T2 itemIndex) | |||||
85 |
|
85 | |||
86 | #define SELECT_ITEM(widget, itemIndex, item)\ |
|
86 | #define SELECT_ITEM(widget, itemIndex, item)\ | |
87 | auto item = getItem(widget, itemIndex);\ |
|
87 | auto item = getItem(widget, itemIndex);\ | |
88 | {\ |
|
88 | {\ | |
89 | auto itemCenterPos = widget->visualItemRect(item).center();\ |
|
89 | auto itemCenterPos = widget->visualItemRect(item).center();\ | |
90 | QTest::mouseClick(widget->viewport(), Qt::LeftButton, Qt::NoModifier, itemCenterPos);\ |
|
90 | QTest::mouseClick(widget->viewport(), Qt::LeftButton, Qt::NoModifier, itemCenterPos);\ | |
91 | QVERIFY(widget->selectedItems().size() > 0);\ |
|
91 | QVERIFY(widget->selectedItems().size() > 0);\ | |
92 | QVERIFY(widget->selectedItems().contains(item));\ |
|
92 | QVERIFY(widget->selectedItems().contains(item));\ | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 |
|
95 | |||
@@ -133,12 +133,15 void dragnDropItem(T1* sourceWidget, T2* destWidget, T3* item, T4* destItem=Q_NU | |||||
133 | mouseMove(sourceWidget,itemCenterPos,Qt::LeftButton); |
|
133 | mouseMove(sourceWidget,itemCenterPos,Qt::LeftButton); | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | #define PREPARE_GUI_TEST(main_widget)\ |
|
136 | template<typename T> | |
137 | main_widget.setGeometry(QRect(QPoint(QApplication::desktop()->geometry().center() - QPoint(250, 250)),\ |
|
137 | bool prepare_gui_test(T* w) | |
138 | QSize(500, 500)));\ |
|
138 | { | |
139 | main_widget.show();\ |
|
139 | w->setGeometry(QRect(QPoint(QApplication::desktop()->geometry().center() - QPoint(250, 250)), | |
140 | qApp->setActiveWindow(&main_widget);\ |
|
140 | QSize(500, 500))); | |
141 | QVERIFY(QTest::qWaitForWindowActive(&main_widget)) |
|
141 | w->show(); | |
|
142 | qApp->setActiveWindow(w); | |||
|
143 | return QTest::qWaitForWindowActive(w); | |||
|
144 | } | |||
142 |
|
145 | |||
143 | #define GET_CHILD_WIDGET_FOR_GUI_TESTS(parent, child, childType, childName)\ |
|
146 | #define GET_CHILD_WIDGET_FOR_GUI_TESTS(parent, child, childType, childName)\ | |
144 | childType* child = parent.findChild<childType*>(childName); \ |
|
147 | childType* child = parent.findChild<childType*>(childName); \ |
@@ -12,40 +12,52 | |||||
12 | #include <Common/cpp_utils.h> |
|
12 | #include <Common/cpp_utils.h> | |
13 |
|
13 | |||
14 | #include <Visualization/VisualizationZoneWidget.h> |
|
14 | #include <Visualization/VisualizationZoneWidget.h> | |
|
15 | #include <Visualization/VisualizationGraphWidget.h> | |||
15 | #include <TestProviders.h> |
|
16 | #include <TestProviders.h> | |
16 | #include <GUITestUtils.h> |
|
17 | #include <GUITestUtils.h> | |
17 |
|
18 | |||
18 |
|
19 | |||
19 | ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableController().isReady) |
|
20 | ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableController().isReady) | |
20 |
|
21 | |||
21 | #define A_SIMPLE_GRAPH_FIXTURE \ |
|
22 | template <int GraphCount=2> | |
22 | VisualizationZoneWidget w;\ |
|
23 | std::tuple< std::unique_ptr<VisualizationZoneWidget>, | |
23 | PREPARE_GUI_TEST(w);\ |
|
24 | std::vector<std::shared_ptr<Variable>>, | |
24 | auto provider = std::make_shared<SimpleRange<10> >();\ |
|
25 | std::vector<VisualizationGraphWidget*> > | |
25 | auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),\ |
|
26 | build_multi_graph_test() | |
26 | QTime(16, 00));\ |
|
27 | { | |
27 | auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable(\ |
|
28 | auto w = std::make_unique<VisualizationZoneWidget>(); | |
28 | "V1", {{"", "scalar"}}, provider, range);\ |
|
29 | auto provider = std::make_shared<SimpleRange<10> >(); | |
29 | while (!isReady(var))\ |
|
30 | auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),QTime(16, 00)); | |
30 | QCoreApplication::processEvents();\ |
|
31 | std::vector<std::shared_ptr<Variable>> variables; | |
31 | //w.addVariable(var, range);\ |
|
32 | std::vector<VisualizationGraphWidget*> graphs; | |
32 | auto cent = center(&w); |
|
33 | for(auto i=0;i<GraphCount;i++) | |
33 |
|
34 | { | ||
|
35 | auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable( | |||
|
36 | QString("V%1").arg(i), {{"", "scalar"}}, provider, range); | |||
|
37 | auto graph = new VisualizationGraphWidget(); | |||
|
38 | graph->addVariable(var, range); | |||
|
39 | while (!isReady(var)) | |||
|
40 | QCoreApplication::processEvents(); | |||
|
41 | variables.push_back(var); | |||
|
42 | graphs.push_back(graph); | |||
|
43 | w->addGraph(graph); | |||
|
44 | } | |||
|
45 | auto cent = center(w.get()); | |||
|
46 | return {std::move(w), variables, graphs}; | |||
|
47 | } | |||
34 |
|
48 | |||
35 |
|
49 | |||
36 |
class A_ |
|
50 | class A_MultipleSyncGraphs : public QObject { | |
37 | Q_OBJECT |
|
51 | Q_OBJECT | |
38 | public: |
|
52 | public: | |
39 |
explicit A_ |
|
53 | explicit A_MultipleSyncGraphs(QObject *parent = Q_NULLPTR) : QObject(parent) {} | |
40 |
|
54 | |||
41 | private slots: |
|
55 | private slots: | |
42 | void scrolls_left_with_mouse() |
|
56 | void scrolls_left_with_mouse() | |
43 | { |
|
57 | { | |
44 | A_SIMPLE_GRAPH_FIXTURE; |
|
58 | auto [w, variables, graphs] = build_multi_graph_test<3>(); | |
|
59 | QVERIFY(prepare_gui_test(w.get())); | |||
45 |
|
60 | |||
46 | while (!isReady(var)) |
|
|||
47 | QCoreApplication::processEvents(); |
|
|||
48 | auto r = var->range(); |
|
|||
49 | /* |
|
61 | /* | |
50 | * Scrolling to the left implies going back in time |
|
62 | * Scrolling to the left implies going back in time | |
51 | * Scroll only implies keeping the same delta T -> shit only transformation |
|
63 | * Scroll only implies keeping the same delta T -> shit only transformation | |
@@ -56,11 +68,15 private slots: | |||||
56 |
|
68 | |||
57 | void scrolls_right_with_mouse() |
|
69 | void scrolls_right_with_mouse() | |
58 | { |
|
70 | { | |
59 | A_SIMPLE_GRAPH_FIXTURE; |
|
71 | auto [w, variables, graphs] = build_multi_graph_test<3>(); | |
|
72 | QVERIFY(prepare_gui_test(w.get())); | |||
|
73 | w->show(); | |||
|
74 | for(int i=0;i<10000;i++) | |||
|
75 | { | |||
|
76 | QThread::usleep(1000); | |||
|
77 | qApp->processEvents(); | |||
|
78 | } | |||
60 |
|
79 | |||
61 | while (!isReady(var)) |
|
|||
62 | QCoreApplication::processEvents(); |
|
|||
63 | auto r = var->range(); |
|
|||
64 | /* |
|
80 | /* | |
65 | * Scrolling to the right implies going forward in time |
|
81 | * Scrolling to the right implies going forward in time | |
66 | * Scroll only implies keeping the same delta T -> shit only transformation |
|
82 | * Scroll only implies keeping the same delta T -> shit only transformation | |
@@ -70,6 +86,7 private slots: | |||||
70 | } |
|
86 | } | |
71 | }; |
|
87 | }; | |
72 |
|
88 | |||
|
89 | ||||
73 | QT_BEGIN_NAMESPACE |
|
90 | QT_BEGIN_NAMESPACE | |
74 | QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS |
|
91 | QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS | |
75 | QT_END_NAMESPACE |
|
92 | QT_END_NAMESPACE | |
@@ -79,7 +96,7 int main(int argc, char *argv[]) | |||||
79 | app.setAttribute(Qt::AA_Use96Dpi, true); |
|
96 | app.setAttribute(Qt::AA_Use96Dpi, true); | |
80 | QTEST_DISABLE_KEYPAD_NAVIGATION; |
|
97 | QTEST_DISABLE_KEYPAD_NAVIGATION; | |
81 | QTEST_ADD_GPU_BLACKLIST_SUPPORT; |
|
98 | QTEST_ADD_GPU_BLACKLIST_SUPPORT; | |
82 |
A_ |
|
99 | A_MultipleSyncGraphs tc; | |
83 | QTEST_SET_MAIN_SOURCE_PATH; |
|
100 | QTEST_SET_MAIN_SOURCE_PATH; | |
84 | return QTest::qExec(&tc, argc, argv); |
|
101 | return QTest::qExec(&tc, argc, argv); | |
85 | } |
|
102 | } |
@@ -18,19 +18,21 | |||||
18 |
|
18 | |||
19 | ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableController().isReady) |
|
19 | ALIAS_TEMPLATE_FUNCTION(isReady, static_cast<SqpApplication *>(qApp)->variableController().isReady) | |
20 |
|
20 | |||
21 | #define A_SIMPLE_GRAPH_FIXTURE \ |
|
21 | std::tuple< std::unique_ptr<VisualizationGraphWidget>, | |
22 | VisualizationGraphWidget w;\ |
|
22 | std::shared_ptr<Variable>, | |
23 | PREPARE_GUI_TEST(w);\ |
|
23 | DateTimeRange > | |
24 | auto provider = std::make_shared<SimpleRange<10> >();\ |
|
24 | build_simple_graph_test() | |
25 | auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),\ |
|
25 | { | |
26 | QTime(16, 00));\ |
|
26 | auto w = std::make_unique<VisualizationGraphWidget>(); | |
27 | auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable(\ |
|
27 | auto provider = std::make_shared<SimpleRange<10> >(); | |
28 | "V1", {{"", "scalar"}}, provider, range);\ |
|
28 | auto range = DateTimeRange::fromDateTime(QDate(2018, 8, 7), QTime(14, 00), QDate(2018, 8, 7),QTime(16, 00)); | |
29 | while (!isReady(var))\ |
|
29 | auto var = static_cast<SqpApplication *>(qApp)->variableController().createVariable("V1", {{"", "scalar"}}, provider, range); | |
30 | QCoreApplication::processEvents();\ |
|
30 | w->addVariable(var, range); | |
31 | w.addVariable(var, range);\ |
|
31 | while (!isReady(var)) | |
32 | auto cent = center(&w); |
|
32 | QCoreApplication::processEvents(); | |
33 |
|
33 | auto cent = center(w.get()); | ||
|
34 | return {std::move(w), var, range}; | |||
|
35 | } | |||
34 |
|
36 | |||
35 |
|
37 | |||
36 | class A_SimpleGraph : public QObject { |
|
38 | class A_SimpleGraph : public QObject { | |
@@ -41,12 +43,14 public: | |||||
41 | private slots: |
|
43 | private slots: | |
42 | void scrolls_left_with_mouse() |
|
44 | void scrolls_left_with_mouse() | |
43 | { |
|
45 | { | |
44 | A_SIMPLE_GRAPH_FIXTURE; |
|
46 | auto [w, var, range] = build_simple_graph_test(); | |
|
47 | QVERIFY(prepare_gui_test(w.get())); | |||
|
48 | auto cent = center(w.get()); | |||
45 |
|
49 | |||
46 | for (auto i = 0; i < 100; i++) { |
|
50 | for (auto i = 0; i < 100; i++) { | |
47 |
QTest::mousePress( |
|
51 | QTest::mousePress(w.get(), Qt::LeftButton, Qt::NoModifier, cent, 1); | |
48 |
mouseMove( |
|
52 | mouseMove(w.get(), {cent.x() + 200, cent.y()}, Qt::LeftButton); | |
49 |
QTest::mouseRelease( |
|
53 | QTest::mouseRelease(w.get(), Qt::LeftButton); | |
50 | while (!isReady(var)) |
|
54 | while (!isReady(var)) | |
51 | QCoreApplication::processEvents(); |
|
55 | QCoreApplication::processEvents(); | |
52 | } |
|
56 | } | |
@@ -63,12 +67,14 private slots: | |||||
63 |
|
67 | |||
64 | void scrolls_right_with_mouse() |
|
68 | void scrolls_right_with_mouse() | |
65 | { |
|
69 | { | |
66 | A_SIMPLE_GRAPH_FIXTURE; |
|
70 | auto [w, var, range] = build_simple_graph_test(); | |
|
71 | QVERIFY(prepare_gui_test(w.get())); | |||
|
72 | auto cent = center(w.get()); | |||
67 |
|
73 | |||
68 | for (auto i = 0; i < 100; i++) { |
|
74 | for (auto i = 0; i < 100; i++) { | |
69 |
QTest::mousePress( |
|
75 | QTest::mousePress(w.get(), Qt::LeftButton, Qt::NoModifier, cent, 1); | |
70 |
mouseMove( |
|
76 | mouseMove(w.get(), {cent.x() - 200, cent.y()}, Qt::LeftButton); | |
71 |
QTest::mouseRelease( |
|
77 | QTest::mouseRelease(w.get(), Qt::LeftButton); | |
72 | while (!isReady(var)) |
|
78 | while (!isReady(var)) | |
73 | QCoreApplication::processEvents(); |
|
79 | QCoreApplication::processEvents(); | |
74 | } |
|
80 | } |
General Comments 0
You need to be logged in to leave comments.
Login now