##// END OF EJS Templates
tst_qchart and tst_qchartview updates
Michal Klocek -
r914:5d82b4aac9d4
parent child
Show More
@@ -1,775 +1,762
1 #include <QtTest/QtTest>
1 #include <QtTest/QtTest>
2 #include <qchartview.h>
2 #include <qchartview.h>
3 #include <qlineseries.h>
3 #include <qlineseries.h>
4 #include <qareaseries.h>
4 #include <qareaseries.h>
5 #include <qscatterseries.h>
5 #include <qscatterseries.h>
6 #include <qsplineseries.h>
6 #include <qsplineseries.h>
7 #include <qpieseries.h>
7 #include <qpieseries.h>
8 #include <qbarseries.h>
8 #include <qbarseries.h>
9 #include <qpercentbarseries.h>
9 #include <qpercentbarseries.h>
10 #include <qstackedbarseries.h>
10 #include <qstackedbarseries.h>
11
11
12 QTCOMMERCIALCHART_USE_NAMESPACE
12 QTCOMMERCIALCHART_USE_NAMESPACE
13
13
14 Q_DECLARE_METATYPE(QChartAxis*)
14 Q_DECLARE_METATYPE(QChartAxis*)
15 Q_DECLARE_METATYPE(QSeries*)
15 Q_DECLARE_METATYPE(QSeries*)
16 Q_DECLARE_METATYPE(QChart::AnimationOption)
16
17
17 class tst_QChart : public QObject
18 class tst_QChart : public QObject
18 {
19 {
19 Q_OBJECT
20 Q_OBJECT
20
21
21 public slots:
22 public slots:
22 void initTestCase();
23 void initTestCase();
23 void cleanupTestCase();
24 void cleanupTestCase();
24 void init();
25 void init();
25 void cleanup();
26 void cleanup();
26
27
27 private slots:
28 private slots:
28 void qchart_data();
29 void qchart_data();
29 void qchart();
30 void qchart();
30
31
31 void addSeries_data();
32 void addSeries_data();
32 void addSeries();
33 void addSeries();
33 void animationOptions_data();
34 void animationOptions_data();
34 void animationOptions();
35 void animationOptions();
35 void axisX_data();
36 void axisX_data();
36 void axisX();
37 void axisX();
37 void axisY_data();
38 void axisY_data();
38 void axisY();
39 void axisY();
39 void backgroundBrush_data();
40 void backgroundBrush_data();
40 void backgroundBrush();
41 void backgroundBrush();
41 void backgroundPen_data();
42 void backgroundPen_data();
42 void backgroundPen();
43 void backgroundPen();
43 void isBackgroundVisible_data();
44 void isBackgroundVisible_data();
44 void isBackgroundVisible();
45 void isBackgroundVisible();
45 void legend_data();
46 void legend_data();
46 void legend();
47 void legend();
47 void margins_data();
48 void margins_data();
48 void margins();
49 void margins();
49 void removeAllSeries_data();
50 void removeAllSeries_data();
50 void removeAllSeries();
51 void removeAllSeries();
51 void removeSeries_data();
52 void removeSeries_data();
52 void removeSeries();
53 void removeSeries();
53 void scrollDown_data();
54 void scrollDown_data();
54 void scrollDown();
55 void scrollDown();
55 void scrollLeft_data();
56 void scrollLeft_data();
56 void scrollLeft();
57 void scrollLeft();
57 void scrollRight_data();
58 void scrollRight_data();
58 void scrollRight();
59 void scrollRight();
59 void scrollUp_data();
60 void scrollUp_data();
60 void scrollUp();
61 void scrollUp();
61 void setAnimationOptions_data();
62 void setAnimationOptions();
63 void setBackgroundBrush_data();
62 void setBackgroundBrush_data();
64 void setBackgroundBrush();
63 void setBackgroundBrush();
65 void setBackgroundPen_data();
64 void setBackgroundPen_data();
66 void setBackgroundPen();
65 void setBackgroundPen();
67 void setBackgroundVisible_data();
66 void setBackgroundVisible_data();
68 void setBackgroundVisible();
67 void setBackgroundVisible();
69 void setTheme_data();
68 void setTheme_data();
70 void setTheme();
69 void setTheme();
71 void setTitle_data();
70 void setTitle_data();
72 void setTitle();
71 void setTitle();
73 void setTitleBrush_data();
72 void setTitleBrush_data();
74 void setTitleBrush();
73 void setTitleBrush();
75 void setTitleFont_data();
74 void setTitleFont_data();
76 void setTitleFont();
75 void setTitleFont();
77 void theme_data();
76 void theme_data();
78 void theme();
77 void theme();
79 void title_data();
78 void title_data();
80 void title();
79 void title();
81 void titleBrush_data();
80 void titleBrush_data();
82 void titleBrush();
81 void titleBrush();
83 void titleFont_data();
82 void titleFont_data();
84 void titleFont();
83 void titleFont();
85 void zoomIn_data();
84 void zoomIn_data();
86 void zoomIn();
85 void zoomIn();
87 void zoomOut_data();
86 void zoomOut_data();
88 void zoomOut();
87 void zoomOut();
89
88
90 private:
89 private:
90 void createTestData();
91
92 private:
91 QChartView* m_view;
93 QChartView* m_view;
92 QChart* m_chart;
94 QChart* m_chart;
93 };
95 };
94
96
95 void tst_QChart::initTestCase()
97 void tst_QChart::initTestCase()
96 {
98 {
97
99
98 }
100 }
99
101
100 void tst_QChart::cleanupTestCase()
102 void tst_QChart::cleanupTestCase()
101 {
103 {
102
104
103 }
105 }
104
106
105 void tst_QChart::init()
107 void tst_QChart::init()
106 {
108 {
107 m_view = new QChartView(new QChart());
109 m_view = new QChartView(new QChart());
108 m_chart = m_view->chart();
110 m_chart = m_view->chart();
111 }
109
112
113 void tst_QChart::createTestData()
114 {
115 QLineSeries* series0 = new QLineSeries(this);
116 *series0 << QPointF(0, 0) << QPointF(100, 100);
117 m_chart->addSeries(series0);
118 m_view->show();
119 QTest::qWaitForWindowShown(m_view);
110 }
120 }
111
121
112 void tst_QChart::cleanup()
122 void tst_QChart::cleanup()
113 {
123 {
114 delete m_view;
124 delete m_view;
115 m_view = 0;
125 m_view = 0;
116 m_chart = 0;
126 m_chart = 0;
117 }
127 }
118
128
119 void tst_QChart::qchart_data()
129 void tst_QChart::qchart_data()
120 {
130 {
121 }
131 }
122
132
123 void tst_QChart::qchart()
133 void tst_QChart::qchart()
124 {
134 {
125 QVERIFY(m_chart);
135 QVERIFY(m_chart);
126 QVERIFY(m_chart->legend());
136 QVERIFY(m_chart->legend());
127 QVERIFY(!m_chart->legend()->isVisible());
137 QVERIFY(!m_chart->legend()->isVisible());
128
138
129 QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation);
139 QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation);
130 QVERIFY(m_chart->axisX());
140 QVERIFY(m_chart->axisX());
131 QVERIFY(m_chart->axisY());
141 QVERIFY(m_chart->axisY());
132 QVERIFY(m_chart->backgroundBrush()!=QBrush());
142 QVERIFY(m_chart->backgroundBrush()!=QBrush());
133 QVERIFY(m_chart->backgroundPen()!=QPen());
143 QVERIFY(m_chart->backgroundPen()!=QPen());
134 QCOMPARE(m_chart->isBackgroundVisible(), true);
144 QCOMPARE(m_chart->isBackgroundVisible(), true);
135
145
136 QVERIFY(m_chart->margins().top()>0);
146 QVERIFY(m_chart->margins().top()>0);
137 QVERIFY(m_chart->margins().left()>0);
147 QVERIFY(m_chart->margins().left()>0);
138 QVERIFY(m_chart->margins().right()>0);
148 QVERIFY(m_chart->margins().right()>0);
139 QVERIFY(m_chart->margins().bottom()>0);
149 QVERIFY(m_chart->margins().bottom()>0);
140 m_chart->removeAllSeries();
150 m_chart->removeAllSeries();
141 m_chart->scrollDown();
151 m_chart->scrollDown();
142 m_chart->scrollLeft();
152 m_chart->scrollLeft();
143 m_chart->scrollRight();
153 m_chart->scrollRight();
144 m_chart->scrollUp();
154 m_chart->scrollUp();
145 QCOMPARE(m_chart->theme(), QChart::ChartThemeLight);
155 QCOMPARE(m_chart->theme(), QChart::ChartThemeLight);
146 QCOMPARE(m_chart->title(), QString());
156 QCOMPARE(m_chart->title(), QString());
147 QCOMPARE(m_chart->titleBrush(),QBrush());
157 QCOMPARE(m_chart->titleBrush(),QBrush());
148 QCOMPARE(m_chart->titleFont(),QFont());
158 QCOMPARE(m_chart->titleFont(),QFont());
149 m_chart->zoomIn();
159 m_chart->zoomIn();
150 m_chart->zoomIn(QRectF());
160 m_chart->zoomIn(QRectF());
151 m_chart->zoomOut();
161 m_chart->zoomOut();
152 }
162 }
153
163
154 void tst_QChart::addSeries_data()
164 void tst_QChart::addSeries_data()
155 {
165 {
156 QTest::addColumn<QSeries*>("series");
166 QTest::addColumn<QSeries*>("series");
157 QTest::addColumn<QChartAxis*>("axis");
167 QTest::addColumn<QChartAxis*>("axis");
158
168
159 QSeries* series0 = new QLineSeries(this);
169 QSeries* series0 = new QLineSeries(this);
160 QSeries* series1 = new QAreaSeries(static_cast<QLineSeries*>(series0));
170 QSeries* series1 = new QAreaSeries(static_cast<QLineSeries*>(series0));
161 QSeries* series2 = new QScatterSeries(this);
171 QSeries* series2 = new QScatterSeries(this);
162 QSeries* series3 = new QSplineSeries(this);
172 QSeries* series3 = new QSplineSeries(this);
163 QSeries* series4 = new QPieSeries(this);
173 QSeries* series4 = new QPieSeries(this);
164 QSeries* series5 = new QBarSeries(QBarCategories(),this);
174 QSeries* series5 = new QBarSeries(QBarCategories(),this);
165 QSeries* series6 = new QPercentBarSeries(QBarCategories(),this);
175 QSeries* series6 = new QPercentBarSeries(QBarCategories(),this);
166 QSeries* series7 = new QStackedBarSeries(QBarCategories(),this);
176 QSeries* series7 = new QStackedBarSeries(QBarCategories(),this);
167
177
168 QChartAxis* axis = new QChartAxis(this);
178 QChartAxis* axis = new QChartAxis(this);
169
179
170 QTest::newRow("default axis: lineSeries") << series0 << (QChartAxis*) 0;
180 QTest::newRow("default axis: lineSeries") << series0 << (QChartAxis*) 0;
171 QTest::newRow("axis0: lineSeries") << series0 << axis;
181 QTest::newRow("axis0: lineSeries") << series0 << axis;
172 QTest::newRow("default axis: areaSeries") << series1 << (QChartAxis*) 0;
182 QTest::newRow("default axis: areaSeries") << series1 << (QChartAxis*) 0;
173 QTest::newRow("axis: areaSeries") << series1 << axis;
183 QTest::newRow("axis: areaSeries") << series1 << axis;
174 QTest::newRow("default axis: scatterSeries") << series2 << (QChartAxis*) 0;
184 QTest::newRow("default axis: scatterSeries") << series2 << (QChartAxis*) 0;
175 QTest::newRow("axis1: scatterSeries") << series2 << axis;
185 QTest::newRow("axis1: scatterSeries") << series2 << axis;
176 QTest::newRow("default axis: splineSeries") << series3 << (QChartAxis*) 0;
186 QTest::newRow("default axis: splineSeries") << series3 << (QChartAxis*) 0;
177 QTest::newRow("axis: splineSeries") << series3 << axis;
187 QTest::newRow("axis: splineSeries") << series3 << axis;
178 QTest::newRow("default axis: pieSeries") << series4 << (QChartAxis*) 0;
188 QTest::newRow("default axis: pieSeries") << series4 << (QChartAxis*) 0;
179 QTest::newRow("axis: pieSeries") << series4 << axis;
189 QTest::newRow("axis: pieSeries") << series4 << axis;
180 QTest::newRow("default axis: barSeries") << series5 << (QChartAxis*) 0;
190 QTest::newRow("default axis: barSeries") << series5 << (QChartAxis*) 0;
181 QTest::newRow("axis: barSeries") << series5 << axis;
191 QTest::newRow("axis: barSeries") << series5 << axis;
182 QTest::newRow("default axis: percentBarSeries") << series6 << (QChartAxis*) 0;
192 QTest::newRow("default axis: percentBarSeries") << series6 << (QChartAxis*) 0;
183 QTest::newRow("axis: barSeries") << series6 << axis;
193 QTest::newRow("axis: barSeries") << series6 << axis;
184 QTest::newRow("default axis: stackedBarSeries") << series7 << (QChartAxis*) 0;
194 QTest::newRow("default axis: stackedBarSeries") << series7 << (QChartAxis*) 0;
185 QTest::newRow("axis: barSeries") << series7 << axis;
195 QTest::newRow("axis: barSeries") << series7 << axis;
186
196
187 }
197 }
188
198
189 void tst_QChart::addSeries()
199 void tst_QChart::addSeries()
190 {
200 {
191 QFETCH(QSeries*, series);
201 QFETCH(QSeries*, series);
192 QFETCH(QChartAxis*, axis);
202 QFETCH(QChartAxis*, axis);
203 m_view->show();
204 QTest::qWaitForWindowShown(m_view);
193 if(!axis) axis = m_chart->axisY();
205 if(!axis) axis = m_chart->axisY();
194 m_chart->addSeries(series,axis);
206 //m_chart->addSeries(series,axis);
195 QCOMPARE(m_chart->axisY(series),axis);
207 QCOMPARE(m_chart->axisY(series),axis);
196 }
208 }
197
209
198 Q_DECLARE_METATYPE(QChart::AnimationOptions)
199 void tst_QChart::animationOptions_data()
210 void tst_QChart::animationOptions_data()
200 {
211 {
201 #if 0
212 QTest::addColumn<QChart::AnimationOption>("animationOptions");
202 QTest::addColumn<QChart::AnimationOptions>("animationOptions");
213 QTest::newRow("AllAnimations") << QChart::AllAnimations;
203 QTest::newRow("null") << QChart::AnimationOptions();
214 QTest::newRow("NoAnimation") << QChart::NoAnimation;
204 #endif
215 QTest::newRow("GridAxisAnimations") << QChart::GridAxisAnimations;
216 QTest::newRow("SeriesAnimations") << QChart::SeriesAnimations;
205 }
217 }
206
218
207 // public QChart::AnimationOptions animationOptions() const
208 void tst_QChart::animationOptions()
219 void tst_QChart::animationOptions()
209 {
220 {
210 #if 0
221 createTestData();
211 QFETCH(QChart::AnimationOptions, animationOptions);
222 QFETCH(QChart::AnimationOption, animationOptions);
223 m_chart->setAnimationOptions(animationOptions);
224 QCOMPARE(m_chart->animationOptions(), animationOptions);
212
225
213 SubQChart chart;
214
215 QCOMPARE(chart.animationOptions(), animationOptions);
216 #endif
217 QSKIP("Test is not implemented.", SkipAll);
218 }
226 }
219
227
220 void tst_QChart::axisX_data()
228 void tst_QChart::axisX_data()
221 {
229 {
222 #if 0
230 #if 0
223 QTest::addColumn<QChartAxis*>("axisX");
231 QTest::addColumn<QChartAxis*>("axisX");
224 QTest::newRow("null") << QChartAxis*();
232 QTest::newRow("null") << QChartAxis*();
225 #endif
233 #endif
226 }
234 }
227
235
228 // public QChartAxis* axisX() const
236 // public QChartAxis* axisX() const
229 void tst_QChart::axisX()
237 void tst_QChart::axisX()
230 {
238 {
231 #if 0
239 #if 0
232 QFETCH(QChartAxis*, axisX);
240 QFETCH(QChartAxis*, axisX);
233
241
234 SubQChart chart;
242 SubQChart chart;
235
243
236 QCOMPARE(chart.axisX(), axisX);
244 QCOMPARE(chart.axisX(), axisX);
237 #endif
245 #endif
238 QSKIP("Test is not implemented.", SkipAll);
246 QSKIP("Test is not implemented.", SkipAll);
239 }
247 }
240
248
241 void tst_QChart::axisY_data()
249 void tst_QChart::axisY_data()
242 {
250 {
243 #if 0
251 #if 0
244 QTest::addColumn<QChartAxis*>("axisY");
252 QTest::addColumn<QChartAxis*>("axisY");
245 QTest::newRow("null") << QChartAxis*();
253 QTest::newRow("null") << QChartAxis*();
246 #endif
254 #endif
247 }
255 }
248
256
249 // public QChartAxis* axisY() const
257 // public QChartAxis* axisY() const
250 void tst_QChart::axisY()
258 void tst_QChart::axisY()
251 {
259 {
252 #if 0
260 #if 0
253 QFETCH(QChartAxis*, axisY);
261 QFETCH(QChartAxis*, axisY);
254
262
255 SubQChart chart;
263 SubQChart chart;
256
264
257 QCOMPARE(chart.axisY(), axisY);
265 QCOMPARE(chart.axisY(), axisY);
258 #endif
266 #endif
259 QSKIP("Test is not implemented.", SkipAll);
267 QSKIP("Test is not implemented.", SkipAll);
260 }
268 }
261
269
262 Q_DECLARE_METATYPE(QBrush)
270 Q_DECLARE_METATYPE(QBrush)
263 void tst_QChart::backgroundBrush_data()
271 void tst_QChart::backgroundBrush_data()
264 {
272 {
265 #if 0
273 #if 0
266 QTest::addColumn<QBrush>("backgroundBrush");
274 QTest::addColumn<QBrush>("backgroundBrush");
267 QTest::newRow("null") << QBrush();
275 QTest::newRow("null") << QBrush();
268 #endif
276 #endif
269 }
277 }
270
278
271 // public QBrush backgroundBrush() const
279 // public QBrush backgroundBrush() const
272 void tst_QChart::backgroundBrush()
280 void tst_QChart::backgroundBrush()
273 {
281 {
274 #if 0
282 #if 0
275 QFETCH(QBrush, backgroundBrush);
283 QFETCH(QBrush, backgroundBrush);
276
284
277 SubQChart chart;
285 SubQChart chart;
278
286
279 QCOMPARE(chart.backgroundBrush(), backgroundBrush);
287 QCOMPARE(chart.backgroundBrush(), backgroundBrush);
280 #endif
288 #endif
281 QSKIP("Test is not implemented.", SkipAll);
289 QSKIP("Test is not implemented.", SkipAll);
282 }
290 }
283
291
284 Q_DECLARE_METATYPE(QPen)
292 Q_DECLARE_METATYPE(QPen)
285 void tst_QChart::backgroundPen_data()
293 void tst_QChart::backgroundPen_data()
286 {
294 {
287 #if 0
295 #if 0
288 QTest::addColumn<QPen>("backgroundPen");
296 QTest::addColumn<QPen>("backgroundPen");
289 QTest::newRow("null") << QPen();
297 QTest::newRow("null") << QPen();
290 #endif
298 #endif
291 }
299 }
292
300
293 // public QPen backgroundPen() const
301 // public QPen backgroundPen() const
294 void tst_QChart::backgroundPen()
302 void tst_QChart::backgroundPen()
295 {
303 {
296 #if 0
304 #if 0
297 QFETCH(QPen, backgroundPen);
305 QFETCH(QPen, backgroundPen);
298
306
299 SubQChart chart;
307 SubQChart chart;
300
308
301 QCOMPARE(chart.backgroundPen(), backgroundPen);
309 QCOMPARE(chart.backgroundPen(), backgroundPen);
302 #endif
310 #endif
303 QSKIP("Test is not implemented.", SkipAll);
311 QSKIP("Test is not implemented.", SkipAll);
304 }
312 }
305
313
306 void tst_QChart::isBackgroundVisible_data()
314 void tst_QChart::isBackgroundVisible_data()
307 {
315 {
308 QTest::addColumn<bool>("isBackgroundVisible");
316 QTest::addColumn<bool>("isBackgroundVisible");
309 QTest::newRow("true") << true;
317 QTest::newRow("true") << true;
310 QTest::newRow("false") << false;
318 QTest::newRow("false") << false;
311 }
319 }
312
320
313 // public bool isBackgroundVisible() const
321 // public bool isBackgroundVisible() const
314 void tst_QChart::isBackgroundVisible()
322 void tst_QChart::isBackgroundVisible()
315 {
323 {
316 #if 0
324 #if 0
317 QFETCH(bool, isBackgroundVisible);
325 QFETCH(bool, isBackgroundVisible);
318
326
319 SubQChart chart;
327 SubQChart chart;
320
328
321 QCOMPARE(chart.isBackgroundVisible(), isBackgroundVisible);
329 QCOMPARE(chart.isBackgroundVisible(), isBackgroundVisible);
322 #endif
330 #endif
323 QSKIP("Test is not implemented.", SkipAll);
331 QSKIP("Test is not implemented.", SkipAll);
324 }
332 }
325
333
326 Q_DECLARE_METATYPE(QLegend*)
334 Q_DECLARE_METATYPE(QLegend*)
327 void tst_QChart::legend_data()
335 void tst_QChart::legend_data()
328 {
336 {
329 #if 0
337 #if 0
330 QTest::addColumn<QLegend*>("legend");
338 QTest::addColumn<QLegend*>("legend");
331 QTest::newRow("null") << QLegend*();
339 QTest::newRow("null") << QLegend*();
332 #endif
340 #endif
333 }
341 }
334
342
335 // public QLegend* legend() const
343 // public QLegend* legend() const
336 void tst_QChart::legend()
344 void tst_QChart::legend()
337 {
345 {
338 #if 0
346 #if 0
339 QFETCH(QLegend*, legend);
347 QFETCH(QLegend*, legend);
340
348
341 SubQChart chart;
349 SubQChart chart;
342
350
343 QCOMPARE(chart.legend(), legend);
351 QCOMPARE(chart.legend(), legend);
344 #endif
352 #endif
345 QSKIP("Test is not implemented.", SkipAll);
353 QSKIP("Test is not implemented.", SkipAll);
346 }
354 }
347
355
348 void tst_QChart::margins_data()
356 void tst_QChart::margins_data()
349 {
357 {
350 QTest::addColumn<QRectF>("margins");
358 QTest::addColumn<QRectF>("margins");
351 QTest::newRow("null") << QRectF();
359 QTest::newRow("null") << QRectF();
352 }
360 }
353
361
354 // public QRectF margins() const
362 // public QRectF margins() const
355 void tst_QChart::margins()
363 void tst_QChart::margins()
356 {
364 {
357 #if 0
365 #if 0
358 QFETCH(QRectF, margins);
366 QFETCH(QRectF, margins);
359
367
360 SubQChart chart;
368 SubQChart chart;
361
369
362 QCOMPARE(chart.margins(), margins);
370 QCOMPARE(chart.margins(), margins);
363 #endif
371 #endif
364 QSKIP("Test is not implemented.", SkipAll);
372 QSKIP("Test is not implemented.", SkipAll);
365 }
373 }
366
374
367 void tst_QChart::removeAllSeries_data()
375 void tst_QChart::removeAllSeries_data()
368 {
376 {
369 QTest::addColumn<int>("foo");
377 QTest::addColumn<int>("foo");
370 QTest::newRow("0") << 0;
378 QTest::newRow("0") << 0;
371 QTest::newRow("-1") << -1;
379 QTest::newRow("-1") << -1;
372 }
380 }
373
381
374 // public void removeAllSeries()
382 // public void removeAllSeries()
375 void tst_QChart::removeAllSeries()
383 void tst_QChart::removeAllSeries()
376 {
384 {
377 #if 0
385 #if 0
378 QFETCH(int, foo);
386 QFETCH(int, foo);
379
387
380 SubQChart chart;
388 SubQChart chart;
381
389
382 chart.removeAllSeries();
390 chart.removeAllSeries();
383 #endif
391 #endif
384 QSKIP("Test is not implemented.", SkipAll);
392 QSKIP("Test is not implemented.", SkipAll);
385 }
393 }
386
394
387 void tst_QChart::removeSeries_data()
395 void tst_QChart::removeSeries_data()
388 {
396 {
389 QTest::addColumn<int>("seriesCount");
397 QTest::addColumn<int>("seriesCount");
390 QTest::newRow("0") << 0;
398 QTest::newRow("0") << 0;
391 QTest::newRow("-1") << -1;
399 QTest::newRow("-1") << -1;
392 }
400 }
393
401
394 // public void removeSeries(QSeries* series)
402 // public void removeSeries(QSeries* series)
395 void tst_QChart::removeSeries()
403 void tst_QChart::removeSeries()
396 {
404 {
397 #if 0
405 #if 0
398 QFETCH(int, seriesCount);
406 QFETCH(int, seriesCount);
399
407
400 SubQChart chart;
408 SubQChart chart;
401
409
402 chart.removeSeries(series);
410 chart.removeSeries(series);
403 #endif
411 #endif
404 QSKIP("Test is not implemented.", SkipAll);
412 QSKIP("Test is not implemented.", SkipAll);
405 }
413 }
406
414
407 void tst_QChart::scrollDown_data()
415 void tst_QChart::scrollDown_data()
408 {
416 {
409 QTest::addColumn<int>("foo");
417 QTest::addColumn<int>("foo");
410 QTest::newRow("0") << 0;
418 QTest::newRow("0") << 0;
411 QTest::newRow("-1") << -1;
419 QTest::newRow("-1") << -1;
412 }
420 }
413
421
414 // public void scrollDown()
422 // public void scrollDown()
415 void tst_QChart::scrollDown()
423 void tst_QChart::scrollDown()
416 {
424 {
417 #if 0
425 #if 0
418 QFETCH(int, foo);
426 QFETCH(int, foo);
419
427
420 SubQChart chart;
428 SubQChart chart;
421
429
422 chart.scrollDown();
430 chart.scrollDown();
423 #endif
431 #endif
424 QSKIP("Test is not implemented.", SkipAll);
432 QSKIP("Test is not implemented.", SkipAll);
425 }
433 }
426
434
427 void tst_QChart::scrollLeft_data()
435 void tst_QChart::scrollLeft_data()
428 {
436 {
429 QTest::addColumn<int>("foo");
437 QTest::addColumn<int>("foo");
430 QTest::newRow("0") << 0;
438 QTest::newRow("0") << 0;
431 QTest::newRow("-1") << -1;
439 QTest::newRow("-1") << -1;
432 }
440 }
433
441
434 // public void scrollLeft()
442 // public void scrollLeft()
435 void tst_QChart::scrollLeft()
443 void tst_QChart::scrollLeft()
436 {
444 {
437 #if 0
445 #if 0
438 QFETCH(int, foo);
446 QFETCH(int, foo);
439
447
440 SubQChart chart;
448 SubQChart chart;
441
449
442 chart.scrollLeft();
450 chart.scrollLeft();
443 #endif
451 #endif
444 QSKIP("Test is not implemented.", SkipAll);
452 QSKIP("Test is not implemented.", SkipAll);
445 }
453 }
446
454
447 void tst_QChart::scrollRight_data()
455 void tst_QChart::scrollRight_data()
448 {
456 {
449 QTest::addColumn<int>("foo");
457 QTest::addColumn<int>("foo");
450 QTest::newRow("0") << 0;
458 QTest::newRow("0") << 0;
451 QTest::newRow("-1") << -1;
459 QTest::newRow("-1") << -1;
452 }
460 }
453
461
454 // public void scrollRight()
462 // public void scrollRight()
455 void tst_QChart::scrollRight()
463 void tst_QChart::scrollRight()
456 {
464 {
457 #if 0
465 #if 0
458 QFETCH(int, foo);
466 QFETCH(int, foo);
459
467
460 SubQChart chart;
468 SubQChart chart;
461
469
462 chart.scrollRight();
470 chart.scrollRight();
463 #endif
471 #endif
464 QSKIP("Test is not implemented.", SkipAll);
472 QSKIP("Test is not implemented.", SkipAll);
465 }
473 }
466
474
467 void tst_QChart::scrollUp_data()
475 void tst_QChart::scrollUp_data()
468 {
476 {
469 QTest::addColumn<int>("foo");
477 QTest::addColumn<int>("foo");
470 QTest::newRow("0") << 0;
478 QTest::newRow("0") << 0;
471 QTest::newRow("-1") << -1;
479 QTest::newRow("-1") << -1;
472 }
480 }
473
481
474 // public void scrollUp()
482 // public void scrollUp()
475 void tst_QChart::scrollUp()
483 void tst_QChart::scrollUp()
476 {
484 {
477 #if 0
485 #if 0
478 QFETCH(int, foo);
486 QFETCH(int, foo);
479
487
480 SubQChart chart;
488 SubQChart chart;
481
489
482 chart.scrollUp();
490 chart.scrollUp();
483 #endif
491 #endif
484 QSKIP("Test is not implemented.", SkipAll);
492 QSKIP("Test is not implemented.", SkipAll);
485 }
493 }
486
494
487 void tst_QChart::setAnimationOptions_data()
488 {
489 #if 0
490 QTest::addColumn<QChart::AnimationOptions>("options");
491 QTest::newRow("null") << QChart::AnimationOptions();
492 #endif
493 }
494
495 // public void setAnimationOptions(QChart::AnimationOptions options)
496 void tst_QChart::setAnimationOptions()
497 {
498 #if 0
499 QFETCH(QChart::AnimationOptions, options);
500
501 SubQChart chart;
502
503 chart.setAnimationOptions(options);
504 #endif
505 QSKIP("Test is not implemented.", SkipAll);
506 }
507
508 void tst_QChart::setBackgroundBrush_data()
495 void tst_QChart::setBackgroundBrush_data()
509 {
496 {
510 #if 0
497 #if 0
511 QTest::addColumn<QBrush>("brush");
498 QTest::addColumn<QBrush>("brush");
512 QTest::newRow("null") << QBrush();
499 QTest::newRow("null") << QBrush();
513 #endif
500 #endif
514 }
501 }
515
502
516 // public void setBackgroundBrush(QBrush const& brush)
503 // public void setBackgroundBrush(QBrush const& brush)
517 void tst_QChart::setBackgroundBrush()
504 void tst_QChart::setBackgroundBrush()
518 {
505 {
519 #if 0
506 #if 0
520 QFETCH(QBrush, brush);
507 QFETCH(QBrush, brush);
521
508
522 SubQChart chart;
509 SubQChart chart;
523
510
524 chart.setBackgroundBrush(brush);
511 chart.setBackgroundBrush(brush);
525 #endif
512 #endif
526 QSKIP("Test is not implemented.", SkipAll);
513 QSKIP("Test is not implemented.", SkipAll);
527 }
514 }
528
515
529 void tst_QChart::setBackgroundPen_data()
516 void tst_QChart::setBackgroundPen_data()
530 {
517 {
531 #if 0
518 #if 0
532 QTest::addColumn<QPen>("pen");
519 QTest::addColumn<QPen>("pen");
533 QTest::newRow("null") << QPen();
520 QTest::newRow("null") << QPen();
534 #endif
521 #endif
535 }
522 }
536
523
537 // public void setBackgroundPen(QPen const& pen)
524 // public void setBackgroundPen(QPen const& pen)
538 void tst_QChart::setBackgroundPen()
525 void tst_QChart::setBackgroundPen()
539 {
526 {
540 #if 0
527 #if 0
541 QFETCH(QPen, pen);
528 QFETCH(QPen, pen);
542
529
543 SubQChart chart;
530 SubQChart chart;
544
531
545 chart.setBackgroundPen(pen);
532 chart.setBackgroundPen(pen);
546 #endif
533 #endif
547 QSKIP("Test is not implemented.", SkipAll);
534 QSKIP("Test is not implemented.", SkipAll);
548 }
535 }
549
536
550 void tst_QChart::setBackgroundVisible_data()
537 void tst_QChart::setBackgroundVisible_data()
551 {
538 {
552 QTest::addColumn<bool>("visible");
539 QTest::addColumn<bool>("visible");
553 QTest::newRow("true") << true;
540 QTest::newRow("true") << true;
554 QTest::newRow("false") << false;
541 QTest::newRow("false") << false;
555 }
542 }
556
543
557 // public void setBackgroundVisible(bool visible)
544 // public void setBackgroundVisible(bool visible)
558 void tst_QChart::setBackgroundVisible()
545 void tst_QChart::setBackgroundVisible()
559 {
546 {
560 #if 0
547 #if 0
561 QFETCH(bool, visible);
548 QFETCH(bool, visible);
562
549
563 SubQChart chart;
550 SubQChart chart;
564
551
565 chart.setBackgroundVisible(visible);
552 chart.setBackgroundVisible(visible);
566 #endif
553 #endif
567 QSKIP("Test is not implemented.", SkipAll);
554 QSKIP("Test is not implemented.", SkipAll);
568 }
555 }
569
556
570 Q_DECLARE_METATYPE(QChart::ChartTheme)
557 Q_DECLARE_METATYPE(QChart::ChartTheme)
571 void tst_QChart::setTheme_data()
558 void tst_QChart::setTheme_data()
572 {
559 {
573 #if 0
560 #if 0
574 QTest::addColumn<QChart::ChartTheme>("theme");
561 QTest::addColumn<QChart::ChartTheme>("theme");
575 QTest::newRow("null") << QChart::ChartTheme();
562 QTest::newRow("null") << QChart::ChartTheme();
576 #endif
563 #endif
577 }
564 }
578
565
579 // public void setTheme(QChart::ChartTheme theme)
566 // public void setTheme(QChart::ChartTheme theme)
580 void tst_QChart::setTheme()
567 void tst_QChart::setTheme()
581 {
568 {
582 #if 0
569 #if 0
583 QFETCH(QChart::ChartTheme, theme);
570 QFETCH(QChart::ChartTheme, theme);
584
571
585 SubQChart chart;
572 SubQChart chart;
586
573
587 chart.setTheme(theme);
574 chart.setTheme(theme);
588 #endif
575 #endif
589 QSKIP("Test is not implemented.", SkipAll);
576 QSKIP("Test is not implemented.", SkipAll);
590 }
577 }
591
578
592 void tst_QChart::setTitle_data()
579 void tst_QChart::setTitle_data()
593 {
580 {
594 QTest::addColumn<QString>("title");
581 QTest::addColumn<QString>("title");
595 QTest::newRow("null") << QString();
582 QTest::newRow("null") << QString();
596 QTest::newRow("foo") << QString("foo");
583 QTest::newRow("foo") << QString("foo");
597 }
584 }
598
585
599 // public void setTitle(QString const& title)
586 // public void setTitle(QString const& title)
600 void tst_QChart::setTitle()
587 void tst_QChart::setTitle()
601 {
588 {
602 #if 0
589 #if 0
603 QFETCH(QString, title);
590 QFETCH(QString, title);
604
591
605 SubQChart chart;
592 SubQChart chart;
606
593
607 chart.setTitle(title);
594 chart.setTitle(title);
608 #endif
595 #endif
609 QSKIP("Test is not implemented.", SkipAll);
596 QSKIP("Test is not implemented.", SkipAll);
610 }
597 }
611
598
612 void tst_QChart::setTitleBrush_data()
599 void tst_QChart::setTitleBrush_data()
613 {
600 {
614 #if 0
601 #if 0
615 QTest::addColumn<QBrush>("brush");
602 QTest::addColumn<QBrush>("brush");
616 QTest::newRow("null") << QBrush();
603 QTest::newRow("null") << QBrush();
617 #endif
604 #endif
618 }
605 }
619
606
620 // public void setTitleBrush(QBrush const& brush)
607 // public void setTitleBrush(QBrush const& brush)
621 void tst_QChart::setTitleBrush()
608 void tst_QChart::setTitleBrush()
622 {
609 {
623 #if 0
610 #if 0
624 QFETCH(QBrush, brush);
611 QFETCH(QBrush, brush);
625
612
626 SubQChart chart;
613 SubQChart chart;
627
614
628 chart.setTitleBrush(brush);
615 chart.setTitleBrush(brush);
629 #endif
616 #endif
630 QSKIP("Test is not implemented.", SkipAll);
617 QSKIP("Test is not implemented.", SkipAll);
631 }
618 }
632
619
633 void tst_QChart::setTitleFont_data()
620 void tst_QChart::setTitleFont_data()
634 {
621 {
635 QTest::addColumn<QFont>("font");
622 QTest::addColumn<QFont>("font");
636 QTest::newRow("null") << QFont();
623 QTest::newRow("null") << QFont();
637 }
624 }
638
625
639 // public void setTitleFont(QFont const& font)
626 // public void setTitleFont(QFont const& font)
640 void tst_QChart::setTitleFont()
627 void tst_QChart::setTitleFont()
641 {
628 {
642 #if 0
629 #if 0
643 QFETCH(QFont, font);
630 QFETCH(QFont, font);
644
631
645 SubQChart chart;
632 SubQChart chart;
646
633
647 chart.setTitleFont(font);
634 chart.setTitleFont(font);
648 #endif
635 #endif
649 QSKIP("Test is not implemented.", SkipAll);
636 QSKIP("Test is not implemented.", SkipAll);
650 }
637 }
651
638
652 void tst_QChart::theme_data()
639 void tst_QChart::theme_data()
653 {
640 {
654 #if 0
641 #if 0
655 QTest::addColumn<QChart::ChartTheme>("theme");
642 QTest::addColumn<QChart::ChartTheme>("theme");
656 QTest::newRow("null") << QChart::ChartTheme();
643 QTest::newRow("null") << QChart::ChartTheme();
657 #endif
644 #endif
658 }
645 }
659
646
660 // public QChart::ChartTheme theme() const
647 // public QChart::ChartTheme theme() const
661 void tst_QChart::theme()
648 void tst_QChart::theme()
662 {
649 {
663 #if 0
650 #if 0
664 QFETCH(QChart::ChartTheme, theme);
651 QFETCH(QChart::ChartTheme, theme);
665
652
666 SubQChart chart;
653 SubQChart chart;
667
654
668 QCOMPARE(chart.theme(), theme);
655 QCOMPARE(chart.theme(), theme);
669 #endif
656 #endif
670 QSKIP("Test is not implemented.", SkipAll);
657 QSKIP("Test is not implemented.", SkipAll);
671 }
658 }
672
659
673 void tst_QChart::title_data()
660 void tst_QChart::title_data()
674 {
661 {
675 QTest::addColumn<QString>("title");
662 QTest::addColumn<QString>("title");
676 QTest::newRow("null") << QString();
663 QTest::newRow("null") << QString();
677 QTest::newRow("foo") << QString("foo");
664 QTest::newRow("foo") << QString("foo");
678 }
665 }
679
666
680 // public QString title() const
667 // public QString title() const
681 void tst_QChart::title()
668 void tst_QChart::title()
682 {
669 {
683 #if 0
670 #if 0
684 QFETCH(QString, title);
671 QFETCH(QString, title);
685
672
686 SubQChart chart;
673 SubQChart chart;
687
674
688 QCOMPARE(chart.title(), title);
675 QCOMPARE(chart.title(), title);
689 #endif
676 #endif
690 QSKIP("Test is not implemented.", SkipAll);
677 QSKIP("Test is not implemented.", SkipAll);
691 }
678 }
692
679
693 void tst_QChart::titleBrush_data()
680 void tst_QChart::titleBrush_data()
694 {
681 {
695 #if 0
682 #if 0
696 QTest::addColumn<QBrush>("titleBrush");
683 QTest::addColumn<QBrush>("titleBrush");
697 QTest::newRow("null") << QBrush();
684 QTest::newRow("null") << QBrush();
698 #endif
685 #endif
699 }
686 }
700
687
701 // public QBrush titleBrush() const
688 // public QBrush titleBrush() const
702 void tst_QChart::titleBrush()
689 void tst_QChart::titleBrush()
703 {
690 {
704 #if 0
691 #if 0
705 QFETCH(QBrush, titleBrush);
692 QFETCH(QBrush, titleBrush);
706
693
707 SubQChart chart;
694 SubQChart chart;
708
695
709 QCOMPARE(chart.titleBrush(), titleBrush);
696 QCOMPARE(chart.titleBrush(), titleBrush);
710 #endif
697 #endif
711 QSKIP("Test is not implemented.", SkipAll);
698 QSKIP("Test is not implemented.", SkipAll);
712 }
699 }
713
700
714 void tst_QChart::titleFont_data()
701 void tst_QChart::titleFont_data()
715 {
702 {
716 QTest::addColumn<QFont>("titleFont");
703 QTest::addColumn<QFont>("titleFont");
717 QTest::newRow("null") << QFont();
704 QTest::newRow("null") << QFont();
718 }
705 }
719
706
720 // public QFont titleFont() const
707 // public QFont titleFont() const
721 void tst_QChart::titleFont()
708 void tst_QChart::titleFont()
722 {
709 {
723 #if 0
710 #if 0
724 QFETCH(QFont, titleFont);
711 QFETCH(QFont, titleFont);
725
712
726 SubQChart chart;
713 SubQChart chart;
727
714
728 QCOMPARE(chart.titleFont(), titleFont);
715 QCOMPARE(chart.titleFont(), titleFont);
729 #endif
716 #endif
730 QSKIP("Test is not implemented.", SkipAll);
717 QSKIP("Test is not implemented.", SkipAll);
731 }
718 }
732
719
733 void tst_QChart::zoomIn_data()
720 void tst_QChart::zoomIn_data()
734 {
721 {
735 QTest::addColumn<int>("foo");
722 QTest::addColumn<int>("foo");
736 QTest::newRow("0") << 0;
723 QTest::newRow("0") << 0;
737 QTest::newRow("-1") << -1;
724 QTest::newRow("-1") << -1;
738 }
725 }
739
726
740 // public void zoomIn()
727 // public void zoomIn()
741 void tst_QChart::zoomIn()
728 void tst_QChart::zoomIn()
742 {
729 {
743 #if 0
730 #if 0
744 QFETCH(int, foo);
731 QFETCH(int, foo);
745
732
746 SubQChart chart;
733 SubQChart chart;
747
734
748 chart.zoomIn();
735 chart.zoomIn();
749 #endif
736 #endif
750 QSKIP("Test is not implemented.", SkipAll);
737 QSKIP("Test is not implemented.", SkipAll);
751 }
738 }
752
739
753 void tst_QChart::zoomOut_data()
740 void tst_QChart::zoomOut_data()
754 {
741 {
755 QTest::addColumn<int>("foo");
742 QTest::addColumn<int>("foo");
756 QTest::newRow("0") << 0;
743 QTest::newRow("0") << 0;
757 QTest::newRow("-1") << -1;
744 QTest::newRow("-1") << -1;
758 }
745 }
759
746
760 // public void zoomOut()
747 // public void zoomOut()
761 void tst_QChart::zoomOut()
748 void tst_QChart::zoomOut()
762 {
749 {
763 #if 0
750 #if 0
764 QFETCH(int, foo);
751 QFETCH(int, foo);
765
752
766 SubQChart chart;
753 SubQChart chart;
767
754
768 chart.zoomOut();
755 chart.zoomOut();
769 #endif
756 #endif
770 QSKIP("Test is not implemented.", SkipAll);
757 QSKIP("Test is not implemented.", SkipAll);
771 }
758 }
772
759
773 QTEST_MAIN(tst_QChart)
760 QTEST_MAIN(tst_QChart)
774 #include "tst_qchart.moc"
761 #include "tst_qchart.moc"
775
762
@@ -1,215 +1,215
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
21
22 #include <QtTest/QtTest>
22 #include <QtTest/QtTest>
23 #include <qchartview.h>
23 #include <qchartview.h>
24 #include <qlineseries.h>
24 #include <qlineseries.h>
25 #include <cmath>
25 #include <cmath>
26
26
27 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
28
28
29
29
30 Q_DECLARE_METATYPE(QChart*)
30 Q_DECLARE_METATYPE(QChart*)
31 Q_DECLARE_METATYPE(QChartView::RubberBands)
31 Q_DECLARE_METATYPE(QChartView::RubberBands)
32 Q_DECLARE_METATYPE(Qt::Key)
32 Q_DECLARE_METATYPE(Qt::Key)
33
33
34 class tst_QChartView : public QObject
34 class tst_QChartView : public QObject
35 {
35 {
36 Q_OBJECT
36 Q_OBJECT
37
37
38 public Q_SLOTS:
38 public Q_SLOTS:
39 void initTestCase();
39 void initTestCase();
40 void cleanupTestCase();
40 void cleanupTestCase();
41 void init();
41 void init();
42 void cleanup();
42 void cleanup();
43
43
44 private Q_SLOTS:
44 private Q_SLOTS:
45 void qchartview_data();
45 void qchartview_data();
46 void qchartview();
46 void qchartview();
47 void chart_data();
47 void chart_data();
48 void chart();
48 void chart();
49 void rubberBand_data();
49 void rubberBand_data();
50 void rubberBand();
50 void rubberBand();
51 void keys_data();
51 void keys_data();
52 void keys();
52 void keys();
53
53
54 private:
54 private:
55 QChartView* m_view;
55 QChartView* m_view;
56 };
56 };
57
57
58 void tst_QChartView::initTestCase()
58 void tst_QChartView::initTestCase()
59 {
59 {
60 //test tracks mouse, give a while to user to relese it
60 //test tracks mouse, give a while to user to relese it
61 QTest::qWait(1000);
61 QTest::qWait(1000);
62 }
62 }
63
63
64 void tst_QChartView::cleanupTestCase()
64 void tst_QChartView::cleanupTestCase()
65 {
65 {
66 }
66 }
67
67
68 void tst_QChartView::init()
68 void tst_QChartView::init()
69 {
69 {
70 m_view = new QChartView(new QChart());
70 m_view = new QChartView(new QChart());
71 m_view->chart()->legend()->setVisible(false);
71 m_view->chart()->legend()->setVisible(false);
72 }
72 }
73
73
74 void tst_QChartView::cleanup()
74 void tst_QChartView::cleanup()
75 {
75 {
76 delete m_view;
76 delete m_view;
77 m_view =0;
77 m_view =0;
78 }
78 }
79
79
80 void tst_QChartView::qchartview_data()
80 void tst_QChartView::qchartview_data()
81 {
81 {
82
82
83 }
83 }
84
84
85 void tst_QChartView::qchartview()
85 void tst_QChartView::qchartview()
86 {
86 {
87 QVERIFY(m_view->chart());
87 QVERIFY(m_view->chart());
88 QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand);
88 QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand);
89 m_view->show();
89 m_view->show();
90 QTest::qWaitForWindowShown(m_view);
90 QTest::qWaitForWindowShown(m_view);
91 }
91 }
92
92
93 void tst_QChartView::chart_data()
93 void tst_QChartView::chart_data()
94 {
94 {
95
95
96 QTest::addColumn<QChart*>("chart");
96 QTest::addColumn<QChart*>("chart");
97 QTest::newRow("qchart") << new QChart();
97 QTest::newRow("qchart") << new QChart();
98 }
98 }
99
99
100 void tst_QChartView::chart()
100 void tst_QChartView::chart()
101 {
101 {
102 QFETCH(QChart*, chart);
102 QFETCH(QChart*, chart);
103 QChartView* view = new QChartView(chart);
103 QChartView* view = new QChartView(chart);
104 QCOMPARE(view->chart(), chart);
104 QCOMPARE(view->chart(), chart);
105 delete view;
105 delete view;
106 }
106 }
107
107
108 void tst_QChartView::rubberBand_data()
108 void tst_QChartView::rubberBand_data()
109 {
109 {
110 QTest::addColumn<QChartView::RubberBands>("rubberBand");
110 QTest::addColumn<QChartView::RubberBands>("rubberBand");
111 QTest::addColumn<int>("Xcount");
111 QTest::addColumn<int>("Xcount");
112 QTest::addColumn<int>("Ycount");
112 QTest::addColumn<int>("Ycount");
113
113
114 QTest::addColumn<int>("minX");
114 QTest::addColumn<int>("minX");
115 QTest::addColumn<int>("maxX");
115 QTest::addColumn<int>("maxX");
116 QTest::addColumn<int>("minY");
116 QTest::addColumn<int>("minY");
117 QTest::addColumn<int>("maxY");
117 QTest::addColumn<int>("maxY");
118
118
119 QTest::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand) << 0 << 1 << 10 << 90 << 0<< 100;
119 QTest::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand) << 0 << 1 << 20 << 180 << 0<< 200;
120 QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand) << 1 << 0 << 0 << 100 << 10<< 90;
120 QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand) << 1 << 0 << 0 << 200 << 20<< 180;
121 QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand) << 1 << 1 <<10 << 90 << 10<< 90;
121 QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand) << 1 << 1 <<20 << 180 << 20<< 180;
122 }
122 }
123
123
124 void tst_QChartView::rubberBand()
124 void tst_QChartView::rubberBand()
125 {
125 {
126 QFETCH(QChartView::RubberBands, rubberBand);
126 QFETCH(QChartView::RubberBands, rubberBand);
127 QFETCH(int, Xcount);
127 QFETCH(int, Xcount);
128 QFETCH(int, Ycount);
128 QFETCH(int, Ycount);
129 QFETCH(int, minX);
129 QFETCH(int, minX);
130 QFETCH(int, maxX);
130 QFETCH(int, maxX);
131 QFETCH(int, minY);
131 QFETCH(int, minY);
132 QFETCH(int, maxY);
132 QFETCH(int, maxY);
133
133
134 m_view->setRubberBand(rubberBand);
134 m_view->setRubberBand(rubberBand);
135 QRectF padding = m_view->chart()->margins();
135 QRectF padding = m_view->chart()->margins();
136 QCOMPARE(m_view->rubberBand(), rubberBand);
136 QCOMPARE(m_view->rubberBand(), rubberBand);
137
137
138 QLineSeries* line = new QLineSeries();
138 QLineSeries* line = new QLineSeries();
139 *line << QPointF(0, 0) << QPointF(100, 100);
139 *line << QPointF(0, 0) << QPointF(200, 200);
140
140
141 m_view->chart()->addSeries(line);
141 m_view->chart()->addSeries(line);
142 m_view->resize(100 + padding.left() + padding.right(), 100 + padding.top()+ padding.bottom());
142 m_view->resize(200 + padding.left() + padding.right(), 200 + padding.top()+ padding.bottom());
143 m_view->show();
143 m_view->show();
144
144
145 //this is hack since view does not get events otherwise
145 //this is hack since view does not get events otherwise
146 m_view->setMouseTracking(true);
146 m_view->setMouseTracking(true);
147
147
148 QChartAxis* axisY = m_view->chart()->axisY();
148 QChartAxis* axisY = m_view->chart()->axisY();
149 QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal, qreal)));
149 QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal, qreal)));
150 QChartAxis* axisX = m_view->chart()->axisX();
150 QChartAxis* axisX = m_view->chart()->axisX();
151 QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal, qreal)));
151 QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal, qreal)));
152
152
153 QTest::qWaitForWindowShown(m_view);
153 QTest::qWaitForWindowShown(m_view);
154 QTest::qWait(500);
154 QTest::qWait(500);
155 QTest::mouseMove(m_view->viewport(), QPoint(minX, minY) + padding.topLeft().toPoint());
155 QTest::mouseMove(m_view->viewport(), QPoint(minX, minY) + padding.topLeft().toPoint());
156 QTest::mousePress(m_view->viewport(), Qt::LeftButton, 0, QPoint(minX, minY) + padding.topLeft().toPoint());
156 QTest::mousePress(m_view->viewport(), Qt::LeftButton, 0, QPoint(minX, minY) + padding.topLeft().toPoint());
157 QTest::mouseMove(m_view->viewport(), QPoint(maxX, maxY) + padding.topLeft().toPoint());
157 QTest::mouseMove(m_view->viewport(), QPoint(maxX, maxY) + padding.topLeft().toPoint());
158 QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, QPoint(maxX, maxY)+ padding.topLeft().toPoint());
158 QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, QPoint(maxX, maxY)+ padding.topLeft().toPoint());
159
159
160 QCOMPARE(spy0.count(), Xcount);
160 QCOMPARE(spy0.count(), Xcount);
161 QCOMPARE(spy1.count(), Ycount);
161 QCOMPARE(spy1.count(), Ycount);
162
162
163 //this is hack since view does not get events otherwise
163 //this is hack since view does not get events otherwise
164 m_view->setMouseTracking(false);
164 m_view->setMouseTracking(false);
165
165
166 QVERIFY(axisX->min() - minX < 1);
166 QVERIFY(axisX->min() - minX < 1);
167 QVERIFY(axisX->max() - maxX < 1);
167 QVERIFY(axisX->max() - maxX < 1);
168 QVERIFY(axisY->min() - minY < 1);
168 QVERIFY(axisY->min() - minY < 1);
169 QVERIFY(axisY->max() - maxY < 1);
169 QVERIFY(axisY->max() - maxY < 1);
170 }
170 }
171
171
172 void tst_QChartView::keys_data()
172 void tst_QChartView::keys_data()
173 {
173 {
174 QTest::addColumn<Qt::Key>("key");
174 QTest::addColumn<Qt::Key>("key");
175 QTest::addColumn<int>("Xcount");
175 QTest::addColumn<int>("Xcount");
176 QTest::addColumn<int>("Ycount");
176 QTest::addColumn<int>("Ycount");
177 QTest::newRow("Qt::Key_Plus") << Qt::Key_Plus << 1 << 1;
177 QTest::newRow("Qt::Key_Plus") << Qt::Key_Plus << 1 << 1;
178 QTest::newRow("Qt::Key_Minus") << Qt::Key_Minus << 1 << 1;
178 QTest::newRow("Qt::Key_Minus") << Qt::Key_Minus << 1 << 1;
179 QTest::newRow("Qt::Key_Up") << Qt::Key_Up << 0 << 1;
179 QTest::newRow("Qt::Key_Up") << Qt::Key_Up << 0 << 1;
180 QTest::newRow("Qt::Key_Down") << Qt::Key_Down << 0 << 1;
180 QTest::newRow("Qt::Key_Down") << Qt::Key_Down << 0 << 1;
181 QTest::newRow("Qt::Key_Left") << Qt::Key_Left << 1 << 0;
181 QTest::newRow("Qt::Key_Left") << Qt::Key_Left << 1 << 0;
182 QTest::newRow("Qt::Key_Right") << Qt::Key_Right << 1 << 0;
182 QTest::newRow("Qt::Key_Right") << Qt::Key_Right << 1 << 0;
183 }
183 }
184
184
185 void tst_QChartView::keys()
185 void tst_QChartView::keys()
186 {
186 {
187 QFETCH(Qt::Key,key);
187 QFETCH(Qt::Key,key);
188 QFETCH(int, Xcount);
188 QFETCH(int, Xcount);
189 QFETCH(int, Ycount);
189 QFETCH(int, Ycount);
190
190
191 QRectF padding = m_view->chart()->margins();
191 QRectF padding = m_view->chart()->margins();
192
192
193 QLineSeries* line = new QLineSeries();
193 QLineSeries* line = new QLineSeries();
194 *line << QPointF(0, 0) << QPointF(100, 100);
194 *line << QPointF(0, 0) << QPointF(100, 100);
195
195
196 m_view->chart()->addSeries(line);
196 m_view->chart()->addSeries(line);
197 m_view->resize(100 + padding.left() + padding.right(), 100 + padding.top()+ padding.bottom());
197 m_view->resize(100 + padding.left() + padding.right(), 100 + padding.top()+ padding.bottom());
198 m_view->show();
198 m_view->show();
199
199
200 QChartAxis* axisY = m_view->chart()->axisY();
200 QChartAxis* axisY = m_view->chart()->axisY();
201 QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal, qreal)));
201 QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal, qreal)));
202 QChartAxis* axisX = m_view->chart()->axisX();
202 QChartAxis* axisX = m_view->chart()->axisX();
203 QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal, qreal)));
203 QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal, qreal)));
204
204
205 QTest::keyPress(m_view, key);
205 QTest::keyPress(m_view, key);
206 QTest::keyRelease(m_view, key);
206 QTest::keyRelease(m_view, key);
207
207
208 QCOMPARE(spy0.count(), Ycount);
208 QCOMPARE(spy0.count(), Ycount);
209 QCOMPARE(spy1.count(), Xcount);
209 QCOMPARE(spy1.count(), Xcount);
210
210
211 }
211 }
212
212
213 QTEST_MAIN(tst_QChartView)
213 QTEST_MAIN(tst_QChartView)
214 #include "tst_qchartview.moc"
214 #include "tst_qchartview.moc"
215
215
General Comments 0
You need to be logged in to leave comments. Login now