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