From 27e06db17fd4ccd82a4b641ffd42ccd169502804 2012-04-19 10:27:11 From: Michal Klocek Date: 2012-04-19 10:27:11 Subject: [PATCH] Update of tst_qlineseries.cpp --- diff --git a/src/xychart/qxyseries.cpp b/src/xychart/qxyseries.cpp index 5862dd2..f30fa7e 100644 --- a/src/xychart/qxyseries.cpp +++ b/src/xychart/qxyseries.cpp @@ -133,7 +133,7 @@ void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint) { Q_D(QXYSeries); int index = d->m_points.indexOf(oldPoint); - if(index==1) return; + if(index==-1) return; d->m_points[index] = newPoint; emit d->pointReplaced(index); } @@ -153,7 +153,7 @@ void QXYSeries::remove(const QPointF &point) { Q_D(QXYSeries); int index = d->m_points.indexOf(point); - if(index==1) return; + if(index==-1) return; d->m_points.remove(index); emit d->pointRemoved(index); } diff --git a/test/auto/qchartview/tst_qchartview.cpp b/test/auto/qchartview/tst_qchartview.cpp index 7da2f28..7d58e31 100644 --- a/test/auto/qchartview/tst_qchartview.cpp +++ b/test/auto/qchartview/tst_qchartview.cpp @@ -18,7 +18,6 @@ ** ****************************************************************************/ - #include #include #include diff --git a/test/auto/qlineseries/tst_qlineseries.cpp b/test/auto/qlineseries/tst_qlineseries.cpp index 627e72c..67e580f 100644 --- a/test/auto/qlineseries/tst_qlineseries.cpp +++ b/test/auto/qlineseries/tst_qlineseries.cpp @@ -1,5 +1,28 @@ +/**************************************************************************** +** +** 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 #include +#include + +Q_DECLARE_METATYPE(QList) QTCOMMERCIALCHART_USE_NAMESPACE @@ -14,8 +37,8 @@ public slots: void cleanup(); private slots: - void qxyseries_data(); - void qxyseries(); + void qlineseries_data(); + void qlineseries(); void append_data(); void append(); @@ -55,80 +78,67 @@ private slots: void clicked(); void selected_data(); void selected(); -}; - -// Subclass that exposes the protected functions. -class SubQXYSeries : public QLineSeries -{ -public: - void call_clicked(QPointF const& point) - { return SubQXYSeries::clicked(point); } - - void call_selected() - { return SubQXYSeries::selected(); } +private: + QChartView* m_view; + QChart* m_chart; }; -// This will be called before the first test function is executed. -// It is only called once. void tst_QLineSeries::initTestCase() { + m_view = new QChartView(new QChart()); + m_chart = m_view->chart(); } -// This will be called after the last test function is executed. -// It is only called once. void tst_QLineSeries::cleanupTestCase() { } -// This will be called before each test function is executed. void tst_QLineSeries::init() { } -// This will be called after every test function. void tst_QLineSeries::cleanup() { + delete m_view; + m_view = 0; + m_chart = 0; } -void tst_QLineSeries::qxyseries_data() +void tst_QLineSeries::qlineseries_data() { } -void tst_QLineSeries::qxyseries() +void tst_QLineSeries::qlineseries() { - SubQXYSeries series; -#if 0 - series.append(QList const); - series.append(qreal, qreal); - series.append(QPointF()); - QCOMPARE(series.brush(), QBrush); - QCOMPARE(series.count(), -1); - QCOMPARE(series.data(), QList()); - QCOMPARE(series.operator<<(QList const), QXYSeries&); - QCOMPARE(series.operator<<(QPointF()), QXYSeries&); - QCOMPARE(series.pen(), QPen); + QLineSeries series; + + QCOMPARE(series.count(),0); + QCOMPARE(series.brush(), QBrush()); + QCOMPARE(series.points(), QList()); + QCOMPARE(series.pen(), QPen()); QCOMPARE(series.pointsVisible(), false); - series.remove(qreal, qreal); + + series.append(QList()); + series.append(0.0,0.0); + series.append(QPointF()); + + series.remove(0.0,0.0); series.remove(QPointF()); - series.remove(qreal); series.removeAll(); - series.replace(QPointF()); - series.replace(qreal, qreal); + + series.replace(QPointF(),QPointF()); + series.replace(0,0,0,0); series.setBrush(QBrush()); + QCOMPARE(series.setModel((QAbstractItemModel*)0), false); - series.setModelMapping(-1, -1, Qt::Orientation); + + series.setModelMapping(-1, -1, Qt::Orientation(0)); + series.setPen(QPen()); series.setPointsVisible(false); - QCOMPARE(series.x(-1), qreal); - QCOMPARE(series.y(-1), qreal); - series.call_clicked(QPointF()); - series.call_selected(); -#endif - QSKIP("Test is not implemented.", SkipAll); } -Q_DECLARE_METATYPE(QList) void tst_QLineSeries::append_data() { #if 0