@@ -310,13 +310,12 ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) | |||||
310 |
|
310 | |||
311 | void QValuesAxisPrivate::intializeDomain(Domain* domain) |
|
311 | void QValuesAxisPrivate::intializeDomain(Domain* domain) | |
312 | { |
|
312 | { | |
|
313 | Q_Q(QValuesAxis); | |||
313 | if(qFuzzyCompare(m_max,m_min)) { |
|
314 | if(qFuzzyCompare(m_max,m_min)) { | |
314 | if(m_orientation==Qt::Vertical){ |
|
315 | if(m_orientation==Qt::Vertical){ | |
315 |
|
|
316 | q->setRange(domain->minY(),domain->maxY()); | |
316 | m_max = domain->maxY(); |
|
|||
317 | }else{ |
|
317 | }else{ | |
318 |
|
|
318 | q->setRange(domain->minX(), domain->maxX()); | |
319 | m_max = domain->maxX(); |
|
|||
320 | } |
|
319 | } | |
321 | } else { |
|
320 | } else { | |
322 | if(m_orientation==Qt::Vertical){ |
|
321 | if(m_orientation==Qt::Vertical){ |
@@ -35,7 +35,6 public slots: | |||||
35 | private slots: |
|
35 | private slots: | |
36 | void qvaluesaxis_data(); |
|
36 | void qvaluesaxis_data(); | |
37 | void qvaluesaxis(); |
|
37 | void qvaluesaxis(); | |
38 |
|
||||
39 | void max_raw_data(); |
|
38 | void max_raw_data(); | |
40 | void max_raw(); |
|
39 | void max_raw(); | |
41 | void max_data(); |
|
40 | void max_data(); | |
@@ -58,6 +57,10 private slots: | |||||
58 | void range_animation(); |
|
57 | void range_animation(); | |
59 | void ticksCount_data(); |
|
58 | void ticksCount_data(); | |
60 | void ticksCount(); |
|
59 | void ticksCount(); | |
|
60 | void noautoscale_data(); | |||
|
61 | void noautoscale(); | |||
|
62 | void autoscale_data(); | |||
|
63 | void autoscale(); | |||
61 |
|
64 | |||
62 | private: |
|
65 | private: | |
63 | QValuesAxis* m_valuesaxis; |
|
66 | QValuesAxis* m_valuesaxis; | |
@@ -346,6 +349,64 void tst_QValuesAxis::ticksCount() | |||||
346 | QCOMPARE(m_valuesaxis->ticksCount(), ticksCount); |
|
349 | QCOMPARE(m_valuesaxis->ticksCount(), ticksCount); | |
347 | } |
|
350 | } | |
348 |
|
351 | |||
|
352 | void tst_QValuesAxis::noautoscale_data() | |||
|
353 | { | |||
|
354 | QTest::addColumn<qreal>("min"); | |||
|
355 | QTest::addColumn<qreal>("max"); | |||
|
356 | QTest::newRow("1.0 - 101.0") << -1.0 << 101.0; | |||
|
357 | QTest::newRow("25.0 - 75.0") << 25.0 << 75.0; | |||
|
358 | QTest::newRow("101.0") << 40.0 << 60.0; | |||
|
359 | } | |||
|
360 | ||||
|
361 | void tst_QValuesAxis::noautoscale() | |||
|
362 | { | |||
|
363 | QFETCH(qreal, min); | |||
|
364 | QFETCH(qreal, max); | |||
|
365 | ||||
|
366 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); | |||
|
367 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); | |||
|
368 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); | |||
|
369 | ||||
|
370 | m_valuesaxis->setRange(min, max); | |||
|
371 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); | |||
|
372 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); | |||
|
373 | ||||
|
374 | QCOMPARE(spy0.count(), 1); | |||
|
375 | QCOMPARE(spy1.count(), 1); | |||
|
376 | QCOMPARE(spy2.count(), 1); | |||
|
377 | ||||
|
378 | m_chart->setAxisX(m_valuesaxis, m_series); | |||
|
379 | m_view->show(); | |||
|
380 | QTest::qWaitForWindowShown(m_view); | |||
|
381 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); | |||
|
382 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); | |||
|
383 | } | |||
|
384 | ||||
|
385 | void tst_QValuesAxis::autoscale_data() | |||
|
386 | { | |||
|
387 | ||||
|
388 | } | |||
|
389 | ||||
|
390 | void tst_QValuesAxis::autoscale() | |||
|
391 | { | |||
|
392 | QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); | |||
|
393 | QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); | |||
|
394 | QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); | |||
|
395 | ||||
|
396 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min()), "Min not equal"); | |||
|
397 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max()), "Max not equal"); | |||
|
398 | m_chart->setAxisX(m_valuesaxis, m_series); | |||
|
399 | ||||
|
400 | QCOMPARE(spy0.count(), 1); | |||
|
401 | QCOMPARE(spy1.count(), 1); | |||
|
402 | QCOMPARE(spy2.count(), 1); | |||
|
403 | ||||
|
404 | m_view->show(); | |||
|
405 | QTest::qWaitForWindowShown(m_view); | |||
|
406 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() + 100), "Min not equal"); | |||
|
407 | QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - 100), "Max not equal"); | |||
|
408 | } | |||
|
409 | ||||
349 | QTEST_MAIN(tst_QValuesAxis) |
|
410 | QTEST_MAIN(tst_QValuesAxis) | |
350 | #include "tst_qvaluesaxis.moc" |
|
411 | #include "tst_qvaluesaxis.moc" | |
351 |
|
412 |
General Comments 0
You need to be logged in to leave comments.
Login now