tst_qchart.cpp
585 lines
| 14.5 KiB
| text/x-c
|
CppLexer
Michal Klocek
|
r896 | #include <QtTest/QtTest> | ||
#include <qchartview.h> | ||||
#include <qlineseries.h> | ||||
#include <qareaseries.h> | ||||
#include <qscatterseries.h> | ||||
#include <qsplineseries.h> | ||||
#include <qpieseries.h> | ||||
#include <qbarseries.h> | ||||
#include <qpercentbarseries.h> | ||||
#include <qstackedbarseries.h> | ||||
QTCOMMERCIALCHART_USE_NAMESPACE | ||||
Michal Klocek
|
r1006 | Q_DECLARE_METATYPE(QAxis *) | ||
Tero Ahola
|
r988 | Q_DECLARE_METATYPE(QAbstractSeries *) | ||
Michal Klocek
|
r914 | Q_DECLARE_METATYPE(QChart::AnimationOption) | ||
Michal Klocek
|
r929 | Q_DECLARE_METATYPE(QBrush) | ||
Q_DECLARE_METATYPE(QPen) | ||||
Q_DECLARE_METATYPE(QChart::ChartTheme) | ||||
Michal Klocek
|
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(); | ||||
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(); | ||||
void legend_data(); | ||||
void legend(); | ||||
void margins_data(); | ||||
void margins(); | ||||
void removeAllSeries_data(); | ||||
void removeAllSeries(); | ||||
void removeSeries_data(); | ||||
void removeSeries(); | ||||
void scrollDown_data(); | ||||
void scrollDown(); | ||||
void scrollLeft_data(); | ||||
void scrollLeft(); | ||||
void scrollRight_data(); | ||||
void scrollRight(); | ||||
void scrollUp_data(); | ||||
void scrollUp(); | ||||
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(); | ||||
Michal Klocek
|
r914 | private: | ||
void createTestData(); | ||||
Michal Klocek
|
r896 | private: | ||
QChartView* m_view; | ||||
QChart* m_chart; | ||||
}; | ||||
void tst_QChart::initTestCase() | ||||
{ | ||||
} | ||||
void tst_QChart::cleanupTestCase() | ||||
{ | ||||
} | ||||
void tst_QChart::init() | ||||
{ | ||||
m_view = new QChartView(new QChart()); | ||||
m_chart = m_view->chart(); | ||||
Michal Klocek
|
r914 | } | ||
Michal Klocek
|
r896 | |||
Michal Klocek
|
r914 | 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); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::cleanup() | ||||
{ | ||||
delete m_view; | ||||
m_view = 0; | ||||
m_chart = 0; | ||||
} | ||||
void tst_QChart::qchart_data() | ||||
{ | ||||
} | ||||
void tst_QChart::qchart() | ||||
{ | ||||
QVERIFY(m_chart); | ||||
QVERIFY(m_chart->legend()); | ||||
QVERIFY(!m_chart->legend()->isVisible()); | ||||
QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation); | ||||
QVERIFY(m_chart->axisX()); | ||||
QVERIFY(m_chart->axisY()); | ||||
QVERIFY(m_chart->backgroundBrush()!=QBrush()); | ||||
QVERIFY(m_chart->backgroundPen()!=QPen()); | ||||
QCOMPARE(m_chart->isBackgroundVisible(), true); | ||||
QVERIFY(m_chart->margins().top()>0); | ||||
QVERIFY(m_chart->margins().left()>0); | ||||
QVERIFY(m_chart->margins().right()>0); | ||||
QVERIFY(m_chart->margins().bottom()>0); | ||||
Michal Klocek
|
r929 | |||
QCOMPARE(m_chart->theme(), QChart::ChartThemeLight); | ||||
QCOMPARE(m_chart->title(), QString()); | ||||
//QCOMPARE(m_chart->titleBrush(),QBrush()); | ||||
//QCOMPARE(m_chart->titleFont(),QFont()); | ||||
Michal Klocek
|
r896 | m_chart->removeAllSeries(); | ||
m_chart->scrollDown(); | ||||
m_chart->scrollLeft(); | ||||
m_chart->scrollRight(); | ||||
m_chart->scrollUp(); | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | m_chart->zoomIn(); | ||
m_chart->zoomIn(QRectF()); | ||||
m_chart->zoomOut(); | ||||
} | ||||
void tst_QChart::addSeries_data() | ||||
{ | ||||
Tero Ahola
|
r988 | QTest::addColumn<QAbstractSeries *>("series"); | ||
Michal Klocek
|
r1006 | QTest::addColumn<QAxis *>("axis"); | ||
Tero Ahola
|
r988 | |||
QAbstractSeries* series0 = new QLineSeries(this); | ||||
QAbstractSeries* series1 = new QAreaSeries(static_cast<QLineSeries*>(series0)); | ||||
QAbstractSeries* series2 = new QScatterSeries(this); | ||||
QAbstractSeries* series3 = new QSplineSeries(this); | ||||
QAbstractSeries* series4 = new QPieSeries(this); | ||||
sauimone
|
r1114 | QAbstractSeries* series5 = new QBarSeries(this); | ||
QAbstractSeries* series6 = new QPercentBarSeries(this); | ||||
QAbstractSeries* series7 = new QStackedBarSeries(this); | ||||
QBarSeries* s5 = static_cast<QBarSeries*> (series5); | ||||
s5->setCategories(QBarCategories()); | ||||
QPercentBarSeries* s6 = static_cast<QPercentBarSeries*> (series6); | ||||
s6->setCategories(QBarCategories()); | ||||
QStackedBarSeries* s7 = static_cast<QStackedBarSeries*> (series7); | ||||
s7->setCategories(QBarCategories()); | ||||
Michal Klocek
|
r896 | |||
Michal Klocek
|
r1006 | QAxis* axis = new QAxis(this); | ||
Michal Klocek
|
r896 | |||
Michal Klocek
|
r1006 | QTest::newRow("default axis: lineSeries") << series0 << (QAxis*) 0; | ||
Michal Klocek
|
r896 | QTest::newRow("axis0: lineSeries") << series0 << axis; | ||
Michal Klocek
|
r1006 | QTest::newRow("default axis: areaSeries") << series1 << (QAxis*) 0; | ||
Michal Klocek
|
r896 | QTest::newRow("axis: areaSeries") << series1 << axis; | ||
Michal Klocek
|
r1006 | QTest::newRow("default axis: scatterSeries") << series2 << (QAxis*) 0; | ||
Michal Klocek
|
r896 | QTest::newRow("axis1: scatterSeries") << series2 << axis; | ||
Michal Klocek
|
r1006 | QTest::newRow("default axis: splineSeries") << series3 << (QAxis*) 0; | ||
Michal Klocek
|
r896 | QTest::newRow("axis: splineSeries") << series3 << axis; | ||
Michal Klocek
|
r1006 | QTest::newRow("default axis: pieSeries") << series4 << (QAxis*) 0; | ||
Michal Klocek
|
r896 | QTest::newRow("axis: pieSeries") << series4 << axis; | ||
Michal Klocek
|
r1006 | QTest::newRow("default axis: barSeries") << series5 << (QAxis*) 0; | ||
Michal Klocek
|
r896 | QTest::newRow("axis: barSeries") << series5 << axis; | ||
Michal Klocek
|
r1006 | QTest::newRow("default axis: percentBarSeries") << series6 << (QAxis*) 0; | ||
Michal Klocek
|
r896 | QTest::newRow("axis: barSeries") << series6 << axis; | ||
Michal Klocek
|
r1006 | QTest::newRow("default axis: stackedBarSeries") << series7 << (QAxis*) 0; | ||
Michal Klocek
|
r896 | QTest::newRow("axis: barSeries") << series7 << axis; | ||
} | ||||
void tst_QChart::addSeries() | ||||
{ | ||||
Tero Ahola
|
r988 | QFETCH(QAbstractSeries *, series); | ||
Michal Klocek
|
r1006 | QFETCH(QAxis *, axis); | ||
Michal Klocek
|
r914 | m_view->show(); | ||
QTest::qWaitForWindowShown(m_view); | ||||
Michal Klocek
|
r896 | if(!axis) axis = m_chart->axisY(); | ||
Michal Klocek
|
r915 | m_chart->addSeries(series,axis); | ||
Michal Klocek
|
r896 | QCOMPARE(m_chart->axisY(series),axis); | ||
Michal Klocek
|
r974 | m_chart->removeSeries(series); | ||
Michal Klocek
|
r896 | } | ||
void tst_QChart::animationOptions_data() | ||||
{ | ||||
Michal Klocek
|
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; | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::animationOptions() | ||||
{ | ||||
Michal Klocek
|
r914 | createTestData(); | ||
QFETCH(QChart::AnimationOption, animationOptions); | ||||
m_chart->setAnimationOptions(animationOptions); | ||||
QCOMPARE(m_chart->animationOptions(), animationOptions); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::axisX_data() | ||||
{ | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | } | ||
void tst_QChart::axisX() | ||||
{ | ||||
Michal Klocek
|
r929 | QVERIFY(m_chart->axisX()); | ||
Michal Klocek
|
r1006 | QAxis* axis = m_chart->axisX(); | ||
Michal Klocek
|
r929 | createTestData(); | ||
//it should be the same axis | ||||
QCOMPARE(axis,m_chart->axisX()); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::axisY_data() | ||||
{ | ||||
Michal Klocek
|
r1006 | QTest::addColumn<QAxis*>("axis0"); | ||
QTest::addColumn<QAxis*>("axis1"); | ||||
QTest::addColumn<QAxis*>("axis2"); | ||||
QTest::newRow("1 defualt, 2 optional") << (QAxis*)0 << new QAxis() << new QAxis(); | ||||
QTest::newRow("3 optional") << new QAxis() << new QAxis() << new QAxis(); | ||||
Michal Klocek
|
r896 | } | ||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | void tst_QChart::axisY() | ||
{ | ||||
Michal Klocek
|
r1006 | QFETCH(QAxis*, axis0); | ||
QFETCH(QAxis*, axis1); | ||||
QFETCH(QAxis*, axis2); | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r1006 | QAxis* defaultAxisY = m_chart->axisY(); | ||
Michal Klocek
|
r929 | |||
QVERIFY2(defaultAxisY, "Missing axisY."); | ||||
QLineSeries* series0 = new QLineSeries(); | ||||
m_chart->addSeries(series0, axis0); | ||||
QLineSeries* series1 = new QLineSeries(); | ||||
m_chart->addSeries(series1, axis1); | ||||
Michal Klocek
|
r896 | |||
Michal Klocek
|
r929 | QLineSeries* series2 = new QLineSeries(); | ||
m_chart->addSeries(series2, axis2); | ||||
Michal Klocek
|
r896 | |||
Michal Klocek
|
r929 | if (!axis0) | ||
axis0 = defaultAxisY; | ||||
if (!axis1) | ||||
axis1 = defaultAxisY; | ||||
if (!axis2) | ||||
axis2 = defaultAxisY; | ||||
QVERIFY(m_chart->axisY(series0) == axis0); | ||||
QVERIFY(m_chart->axisY(series1) == axis1); | ||||
QVERIFY(m_chart->axisY(series2) == axis2); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::backgroundBrush_data() | ||||
{ | ||||
QTest::addColumn<QBrush>("backgroundBrush"); | ||||
QTest::newRow("null") << QBrush(); | ||||
Michal Klocek
|
r929 | QTest::newRow("blue") << QBrush(Qt::blue); | ||
QTest::newRow("white") << QBrush(Qt::white); | ||||
QTest::newRow("black") << QBrush(Qt::black); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::backgroundBrush() | ||||
{ | ||||
QFETCH(QBrush, backgroundBrush); | ||||
Michal Klocek
|
r929 | m_chart->setBackgroundBrush(backgroundBrush); | ||
QCOMPARE(m_chart->backgroundBrush(), backgroundBrush); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::backgroundPen_data() | ||||
{ | ||||
QTest::addColumn<QPen>("backgroundPen"); | ||||
QTest::newRow("null") << QPen(); | ||||
Michal Klocek
|
r929 | QTest::newRow("blue") << QPen(Qt::blue); | ||
QTest::newRow("white") << QPen(Qt::white); | ||||
QTest::newRow("black") << QPen(Qt::black); | ||||
Michal Klocek
|
r896 | } | ||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | void tst_QChart::backgroundPen() | ||
{ | ||||
QFETCH(QPen, backgroundPen); | ||||
Michal Klocek
|
r929 | m_chart->setBackgroundPen(backgroundPen); | ||
QCOMPARE(m_chart->backgroundPen(), backgroundPen); | ||||
Michal Klocek
|
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); | ||||
Michal Klocek
|
r929 | m_chart->setBackgroundVisible(isBackgroundVisible); | ||
QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::legend_data() | ||||
{ | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | } | ||
void tst_QChart::legend() | ||||
{ | ||||
Michal Klocek
|
r929 | QVERIFY(m_chart->legend()); | ||
Michal Klocek
|
r896 | } | ||
void tst_QChart::margins_data() | ||||
{ | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | } | ||
void tst_QChart::margins() | ||||
Michal Klocek
|
r1082 | { | ||
Michal Klocek
|
r929 | createTestData(); | ||
QRectF rect = m_chart->geometry(); | ||||
Michal Klocek
|
r896 | |||
Michal Klocek
|
r929 | QVERIFY(m_chart->margins().top()+m_chart->margins().bottom() < rect.height()); | ||
QVERIFY(m_chart->margins().left()+m_chart->margins().right() < rect.width()); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::removeAllSeries_data() | ||||
{ | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | } | ||
void tst_QChart::removeAllSeries() | ||||
{ | ||||
Michal Klocek
|
r929 | QLineSeries* series0 = new QLineSeries(this); | ||
QLineSeries* series1 = new QLineSeries(this); | ||||
QLineSeries* series2 = new QLineSeries(this); | ||||
m_chart->addSeries(series0); | ||||
m_chart->addSeries(series1); | ||||
m_chart->addSeries(series2); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
Michal Klocek
|
r896 | |||
Michal Klocek
|
r929 | QVERIFY(m_chart->axisY(series0)!=0); | ||
QVERIFY(m_chart->axisY(series1)!=0); | ||||
QVERIFY(m_chart->axisY(series2)!=0); | ||||
Michal Klocek
|
r896 | |||
Michal Klocek
|
r929 | m_chart->removeAllSeries(); | ||
QVERIFY(m_chart->axisY(series0)==0); | ||||
QVERIFY(m_chart->axisY(series1)==0); | ||||
QVERIFY(m_chart->axisY(series2)==0); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::removeSeries_data() | ||||
{ | ||||
Michal Klocek
|
r929 | addSeries_data(); | ||
Michal Klocek
|
r896 | } | ||
void tst_QChart::removeSeries() | ||||
{ | ||||
Tero Ahola
|
r988 | QFETCH(QAbstractSeries *, series); | ||
Michal Klocek
|
r1006 | QFETCH(QAxis *, axis); | ||
Michal Klocek
|
r929 | m_view->show(); | ||
QTest::qWaitForWindowShown(m_view); | ||||
if(!axis) axis = m_chart->axisY(); | ||||
m_chart->addSeries(series,axis); | ||||
QCOMPARE(m_chart->axisY(series),axis); | ||||
m_chart->removeSeries(series); | ||||
QVERIFY(m_chart->axisY(series)==0); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::scrollDown_data() | ||||
{ | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | } | ||
void tst_QChart::scrollDown() | ||||
{ | ||||
Michal Klocek
|
r929 | createTestData(); | ||
qreal min = m_chart->axisY()->min(); | ||||
m_chart->scrollDown(); | ||||
QVERIFY(m_chart->axisY()->min()<min); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::scrollLeft_data() | ||||
{ | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | } | ||
void tst_QChart::scrollLeft() | ||||
{ | ||||
Michal Klocek
|
r929 | createTestData(); | ||
qreal min = m_chart->axisX()->min(); | ||||
m_chart->scrollLeft(); | ||||
QVERIFY(m_chart->axisX()->min()<min); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::scrollRight_data() | ||||
{ | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | } | ||
void tst_QChart::scrollRight() | ||||
{ | ||||
Michal Klocek
|
r929 | createTestData(); | ||
qreal min = m_chart->axisX()->min(); | ||||
m_chart->scrollRight(); | ||||
QVERIFY(m_chart->axisX()->min()>min); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::scrollUp_data() | ||||
{ | ||||
} | ||||
Michal Klocek
|
r929 | void tst_QChart::scrollUp() | ||
Michal Klocek
|
r896 | { | ||
Michal Klocek
|
r929 | createTestData(); | ||
qreal min = m_chart->axisY()->min(); | ||||
m_chart->scrollUp(); | ||||
QVERIFY(m_chart->axisY()->min()>min); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::theme_data() | ||||
{ | ||||
QTest::addColumn<QChart::ChartTheme>("theme"); | ||||
Michal Klocek
|
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; | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::theme() | ||||
{ | ||||
QFETCH(QChart::ChartTheme, theme); | ||||
Michal Klocek
|
r929 | createTestData(); | ||
m_chart->setTheme(theme); | ||||
QVERIFY(m_chart->theme()==theme); | ||||
Michal Klocek
|
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); | ||||
Michal Klocek
|
r929 | m_chart->setTitle(title); | ||
QCOMPARE(m_chart->title(), title); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::titleBrush_data() | ||||
{ | ||||
QTest::addColumn<QBrush>("titleBrush"); | ||||
QTest::newRow("null") << QBrush(); | ||||
Michal Klocek
|
r929 | QTest::newRow("blue") << QBrush(Qt::blue); | ||
QTest::newRow("white") << QBrush(Qt::white); | ||||
QTest::newRow("black") << QBrush(Qt::black); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::titleBrush() | ||||
{ | ||||
QFETCH(QBrush, titleBrush); | ||||
Michal Klocek
|
r929 | m_chart->setTitleBrush(titleBrush); | ||
QCOMPARE(m_chart->titleBrush(), titleBrush); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::titleFont_data() | ||||
{ | ||||
QTest::addColumn<QFont>("titleFont"); | ||||
QTest::newRow("null") << QFont(); | ||||
Michal Klocek
|
r929 | QTest::newRow("courier") << QFont("Courier", 8, QFont::Bold, true); | ||
Michal Klocek
|
r896 | } | ||
void tst_QChart::titleFont() | ||||
{ | ||||
QFETCH(QFont, titleFont); | ||||
Michal Klocek
|
r929 | m_chart->setTitleFont(titleFont); | ||
QCOMPARE(m_chart->titleFont(), titleFont); | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::zoomIn_data() | ||||
{ | ||||
Michal Klocek
|
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); | ||||
Michal Klocek
|
r896 | } | ||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | void tst_QChart::zoomIn() | ||
{ | ||||
Michal Klocek
|
r929 | QFETCH(QRectF, rect); | ||
createTestData(); | ||||
QRectF marigns = m_chart->margins(); | ||||
rect.adjust(marigns.left(),marigns.top(),-marigns.right(),-marigns.bottom()); | ||||
qreal minX = m_chart->axisX()->min(); | ||||
qreal minY = m_chart->axisY()->min(); | ||||
qreal maxX = m_chart->axisX()->max(); | ||||
qreal maxY = m_chart->axisY()->max(); | ||||
m_chart->zoomIn(rect); | ||||
if(rect.isValid()){ | ||||
QVERIFY(minX<m_chart->axisX()->min()); | ||||
QVERIFY(maxX>m_chart->axisX()->max()); | ||||
QVERIFY(minY<m_chart->axisY()->min()); | ||||
QVERIFY(maxY>m_chart->axisY()->max()); | ||||
} | ||||
Michal Klocek
|
r896 | } | ||
void tst_QChart::zoomOut_data() | ||||
{ | ||||
Michal Klocek
|
r929 | |||
Michal Klocek
|
r896 | } | ||
void tst_QChart::zoomOut() | ||||
{ | ||||
Michal Klocek
|
r929 | createTestData(); | ||
qreal minX = m_chart->axisX()->min(); | ||||
qreal minY = m_chart->axisY()->min(); | ||||
qreal maxX = m_chart->axisX()->max(); | ||||
qreal maxY = m_chart->axisY()->max(); | ||||
m_chart->zoomIn(); | ||||
Michal Klocek
|
r896 | |||
Tero Ahola
|
r1115 | QVERIFY(minX < m_chart->axisX()->min()); | ||
QVERIFY(maxX > m_chart->axisX()->max()); | ||||
QVERIFY(minY < m_chart->axisY()->min()); | ||||
QVERIFY(maxY > m_chart->axisY()->max()); | ||||
Michal Klocek
|
r929 | |||
m_chart->zoomOut(); | ||||
Michal Klocek
|
r896 | |||
Tero Ahola
|
r1115 | // min x may be a zero value | ||
if (qFuzzyIsNull(minX)) | ||||
QVERIFY(qFuzzyIsNull(m_chart->axisX()->min())); | ||||
else | ||||
QCOMPARE(minX, m_chart->axisX()->min()); | ||||
// min y may be a zero value | ||||
if (qFuzzyIsNull(minY)) | ||||
QVERIFY(qFuzzyIsNull(m_chart->axisY()->min())); | ||||
else | ||||
QCOMPARE(minY, m_chart->axisY()->min()); | ||||
QVERIFY(maxX == m_chart->axisX()->max()); | ||||
QVERIFY(maxY == m_chart->axisY()->max()); | ||||
Michal Klocek
|
r896 | } | ||
QTEST_MAIN(tst_QChart) | ||||
#include "tst_qchart.moc" | ||||