##// END OF EJS Templates
Update of tst_qlineseries.cpp
Michal Klocek -
r1064:27e06db17fd4
parent child
Show More
@@ -133,7 +133,7 void QXYSeries::replace(const QPointF &oldPoint,const QPointF &newPoint)
133 {
133 {
134 Q_D(QXYSeries);
134 Q_D(QXYSeries);
135 int index = d->m_points.indexOf(oldPoint);
135 int index = d->m_points.indexOf(oldPoint);
136 if(index==1) return;
136 if(index==-1) return;
137 d->m_points[index] = newPoint;
137 d->m_points[index] = newPoint;
138 emit d->pointReplaced(index);
138 emit d->pointReplaced(index);
139 }
139 }
@@ -153,7 +153,7 void QXYSeries::remove(const QPointF &point)
153 {
153 {
154 Q_D(QXYSeries);
154 Q_D(QXYSeries);
155 int index = d->m_points.indexOf(point);
155 int index = d->m_points.indexOf(point);
156 if(index==1) return;
156 if(index==-1) return;
157 d->m_points.remove(index);
157 d->m_points.remove(index);
158 emit d->pointRemoved(index);
158 emit d->pointRemoved(index);
159 }
159 }
@@ -18,7 +18,6
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21
22 #include <QtTest/QtTest>
21 #include <QtTest/QtTest>
23 #include <qchartview.h>
22 #include <qchartview.h>
24 #include <qlineseries.h>
23 #include <qlineseries.h>
@@ -1,5 +1,28
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 #include <QtTest/QtTest>
21 #include <QtTest/QtTest>
2 #include <qlineseries.h>
22 #include <qlineseries.h>
23 #include <qchartview.h>
24
25 Q_DECLARE_METATYPE(QList<QPointF>)
3
26
4 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
5
28
@@ -14,8 +37,8 public slots:
14 void cleanup();
37 void cleanup();
15
38
16 private slots:
39 private slots:
17 void qxyseries_data();
40 void qlineseries_data();
18 void qxyseries();
41 void qlineseries();
19
42
20 void append_data();
43 void append_data();
21 void append();
44 void append();
@@ -55,80 +78,67 private slots:
55 void clicked();
78 void clicked();
56 void selected_data();
79 void selected_data();
57 void selected();
80 void selected();
58 };
59
60 // Subclass that exposes the protected functions.
61 class SubQXYSeries : public QLineSeries
62 {
63 public:
64 void call_clicked(QPointF const& point)
65 { return SubQXYSeries::clicked(point); }
66
67 void call_selected()
68 { return SubQXYSeries::selected(); }
69
81
82 private:
83 QChartView* m_view;
84 QChart* m_chart;
70 };
85 };
71
86
72 // This will be called before the first test function is executed.
73 // It is only called once.
74 void tst_QLineSeries::initTestCase()
87 void tst_QLineSeries::initTestCase()
75 {
88 {
89 m_view = new QChartView(new QChart());
90 m_chart = m_view->chart();
76 }
91 }
77
92
78 // This will be called after the last test function is executed.
79 // It is only called once.
80 void tst_QLineSeries::cleanupTestCase()
93 void tst_QLineSeries::cleanupTestCase()
81 {
94 {
82 }
95 }
83
96
84 // This will be called before each test function is executed.
85 void tst_QLineSeries::init()
97 void tst_QLineSeries::init()
86 {
98 {
87 }
99 }
88
100
89 // This will be called after every test function.
90 void tst_QLineSeries::cleanup()
101 void tst_QLineSeries::cleanup()
91 {
102 {
103 delete m_view;
104 m_view = 0;
105 m_chart = 0;
92 }
106 }
93
107
94 void tst_QLineSeries::qxyseries_data()
108 void tst_QLineSeries::qlineseries_data()
95 {
109 {
96 }
110 }
97
111
98 void tst_QLineSeries::qxyseries()
112 void tst_QLineSeries::qlineseries()
99 {
113 {
100 SubQXYSeries series;
114 QLineSeries series;
101 #if 0
115
102 series.append(QList<QPointF> const);
116 QCOMPARE(series.count(),0);
103 series.append(qreal, qreal);
117 QCOMPARE(series.brush(), QBrush());
104 series.append(QPointF());
118 QCOMPARE(series.points(), QList<QPointF>());
105 QCOMPARE(series.brush(), QBrush);
119 QCOMPARE(series.pen(), QPen());
106 QCOMPARE(series.count(), -1);
107 QCOMPARE(series.data(), QList<QPointF>());
108 QCOMPARE(series.operator<<(QList<QPointF> const), QXYSeries&);
109 QCOMPARE(series.operator<<(QPointF()), QXYSeries&);
110 QCOMPARE(series.pen(), QPen);
111 QCOMPARE(series.pointsVisible(), false);
120 QCOMPARE(series.pointsVisible(), false);
112 series.remove(qreal, qreal);
121
122 series.append(QList<QPointF>());
123 series.append(0.0,0.0);
124 series.append(QPointF());
125
126 series.remove(0.0,0.0);
113 series.remove(QPointF());
127 series.remove(QPointF());
114 series.remove(qreal);
115 series.removeAll();
128 series.removeAll();
116 series.replace(QPointF());
129
117 series.replace(qreal, qreal);
130 series.replace(QPointF(),QPointF());
131 series.replace(0,0,0,0);
118 series.setBrush(QBrush());
132 series.setBrush(QBrush());
133
119 QCOMPARE(series.setModel((QAbstractItemModel*)0), false);
134 QCOMPARE(series.setModel((QAbstractItemModel*)0), false);
120 series.setModelMapping(-1, -1, Qt::Orientation);
135
136 series.setModelMapping(-1, -1, Qt::Orientation(0));
137
121 series.setPen(QPen());
138 series.setPen(QPen());
122 series.setPointsVisible(false);
139 series.setPointsVisible(false);
123 QCOMPARE(series.x(-1), qreal);
124 QCOMPARE(series.y(-1), qreal);
125 series.call_clicked(QPointF());
126 series.call_selected();
127 #endif
128 QSKIP("Test is not implemented.", SkipAll);
129 }
140 }
130
141
131 Q_DECLARE_METATYPE(QList<QPointF>)
132 void tst_QLineSeries::append_data()
142 void tst_QLineSeries::append_data()
133 {
143 {
134 #if 0
144 #if 0
General Comments 0
You need to be logged in to leave comments. Login now