diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 09f0e45..5c21980 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -3,7 +3,7 @@ } TEMPLATE = subdirs -SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qgroupedbarseries qpieslice qpieseries qpiemodelmapper +SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qgroupedbarseries qpieslice qpieseries qpiemodelmapper qsplineseries qscatterseries test_private:{ SUBDIRS += chartdataset domain diff --git a/tests/auto/qlineseries/qlineseries.pro b/tests/auto/qlineseries/qlineseries.pro index cb35386..14f85d2 100644 --- a/tests/auto/qlineseries/qlineseries.pro +++ b/tests/auto/qlineseries/qlineseries.pro @@ -1,6 +1,7 @@ !include( ../auto.pri ) { error( "Couldn't find the auto.pri file!" ) } -SOURCES += tst_qlineseries.cpp +HEADERS += ../qxyseries/tst_qxyseries.h +SOURCES += tst_qlineseries.cpp ../qxyseries/tst_qxyseries.cpp !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" diff --git a/tests/auto/qlineseries/tst_qlineseries.cpp b/tests/auto/qlineseries/tst_qlineseries.cpp index ef08e82..ffe442a 100644 --- a/tests/auto/qlineseries/tst_qlineseries.cpp +++ b/tests/auto/qlineseries/tst_qlineseries.cpp @@ -18,73 +18,26 @@ ** ****************************************************************************/ -#include +#include "../qxyseries/tst_qxyseries.h" #include -#include -#include -#include -#include -Q_DECLARE_METATYPE(QList) -QTCOMMERCIALCHART_USE_NAMESPACE +Q_DECLARE_METATYPE(QList) -class tst_QLineSeries : public QObject +class tst_QLineSeries : public tst_QXYSeries { Q_OBJECT - public slots: +public slots: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); - - private slots: +private slots: void qlineseries_data(); void qlineseries(); - void append_raw_data(); - void append_raw(); - void append_chart_data(); - void append_chart(); - void append_chart_animation_data(); - void append_chart_animation(); - void chart_append_data(); - void chart_append(); - void count_raw_data(); - void count_raw(); - void oper_data(); - void oper(); - void pen_data(); - void pen(); - void pointsVisible_raw_data(); - void pointsVisible_raw(); - void remove_raw_data(); - void remove_raw(); - void remove_chart_data(); - void remove_chart(); - void remove_chart_animation_data(); - void remove_chart_animation(); - void removeAll_raw_data(); - void removeAll_raw(); - void removeAll_chart_data(); - void removeAll_chart(); - void removeAll_chart_animation_data(); - void removeAll_chart_animation(); - void replace_raw_data(); - void replace_raw(); - void replace_chart_data(); - void replace_chart(); - void replace_chart_animation_data(); - void replace_chart_animation(); - private: - void append_data(); - void count_data(); +protected: void pointsVisible_data(); - - private: - QChartView* m_view; - QChart* m_chart; - QLineSeries* m_series; }; void tst_QLineSeries::initTestCase() @@ -97,18 +50,14 @@ void tst_QLineSeries::cleanupTestCase() void tst_QLineSeries::init() { - m_view = new QChartView(new QChart()); - m_chart = m_view->chart(); + tst_QXYSeries::init(); m_series = new QLineSeries(); } void tst_QLineSeries::cleanup() { delete m_series; - delete m_view; - m_view = 0; - m_chart = 0; - m_series = 0; + tst_QXYSeries::cleanup(); } void tst_QLineSeries::qlineseries_data() @@ -138,10 +87,6 @@ void tst_QLineSeries::qlineseries() series.replace(0,0,0,0); series.setBrush(QBrush()); -// QCOMPARE(series.setModel((QAbstractItemModel*)0), false); - -// series.setModelMapping(-1, -1, Qt::Orientation(0)); - series.setPen(QPen()); series.setPointsVisible(false); @@ -150,301 +95,6 @@ void tst_QLineSeries::qlineseries() QTest::qWaitForWindowShown(m_view); } -void tst_QLineSeries::append_data() -{ - QTest::addColumn< QList >("points"); - QTest::newRow("0,0 1,1 2,2 3,3") << (QList() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)); - QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)); -} - - -void tst_QLineSeries::append_raw_data() -{ - append_data(); -} - -void tst_QLineSeries::append_raw() -{ - QFETCH(QList, points); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->append(points); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points(), points); -} - -void tst_QLineSeries::chart_append_data() -{ - append_data(); -} - -void tst_QLineSeries::chart_append() -{ - append_raw(); - m_chart->addSeries(m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); -} - -void tst_QLineSeries::append_chart_data() -{ - append_data(); -} - -void tst_QLineSeries::append_chart() -{ - m_view->show(); - m_chart->addSeries(m_series); - QTest::qWaitForWindowShown(m_view); - append_raw(); - -} - -void tst_QLineSeries::append_chart_animation_data() -{ - append_data(); -} - -void tst_QLineSeries::append_chart_animation() -{ - m_chart->setAnimationOptions(QChart::AllAnimations); - append_chart(); -} - -void tst_QLineSeries::count_data() -{ - QTest::addColumn("count"); - QTest::newRow("0") << 0; - QTest::newRow("5") << 5; - QTest::newRow("10") << 5; -} - -void tst_QLineSeries::count_raw_data() -{ - count_data(); -} - -void tst_QLineSeries::count_raw() -{ - QFETCH(int, count); - - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - - for(int i=0 ; i< count; ++i) - m_series->append(i,i); - - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->count(), count); -} - -void tst_QLineSeries::oper_data() -{ - append_data(); -} - -void tst_QLineSeries::oper() -{ - QFETCH(QList, points); - QLineSeries series; - - QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); - - foreach(const QPointF& point,points) - { - series<("pen"); - QTest::newRow("null") << QPen(); - QTest::newRow("blue") << QPen(Qt::blue); - QTest::newRow("black") << QPen(Qt::black); - QTest::newRow("red") << QPen(Qt::red); -} - -void tst_QLineSeries::pen() -{ - QFETCH(QPen, pen); - QLineSeries series; - - QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); - series.setPen(pen); - - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(series.pen(), pen); - - m_chart->addSeries(&series); - - if(pen!=QPen()) QCOMPARE(series.pen(), pen); - - m_chart->setTheme(QChart::ChartThemeDark); - - QVERIFY(series.pen() != pen); -} - -void tst_QLineSeries::pointsVisible_data() -{ - QTest::addColumn("pointsVisible"); - QTest::newRow("true") << true; - QTest::newRow("false") << false; -} - -void tst_QLineSeries::pointsVisible_raw_data() -{ - pointsVisible_data(); -} - -void tst_QLineSeries::pointsVisible_raw() -{ - QFETCH(bool, pointsVisible); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->setPointsVisible(pointsVisible); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->pointsVisible(), pointsVisible); -} - -void tst_QLineSeries::remove_raw_data() -{ - append_data(); -} - -void tst_QLineSeries::remove_raw() -{ - QFETCH(QList, points); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->append(points); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points(), points); - - foreach(const QPointF& point,points) - m_series->remove(point); - - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points().count(), 0); -} - -void tst_QLineSeries::remove_chart_data() -{ - append_data(); -} - -void tst_QLineSeries::remove_chart() -{ - m_view->show(); - m_chart->addSeries(m_series); - QTest::qWaitForWindowShown(m_view); - remove_raw(); -} - -void tst_QLineSeries::remove_chart_animation_data() -{ - append_data(); -} - -void tst_QLineSeries::remove_chart_animation() -{ - m_chart->setAnimationOptions(QChart::AllAnimations); - remove_chart(); -} - - -void tst_QLineSeries::removeAll_raw_data() -{ - append_data(); -} - -void tst_QLineSeries::removeAll_raw() -{ - QFETCH(QList, points); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->append(points); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points(), points); - m_series->removeAll(); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points().count(), 0); -} - -void tst_QLineSeries::removeAll_chart_data() -{ - append_data(); -} - -void tst_QLineSeries::removeAll_chart() -{ - m_view->show(); - m_chart->addSeries(m_series); - QTest::qWaitForWindowShown(m_view); - removeAll_raw(); -} - -void tst_QLineSeries::removeAll_chart_animation_data() -{ - append_data(); -} - -void tst_QLineSeries::removeAll_chart_animation() -{ - m_chart->setAnimationOptions(QChart::AllAnimations); - removeAll_chart(); -} - -void tst_QLineSeries::replace_raw_data() -{ - append_data(); -} - -void tst_QLineSeries::replace_raw() -{ - QFETCH(QList, points); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->append(points); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points(), points); - - foreach(const QPointF& point,points) - m_series->replace(point.x(),point.y(),point.x(),0); - - QList newPoints = m_series->points(); - - QCOMPARE(newPoints.count(), points.count()); - - for(int i =0 ; ishow(); - m_chart->addSeries(m_series); - QTest::qWaitForWindowShown(m_view); - replace_raw(); -} - -void tst_QLineSeries::replace_chart_animation_data() -{ - append_data(); -} - -void tst_QLineSeries::replace_chart_animation() -{ - m_chart->setAnimationOptions(QChart::AllAnimations); - replace_chart(); -} - QTEST_MAIN(tst_QLineSeries) #include "tst_qlineseries.moc" diff --git a/tests/auto/qscatterseries/qscatterseries.pro b/tests/auto/qscatterseries/qscatterseries.pro new file mode 100644 index 0000000..2426a1d --- /dev/null +++ b/tests/auto/qscatterseries/qscatterseries.pro @@ -0,0 +1,6 @@ +!include( ../auto.pri ):error( "Couldn't find the auto.pri file!" ) + +HEADERS += ../qxyseries/tst_qxyseries.h +SOURCES += tst_qscatterseries.cpp ../qxyseries/tst_qxyseries.cpp + +!system_build:mac:QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" diff --git a/tests/auto/qscatterseries/tst_qscatterseries.cpp b/tests/auto/qscatterseries/tst_qscatterseries.cpp new file mode 100644 index 0000000..3b8b868 --- /dev/null +++ b/tests/auto/qscatterseries/tst_qscatterseries.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../qxyseries/tst_qxyseries.h" +#include + +Q_DECLARE_METATYPE(QList) + +class tst_QScatterSeries : public tst_QXYSeries +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); +private slots: + void qscatterseries_data(); + void qscatterseries(); +protected: + void pointsVisible_data(); +}; + +void tst_QScatterSeries::initTestCase() +{ +} + +void tst_QScatterSeries::cleanupTestCase() +{ +} + +void tst_QScatterSeries::init() +{ + tst_QXYSeries::init(); + m_series = new QScatterSeries(); +} + +void tst_QScatterSeries::cleanup() +{ + delete m_series; + tst_QXYSeries::cleanup(); +} + +void tst_QScatterSeries::qscatterseries_data() +{ + +} + +void tst_QScatterSeries::qscatterseries() +{ + QScatterSeries series; + + QCOMPARE(series.count(),0); + QCOMPARE(series.brush(), QBrush()); + QCOMPARE(series.points(), QList()); + QCOMPARE(series.pen(), QPen()); + QCOMPARE(series.pointsVisible(), false); + + series.append(QList()); + series.append(0.0,0.0); + series.append(QPointF()); + + series.remove(0.0,0.0); + series.remove(QPointF()); + series.removeAll(); + + series.replace(QPointF(),QPointF()); + series.replace(0,0,0,0); + series.setBrush(QBrush()); + + series.setPen(QPen()); + series.setPointsVisible(false); + + m_chart->addSeries(&series); + m_view->show(); + QTest::qWaitForWindowShown(m_view); +} + +QTEST_MAIN(tst_QScatterSeries) + +#include "tst_qscatterseries.moc" + diff --git a/tests/auto/qsplineseries/qsplineseries.pro b/tests/auto/qsplineseries/qsplineseries.pro new file mode 100644 index 0000000..bc1f9d8 --- /dev/null +++ b/tests/auto/qsplineseries/qsplineseries.pro @@ -0,0 +1,7 @@ +!include( ../auto.pri ) { + error( "Couldn't find the auto.pri file!" ) +} +HEADERS += ../qxyseries/tst_qxyseries.h +SOURCES += tst_qsplineseries.cpp ../qxyseries/tst_qxyseries.cpp + +!system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" diff --git a/tests/auto/qsplineseries/tst_qsplineseries.cpp b/tests/auto/qsplineseries/tst_qsplineseries.cpp new file mode 100644 index 0000000..8edbac8 --- /dev/null +++ b/tests/auto/qsplineseries/tst_qsplineseries.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../qxyseries/tst_qxyseries.h" +#include + +Q_DECLARE_METATYPE(QList) + +class tst_QSplineSeries : public tst_QXYSeries +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); +private slots: + void qsplineseries_data(); + void qsplineseries(); +protected: + void pointsVisible_data(); +}; + +void tst_QSplineSeries::initTestCase() +{ +} + +void tst_QSplineSeries::cleanupTestCase() +{ +} + +void tst_QSplineSeries::init() +{ + tst_QXYSeries::init(); + m_series = new QSplineSeries(); +} + +void tst_QSplineSeries::cleanup() +{ + delete m_series; + tst_QXYSeries::cleanup(); +} + +void tst_QSplineSeries::qsplineseries_data() +{ + +} + +void tst_QSplineSeries::qsplineseries() +{ + QSplineSeries series; + + QCOMPARE(series.count(),0); + QCOMPARE(series.brush(), QBrush()); + QCOMPARE(series.points(), QList()); + QCOMPARE(series.pen(), QPen()); + QCOMPARE(series.pointsVisible(), false); + + series.append(QList()); + series.append(0.0,0.0); + series.append(QPointF()); + + series.remove(0.0,0.0); + series.remove(QPointF()); + series.removeAll(); + + series.replace(QPointF(),QPointF()); + series.replace(0,0,0,0); + series.setBrush(QBrush()); + + series.setPen(QPen()); + series.setPointsVisible(false); + + m_chart->addSeries(&series); + m_view->show(); + QTest::qWaitForWindowShown(m_view); +} + +QTEST_MAIN(tst_QSplineSeries) + +#include "tst_qsplineseries.moc" + diff --git a/tests/auto/qxyseries/qlineseries.pro b/tests/auto/qxyseries/qlineseries.pro new file mode 100644 index 0000000..cb35386 --- /dev/null +++ b/tests/auto/qxyseries/qlineseries.pro @@ -0,0 +1,6 @@ +!include( ../auto.pri ) { + error( "Couldn't find the auto.pri file!" ) +} +SOURCES += tst_qlineseries.cpp + +!system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" diff --git a/tests/auto/qxyseries/tst_qxyseries.cpp b/tests/auto/qxyseries/tst_qxyseries.cpp new file mode 100644 index 0000000..ae6175c --- /dev/null +++ b/tests/auto/qxyseries/tst_qxyseries.cpp @@ -0,0 +1,347 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tst_qxyseries.h" + +Q_DECLARE_METATYPE(QList) + +void tst_QXYSeries::initTestCase() +{ +} + +void tst_QXYSeries::cleanupTestCase() +{ +} + +void tst_QXYSeries::init() +{ + m_view = new QChartView(new QChart()); + m_chart = m_view->chart(); +} + +void tst_QXYSeries::cleanup() +{ + delete m_view; + m_view = 0; + m_chart = 0; + m_series = 0; +} + +void tst_QXYSeries::append_data() +{ + QTest::addColumn< QList >("points"); + QTest::newRow("0,0 1,1 2,2 3,3") << (QList() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)); + QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)); +} + + +void tst_QXYSeries::append_raw_data() +{ + append_data(); +} + +void tst_QXYSeries::append_raw() +{ + QFETCH(QList, points); + QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); + m_series->append(points); + TRY_COMPARE(spy0.count(), 0); + QCOMPARE(m_series->points(), points); +} + +void tst_QXYSeries::chart_append_data() +{ + append_data(); +} + +void tst_QXYSeries::chart_append() +{ + append_raw(); + m_chart->addSeries(m_series); + m_view->show(); + QTest::qWaitForWindowShown(m_view); +} + +void tst_QXYSeries::append_chart_data() +{ + append_data(); +} + +void tst_QXYSeries::append_chart() +{ + m_view->show(); + m_chart->addSeries(m_series); + QTest::qWaitForWindowShown(m_view); + append_raw(); + +} + +void tst_QXYSeries::append_chart_animation_data() +{ + append_data(); +} + +void tst_QXYSeries::append_chart_animation() +{ + m_chart->setAnimationOptions(QChart::AllAnimations); + append_chart(); +} + +void tst_QXYSeries::count_data() +{ + QTest::addColumn("count"); + QTest::newRow("0") << 0; + QTest::newRow("5") << 5; + QTest::newRow("10") << 5; +} + +void tst_QXYSeries::count_raw_data() +{ + count_data(); +} + +void tst_QXYSeries::count_raw() +{ + QFETCH(int, count); + + QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); + + for(int i=0 ; i< count; ++i) + m_series->append(i,i); + + TRY_COMPARE(spy0.count(), 0); + QCOMPARE(m_series->count(), count); +} + +void tst_QXYSeries::remove_raw_data() +{ + append_data(); +} + +void tst_QXYSeries::remove_raw() +{ + QFETCH(QList, points); + QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); + m_series->append(points); + TRY_COMPARE(spy0.count(), 0); + QCOMPARE(m_series->points(), points); + + foreach(const QPointF& point,points) + m_series->remove(point); + + QCOMPARE(m_series->points().count(), 0); + TRY_COMPARE(spy0.count(), 0); + + m_series->append(points); + QCOMPARE(m_series->points(), points); + + //reverse order + for(int i = points.count()-1 ; i>=0; i--){ + m_series->remove(points[i]); + } + QCOMPARE(m_series->points().count(), 0); +} + +void tst_QXYSeries::remove_chart_data() +{ + append_data(); +} + +void tst_QXYSeries::remove_chart() +{ + m_view->show(); + m_chart->addSeries(m_series); + QTest::qWaitForWindowShown(m_view); + remove_raw(); +} + +void tst_QXYSeries::remove_chart_animation_data() +{ + append_data(); +} + +void tst_QXYSeries::remove_chart_animation() +{ + m_chart->setAnimationOptions(QChart::AllAnimations); + remove_chart(); +} + + +void tst_QXYSeries::removeAll_raw_data() +{ + append_data(); +} + +void tst_QXYSeries::removeAll_raw() +{ + QFETCH(QList, points); + QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); + m_series->append(points); + TRY_COMPARE(spy0.count(), 0); + QCOMPARE(m_series->points(), points); + m_series->removeAll(); + TRY_COMPARE(spy0.count(), 0); + QCOMPARE(m_series->points().count(), 0); +} + +void tst_QXYSeries::removeAll_chart_data() +{ + append_data(); +} + +void tst_QXYSeries::removeAll_chart() +{ + m_view->show(); + m_chart->addSeries(m_series); + QTest::qWaitForWindowShown(m_view); + removeAll_raw(); +} + +void tst_QXYSeries::removeAll_chart_animation_data() +{ + append_data(); +} + +void tst_QXYSeries::removeAll_chart_animation() +{ + m_chart->setAnimationOptions(QChart::AllAnimations); + removeAll_chart(); +} + +void tst_QXYSeries::replace_raw_data() +{ + append_data(); +} + +void tst_QXYSeries::replace_raw() +{ + QFETCH(QList, points); + QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); + m_series->append(points); + TRY_COMPARE(spy0.count(), 0); + QCOMPARE(m_series->points(), points); + + foreach(const QPointF& point,points) + m_series->replace(point.x(),point.y(),point.x(),0); + + QList newPoints = m_series->points(); + + QCOMPARE(newPoints.count(), points.count()); + + for(int i =0 ; ishow(); + m_chart->addSeries(m_series); + QTest::qWaitForWindowShown(m_view); + replace_raw(); +} + +void tst_QXYSeries::replace_chart_animation_data() +{ + append_data(); +} + +void tst_QXYSeries::replace_chart_animation() +{ + m_chart->setAnimationOptions(QChart::AllAnimations); + replace_chart(); +} + +void tst_QXYSeries::oper_data() +{ + append_data(); +} + +void tst_QXYSeries::oper() +{ + QFETCH(QList, points); + + QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); + + foreach(const QPointF& point,points) + { + *m_series<points(), points); + TRY_COMPARE(spy0.count(), 0); +} + + +void tst_QXYSeries::pen_data() +{ + QTest::addColumn("pen"); + QTest::newRow("null") << QPen(); + QTest::newRow("blue") << QPen(Qt::blue); + QTest::newRow("black") << QPen(Qt::black); + QTest::newRow("red") << QPen(Qt::red); +} + +void tst_QXYSeries::pen() +{ + QFETCH(QPen, pen); + + QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); + m_series->setPen(pen); + + TRY_COMPARE(spy0.count(), 0); + QCOMPARE(m_series->pen(), pen); + + m_chart->addSeries(m_series); + + if(pen!=QPen()) QCOMPARE(m_series->pen(), pen); + + m_chart->setTheme(QChart::ChartThemeDark); + + if(pen!=QPen()) QCOMPARE(m_series->pen(), pen); +} + +void tst_QXYSeries::pointsVisible_data() +{ + QTest::addColumn("pointsVisible"); + QTest::newRow("true") << true; + QTest::newRow("false") << false; +} + +void tst_QXYSeries::pointsVisible_raw_data() +{ + pointsVisible_data(); +} + +void tst_QXYSeries::pointsVisible_raw() +{ + QFETCH(bool, pointsVisible); + QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); + m_series->setPointsVisible(pointsVisible); + TRY_COMPARE(spy0.count(), 0); + QCOMPARE(m_series->pointsVisible(), pointsVisible); +} diff --git a/tests/auto/qxyseries/tst_qxyseries.h b/tests/auto/qxyseries/tst_qxyseries.h new file mode 100644 index 0000000..b5f59ec --- /dev/null +++ b/tests/auto/qxyseries/tst_qxyseries.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TST_QXYSERIES_H +#define TST_QXYSERIES_H + +#include +#include +#include +#include +#include + +QTCOMMERCIALCHART_USE_NAMESPACE + +class tst_QXYSeries : public QObject +{ + Q_OBJECT + +public slots: + virtual void initTestCase(); + virtual void cleanupTestCase(); + virtual void init(); + virtual void cleanup(); + +private slots: + void oper_data(); + void oper(); + void pen_data(); + void pen(); + void pointsVisible_raw_data(); + void pointsVisible_raw(); + void append_raw_data(); + void append_raw(); + void append_chart_data(); + void append_chart(); + void append_chart_animation_data(); + void append_chart_animation(); + void chart_append_data(); + void chart_append(); + void count_raw_data(); + void count_raw(); + void remove_raw_data(); + void remove_raw(); + void remove_chart_data(); + void remove_chart(); + void remove_chart_animation_data(); + void remove_chart_animation(); + void removeAll_raw_data(); + void removeAll_raw(); + void removeAll_chart_data(); + void removeAll_chart(); + void removeAll_chart_animation_data(); + void removeAll_chart_animation(); + void replace_raw_data(); + void replace_raw(); + void replace_chart_data(); + void replace_chart(); + void replace_chart_animation_data(); + void replace_chart_animation(); +protected: + void append_data(); + void count_data(); + void pointsVisible_data(); + +protected: + QChartView* m_view; + QChart* m_chart; + QXYSeries* m_series; +}; + +#endif