@@ -1,457 +1,470 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qlineseries.h> |
|
22 | #include <qlineseries.h> | |
23 | #include <qchartview.h> |
|
23 | #include <qchartview.h> | |
|
24 | #include <QStandardItemModel> | |||
24 |
|
25 | |||
25 | Q_DECLARE_METATYPE(QList<QPointF>) |
|
26 | Q_DECLARE_METATYPE(QList<QPointF>) | |
26 |
|
27 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
29 | |||
29 | class tst_QLineSeries : public QObject |
|
30 | class tst_QLineSeries : public QObject | |
30 | { |
|
31 | { | |
31 | Q_OBJECT |
|
32 | Q_OBJECT | |
32 |
|
33 | |||
33 | public slots: |
|
34 | public slots: | |
34 | void initTestCase(); |
|
35 | void initTestCase(); | |
35 | void cleanupTestCase(); |
|
36 | void cleanupTestCase(); | |
36 | void init(); |
|
37 | void init(); | |
37 | void cleanup(); |
|
38 | void cleanup(); | |
38 |
|
39 | |||
39 | private slots: |
|
40 | private slots: | |
40 | void qlineseries_data(); |
|
41 | void qlineseries_data(); | |
41 | void qlineseries(); |
|
42 | void qlineseries(); | |
42 | void append_raw_data(); |
|
43 | void append_raw_data(); | |
43 | void append_raw(); |
|
44 | void append_raw(); | |
44 | void append_chart_data(); |
|
45 | void append_chart_data(); | |
45 | void append_chart(); |
|
46 | void append_chart(); | |
46 | void append_chart_animation_data(); |
|
47 | void append_chart_animation_data(); | |
47 | void append_chart_animation(); |
|
48 | void append_chart_animation(); | |
48 | void chart_append_data(); |
|
49 | void chart_append_data(); | |
49 | void chart_append(); |
|
50 | void chart_append(); | |
50 | void count_raw_data(); |
|
51 | void count_raw_data(); | |
51 | void count_raw(); |
|
52 | void count_raw(); | |
52 | void oper_data(); |
|
53 | void oper_data(); | |
53 | void oper(); |
|
54 | void oper(); | |
54 | void pen_data(); |
|
55 | void pen_data(); | |
55 | void pen(); |
|
56 | void pen(); | |
56 | void pointsVisible_raw_data(); |
|
57 | void pointsVisible_raw_data(); | |
57 | void pointsVisible_raw(); |
|
58 | void pointsVisible_raw(); | |
58 | void remove_raw_data(); |
|
59 | void remove_raw_data(); | |
59 | void remove_raw(); |
|
60 | void remove_raw(); | |
60 | void remove_chart_data(); |
|
61 | void remove_chart_data(); | |
61 | void remove_chart(); |
|
62 | void remove_chart(); | |
62 | void remove_chart_animation_data(); |
|
63 | void remove_chart_animation_data(); | |
63 | void remove_chart_animation(); |
|
64 | void remove_chart_animation(); | |
64 | void removeAll_data(); |
|
65 | void removeAll_data(); | |
65 | void removeAll(); |
|
66 | void removeAll(); | |
66 | void replace_data(); |
|
67 | void replace_data(); | |
67 | void replace(); |
|
68 | void replace(); | |
68 | void setModel_data(); |
|
69 | void setModel_data(); | |
69 | void setModel(); |
|
70 | void setModel(); | |
70 | void setModelMapping_data(); |
|
71 | void setModelMapping_data(); | |
71 | void setModelMapping(); |
|
72 | void setModelMapping(); | |
72 | private: |
|
73 | private: | |
73 | void append_data(); |
|
74 | void append_data(); | |
74 | void count_data(); |
|
75 | void count_data(); | |
75 | void pointsVisible_data(); |
|
76 | void pointsVisible_data(); | |
76 |
|
77 | |||
77 | private: |
|
78 | private: | |
78 | QChartView* m_view; |
|
79 | QChartView* m_view; | |
79 | QChart* m_chart; |
|
80 | QChart* m_chart; | |
80 | QLineSeries* m_series; |
|
81 | QLineSeries* m_series; | |
81 | }; |
|
82 | }; | |
82 |
|
83 | |||
83 | void tst_QLineSeries::initTestCase() |
|
84 | void tst_QLineSeries::initTestCase() | |
84 | { |
|
85 | { | |
85 | } |
|
86 | } | |
86 |
|
87 | |||
87 | void tst_QLineSeries::cleanupTestCase() |
|
88 | void tst_QLineSeries::cleanupTestCase() | |
88 | { |
|
89 | { | |
89 | } |
|
90 | } | |
90 |
|
91 | |||
91 | void tst_QLineSeries::init() |
|
92 | void tst_QLineSeries::init() | |
92 | { |
|
93 | { | |
93 | m_view = new QChartView(new QChart()); |
|
94 | m_view = new QChartView(new QChart()); | |
94 | m_chart = m_view->chart(); |
|
95 | m_chart = m_view->chart(); | |
95 | m_series = new QLineSeries(); |
|
96 | m_series = new QLineSeries(); | |
96 | } |
|
97 | } | |
97 |
|
98 | |||
98 | void tst_QLineSeries::cleanup() |
|
99 | void tst_QLineSeries::cleanup() | |
99 | { |
|
100 | { | |
100 | delete m_series; |
|
101 | delete m_series; | |
101 | delete m_view; |
|
102 | delete m_view; | |
102 | m_view = 0; |
|
103 | m_view = 0; | |
103 | m_chart = 0; |
|
104 | m_chart = 0; | |
104 | m_series = 0; |
|
105 | m_series = 0; | |
105 | } |
|
106 | } | |
106 |
|
107 | |||
107 | void tst_QLineSeries::qlineseries_data() |
|
108 | void tst_QLineSeries::qlineseries_data() | |
108 | { |
|
109 | { | |
109 |
|
110 | |||
110 | } |
|
111 | } | |
111 |
|
112 | |||
112 | void tst_QLineSeries::qlineseries() |
|
113 | void tst_QLineSeries::qlineseries() | |
113 | { |
|
114 | { | |
114 | QLineSeries series; |
|
115 | QLineSeries series; | |
115 |
|
116 | |||
116 | QCOMPARE(series.count(),0); |
|
117 | QCOMPARE(series.count(),0); | |
117 | QCOMPARE(series.brush(), QBrush()); |
|
118 | QCOMPARE(series.brush(), QBrush()); | |
118 | QCOMPARE(series.points(), QList<QPointF>()); |
|
119 | QCOMPARE(series.points(), QList<QPointF>()); | |
119 | QCOMPARE(series.pen(), QPen()); |
|
120 | QCOMPARE(series.pen(), QPen()); | |
120 | QCOMPARE(series.pointsVisible(), false); |
|
121 | QCOMPARE(series.pointsVisible(), false); | |
121 |
|
122 | |||
122 | series.append(QList<QPointF>()); |
|
123 | series.append(QList<QPointF>()); | |
123 | series.append(0.0,0.0); |
|
124 | series.append(0.0,0.0); | |
124 | series.append(QPointF()); |
|
125 | series.append(QPointF()); | |
125 |
|
126 | |||
126 | series.remove(0.0,0.0); |
|
127 | series.remove(0.0,0.0); | |
127 | series.remove(QPointF()); |
|
128 | series.remove(QPointF()); | |
128 | series.removeAll(); |
|
129 | series.removeAll(); | |
129 |
|
130 | |||
130 | series.replace(QPointF(),QPointF()); |
|
131 | series.replace(QPointF(),QPointF()); | |
131 | series.replace(0,0,0,0); |
|
132 | series.replace(0,0,0,0); | |
132 | series.setBrush(QBrush()); |
|
133 | series.setBrush(QBrush()); | |
133 |
|
134 | |||
134 | QCOMPARE(series.setModel((QAbstractItemModel*)0), false); |
|
135 | QCOMPARE(series.setModel((QAbstractItemModel*)0), false); | |
135 |
|
136 | |||
136 | series.setModelMapping(-1, -1, Qt::Orientation(0)); |
|
137 | series.setModelMapping(-1, -1, Qt::Orientation(0)); | |
137 |
|
138 | |||
138 | series.setPen(QPen()); |
|
139 | series.setPen(QPen()); | |
139 | series.setPointsVisible(false); |
|
140 | series.setPointsVisible(false); | |
140 |
|
141 | |||
141 | m_chart->addSeries(&series); |
|
142 | m_chart->addSeries(&series); | |
142 | m_view->show(); |
|
143 | m_view->show(); | |
143 | QTest::qWaitForWindowShown(m_view); |
|
144 | QTest::qWaitForWindowShown(m_view); | |
144 | } |
|
145 | } | |
145 |
|
146 | |||
146 | void tst_QLineSeries::append_data() |
|
147 | void tst_QLineSeries::append_data() | |
147 | { |
|
148 | { | |
148 | QTest::addColumn< QList<QPointF> >("points"); |
|
149 | QTest::addColumn< QList<QPointF> >("points"); | |
149 | QTest::newRow("0,0 1,1 2,2 3,3") << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)); |
|
150 | QTest::newRow("0,0 1,1 2,2 3,3") << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)); | |
150 | QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)); |
|
151 | QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)); | |
151 | } |
|
152 | } | |
152 |
|
153 | |||
153 |
|
154 | |||
154 | void tst_QLineSeries::append_raw_data() |
|
155 | void tst_QLineSeries::append_raw_data() | |
155 | { |
|
156 | { | |
156 | append_data(); |
|
157 | append_data(); | |
157 | } |
|
158 | } | |
158 |
|
159 | |||
159 | void tst_QLineSeries::append_raw() |
|
160 | void tst_QLineSeries::append_raw() | |
160 | { |
|
161 | { | |
161 | QFETCH(QList<QPointF>, points); |
|
162 | QFETCH(QList<QPointF>, points); | |
162 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
163 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
163 | QTest::qWait(200); |
|
164 | QTest::qWait(200); | |
164 | m_series->append(points); |
|
165 | m_series->append(points); | |
165 | QTest::qWait(200); |
|
166 | QTest::qWait(200); | |
166 | QCOMPARE(spy0.count(), 0); |
|
167 | QCOMPARE(spy0.count(), 0); | |
167 | QCOMPARE(m_series->points(), points); |
|
168 | QCOMPARE(m_series->points(), points); | |
168 | } |
|
169 | } | |
169 |
|
170 | |||
170 | void tst_QLineSeries::chart_append_data() |
|
171 | void tst_QLineSeries::chart_append_data() | |
171 | { |
|
172 | { | |
172 | append_data(); |
|
173 | append_data(); | |
173 | } |
|
174 | } | |
174 |
|
175 | |||
175 | void tst_QLineSeries::chart_append() |
|
176 | void tst_QLineSeries::chart_append() | |
176 | { |
|
177 | { | |
177 | append_raw(); |
|
178 | append_raw(); | |
178 | m_chart->addSeries(m_series); |
|
179 | m_chart->addSeries(m_series); | |
179 | m_view->show(); |
|
180 | m_view->show(); | |
180 | QTest::qWaitForWindowShown(m_view); |
|
181 | QTest::qWaitForWindowShown(m_view); | |
181 | } |
|
182 | } | |
182 |
|
183 | |||
183 | void tst_QLineSeries::append_chart_data() |
|
184 | void tst_QLineSeries::append_chart_data() | |
184 | { |
|
185 | { | |
185 | append_data(); |
|
186 | append_data(); | |
186 | } |
|
187 | } | |
187 |
|
188 | |||
188 | void tst_QLineSeries::append_chart() |
|
189 | void tst_QLineSeries::append_chart() | |
189 | { |
|
190 | { | |
190 | m_view->show(); |
|
191 | m_view->show(); | |
191 | m_chart->addSeries(m_series); |
|
192 | m_chart->addSeries(m_series); | |
192 | append_raw(); |
|
193 | append_raw(); | |
193 | QTest::qWaitForWindowShown(m_view); |
|
194 | QTest::qWaitForWindowShown(m_view); | |
194 | } |
|
195 | } | |
195 |
|
196 | |||
196 | void tst_QLineSeries::append_chart_animation_data() |
|
197 | void tst_QLineSeries::append_chart_animation_data() | |
197 | { |
|
198 | { | |
198 | append_data(); |
|
199 | append_data(); | |
199 | } |
|
200 | } | |
200 |
|
201 | |||
201 | void tst_QLineSeries::append_chart_animation() |
|
202 | void tst_QLineSeries::append_chart_animation() | |
202 | { |
|
203 | { | |
203 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
204 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
204 | append_chart(); |
|
205 | append_chart(); | |
205 | } |
|
206 | } | |
206 |
|
207 | |||
207 | void tst_QLineSeries::count_data() |
|
208 | void tst_QLineSeries::count_data() | |
208 | { |
|
209 | { | |
209 | QTest::addColumn<int>("count"); |
|
210 | QTest::addColumn<int>("count"); | |
210 | QTest::newRow("0") << 0; |
|
211 | QTest::newRow("0") << 0; | |
211 | QTest::newRow("5") << 5; |
|
212 | QTest::newRow("5") << 5; | |
212 | QTest::newRow("10") << 5; |
|
213 | QTest::newRow("10") << 5; | |
213 | } |
|
214 | } | |
214 |
|
215 | |||
215 | void tst_QLineSeries::count_raw_data() |
|
216 | void tst_QLineSeries::count_raw_data() | |
216 | { |
|
217 | { | |
217 | count_data(); |
|
218 | count_data(); | |
218 | } |
|
219 | } | |
219 |
|
220 | |||
220 | void tst_QLineSeries::count_raw() |
|
221 | void tst_QLineSeries::count_raw() | |
221 | { |
|
222 | { | |
222 | QFETCH(int, count); |
|
223 | QFETCH(int, count); | |
223 |
|
224 | |||
224 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
225 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
225 |
|
226 | |||
226 | for(int i=0 ; i< count; ++i) |
|
227 | for(int i=0 ; i< count; ++i) | |
227 | m_series->append(i,i); |
|
228 | m_series->append(i,i); | |
228 |
|
229 | |||
229 | QCOMPARE(spy0.count(), 0); |
|
230 | QCOMPARE(spy0.count(), 0); | |
230 | QCOMPARE(m_series->count(), count); |
|
231 | QCOMPARE(m_series->count(), count); | |
231 | } |
|
232 | } | |
232 |
|
233 | |||
233 | void tst_QLineSeries::oper_data() |
|
234 | void tst_QLineSeries::oper_data() | |
234 | { |
|
235 | { | |
235 | append_data(); |
|
236 | append_data(); | |
236 | } |
|
237 | } | |
237 |
|
238 | |||
238 | void tst_QLineSeries::oper() |
|
239 | void tst_QLineSeries::oper() | |
239 | { |
|
240 | { | |
240 | QFETCH(QList<QPointF>, points); |
|
241 | QFETCH(QList<QPointF>, points); | |
241 | QLineSeries series; |
|
242 | QLineSeries series; | |
242 |
|
243 | |||
243 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
244 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); | |
244 |
|
245 | |||
245 | foreach(const QPointF& point,points) |
|
246 | foreach(const QPointF& point,points) | |
246 | { |
|
247 | { | |
247 | series<<point; |
|
248 | series<<point; | |
248 | } |
|
249 | } | |
249 |
|
250 | |||
250 | QCOMPARE(series.points(), points); |
|
251 | QCOMPARE(series.points(), points); | |
251 | QCOMPARE(spy0.count(), 0); |
|
252 | QCOMPARE(spy0.count(), 0); | |
252 | } |
|
253 | } | |
253 |
|
254 | |||
254 |
|
255 | |||
255 | void tst_QLineSeries::pen_data() |
|
256 | void tst_QLineSeries::pen_data() | |
256 | { |
|
257 | { | |
257 | QTest::addColumn<QPen>("pen"); |
|
258 | QTest::addColumn<QPen>("pen"); | |
258 | QTest::newRow("null") << QPen(); |
|
259 | QTest::newRow("null") << QPen(); | |
259 | QTest::newRow("blue") << QPen(Qt::blue); |
|
260 | QTest::newRow("blue") << QPen(Qt::blue); | |
260 | QTest::newRow("black") << QPen(Qt::black); |
|
261 | QTest::newRow("black") << QPen(Qt::black); | |
261 | QTest::newRow("red") << QPen(Qt::red); |
|
262 | QTest::newRow("red") << QPen(Qt::red); | |
262 | } |
|
263 | } | |
263 |
|
264 | |||
264 | void tst_QLineSeries::pen() |
|
265 | void tst_QLineSeries::pen() | |
265 | { |
|
266 | { | |
266 | QFETCH(QPen, pen); |
|
267 | QFETCH(QPen, pen); | |
267 | QLineSeries series; |
|
268 | QLineSeries series; | |
268 |
|
269 | |||
269 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
270 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); | |
270 | series.setPen(pen); |
|
271 | series.setPen(pen); | |
271 |
|
272 | |||
272 | QCOMPARE(spy0.count(), 0); |
|
273 | QCOMPARE(spy0.count(), 0); | |
273 | QCOMPARE(series.pen(), pen); |
|
274 | QCOMPARE(series.pen(), pen); | |
274 |
|
275 | |||
275 | m_chart->addSeries(&series); |
|
276 | m_chart->addSeries(&series); | |
276 |
|
277 | |||
277 | if(pen!=QPen()) QCOMPARE(series.pen(), pen); |
|
278 | if(pen!=QPen()) QCOMPARE(series.pen(), pen); | |
278 | } |
|
279 | } | |
279 |
|
280 | |||
280 | void tst_QLineSeries::pointsVisible_data() |
|
281 | void tst_QLineSeries::pointsVisible_data() | |
281 | { |
|
282 | { | |
282 | QTest::addColumn<bool>("pointsVisible"); |
|
283 | QTest::addColumn<bool>("pointsVisible"); | |
283 | QTest::newRow("true") << true; |
|
284 | QTest::newRow("true") << true; | |
284 | QTest::newRow("false") << false; |
|
285 | QTest::newRow("false") << false; | |
285 | } |
|
286 | } | |
286 |
|
287 | |||
287 | void tst_QLineSeries::pointsVisible_raw_data() |
|
288 | void tst_QLineSeries::pointsVisible_raw_data() | |
288 | { |
|
289 | { | |
289 | pointsVisible_data(); |
|
290 | pointsVisible_data(); | |
290 | } |
|
291 | } | |
291 |
|
292 | |||
292 | void tst_QLineSeries::pointsVisible_raw() |
|
293 | void tst_QLineSeries::pointsVisible_raw() | |
293 | { |
|
294 | { | |
294 | QFETCH(bool, pointsVisible); |
|
295 | QFETCH(bool, pointsVisible); | |
295 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
296 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
296 | m_series->setPointsVisible(pointsVisible); |
|
297 | m_series->setPointsVisible(pointsVisible); | |
297 | QCOMPARE(spy0.count(), 0); |
|
298 | QCOMPARE(spy0.count(), 0); | |
298 | QCOMPARE(m_series->pointsVisible(), pointsVisible); |
|
299 | QCOMPARE(m_series->pointsVisible(), pointsVisible); | |
299 | } |
|
300 | } | |
300 |
|
301 | |||
301 | void tst_QLineSeries::remove_raw_data() |
|
302 | void tst_QLineSeries::remove_raw_data() | |
302 | { |
|
303 | { | |
303 | append_data(); |
|
304 | append_data(); | |
304 | } |
|
305 | } | |
305 |
|
306 | |||
306 | void tst_QLineSeries::remove_raw() |
|
307 | void tst_QLineSeries::remove_raw() | |
307 | { |
|
308 | { | |
308 | QFETCH(QList<QPointF>, points); |
|
309 | QFETCH(QList<QPointF>, points); | |
309 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
310 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
310 | m_series->append(points); |
|
311 | m_series->append(points); | |
311 | QTest::qWait(200); |
|
312 | QTest::qWait(200); | |
312 | QCOMPARE(spy0.count(), 0); |
|
313 | QCOMPARE(spy0.count(), 0); | |
313 | QCOMPARE(m_series->points(), points); |
|
314 | QCOMPARE(m_series->points(), points); | |
314 |
|
315 | |||
315 | foreach(const QPointF& point,points) |
|
316 | foreach(const QPointF& point,points) | |
316 | { |
|
317 | { | |
317 | m_series->remove(point); |
|
318 | m_series->remove(point); | |
318 | QTest::qWait(200); |
|
319 | QTest::qWait(200); | |
319 | } |
|
320 | } | |
320 |
|
321 | |||
321 | QCOMPARE(spy0.count(), 0); |
|
322 | QCOMPARE(spy0.count(), 0); | |
322 | QCOMPARE(m_series->points().count(), 0); |
|
323 | QCOMPARE(m_series->points().count(), 0); | |
323 | } |
|
324 | } | |
324 |
|
325 | |||
325 | void tst_QLineSeries::remove_chart_data() |
|
326 | void tst_QLineSeries::remove_chart_data() | |
326 | { |
|
327 | { | |
327 | append_data(); |
|
328 | append_data(); | |
328 | } |
|
329 | } | |
329 |
|
330 | |||
330 | void tst_QLineSeries::remove_chart() |
|
331 | void tst_QLineSeries::remove_chart() | |
331 | { |
|
332 | { | |
332 | m_view->show(); |
|
333 | m_view->show(); | |
333 | m_chart->addSeries(m_series); |
|
334 | m_chart->addSeries(m_series); | |
334 | remove_raw(); |
|
335 | remove_raw(); | |
335 | QTest::qWaitForWindowShown(m_view); |
|
336 | QTest::qWaitForWindowShown(m_view); | |
336 | } |
|
337 | } | |
337 |
|
338 | |||
338 | void tst_QLineSeries::remove_chart_animation_data() |
|
339 | void tst_QLineSeries::remove_chart_animation_data() | |
339 | { |
|
340 | { | |
340 | append_data(); |
|
341 | append_data(); | |
341 | } |
|
342 | } | |
342 |
|
343 | |||
343 | void tst_QLineSeries::remove_chart_animation() |
|
344 | void tst_QLineSeries::remove_chart_animation() | |
344 | { |
|
345 | { | |
345 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
346 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
346 | remove_chart(); |
|
347 | remove_chart(); | |
347 | } |
|
348 | } | |
348 |
|
349 | |||
349 |
|
350 | |||
350 | void tst_QLineSeries::removeAll_data() |
|
351 | void tst_QLineSeries::removeAll_data() | |
351 | { |
|
352 | { | |
352 | append_data(); |
|
353 | append_data(); | |
353 | } |
|
354 | } | |
354 |
|
355 | |||
355 | void tst_QLineSeries::removeAll() |
|
356 | void tst_QLineSeries::removeAll() | |
356 | { |
|
357 | { | |
357 | #if 0 |
|
358 | #if 0 | |
358 | QFETCH(int, foo); |
|
359 | QFETCH(int, foo); | |
359 |
|
360 | |||
360 | SubQXYSeries series; |
|
361 | SubQXYSeries series; | |
361 |
|
362 | |||
362 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
363 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); | |
363 | QSignalSpy spy1(&series, SIGNAL(selected())); |
|
364 | QSignalSpy spy1(&series, SIGNAL(selected())); | |
364 |
|
365 | |||
365 | series.removeAll(); |
|
366 | series.removeAll(); | |
366 |
|
367 | |||
367 | QCOMPARE(spy0.count(), 0); |
|
368 | QCOMPARE(spy0.count(), 0); | |
368 | QCOMPARE(spy1.count(), 0); |
|
369 | QCOMPARE(spy1.count(), 0); | |
369 | #endif |
|
370 | #endif | |
370 | QSKIP("Test is not implemented.", SkipAll); |
|
371 | QSKIP("Test is not implemented.", SkipAll); | |
371 | } |
|
372 | } | |
372 |
|
373 | |||
373 | void tst_QLineSeries::replace_data() |
|
374 | void tst_QLineSeries::replace_data() | |
374 | { |
|
375 | { | |
375 | QTest::addColumn<QPointF>("point"); |
|
376 | QTest::addColumn<QPointF>("point"); | |
376 | QTest::newRow("null") << QPointF(); |
|
377 | QTest::newRow("null") << QPointF(); | |
377 | } |
|
378 | } | |
378 |
|
379 | |||
379 | void tst_QLineSeries::replace() |
|
380 | void tst_QLineSeries::replace() | |
380 | { |
|
381 | { | |
381 | #if 0 |
|
382 | #if 0 | |
382 | QFETCH(QPointF, point); |
|
383 | QFETCH(QPointF, point); | |
383 |
|
384 | |||
384 | SubQXYSeries series; |
|
385 | SubQXYSeries series; | |
385 |
|
386 | |||
386 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
387 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); | |
387 | QSignalSpy spy1(&series, SIGNAL(selected())); |
|
388 | QSignalSpy spy1(&series, SIGNAL(selected())); | |
388 |
|
389 | |||
389 | series.replace(point); |
|
390 | series.replace(point); | |
390 |
|
391 | |||
391 | QCOMPARE(spy0.count(), 0); |
|
392 | QCOMPARE(spy0.count(), 0); | |
392 | QCOMPARE(spy1.count(), 0); |
|
393 | QCOMPARE(spy1.count(), 0); | |
393 | #endif |
|
394 | #endif | |
394 | QSKIP("Test is not implemented.", SkipAll); |
|
395 | QSKIP("Test is not implemented.", SkipAll); | |
395 | } |
|
396 | } | |
396 |
|
397 | |||
397 | void tst_QLineSeries::setModel_data() |
|
398 | void tst_QLineSeries::setModel_data() | |
398 | { |
|
399 | { | |
399 | QTest::addColumn<int>("modelCount"); |
|
400 | QTest::addColumn<int>("modelCount"); | |
400 | QTest::addColumn<bool>("setModel"); |
|
401 | QTest::addColumn<bool>("setModel"); | |
401 | QTest::newRow("null") << 0 << false; |
|
402 | QTest::newRow("null") << 0 << false; | |
402 | } |
|
403 | } | |
403 |
|
404 | |||
404 | void tst_QLineSeries::setModel() |
|
405 | void tst_QLineSeries::setModel() | |
405 | { |
|
406 | { | |
406 | #if 0 |
|
407 | #if 0 | |
407 | QFETCH(int, modelCount); |
|
408 | QFETCH(int, modelCount); | |
408 | QFETCH(bool, setModel); |
|
409 | QFETCH(bool, setModel); | |
409 |
|
410 | |||
410 | SubQXYSeries series; |
|
411 | SubQXYSeries series; | |
411 |
|
412 | |||
412 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
413 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); | |
413 | QSignalSpy spy1(&series, SIGNAL(selected())); |
|
414 | QSignalSpy spy1(&series, SIGNAL(selected())); | |
414 |
|
415 | |||
415 | QCOMPARE(series.setModel(model), setModel); |
|
416 | QCOMPARE(series.setModel(model), setModel); | |
416 |
|
417 | |||
417 | QCOMPARE(spy0.count(), 0); |
|
418 | QCOMPARE(spy0.count(), 0); | |
418 | QCOMPARE(spy1.count(), 0); |
|
419 | QCOMPARE(spy1.count(), 0); | |
419 | #endif |
|
420 | #endif | |
420 | QSKIP("Test is not implemented.", SkipAll); |
|
421 | QSKIP("Test is not implemented.", SkipAll); | |
421 | } |
|
422 | } | |
422 |
|
423 | |||
423 | Q_DECLARE_METATYPE(Qt::Orientation) |
|
424 | Q_DECLARE_METATYPE(Qt::Orientation) | |
424 | void tst_QLineSeries::setModelMapping_data() |
|
425 | void tst_QLineSeries::setModelMapping_data() | |
425 | { |
|
426 | { | |
426 | #if 0 |
|
|||
427 | QTest::addColumn<int>("modelX"); |
|
427 | QTest::addColumn<int>("modelX"); | |
428 | QTest::addColumn<int>("modelY"); |
|
428 | QTest::addColumn<int>("modelY"); | |
429 | QTest::addColumn<Qt::Orientation>("orientation"); |
|
429 | QTest::addColumn<Qt::Orientation>("orientation"); | |
430 |
QTest::newRow(" |
|
430 | QTest::newRow("different x and y, vertical") << 0 << 1 << Qt::Vertical; | |
431 | #endif |
|
431 | QTest::newRow("same x and y, vertical") << 0 << 0 << Qt::Vertical; | |
|
432 | QTest::newRow("invalid x, corrent y, vertical") << -1 << 1 << Qt::Vertical; | |||
|
433 | ||||
|
434 | QTest::newRow("different x and y, horizontal") << 0 << 1 << Qt::Horizontal; | |||
|
435 | QTest::newRow("same x and y, horizontal") << 0 << 0 << Qt::Horizontal; | |||
|
436 | QTest::newRow("invalid x, corrent y, horizontal") << -1 << 1 << Qt::Horizontal; | |||
432 | } |
|
437 | } | |
433 |
|
438 | |||
434 | void tst_QLineSeries::setModelMapping() |
|
439 | void tst_QLineSeries::setModelMapping() | |
435 | { |
|
440 | { | |
436 | #if 0 |
|
|||
437 | QFETCH(int, modelX); |
|
441 | QFETCH(int, modelX); | |
438 | QFETCH(int, modelY); |
|
442 | QFETCH(int, modelY); | |
439 | QFETCH(Qt::Orientation, orientation); |
|
443 | QFETCH(Qt::Orientation, orientation); | |
440 |
|
444 | |||
441 |
|
|
445 | QLineSeries series; | |
442 |
|
||||
443 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
|||
444 | QSignalSpy spy1(&series, SIGNAL(selected())); |
|
|||
445 |
|
446 | |||
|
447 | // model has not been set so setting mapping should do nothing | |||
446 | series.setModelMapping(modelX, modelY, orientation); |
|
448 | series.setModelMapping(modelX, modelY, orientation); | |
|
449 | QCOMPARE(series.mapX(), -1); | |||
|
450 | QCOMPARE(series.mapY(), -1); | |||
|
451 | QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical"); | |||
447 |
|
452 | |||
448 | QCOMPARE(spy0.count(), 0); |
|
453 | // now let us set the model | |
449 | QCOMPARE(spy1.count(), 0); |
|
454 | series.setModel(new QStandardItemModel()); | |
450 | #endif |
|
455 | series.setModelMapping(modelX, modelY, orientation); | |
451 | QSKIP("Test is not implemented.", SkipAll); |
|
456 | QCOMPARE(series.mapX(), modelX); | |
|
457 | QCOMPARE(series.mapY(), modelY); | |||
|
458 | QVERIFY2(series.mapOrientation() == orientation, "not good"); | |||
|
459 | ||||
|
460 | // now let us remove the model, the values should go back to default ones. | |||
|
461 | series.setModel(0); | |||
|
462 | QCOMPARE(series.mapX(), -1); | |||
|
463 | QCOMPARE(series.mapY(), -1); | |||
|
464 | QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical"); | |||
452 | } |
|
465 | } | |
453 |
|
466 | |||
454 | QTEST_MAIN(tst_QLineSeries) |
|
467 | QTEST_MAIN(tst_QLineSeries) | |
455 |
|
468 | |||
456 | #include "tst_qlineseries.moc" |
|
469 | #include "tst_qlineseries.moc" | |
457 |
|
470 |
General Comments 0
You need to be logged in to leave comments.
Login now