##// END OF EJS Templates
Adds default 0,1 domain for emmpty series, update tst_qlineseries
Michal Klocek -
r1070:9e1b807bcb0e
parent child
Show More
@@ -393,6 +393,15 void QXYSeriesPrivate::scaleDomain(Domain& domain)
393 393 Q_Q(QXYSeries);
394 394
395 395 const QList<QPointF>& points = q->points();
396
397 if(points.isEmpty()){
398 minX=0.0;
399 minY=0.0;
400 maxX=1.0;
401 maxY=1.0;
402 }
403
404
396 405 for (int i = 0; i < points.count(); i++)
397 406 {
398 407 qreal x = points[i].x();
@@ -39,55 +39,49 public slots:
39 39 private slots:
40 40 void qlineseries_data();
41 41 void qlineseries();
42
43 void append_data();
44 void append();
45 void brush_data();
46 void brush();
47 void count_data();
48 void count();
49 void data_data();
50 void data();
42 void append_raw_data();
43 void append_raw();
44 void append_chart_data();
45 void append_chart();
46 void append_chart_animation_data();
47 void append_chart_animation();
48 void chart_append_data();
49 void chart_append();
50 void count_raw_data();
51 void count_raw();
51 52 void oper_data();
52 53 void oper();
53 54 void pen_data();
54 55 void pen();
55 void pointsVisible_data();
56 void pointsVisible();
57 void remove_data();
58 void remove();
56 void pointsVisible_raw_data();
57 void pointsVisible_raw();
58 void remove_raw_data();
59 void remove_raw();
60 void remove_chart_data();
61 void remove_chart();
62 void remove_chart_animation_data();
63 void remove_chart_animation();
59 64 void removeAll_data();
60 65 void removeAll();
61 66 void replace_data();
62 67 void replace();
63 void setBrush_data();
64 void setBrush();
65 68 void setModel_data();
66 69 void setModel();
67 70 void setModelMapping_data();
68 71 void setModelMapping();
69 void setPen_data();
70 void setPen();
71 void setPointsVisible_data();
72 void setPointsVisible();
73 void x_data();
74 void x();
75 void y_data();
76 void y();
77 void clicked_data();
78 void clicked();
79 void selected_data();
80 void selected();
72 private:
73 void append_data();
74 void count_data();
75 void pointsVisible_data();
81 76
82 77 private:
83 78 QChartView* m_view;
84 79 QChart* m_chart;
80 QLineSeries* m_series;
85 81 };
86 82
87 83 void tst_QLineSeries::initTestCase()
88 84 {
89 m_view = new QChartView(new QChart());
90 m_chart = m_view->chart();
91 85 }
92 86
93 87 void tst_QLineSeries::cleanupTestCase()
@@ -96,17 +90,23 void tst_QLineSeries::cleanupTestCase()
96 90
97 91 void tst_QLineSeries::init()
98 92 {
93 m_view = new QChartView(new QChart());
94 m_chart = m_view->chart();
95 m_series = new QLineSeries();
99 96 }
100 97
101 98 void tst_QLineSeries::cleanup()
102 99 {
100 delete m_series;
103 101 delete m_view;
104 102 m_view = 0;
105 103 m_chart = 0;
104 m_series = 0;
106 105 }
107 106
108 107 void tst_QLineSeries::qlineseries_data()
109 108 {
109
110 110 }
111 111
112 112 void tst_QLineSeries::qlineseries()
@@ -137,171 +137,144 void tst_QLineSeries::qlineseries()
137 137
138 138 series.setPen(QPen());
139 139 series.setPointsVisible(false);
140
141 m_chart->addSeries(&series);
142 m_view->show();
143 QTest::qWaitForWindowShown(m_view);
140 144 }
141 145
142 146 void tst_QLineSeries::append_data()
143 147 {
144 #if 0
145 QTest::addColumn<QList<QPointF>>("points");
146 QTest::newRow("null") << QList<QPointF>();
147 #endif
148 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));
148 151 }
149 152
150 // public void append(QList<QPointF> const points)
151 void tst_QLineSeries::append()
152 {
153 #if 0
154 QFETCH(QList<QPointF>, points);
155
156 SubQXYSeries series;
157
158 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
159 QSignalSpy spy1(&series, SIGNAL(selected()));
160 153
161 series.append(points);
154 void tst_QLineSeries::append_raw_data()
155 {
156 append_data();
157 }
162 158
159 void tst_QLineSeries::append_raw()
160 {
161 QFETCH(QList<QPointF>, points);
162 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
163 QTest::qWait(200);
164 m_series->append(points);
165 QTest::qWait(200);
163 166 QCOMPARE(spy0.count(), 0);
164 QCOMPARE(spy1.count(), 0);
165 #endif
166 QSKIP("Test is not implemented.", SkipAll);
167 QCOMPARE(m_series->points(), points);
167 168 }
168 169
169 Q_DECLARE_METATYPE(QBrush)
170 void tst_QLineSeries::brush_data()
170 void tst_QLineSeries::chart_append_data()
171 171 {
172 #if 0
173 QTest::addColumn<QBrush>("brush");
174 QTest::newRow("null") << QBrush();
175 #endif
172 append_data();
176 173 }
177 174
178 // public QBrush brush() const
179 void tst_QLineSeries::brush()
175 void tst_QLineSeries::chart_append()
180 176 {
181 #if 0
182 QFETCH(QBrush, brush);
177 append_raw();
178 m_chart->addSeries(m_series);
179 m_view->show();
180 QTest::qWaitForWindowShown(m_view);
181 }
183 182
184 SubQXYSeries series;
183 void tst_QLineSeries::append_chart_data()
184 {
185 append_data();
186 }
185 187
186 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
187 QSignalSpy spy1(&series, SIGNAL(selected()));
188 void tst_QLineSeries::append_chart()
189 {
190 m_view->show();
191 m_chart->addSeries(m_series);
192 append_raw();
193 QTest::qWaitForWindowShown(m_view);
194 }
188 195
189 QCOMPARE(series.brush(), brush);
196 void tst_QLineSeries::append_chart_animation_data()
197 {
198 append_data();
199 }
190 200
191 QCOMPARE(spy0.count(), 0);
192 QCOMPARE(spy1.count(), 0);
193 #endif
194 QSKIP("Test is not implemented.", SkipAll);
201 void tst_QLineSeries::append_chart_animation()
202 {
203 m_chart->setAnimationOptions(QChart::AllAnimations);
204 append_chart();
195 205 }
196 206
197 207 void tst_QLineSeries::count_data()
198 208 {
199 209 QTest::addColumn<int>("count");
200 210 QTest::newRow("0") << 0;
201 QTest::newRow("-1") << -1;
202 }
203
204 // public int count() const
205 void tst_QLineSeries::count()
206 {
207 #if 0
208 QFETCH(int, count);
209
210 SubQXYSeries series;
211
212 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
213 QSignalSpy spy1(&series, SIGNAL(selected()));
214
215 QCOMPARE(series.count(), count);
216
217 QCOMPARE(spy0.count(), 0);
218 QCOMPARE(spy1.count(), 0);
219 #endif
220 QSKIP("Test is not implemented.", SkipAll);
211 QTest::newRow("5") << 5;
212 QTest::newRow("10") << 5;
221 213 }
222 214
223 void tst_QLineSeries::data_data()
215 void tst_QLineSeries::count_raw_data()
224 216 {
225 #if 0
226 QTest::addColumn<QList<QPointF>>("data");
227 QTest::newRow("null") << QList<QPointF>();
228 #endif
217 count_data();
229 218 }
230 219
231 // public QList<QPointF> data()
232 void tst_QLineSeries::data()
220 void tst_QLineSeries::count_raw()
233 221 {
234 #if 0
235 QFETCH(QList<QPointF>, data);
236
237 SubQXYSeries series;
222 QFETCH(int, count);
238 223
239 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
240 QSignalSpy spy1(&series, SIGNAL(selected()));
224 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
241 225
242 QCOMPARE(series.data(), data);
226 for(int i=0 ; i< count; ++i)
227 m_series->append(i,i);
243 228
244 229 QCOMPARE(spy0.count(), 0);
245 QCOMPARE(spy1.count(), 0);
246 #endif
247 QSKIP("Test is not implemented.", SkipAll);
230 QCOMPARE(m_series->count(), count);
248 231 }
249 232
250 233 void tst_QLineSeries::oper_data()
251 234 {
252 #if 0
253 QTest::addColumn<QList<QPointF>>("points");
254 QTest::addColumn<QXYSeries&>("operator<<");
255 QTest::newRow("null") << QList<QPointF>() << QXYSeries&();
256 #endif
235 append_data();
257 236 }
258 237
259 // public QXYSeries& operator<<(QList<QPointF> const points)
260 238 void tst_QLineSeries::oper()
261 239 {
262 #if 0
263 240 QFETCH(QList<QPointF>, points);
264 QFETCH(QXYSeries&, operator<<);
265
266 SubQXYSeries series;
241 QLineSeries series;
267 242
268 243 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
269 QSignalSpy spy1(&series, SIGNAL(selected()));
270 244
271 QCOMPARE(series.operator<<(points), operator<<);
245 foreach(const QPointF& point,points)
246 {
247 series<<point;
248 }
272 249
250 QCOMPARE(series.points(), points);
273 251 QCOMPARE(spy0.count(), 0);
274 QCOMPARE(spy1.count(), 0);
275 #endif
276 QSKIP("Test is not implemented.", SkipAll);
277 252 }
278 253
279 Q_DECLARE_METATYPE(QPen)
254
280 255 void tst_QLineSeries::pen_data()
281 256 {
282 #if 0
283 257 QTest::addColumn<QPen>("pen");
284 258 QTest::newRow("null") << QPen();
285 #endif
259 QTest::newRow("blue") << QPen(Qt::blue);
260 QTest::newRow("black") << QPen(Qt::black);
261 QTest::newRow("red") << QPen(Qt::red);
286 262 }
287 263
288 // public QPen pen() const
289 264 void tst_QLineSeries::pen()
290 265 {
291 #if 0
292 266 QFETCH(QPen, pen);
293
294 SubQXYSeries series;
267 QLineSeries series;
295 268
296 269 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
297 QSignalSpy spy1(&series, SIGNAL(selected()));
270 series.setPen(pen);
298 271
272 QCOMPARE(spy0.count(), 0);
299 273 QCOMPARE(series.pen(), pen);
300 274
301 QCOMPARE(spy0.count(), 0);
302 QCOMPARE(spy1.count(), 0);
303 #endif
304 QSKIP("Test is not implemented.", SkipAll);
275 m_chart->addSeries(&series);
276
277 if(pen!=QPen()) QCOMPARE(series.pen(), pen);
305 278 }
306 279
307 280 void tst_QLineSeries::pointsVisible_data()
@@ -311,60 +284,74 void tst_QLineSeries::pointsVisible_data()
311 284 QTest::newRow("false") << false;
312 285 }
313 286
314 // public bool pointsVisible() const
315 void tst_QLineSeries::pointsVisible()
287 void tst_QLineSeries::pointsVisible_raw_data()
288 {
289 pointsVisible_data();
290 }
291
292 void tst_QLineSeries::pointsVisible_raw()
316 293 {
317 #if 0
318 294 QFETCH(bool, pointsVisible);
295 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
296 m_series->setPointsVisible(pointsVisible);
297 QCOMPARE(spy0.count(), 0);
298 QCOMPARE(m_series->pointsVisible(), pointsVisible);
299 }
319 300
320 SubQXYSeries series;
301 void tst_QLineSeries::remove_raw_data()
302 {
303 append_data();
304 }
321 305
322 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
323 QSignalSpy spy1(&series, SIGNAL(selected()));
306 void tst_QLineSeries::remove_raw()
307 {
308 QFETCH(QList<QPointF>, points);
309 QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
310 m_series->append(points);
311 QTest::qWait(200);
312 QCOMPARE(spy0.count(), 0);
313 QCOMPARE(m_series->points(), points);
324 314
325 QCOMPARE(series.pointsVisible(), pointsVisible);
315 foreach(const QPointF& point,points)
316 {
317 m_series->remove(point);
318 QTest::qWait(200);
319 }
326 320
327 321 QCOMPARE(spy0.count(), 0);
328 QCOMPARE(spy1.count(), 0);
329 #endif
330 QSKIP("Test is not implemented.", SkipAll);
322 QCOMPARE(m_series->points().count(), 0);
331 323 }
332 324
333 void tst_QLineSeries::remove_data()
325 void tst_QLineSeries::remove_chart_data()
334 326 {
335 QTest::addColumn<qreal>("x");
336 QTest::addColumn<qreal>("y");
337 QTest::newRow("null") << 0.0 << 0.0;
327 append_data();
338 328 }
339 329
340 // public void remove(qreal x, qreal y)
341 void tst_QLineSeries::remove()
330 void tst_QLineSeries::remove_chart()
342 331 {
343 #if 0
344 QFETCH(qreal, x);
345 QFETCH(qreal, y);
346
347 SubQXYSeries series;
348
349 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
350 QSignalSpy spy1(&series, SIGNAL(selected()));
332 m_view->show();
333 m_chart->addSeries(m_series);
334 remove_raw();
335 QTest::qWaitForWindowShown(m_view);
336 }
351 337
352 series.remove(x, y);
338 void tst_QLineSeries::remove_chart_animation_data()
339 {
340 append_data();
341 }
353 342
354 QCOMPARE(spy0.count(), 0);
355 QCOMPARE(spy1.count(), 0);
356 #endif
357 QSKIP("Test is not implemented.", SkipAll);
343 void tst_QLineSeries::remove_chart_animation()
344 {
345 m_chart->setAnimationOptions(QChart::AllAnimations);
346 remove_chart();
358 347 }
359 348
349
360 350 void tst_QLineSeries::removeAll_data()
361 351 {
362 QTest::addColumn<int>("foo");
363 QTest::newRow("0") << 0;
364 QTest::newRow("-1") << -1;
352 append_data();
365 353 }
366 354
367 // public void removeAll()
368 355 void tst_QLineSeries::removeAll()
369 356 {
370 357 #if 0
@@ -389,7 +376,6 void tst_QLineSeries::replace_data()
389 376 QTest::newRow("null") << QPointF();
390 377 }
391 378
392 // public void replace(QPointF const& point)
393 379 void tst_QLineSeries::replace()
394 380 {
395 381 #if 0
@@ -408,33 +394,6 void tst_QLineSeries::replace()
408 394 QSKIP("Test is not implemented.", SkipAll);
409 395 }
410 396
411 void tst_QLineSeries::setBrush_data()
412 {
413 #if 0
414 QTest::addColumn<QBrush>("brush");
415 QTest::newRow("null") << QBrush();
416 #endif
417 }
418
419 // public void setBrush(QBrush const& brush)
420 void tst_QLineSeries::setBrush()
421 {
422 #if 0
423 QFETCH(QBrush, brush);
424
425 SubQXYSeries series;
426
427 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
428 QSignalSpy spy1(&series, SIGNAL(selected()));
429
430 series.setBrush(brush);
431
432 QCOMPARE(spy0.count(), 0);
433 QCOMPARE(spy1.count(), 0);
434 #endif
435 QSKIP("Test is not implemented.", SkipAll);
436 }
437
438 397 void tst_QLineSeries::setModel_data()
439 398 {
440 399 QTest::addColumn<int>("modelCount");
@@ -442,7 +401,6 void tst_QLineSeries::setModel_data()
442 401 QTest::newRow("null") << 0 << false;
443 402 }
444 403
445 // public bool setModel(QAbstractItemModel* model)
446 404 void tst_QLineSeries::setModel()
447 405 {
448 406 #if 0
@@ -473,7 +431,6 void tst_QLineSeries::setModelMapping_data()
473 431 #endif
474 432 }
475 433
476 // public void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical)
477 434 void tst_QLineSeries::setModelMapping()
478 435 {
479 436 #if 0
@@ -494,164 +451,6 void tst_QLineSeries::setModelMapping()
494 451 QSKIP("Test is not implemented.", SkipAll);
495 452 }
496 453
497 void tst_QLineSeries::setPen_data()
498 {
499 #if 0
500 QTest::addColumn<QPen>("pen");
501 QTest::newRow("null") << QPen();
502 #endif
503 }
504
505 // public void setPen(QPen const& pen)
506 void tst_QLineSeries::setPen()
507 {
508 #if 0
509 QFETCH(QPen, pen);
510
511 SubQXYSeries series;
512
513 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
514 QSignalSpy spy1(&series, SIGNAL(selected()));
515
516 series.setPen(pen);
517
518 QCOMPARE(spy0.count(), 0);
519 QCOMPARE(spy1.count(), 0);
520 #endif
521 QSKIP("Test is not implemented.", SkipAll);
522 }
523
524 void tst_QLineSeries::setPointsVisible_data()
525 {
526 QTest::addColumn<bool>("visible");
527 QTest::newRow("true") << true;
528 QTest::newRow("false") << false;
529 }
530
531 // public void setPointsVisible(bool visible = true)
532 void tst_QLineSeries::setPointsVisible()
533 {
534 #if 0
535 QFETCH(bool, visible);
536
537 SubQXYSeries series;
538
539 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
540 QSignalSpy spy1(&series, SIGNAL(selected()));
541
542 series.setPointsVisible(visible);
543
544 QCOMPARE(spy0.count(), 0);
545 QCOMPARE(spy1.count(), 0);
546 #endif
547 QSKIP("Test is not implemented.", SkipAll);
548 }
549
550 void tst_QLineSeries::x_data()
551 {
552 QTest::addColumn<int>("pos");
553 QTest::addColumn<qreal>("x");
554 QTest::newRow("null") << 0 << 0.0;
555 }
556
557 // public qreal x(int pos) const
558 void tst_QLineSeries::x()
559 {
560 #if 0
561 QFETCH(int, pos);
562 QFETCH(qreal, x);
563
564 SubQXYSeries series;
565
566 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
567 QSignalSpy spy1(&series, SIGNAL(selected()));
568
569 QCOMPARE(series.x(pos), x);
570
571 QCOMPARE(spy0.count(), 0);
572 QCOMPARE(spy1.count(), 0);
573 #endif
574 QSKIP("Test is not implemented.", SkipAll);
575 }
576
577 void tst_QLineSeries::y_data()
578 {
579 QTest::addColumn<int>("pos");
580 QTest::addColumn<qreal>("y");
581 QTest::newRow("null") << 0 << 0.0;
582 }
583
584 // public qreal y(int pos) const
585 void tst_QLineSeries::y()
586 {
587 #if 0
588 QFETCH(int, pos);
589 QFETCH(qreal, y);
590
591 SubQXYSeries series;
592
593 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
594 QSignalSpy spy1(&series, SIGNAL(selected()));
595
596 QCOMPARE(series.y(pos), y);
597
598 QCOMPARE(spy0.count(), 0);
599 QCOMPARE(spy1.count(), 0);
600 #endif
601 QSKIP("Test is not implemented.", SkipAll);
602 }
603
604 void tst_QLineSeries::clicked_data()
605 {
606 QTest::addColumn<QPointF>("point");
607 QTest::newRow("null") << QPointF();
608 }
609
610 // protected void clicked(QPointF const& point)
611 void tst_QLineSeries::clicked()
612 {
613 #if 0
614 QFETCH(QPointF, point);
615
616 SubQXYSeries series;
617
618 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
619 QSignalSpy spy1(&series, SIGNAL(selected()));
620
621 series.call_clicked(point);
622
623 QCOMPARE(spy0.count(), 0);
624 QCOMPARE(spy1.count(), 0);
625 #endif
626 QSKIP("Test is not implemented.", SkipAll);
627 }
628
629 void tst_QLineSeries::selected_data()
630 {
631 QTest::addColumn<int>("foo");
632 QTest::newRow("0") << 0;
633 QTest::newRow("-1") << -1;
634 }
635
636 // protected void selected()
637 void tst_QLineSeries::selected()
638 {
639 #if 0
640 QFETCH(int, foo);
641
642 SubQXYSeries series;
643
644 QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
645 QSignalSpy spy1(&series, SIGNAL(selected()));
646
647 series.call_selected();
648
649 QCOMPARE(spy0.count(), 0);
650 QCOMPARE(spy1.count(), 0);
651 #endif
652 QSKIP("Test is not implemented.", SkipAll);
653 }
654
655 454 QTEST_MAIN(tst_QLineSeries)
656 455
657 456 #include "tst_qlineseries.moc"
General Comments 0
You need to be logged in to leave comments. Login now