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