tst_qchart.cpp
1092 lines
| 33.8 KiB
| text/x-c
|
CppLexer
|
r2854 | /**************************************************************************** | ||
|
r1365 | ** | ||
|
r2854 | ** Copyright (C) 2016 The Qt Company Ltd. | ||
** Contact: https://www.qt.io/licensing/ | ||||
|
r1365 | ** | ||
|
r2854 | ** This file is part of the Qt Charts module of the Qt Toolkit. | ||
|
r1365 | ** | ||
|
r2854 | ** $QT_BEGIN_LICENSE:GPL$ | ||
|
r2845 | ** Commercial License Usage | ||
** Licensees holding valid commercial Qt licenses may use this file in | ||||
** accordance with the commercial license agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and The Qt Company. For licensing terms | ||||
|
r2854 | ** and conditions see https://www.qt.io/terms-conditions. For further | ||
** information use the contact form at https://www.qt.io/contact-us. | ||||
** | ||||
** GNU General Public License Usage | ||||
** Alternatively, this file may be used under the terms of the GNU | ||||
** General Public License version 3 or (at your option) any later version | ||||
** approved by the KDE Free Qt Foundation. The licenses are as published by | ||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3 | ||||
** included in the packaging of this file. Please review the following | ||||
** information to ensure the GNU General Public License requirements will | ||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html. | ||||
|
r1365 | ** | ||
|
r2845 | ** $QT_END_LICENSE$ | ||
** | ||||
|
r2854 | ****************************************************************************/ | ||
|
r1365 | |||
|
r896 | #include <QtTest/QtTest> | ||
|
r2714 | #include <QtCharts/QChartView> | ||
#include <QtCharts/QLineSeries> | ||||
#include <QtCharts/QAreaSeries> | ||||
#include <QtCharts/QScatterSeries> | ||||
#include <QtCharts/QSplineSeries> | ||||
#include <QtCharts/QPieSeries> | ||||
#include <QtCharts/QAbstractBarSeries> | ||||
#include <QtCharts/QBarSeries> | ||||
#include <QtCharts/QPercentBarSeries> | ||||
#include <QtCharts/QStackedBarSeries> | ||||
#include <QtCharts/QValueAxis> | ||||
#include <QtCharts/QBarCategoryAxis> | ||||
|
r2241 | #include "tst_definitions.h" | ||
|
r896 | |||
|
r2712 | QT_CHARTS_USE_NAMESPACE | ||
|
r896 | |||
|
r1541 | Q_DECLARE_METATYPE(QAbstractAxis *) | ||
|
r1804 | Q_DECLARE_METATYPE(QValueAxis *) | ||
|
r1808 | Q_DECLARE_METATYPE(QBarCategoryAxis *) | ||
|
r988 | Q_DECLARE_METATYPE(QAbstractSeries *) | ||
|
r914 | Q_DECLARE_METATYPE(QChart::AnimationOption) | ||
|
r929 | Q_DECLARE_METATYPE(QBrush) | ||
Q_DECLARE_METATYPE(QPen) | ||||
Q_DECLARE_METATYPE(QChart::ChartTheme) | ||||
|
r896 | |||
class tst_QChart : public QObject | ||||
{ | ||||
Q_OBJECT | ||||
public slots: | ||||
void initTestCase(); | ||||
void cleanupTestCase(); | ||||
void init(); | ||||
void cleanup(); | ||||
private slots: | ||||
void qchart_data(); | ||||
void qchart(); | ||||
void addSeries_data(); | ||||
void addSeries(); | ||||
void animationOptions_data(); | ||||
void animationOptions(); | ||||
|
r2804 | void animationDuration(); | ||
void animationCurve_data(); | ||||
void animationCurve(); | ||||
|
r896 | void axisX_data(); | ||
void axisX(); | ||||
void axisY_data(); | ||||
void axisY(); | ||||
void backgroundBrush_data(); | ||||
void backgroundBrush(); | ||||
void backgroundPen_data(); | ||||
void backgroundPen(); | ||||
void isBackgroundVisible_data(); | ||||
void isBackgroundVisible(); | ||||
|
r2498 | void plotAreaBackgroundBrush_data(); | ||
void plotAreaBackgroundBrush(); | ||||
void plotAreaBackgroundPen_data(); | ||||
void plotAreaBackgroundPen(); | ||||
void isPlotAreaBackgroundVisible_data(); | ||||
void isPlotAreaBackgroundVisible(); | ||||
|
r896 | void legend_data(); | ||
void legend(); | ||||
|
r1883 | void plotArea_data(); | ||
void plotArea(); | ||||
|
r896 | void removeAllSeries_data(); | ||
void removeAllSeries(); | ||||
void removeSeries_data(); | ||||
void removeSeries(); | ||||
|
r1660 | void scroll_right_data(); | ||
void scroll_right(); | ||||
void scroll_left_data(); | ||||
void scroll_left(); | ||||
void scroll_up_data(); | ||||
void scroll_up(); | ||||
void scroll_down_data(); | ||||
void scroll_down(); | ||||
|
r896 | void theme_data(); | ||
void theme(); | ||||
void title_data(); | ||||
void title(); | ||||
void titleBrush_data(); | ||||
void titleBrush(); | ||||
void titleFont_data(); | ||||
void titleFont(); | ||||
void zoomIn_data(); | ||||
void zoomIn(); | ||||
void zoomOut_data(); | ||||
void zoomOut(); | ||||
|
r2545 | void zoomReset(); | ||
|
r2408 | void createDefaultAxesForLineSeries_data(); | ||
void createDefaultAxesForLineSeries(); | ||||
|
r2483 | void axisPolarOrientation(); | ||
|
r2549 | void backgroundRoundness(); | ||
|
r914 | private: | ||
void createTestData(); | ||||
|
r896 | private: | ||
QChartView* m_view; | ||||
QChart* m_chart; | ||||
}; | ||||
void tst_QChart::initTestCase() | ||||
{ | ||||
} | ||||
void tst_QChart::cleanupTestCase() | ||||
{ | ||||
|
r2733 | QTest::qWait(1); // Allow final deleteLaters to run | ||
|
r896 | } | ||
void tst_QChart::init() | ||||
{ | ||||
|
r2483 | m_view = new QChartView(newQChartOrQPolarChart()); | ||
|
r896 | m_chart = m_view->chart(); | ||
|
r914 | } | ||
|
r896 | |||
void tst_QChart::cleanup() | ||||
{ | ||||
delete m_view; | ||||
m_view = 0; | ||||
m_chart = 0; | ||||
} | ||||
|
r1660 | |||
void tst_QChart::createTestData() | ||||
{ | ||||
QLineSeries* series0 = new QLineSeries(this); | ||||
*series0 << QPointF(0, 0) << QPointF(100, 100); | ||||
m_chart->addSeries(series0); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
} | ||||
|
r896 | void tst_QChart::qchart_data() | ||
{ | ||||
} | ||||
void tst_QChart::qchart() | ||||
{ | ||||
QVERIFY(m_chart); | ||||
QVERIFY(m_chart->legend()); | ||||
|
r1227 | QVERIFY(m_chart->legend()->isVisible()); | ||
|
r896 | |||
QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation); | ||||
|
r2804 | QCOMPARE(m_chart->animationDuration(), 1000); | ||
QCOMPARE(m_chart->animationEasingCurve(), QEasingCurve(QEasingCurve::OutQuart)); | ||||
|
r1660 | QVERIFY(!m_chart->axisX()); | ||
QVERIFY(!m_chart->axisY()); | ||||
|
r896 | QVERIFY(m_chart->backgroundBrush()!=QBrush()); | ||
QVERIFY(m_chart->backgroundPen()!=QPen()); | ||||
QCOMPARE(m_chart->isBackgroundVisible(), true); | ||||
|
r1883 | QVERIFY(m_chart->plotArea().top()==0); | ||
QVERIFY(m_chart->plotArea().left()==0); | ||||
QVERIFY(m_chart->plotArea().right()==0); | ||||
QVERIFY(m_chart->plotArea().bottom()==0); | ||||
|
r929 | QCOMPARE(m_chart->theme(), QChart::ChartThemeLight); | ||
QCOMPARE(m_chart->title(), QString()); | ||||
//QCOMPARE(m_chart->titleBrush(),QBrush()); | ||||
//QCOMPARE(m_chart->titleFont(),QFont()); | ||||
|
r896 | m_chart->removeAllSeries(); | ||
|
r1553 | m_chart->scroll(0,0); | ||
|
r929 | |||
|
r896 | m_chart->zoomIn(); | ||
m_chart->zoomIn(QRectF()); | ||||
m_chart->zoomOut(); | ||||
|
r1883 | |||
m_view->show(); | ||||
QVERIFY(m_chart->plotArea().top()>0); | ||||
QVERIFY(m_chart->plotArea().left()>0); | ||||
QVERIFY(m_chart->plotArea().right()>0); | ||||
QVERIFY(m_chart->plotArea().bottom()>0); | ||||
|
r896 | } | ||
void tst_QChart::addSeries_data() | ||||
{ | ||||
|
r988 | QTest::addColumn<QAbstractSeries *>("series"); | ||
|
r1660 | |||
QAbstractSeries* line = new QLineSeries(this); | ||||
|
r2733 | QAbstractSeries* area = new QAreaSeries(new QLineSeries(this)); | ||
|
r1660 | QAbstractSeries* scatter = new QScatterSeries(this); | ||
QAbstractSeries* spline = new QSplineSeries(this); | ||||
QTest::newRow("lineSeries") << line; | ||||
QTest::newRow("areaSeries") << area; | ||||
QTest::newRow("scatterSeries") << scatter; | ||||
QTest::newRow("splineSeries") << spline; | ||||
|
r896 | |||
|
r2483 | if (!isPolarTest()) { | ||
QAbstractSeries* pie = new QPieSeries(this); | ||||
QAbstractSeries* bar = new QBarSeries(this); | ||||
QAbstractSeries* percent = new QPercentBarSeries(this); | ||||
QAbstractSeries* stacked = new QStackedBarSeries(this); | ||||
QTest::newRow("pieSeries") << pie; | ||||
QTest::newRow("barSeries") << bar; | ||||
QTest::newRow("percentBarSeries") << percent; | ||||
QTest::newRow("stackedBarSeries") << stacked; | ||||
} | ||||
|
r896 | } | ||
void tst_QChart::addSeries() | ||||
{ | ||||
|
r988 | QFETCH(QAbstractSeries *, series); | ||
|
r914 | m_view->show(); | ||
QTest::qWaitForWindowShown(m_view); | ||||
|
r1314 | QVERIFY(!series->chart()); | ||
|
r1316 | QCOMPARE(m_chart->series().count(), 0); | ||
|
r1541 | m_chart->addSeries(series); | ||
|
r1316 | QCOMPARE(m_chart->series().count(), 1); | ||
QCOMPARE(m_chart->series().first(), series); | ||||
|
r1314 | QVERIFY(series->chart() == m_chart); | ||
|
r1660 | m_chart->createDefaultAxes(); | ||
if(series->type()!=QAbstractSeries::SeriesTypePie){ | ||||
QVERIFY(m_chart->axisY(series)); | ||||
QVERIFY(m_chart->axisX(series)); | ||||
}else{ | ||||
QVERIFY(!m_chart->axisY(series)); | ||||
QVERIFY(!m_chart->axisX(series)); | ||||
} | ||||
|
r974 | m_chart->removeSeries(series); | ||
|
r1314 | QVERIFY(!series->chart()); | ||
|
r1316 | QCOMPARE(m_chart->series().count(), 0); | ||
|
r2733 | delete series; | ||
|
r896 | } | ||
void tst_QChart::animationOptions_data() | ||||
{ | ||||
|
r914 | QTest::addColumn<QChart::AnimationOption>("animationOptions"); | ||
QTest::newRow("AllAnimations") << QChart::AllAnimations; | ||||
QTest::newRow("NoAnimation") << QChart::NoAnimation; | ||||
QTest::newRow("GridAxisAnimations") << QChart::GridAxisAnimations; | ||||
QTest::newRow("SeriesAnimations") << QChart::SeriesAnimations; | ||||
|
r896 | } | ||
void tst_QChart::animationOptions() | ||||
{ | ||||
|
r914 | createTestData(); | ||
QFETCH(QChart::AnimationOption, animationOptions); | ||||
m_chart->setAnimationOptions(animationOptions); | ||||
QCOMPARE(m_chart->animationOptions(), animationOptions); | ||||
|
r896 | } | ||
|
r2804 | void tst_QChart::animationDuration() | ||
{ | ||||
createTestData(); | ||||
m_chart->setAnimationDuration(2000); | ||||
QVERIFY(m_chart->animationDuration() == 2000); | ||||
} | ||||
void tst_QChart::animationCurve_data() | ||||
{ | ||||
QTest::addColumn<QEasingCurve>("animationCurve"); | ||||
QTest::newRow("Linear") << QEasingCurve(QEasingCurve::Linear); | ||||
QTest::newRow("InCubic") << QEasingCurve(QEasingCurve::InCubic); | ||||
QTest::newRow("OutSine") << QEasingCurve(QEasingCurve::OutSine); | ||||
QTest::newRow("OutInBack") << QEasingCurve(QEasingCurve::OutInBack); | ||||
} | ||||
void tst_QChart::animationCurve() | ||||
{ | ||||
createTestData(); | ||||
QFETCH(QEasingCurve, animationCurve); | ||||
m_chart->setAnimationEasingCurve(animationCurve); | ||||
QCOMPARE(m_chart->animationEasingCurve(), animationCurve); | ||||
} | ||||
|
r896 | void tst_QChart::axisX_data() | ||
{ | ||||
|
r929 | |||
|
r1660 | QTest::addColumn<QAbstractAxis*>("axis"); | ||
QTest::addColumn<QAbstractSeries *>("series"); | ||||
|
r1808 | QTest::newRow("categories,lineSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QLineSeries(this); | ||
QTest::newRow("categories,areaSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QAreaSeries(new QLineSeries(this)); | ||||
QTest::newRow("categories,scatterSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QScatterSeries(this); | ||||
QTest::newRow("categories,splineSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QSplineSeries(this); | ||||
|
r2483 | if (!isPolarTest()) { | ||
QTest::newRow("categories,pieSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QPieSeries(this); | ||||
QTest::newRow("categories,barSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QBarSeries(this); | ||||
QTest::newRow("categories,percentBarSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QPercentBarSeries(this); | ||||
QTest::newRow("categories,stackedBarSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QStackedBarSeries(this); | ||||
} | ||||
|
r1660 | |||
|
r1804 | QTest::newRow("value,lineSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QLineSeries(this); | ||
QTest::newRow("value,areaSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QAreaSeries(new QLineSeries(this)); | ||||
QTest::newRow("value,scatterSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QScatterSeries(this); | ||||
QTest::newRow("value,splineSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QSplineSeries(this); | ||||
|
r2483 | if (!isPolarTest()) { | ||
QTest::newRow("value,pieSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QPieSeries(this); | ||||
QTest::newRow("value,barSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QBarSeries(this); | ||||
QTest::newRow("value,percentBarSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QPercentBarSeries(this); | ||||
QTest::newRow("value,stackedBarSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QStackedBarSeries(this); | ||||
} | ||||
|
r896 | } | ||
void tst_QChart::axisX() | ||||
{ | ||||
|
r1660 | QFETCH(QAbstractAxis*, axis); | ||
QFETCH(QAbstractSeries*, series); | ||||
QVERIFY(!m_chart->axisX()); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
m_chart->addSeries(series); | ||||
m_chart->setAxisX(axis,series); | ||||
QVERIFY(m_chart->axisX(series)==axis); | ||||
|
r896 | } | ||
void tst_QChart::axisY_data() | ||||
{ | ||||
|
r1660 | axisX_data(); | ||
|
r896 | } | ||
|
r929 | |||
|
r896 | void tst_QChart::axisY() | ||
{ | ||||
|
r1660 | QFETCH(QAbstractAxis*, axis); | ||
QFETCH(QAbstractSeries*, series); | ||||
QVERIFY(!m_chart->axisY()); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
m_chart->addSeries(series); | ||||
m_chart->setAxisY(axis,series); | ||||
QVERIFY(m_chart->axisY(series)==axis); | ||||
|
r896 | } | ||
void tst_QChart::backgroundBrush_data() | ||||
{ | ||||
QTest::addColumn<QBrush>("backgroundBrush"); | ||||
QTest::newRow("null") << QBrush(); | ||||
|
r929 | QTest::newRow("blue") << QBrush(Qt::blue); | ||
QTest::newRow("white") << QBrush(Qt::white); | ||||
QTest::newRow("black") << QBrush(Qt::black); | ||||
|
r896 | } | ||
void tst_QChart::backgroundBrush() | ||||
{ | ||||
QFETCH(QBrush, backgroundBrush); | ||||
|
r929 | m_chart->setBackgroundBrush(backgroundBrush); | ||
QCOMPARE(m_chart->backgroundBrush(), backgroundBrush); | ||||
|
r896 | } | ||
void tst_QChart::backgroundPen_data() | ||||
{ | ||||
QTest::addColumn<QPen>("backgroundPen"); | ||||
QTest::newRow("null") << QPen(); | ||||
|
r929 | QTest::newRow("blue") << QPen(Qt::blue); | ||
QTest::newRow("white") << QPen(Qt::white); | ||||
QTest::newRow("black") << QPen(Qt::black); | ||||
|
r896 | } | ||
|
r929 | |||
|
r896 | void tst_QChart::backgroundPen() | ||
{ | ||||
QFETCH(QPen, backgroundPen); | ||||
|
r929 | m_chart->setBackgroundPen(backgroundPen); | ||
QCOMPARE(m_chart->backgroundPen(), backgroundPen); | ||||
|
r896 | } | ||
void tst_QChart::isBackgroundVisible_data() | ||||
{ | ||||
QTest::addColumn<bool>("isBackgroundVisible"); | ||||
QTest::newRow("true") << true; | ||||
QTest::newRow("false") << false; | ||||
} | ||||
void tst_QChart::isBackgroundVisible() | ||||
{ | ||||
QFETCH(bool, isBackgroundVisible); | ||||
|
r929 | m_chart->setBackgroundVisible(isBackgroundVisible); | ||
QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible); | ||||
|
r896 | } | ||
|
r2498 | void tst_QChart::plotAreaBackgroundBrush_data() | ||
{ | ||||
QTest::addColumn<QBrush>("plotAreaBackgroundBrush"); | ||||
QTest::newRow("null") << QBrush(); | ||||
QTest::newRow("blue") << QBrush(Qt::blue); | ||||
QTest::newRow("white") << QBrush(Qt::white); | ||||
QTest::newRow("black") << QBrush(Qt::black); | ||||
} | ||||
void tst_QChart::plotAreaBackgroundBrush() | ||||
{ | ||||
QFETCH(QBrush, plotAreaBackgroundBrush); | ||||
m_chart->setPlotAreaBackgroundBrush(plotAreaBackgroundBrush); | ||||
QCOMPARE(m_chart->plotAreaBackgroundBrush(), plotAreaBackgroundBrush); | ||||
} | ||||
void tst_QChart::plotAreaBackgroundPen_data() | ||||
{ | ||||
QTest::addColumn<QPen>("plotAreaBackgroundPen"); | ||||
QTest::newRow("null") << QPen(); | ||||
QTest::newRow("blue") << QPen(Qt::blue); | ||||
QTest::newRow("white") << QPen(Qt::white); | ||||
QTest::newRow("black") << QPen(Qt::black); | ||||
} | ||||
void tst_QChart::plotAreaBackgroundPen() | ||||
{ | ||||
QFETCH(QPen, plotAreaBackgroundPen); | ||||
m_chart->setPlotAreaBackgroundPen(plotAreaBackgroundPen); | ||||
QCOMPARE(m_chart->plotAreaBackgroundPen(), plotAreaBackgroundPen); | ||||
} | ||||
void tst_QChart::isPlotAreaBackgroundVisible_data() | ||||
{ | ||||
QTest::addColumn<bool>("isPlotAreaBackgroundVisible"); | ||||
QTest::newRow("true") << true; | ||||
QTest::newRow("false") << false; | ||||
} | ||||
void tst_QChart::isPlotAreaBackgroundVisible() | ||||
{ | ||||
QFETCH(bool, isPlotAreaBackgroundVisible); | ||||
m_chart->setPlotAreaBackgroundVisible(isPlotAreaBackgroundVisible); | ||||
QCOMPARE(m_chart->isPlotAreaBackgroundVisible(), isPlotAreaBackgroundVisible); | ||||
} | ||||
|
r896 | void tst_QChart::legend_data() | ||
{ | ||||
|
r929 | |||
|
r896 | } | ||
void tst_QChart::legend() | ||||
{ | ||||
|
r1543 | QLegend *legend = m_chart->legend(); | ||
QVERIFY(legend); | ||||
|
r2676 | QVERIFY(!m_chart->legend()->reverseMarkers()); | ||
|
r1543 | |||
// Colors related signals | ||||
QSignalSpy colorSpy(legend, SIGNAL(colorChanged(QColor))); | ||||
QSignalSpy borderColorSpy(legend, SIGNAL(borderColorChanged(QColor))); | ||||
QSignalSpy labelColorSpy(legend, SIGNAL(labelColorChanged(QColor))); | ||||
// colorChanged | ||||
legend->setColor(QColor("aliceblue")); | ||||
QCOMPARE(colorSpy.count(), 1); | ||||
QBrush b = legend->brush(); | ||||
b.setColor(QColor("aqua")); | ||||
legend->setBrush(b); | ||||
QCOMPARE(colorSpy.count(), 2); | ||||
// borderColorChanged | ||||
legend->setBorderColor(QColor("aliceblue")); | ||||
QCOMPARE(borderColorSpy.count(), 1); | ||||
QPen p = legend->pen(); | ||||
p.setColor(QColor("aqua")); | ||||
legend->setPen(p); | ||||
QCOMPARE(borderColorSpy.count(), 2); | ||||
// labelColorChanged | ||||
legend->setLabelColor(QColor("lightsalmon")); | ||||
QCOMPARE(labelColorSpy.count(), 1); | ||||
b = legend->labelBrush(); | ||||
b.setColor(QColor("lightseagreen")); | ||||
legend->setLabelBrush(b); | ||||
QCOMPARE(labelColorSpy.count(), 2); | ||||
// fontChanged | ||||
QSignalSpy fontSpy(legend, SIGNAL(fontChanged(QFont))); | ||||
QFont f = legend->font(); | ||||
f.setBold(!f.bold()); | ||||
legend->setFont(f); | ||||
QCOMPARE(fontSpy.count(), 1); | ||||
|
r2676 | |||
// reverseMarkersChanged | ||||
QSignalSpy reverseMarkersSpy(legend, SIGNAL(reverseMarkersChanged(bool))); | ||||
QCOMPARE(reverseMarkersSpy.count(), 0); | ||||
legend->setReverseMarkers(); | ||||
QCOMPARE(reverseMarkersSpy.count(), 1); | ||||
QVERIFY(legend->reverseMarkers()); | ||||
|
r896 | } | ||
|
r1883 | void tst_QChart::plotArea_data() | ||
|
r896 | { | ||
|
r929 | |||
|
r896 | } | ||
|
r1883 | void tst_QChart::plotArea() | ||
|
r1082 | { | ||
|
r929 | createTestData(); | ||
QRectF rect = m_chart->geometry(); | ||||
|
r1883 | QVERIFY(m_chart->plotArea().isValid()); | ||
QVERIFY(m_chart->plotArea().height() < rect.height()); | ||||
QVERIFY(m_chart->plotArea().width() < rect.width()); | ||||
|
r896 | } | ||
void tst_QChart::removeAllSeries_data() | ||||
{ | ||||
|
r929 | |||
|
r896 | } | ||
void tst_QChart::removeAllSeries() | ||||
{ | ||||
|
r929 | QLineSeries* series0 = new QLineSeries(this); | ||
QLineSeries* series1 = new QLineSeries(this); | ||||
QLineSeries* series2 = new QLineSeries(this); | ||||
|
r1314 | QSignalSpy deleteSpy1(series0, SIGNAL(destroyed())); | ||
QSignalSpy deleteSpy2(series1, SIGNAL(destroyed())); | ||||
QSignalSpy deleteSpy3(series2, SIGNAL(destroyed())); | ||||
|
r929 | |||
m_chart->addSeries(series0); | ||||
m_chart->addSeries(series1); | ||||
m_chart->addSeries(series2); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
|
r1660 | m_chart->createDefaultAxes(); | ||
|
r2384 | QCOMPARE(m_chart->axes().count(), 2); | ||
|
r929 | QVERIFY(m_chart->axisY(series0)!=0); | ||
QVERIFY(m_chart->axisY(series1)!=0); | ||||
QVERIFY(m_chart->axisY(series2)!=0); | ||||
|
r896 | |||
|
r929 | m_chart->removeAllSeries(); | ||
|
r2384 | QCOMPARE(m_chart->axes().count(), 2); | ||
QVERIFY(m_chart->axisX() != 0); | ||||
QVERIFY(m_chart->axisY() != 0); | ||||
|
r1314 | QCOMPARE(deleteSpy1.count(), 1); | ||
QCOMPARE(deleteSpy2.count(), 1); | ||||
QCOMPARE(deleteSpy3.count(), 1); | ||||
|
r896 | } | ||
void tst_QChart::removeSeries_data() | ||||
{ | ||||
|
r1660 | axisX_data(); | ||
|
r896 | } | ||
void tst_QChart::removeSeries() | ||||
{ | ||||
|
r1541 | QFETCH(QAbstractAxis *, axis); | ||
|
r1660 | QFETCH(QAbstractSeries *, series); | ||
|
r1314 | QSignalSpy deleteSpy(series, SIGNAL(destroyed())); | ||
|
r929 | m_view->show(); | ||
QTest::qWaitForWindowShown(m_view); | ||||
if(!axis) axis = m_chart->axisY(); | ||||
|
r1541 | m_chart->addSeries(series); | ||
|
r1577 | m_chart->setAxisY(axis,series); | ||
|
r929 | QCOMPARE(m_chart->axisY(series),axis); | ||
m_chart->removeSeries(series); | ||||
|
r2384 | QCOMPARE(m_chart->axes().count(), 1); | ||
QVERIFY(m_chart->axisY() != 0); | ||||
|
r929 | QVERIFY(m_chart->axisY(series)==0); | ||
|
r1314 | QCOMPARE(deleteSpy.count(), 0); | ||
|
r2733 | delete series; | ||
|
r896 | } | ||
|
r1660 | void tst_QChart::scroll_right_data() | ||
|
r896 | { | ||
|
r2241 | QTest::addColumn<QAbstractSeries *>("series"); | ||
|
r1660 | |||
|
r2241 | QLineSeries* series0 = new QLineSeries(this); | ||
*series0 << QPointF(0, 0) << QPointF(100, 100); | ||||
|
r1660 | |||
QTest::newRow("lineSeries") << (QAbstractSeries*) series0; | ||||
|
r929 | |||
|
r896 | } | ||
|
r1660 | void tst_QChart::scroll_right() | ||
|
r896 | { | ||
|
r1660 | QFETCH(QAbstractSeries *, series); | ||
m_chart->addSeries(series); | ||||
m_chart->createDefaultAxes(); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QAbstractAxis * axis = m_chart->axisX(); | ||||
QVERIFY(axis!=0); | ||||
switch(axis->type()) | ||||
{ | ||||
|
r1818 | case QAbstractAxis::AxisTypeValue:{ | ||
|
r1804 | QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis); | ||
|
r2241 | QVERIFY(vaxis!=0); | ||
qreal min = vaxis->min(); | ||||
qreal max = vaxis->max(); | ||||
QVERIFY(max>min); | ||||
m_chart->scroll(50, 0); | ||||
QVERIFY(min<vaxis->min()); | ||||
QVERIFY(max<vaxis->max()); | ||||
break; | ||||
} | ||||
|
r1818 | case QAbstractAxis::AxisTypeBarCategory:{ | ||
|
r1808 | QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis); | ||
|
r2241 | QVERIFY(caxis!=0); | ||
qreal min = caxis->min().toDouble(); | ||||
qreal max = caxis->max().toDouble(); | ||||
m_chart->scroll(50, 0); | ||||
QVERIFY(min<caxis->min().toDouble()); | ||||
QVERIFY(max<caxis->max().toDouble()); | ||||
break; | ||||
} | ||||
default: | ||||
qFatal("Unsupported type"); | ||||
break; | ||||
|
r1660 | } | ||
} | ||||
void tst_QChart::scroll_left_data() | ||||
{ | ||||
|
r2241 | scroll_right_data(); | ||
|
r1660 | } | ||
void tst_QChart::scroll_left() | ||||
{ | ||||
|
r2241 | QFETCH(QAbstractSeries *, series); | ||
m_chart->addSeries(series); | ||||
m_chart->createDefaultAxes(); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QAbstractAxis * axis = m_chart->axisX(); | ||||
QVERIFY(axis!=0); | ||||
|
r1660 | |||
|
r2241 | switch(axis->type()) | ||
{ | ||||
|
r1818 | case QAbstractAxis::AxisTypeValue:{ | ||
|
r1804 | QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis); | ||
|
r2241 | QVERIFY(vaxis!=0); | ||
qreal min = vaxis->min(); | ||||
qreal max = vaxis->max(); | ||||
m_chart->scroll(-50, 0); | ||||
QVERIFY(min>vaxis->min()); | ||||
QVERIFY(max>vaxis->max()); | ||||
break; | ||||
} | ||||
|
r1818 | case QAbstractAxis::AxisTypeBarCategory:{ | ||
|
r1808 | QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis); | ||
|
r2241 | QVERIFY(caxis!=0); | ||
qreal min = caxis->min().toDouble(); | ||||
qreal max = caxis->max().toDouble(); | ||||
m_chart->scroll(-50, 0); | ||||
QVERIFY(min>caxis->min().toDouble()); | ||||
QVERIFY(max>caxis->max().toDouble()); | ||||
break; | ||||
} | ||||
default: | ||||
qFatal("Unsupported type"); | ||||
break; | ||||
} | ||||
|
r1660 | } | ||
void tst_QChart::scroll_up_data() | ||||
{ | ||||
|
r2241 | scroll_right_data(); | ||
|
r1660 | } | ||
void tst_QChart::scroll_up() | ||||
{ | ||||
QFETCH(QAbstractSeries *, series); | ||||
m_chart->addSeries(series); | ||||
m_chart->createDefaultAxes(); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QAbstractAxis * axis = m_chart->axisY(); | ||||
QVERIFY(axis!=0); | ||||
switch(axis->type()) | ||||
{ | ||||
|
r1818 | case QAbstractAxis::AxisTypeValue:{ | ||
|
r1804 | QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis); | ||
|
r2241 | QVERIFY(vaxis!=0); | ||
qreal min = vaxis->min(); | ||||
qreal max = vaxis->max(); | ||||
m_chart->scroll(0, 50); | ||||
QVERIFY(min<vaxis->min()); | ||||
QVERIFY(max<vaxis->max()); | ||||
break; | ||||
} | ||||
|
r1818 | case QAbstractAxis::AxisTypeBarCategory:{ | ||
|
r1808 | QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis); | ||
|
r2241 | QVERIFY(caxis!=0); | ||
qreal min = caxis->min().toDouble(); | ||||
qreal max = caxis->max().toDouble(); | ||||
m_chart->scroll(0, 50); | ||||
QVERIFY(min<caxis->min().toDouble()); | ||||
QVERIFY(max<caxis->max().toDouble()); | ||||
break; | ||||
} | ||||
default: | ||||
qFatal("Unsupported type"); | ||||
break; | ||||
|
r1660 | } | ||
} | ||||
void tst_QChart::scroll_down_data() | ||||
{ | ||||
|
r2241 | scroll_right_data(); | ||
|
r1660 | } | ||
void tst_QChart::scroll_down() | ||||
{ | ||||
|
r2241 | QFETCH(QAbstractSeries *, series); | ||
m_chart->addSeries(series); | ||||
m_chart->createDefaultAxes(); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QAbstractAxis * axis = m_chart->axisY(); | ||||
QVERIFY(axis!=0); | ||||
|
r1660 | |||
|
r2241 | switch(axis->type()) | ||
{ | ||||
|
r1818 | case QAbstractAxis::AxisTypeValue:{ | ||
|
r1804 | QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis); | ||
|
r2241 | QVERIFY(vaxis!=0); | ||
qreal min = vaxis->min(); | ||||
qreal max = vaxis->max(); | ||||
m_chart->scroll(0, -50); | ||||
QVERIFY(min>vaxis->min()); | ||||
QVERIFY(max>vaxis->max()); | ||||
break; | ||||
} | ||||
|
r1818 | case QAbstractAxis::AxisTypeBarCategory:{ | ||
|
r1808 | QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis); | ||
|
r2241 | QVERIFY(caxis!=0); | ||
qreal min = caxis->min().toDouble(); | ||||
qreal max = caxis->max().toDouble(); | ||||
m_chart->scroll(0, -50); | ||||
QVERIFY(min>caxis->min().toDouble()); | ||||
QVERIFY(max>caxis->max().toDouble()); | ||||
break; | ||||
} | ||||
default: | ||||
qFatal("Unsupported type"); | ||||
break; | ||||
} | ||||
|
r896 | } | ||
void tst_QChart::theme_data() | ||||
{ | ||||
QTest::addColumn<QChart::ChartTheme>("theme"); | ||||
|
r929 | QTest::newRow("ChartThemeBlueCerulean") << QChart::ChartThemeBlueCerulean; | ||
QTest::newRow("ChartThemeBlueIcy") << QChart::ChartThemeBlueIcy; | ||||
QTest::newRow("ChartThemeBlueNcs") << QChart::ChartThemeBlueNcs; | ||||
QTest::newRow("ChartThemeBrownSand") << QChart::ChartThemeBrownSand; | ||||
QTest::newRow("ChartThemeDark") << QChart::ChartThemeDark; | ||||
QTest::newRow("hartThemeHighContrast") << QChart::ChartThemeHighContrast; | ||||
QTest::newRow("ChartThemeLight") << QChart::ChartThemeLight; | ||||
|
r2625 | QTest::newRow("ChartThemeQt") << QChart::ChartThemeQt; | ||
|
r896 | } | ||
void tst_QChart::theme() | ||||
{ | ||||
QFETCH(QChart::ChartTheme, theme); | ||||
|
r929 | createTestData(); | ||
m_chart->setTheme(theme); | ||||
QVERIFY(m_chart->theme()==theme); | ||||
|
r896 | } | ||
void tst_QChart::title_data() | ||||
{ | ||||
QTest::addColumn<QString>("title"); | ||||
QTest::newRow("null") << QString(); | ||||
QTest::newRow("foo") << QString("foo"); | ||||
} | ||||
void tst_QChart::title() | ||||
{ | ||||
QFETCH(QString, title); | ||||
|
r929 | m_chart->setTitle(title); | ||
QCOMPARE(m_chart->title(), title); | ||||
|
r896 | } | ||
void tst_QChart::titleBrush_data() | ||||
{ | ||||
QTest::addColumn<QBrush>("titleBrush"); | ||||
QTest::newRow("null") << QBrush(); | ||||
|
r929 | QTest::newRow("blue") << QBrush(Qt::blue); | ||
QTest::newRow("white") << QBrush(Qt::white); | ||||
QTest::newRow("black") << QBrush(Qt::black); | ||||
|
r896 | } | ||
void tst_QChart::titleBrush() | ||||
{ | ||||
QFETCH(QBrush, titleBrush); | ||||
|
r929 | m_chart->setTitleBrush(titleBrush); | ||
|
r2539 | QCOMPARE(m_chart->titleBrush().color(), titleBrush.color()); | ||
|
r896 | } | ||
void tst_QChart::titleFont_data() | ||||
{ | ||||
QTest::addColumn<QFont>("titleFont"); | ||||
QTest::newRow("null") << QFont(); | ||||
|
r929 | QTest::newRow("courier") << QFont("Courier", 8, QFont::Bold, true); | ||
|
r896 | } | ||
void tst_QChart::titleFont() | ||||
{ | ||||
QFETCH(QFont, titleFont); | ||||
|
r929 | m_chart->setTitleFont(titleFont); | ||
QCOMPARE(m_chart->titleFont(), titleFont); | ||||
|
r896 | } | ||
void tst_QChart::zoomIn_data() | ||||
{ | ||||
|
r929 | QTest::addColumn<QRectF>("rect"); | ||
QTest::newRow("null") << QRectF(); | ||||
QTest::newRow("100x100") << QRectF(10,10,100,100); | ||||
QTest::newRow("200x200") << QRectF(10,10,200,200); | ||||
|
r896 | } | ||
|
r929 | |||
|
r896 | void tst_QChart::zoomIn() | ||
{ | ||||
|
r1660 | |||
|
r929 | QFETCH(QRectF, rect); | ||
createTestData(); | ||||
|
r1660 | m_chart->createDefaultAxes(); | ||
|
r1883 | QRectF marigns = m_chart->plotArea(); | ||
|
r929 | rect.adjust(marigns.left(),marigns.top(),-marigns.right(),-marigns.bottom()); | ||
|
r1804 | QValueAxis* axisX = qobject_cast<QValueAxis*>(m_chart->axisX()); | ||
|
r1660 | QVERIFY(axisX!=0); | ||
|
r1804 | QValueAxis* axisY = qobject_cast<QValueAxis*>(m_chart->axisY()); | ||
|
r1660 | QVERIFY(axisY!=0); | ||
qreal minX = axisX->min(); | ||||
qreal minY = axisY->min(); | ||||
qreal maxX = axisX->max(); | ||||
qreal maxY = axisY->max(); | ||||
|
r929 | m_chart->zoomIn(rect); | ||
if(rect.isValid()){ | ||||
|
r1660 | QVERIFY(minX<axisX->min()); | ||
QVERIFY(maxX>axisX->max()); | ||||
QVERIFY(minY<axisY->min()); | ||||
QVERIFY(maxY>axisY->max()); | ||||
|
r929 | } | ||
|
r1660 | |||
|
r896 | } | ||
void tst_QChart::zoomOut_data() | ||||
{ | ||||
|
r929 | |||
|
r896 | } | ||
void tst_QChart::zoomOut() | ||||
{ | ||||
|
r929 | createTestData(); | ||
|
r1660 | m_chart->createDefaultAxes(); | ||
|
r1804 | QValueAxis* axisX = qobject_cast<QValueAxis*>(m_chart->axisX()); | ||
|
r1660 | QVERIFY(axisX!=0); | ||
|
r1804 | QValueAxis* axisY = qobject_cast<QValueAxis*>(m_chart->axisY()); | ||
|
r1660 | QVERIFY(axisY!=0); | ||
qreal minX = axisX->min(); | ||||
qreal minY = axisY->min(); | ||||
qreal maxX = axisX->max(); | ||||
qreal maxY = axisY->max(); | ||||
|
r929 | |||
m_chart->zoomIn(); | ||||
|
r896 | |||
|
r1660 | QVERIFY(minX < axisX->min()); | ||
QVERIFY(maxX > axisX->max()); | ||||
QVERIFY(minY < axisY->min()); | ||||
QVERIFY(maxY > axisY->max()); | ||||
|
r929 | |||
m_chart->zoomOut(); | ||||
|
r896 | |||
|
r1115 | // min x may be a zero value | ||
if (qFuzzyIsNull(minX)) | ||||
|
r1660 | QVERIFY(qFuzzyIsNull(axisX->min())); | ||
|
r1115 | else | ||
|
r1660 | QCOMPARE(minX, axisX->min()); | ||
|
r1115 | |||
// min y may be a zero value | ||||
if (qFuzzyIsNull(minY)) | ||||
|
r1660 | QVERIFY(qFuzzyIsNull(axisY->min())); | ||
|
r1115 | else | ||
|
r1660 | QCOMPARE(minY, axisY->min()); | ||
QVERIFY(maxX == axisX->max()); | ||||
QVERIFY(maxY == axisY->max()); | ||||
|
r1115 | |||
|
r896 | } | ||
|
r2545 | void tst_QChart::zoomReset() | ||
{ | ||||
createTestData(); | ||||
m_chart->createDefaultAxes(); | ||||
QValueAxis *axisX = qobject_cast<QValueAxis *>(m_chart->axisX()); | ||||
QVERIFY(axisX != 0); | ||||
QValueAxis *axisY = qobject_cast<QValueAxis *>(m_chart->axisY()); | ||||
QVERIFY(axisY != 0); | ||||
qreal minX = axisX->min(); | ||||
qreal minY = axisY->min(); | ||||
qreal maxX = axisX->max(); | ||||
qreal maxY = axisY->max(); | ||||
QVERIFY(!m_chart->isZoomed()); | ||||
m_chart->zoomIn(); | ||||
QVERIFY(m_chart->isZoomed()); | ||||
QVERIFY(minX < axisX->min()); | ||||
QVERIFY(maxX > axisX->max()); | ||||
QVERIFY(minY < axisY->min()); | ||||
QVERIFY(maxY > axisY->max()); | ||||
m_chart->zoomReset(); | ||||
// Reset after zoomIn should restore originals | ||||
QVERIFY(!m_chart->isZoomed()); | ||||
QVERIFY(minX == axisX->min()); | ||||
QVERIFY(maxX == axisX->max()); | ||||
QVERIFY(minY == axisY->min()); | ||||
QVERIFY(maxY == axisY->max()); | ||||
m_chart->zoomOut(); | ||||
QVERIFY(m_chart->isZoomed()); | ||||
QVERIFY(minX > axisX->min()); | ||||
QVERIFY(maxX < axisX->max()); | ||||
QVERIFY(minY > axisY->min()); | ||||
QVERIFY(maxY < axisY->max()); | ||||
m_chart->zoomReset(); | ||||
// Reset after zoomOut should restore originals | ||||
QVERIFY(!m_chart->isZoomed()); | ||||
QVERIFY(minX == axisX->min()); | ||||
QVERIFY(maxX == axisX->max()); | ||||
QVERIFY(minY == axisY->min()); | ||||
QVERIFY(maxY == axisY->max()); | ||||
axisX->setRange(234, 345); | ||||
axisY->setRange(345, 456); | ||||
minX = axisX->min(); | ||||
minY = axisY->min(); | ||||
maxX = axisX->max(); | ||||
maxY = axisY->max(); | ||||
QVERIFY(!m_chart->isZoomed()); | ||||
m_chart->zoomReset(); | ||||
// Reset without zoom should not change anything | ||||
QVERIFY(!m_chart->isZoomed()); | ||||
QVERIFY(minX == axisX->min()); | ||||
QVERIFY(maxX == axisX->max()); | ||||
QVERIFY(minY == axisY->min()); | ||||
QVERIFY(maxY == axisY->max()); | ||||
} | ||||
|
r2408 | void tst_QChart::createDefaultAxesForLineSeries_data() | ||
{ | ||||
QTest::addColumn<qreal>("series1minX"); | ||||
QTest::addColumn<qreal>("series1midX"); | ||||
QTest::addColumn<qreal>("series1maxX"); | ||||
QTest::addColumn<qreal>("series2minX"); | ||||
QTest::addColumn<qreal>("series2midX"); | ||||
QTest::addColumn<qreal>("series2maxX"); | ||||
QTest::addColumn<qreal>("overallminX"); | ||||
QTest::addColumn<qreal>("overallmaxX"); | ||||
QTest::addColumn<qreal>("series1minY"); | ||||
QTest::addColumn<qreal>("series1midY"); | ||||
QTest::addColumn<qreal>("series1maxY"); | ||||
QTest::addColumn<qreal>("series2minY"); | ||||
QTest::addColumn<qreal>("series2midY"); | ||||
QTest::addColumn<qreal>("series2maxY"); | ||||
QTest::addColumn<qreal>("overallminY"); | ||||
QTest::addColumn<qreal>("overallmaxY"); | ||||
QTest::newRow("series1hasMinAndMax") << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0 | ||||
<< (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0; | ||||
QTest::newRow("series2hasMinAndMax") << (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0 | ||||
<< (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0; | ||||
QTest::newRow("series1hasMinAndMaxX_series2hasMinAndMaxY") << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.1 << (qreal)1.7 << (qreal)2.9 << (qreal)1.0 << (qreal)3.0 | ||||
<< (qreal)1.1 << (qreal)2.0 << (qreal)2.9 << (qreal)1.0 << (qreal)2.0 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0; | ||||
QTest::newRow("series1hasMin_series2hasMax") << (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0 | ||||
<< (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0; | ||||
|
r2414 | QTest::newRow("bothSeriesHaveSameMinAndMax") << (qreal)1.0 << (qreal)2.0 << (qreal)2.9 << (qreal)1.1 << (qreal)1.7 << (qreal)3.0 << (qreal)1.0 << (qreal)3.0 | ||
<< (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)1.1 << (qreal)0.6 << (qreal)1.6; | ||||
|
r2408 | } | ||
void tst_QChart::createDefaultAxesForLineSeries() | ||||
{ | ||||
QFETCH(qreal, series1minX); | ||||
QFETCH(qreal, series1midX); | ||||
QFETCH(qreal, series1maxX); | ||||
QFETCH(qreal, series2minX); | ||||
QFETCH(qreal, series2midX); | ||||
QFETCH(qreal, series2maxX); | ||||
QFETCH(qreal, series1minY); | ||||
QFETCH(qreal, series1midY); | ||||
QFETCH(qreal, series1maxY); | ||||
QFETCH(qreal, series2minY); | ||||
QFETCH(qreal, series2midY); | ||||
QFETCH(qreal, series2maxY); | ||||
QFETCH(qreal, overallminX); | ||||
QFETCH(qreal, overallmaxX); | ||||
QFETCH(qreal, overallminY); | ||||
QFETCH(qreal, overallmaxY); | ||||
QLineSeries* series1 = new QLineSeries(this); | ||||
series1->append(series1minX, series1minY); | ||||
series1->append(series1midX, series1midY); | ||||
series1->append(series1maxX, series1maxY); | ||||
QLineSeries* series2 = new QLineSeries(this); | ||||
series2->append(series2minX, series2minY); | ||||
series2->append(series2midX, series2midY); | ||||
series2->append(series2maxX, series2maxY); | ||||
|
r2483 | QChart *chart = newQChartOrQPolarChart(); | ||
chart->addSeries(series1); | ||||
chart->addSeries(series2); | ||||
chart->createDefaultAxes(); | ||||
QValueAxis *xAxis = (QValueAxis *)chart->axisX(); | ||||
|
r2408 | QCOMPARE(xAxis->min(), overallminX); | ||
QCOMPARE(xAxis->max(), overallmaxX); | ||||
|
r2483 | QValueAxis *yAxis = (QValueAxis *)chart->axisY(); | ||
|
r2408 | QCOMPARE(yAxis->min(), overallminY); | ||
QCOMPARE(yAxis->max(), overallmaxY); | ||||
QLineSeries *series3 = new QLineSeries(this); | ||||
// Numbers clearly out of existing range | ||||
series3->append(0, 0); | ||||
series3->append(100, 100); | ||||
// Adding a new series should not change the axes as they have not been told to update | ||||
|
r2483 | chart->addSeries(series3); | ||
|
r2408 | QCOMPARE(xAxis->min(), overallminX); | ||
QCOMPARE(xAxis->max(), overallmaxX); | ||||
QCOMPARE(yAxis->min(), overallminY); | ||||
QCOMPARE(yAxis->max(), overallmaxY); | ||||
|
r2733 | delete chart; | ||
|
r2483 | } | ||
void tst_QChart::axisPolarOrientation() | ||||
{ | ||||
QLineSeries* series1 = new QLineSeries(this); | ||||
series1->append(1, 2); | ||||
series1->append(2, 4); | ||||
series1->append(3, 8); | ||||
QPolarChart chart; | ||||
chart.addSeries(series1); | ||||
QValueAxis *xAxis = new QValueAxis(); | ||||
QValueAxis *yAxis = new QValueAxis(); | ||||
chart.addAxis(xAxis, QPolarChart::PolarOrientationAngular); | ||||
chart.addAxis(yAxis, QPolarChart::PolarOrientationRadial); | ||||
QList<QAbstractAxis *> xAxes = chart.axes(QPolarChart::PolarOrientationAngular); | ||||
QList<QAbstractAxis *> yAxes = chart.axes(QPolarChart::PolarOrientationRadial); | ||||
QCOMPARE(xAxes.size(), 1); | ||||
QCOMPARE(yAxes.size(), 1); | ||||
QCOMPARE(xAxes[0], xAxis); | ||||
QCOMPARE(yAxes[0], yAxis); | ||||
|
r2408 | |||
|
r2483 | QCOMPARE(chart.axisPolarOrientation(xAxes[0]), QPolarChart::PolarOrientationAngular); | ||
QCOMPARE(chart.axisPolarOrientation(yAxes[0]), QPolarChart::PolarOrientationRadial); | ||||
|
r2408 | } | ||
|
r2549 | void tst_QChart::backgroundRoundness() | ||
{ | ||||
createTestData(); | ||||
m_chart->createDefaultAxes(); | ||||
m_chart->setBackgroundRoundness(100.0); | ||||
QVERIFY(m_chart->backgroundRoundness() == 100.0); | ||||
} | ||||
|
r896 | QTEST_MAIN(tst_QChart) | ||
#include "tst_qchart.moc" | ||||