|
@@
-1,631
+1,631
|
|
1
|
/****************************************************************************
|
|
1
|
/****************************************************************************
|
|
2
|
**
|
|
2
|
**
|
|
3
|
** Copyright (C) 2012 Digia Plc
|
|
3
|
** Copyright (C) 2012 Digia Plc
|
|
4
|
** All rights reserved.
|
|
4
|
** All rights reserved.
|
|
5
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
|
5
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
|
6
|
**
|
|
6
|
**
|
|
7
|
** This file is part of the Qt Commercial Charts Add-on.
|
|
7
|
** This file is part of the Qt Commercial Charts Add-on.
|
|
8
|
**
|
|
8
|
**
|
|
9
|
** $QT_BEGIN_LICENSE$
|
|
9
|
** $QT_BEGIN_LICENSE$
|
|
10
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
10
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
11
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
11
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
12
|
** Software or, alternatively, in accordance with the terms contained in
|
|
12
|
** Software or, alternatively, in accordance with the terms contained in
|
|
13
|
** a written agreement between you and Digia.
|
|
13
|
** a written agreement between you and Digia.
|
|
14
|
**
|
|
14
|
**
|
|
15
|
** If you have questions regarding the use of this file, please use
|
|
15
|
** If you have questions regarding the use of this file, please use
|
|
16
|
** contact form at http://qt.digia.com
|
|
16
|
** contact form at http://qt.digia.com
|
|
17
|
** $QT_END_LICENSE$
|
|
17
|
** $QT_END_LICENSE$
|
|
18
|
**
|
|
18
|
**
|
|
19
|
****************************************************************************/
|
|
19
|
****************************************************************************/
|
|
20
|
|
|
20
|
|
|
21
|
#include <QtTest/QtTest>
|
|
21
|
#include <QtTest/QtTest>
|
|
22
|
#include <qlineseries.h>
|
|
22
|
#include <qlineseries.h>
|
|
23
|
#include <qchartview.h>
|
|
23
|
#include <qchartview.h>
|
|
24
|
#include <QStandardItemModel>
|
|
24
|
#include <QStandardItemModel>
|
|
25
|
#include <tst_definitions.h>
|
|
25
|
#include <tst_definitions.h>
|
|
26
|
|
|
26
|
|
|
27
|
Q_DECLARE_METATYPE(QList<QPointF>)
|
|
27
|
Q_DECLARE_METATYPE(QList<QPointF>)
|
|
28
|
|
|
28
|
|
|
29
|
QTCOMMERCIALCHART_USE_NAMESPACE
|
|
29
|
QTCOMMERCIALCHART_USE_NAMESPACE
|
|
30
|
|
|
30
|
|
|
31
|
class tst_QLineSeries : public QObject
|
|
31
|
class tst_QLineSeries : public QObject
|
|
32
|
{
|
|
32
|
{
|
|
33
|
Q_OBJECT
|
|
33
|
Q_OBJECT
|
|
34
|
|
|
34
|
|
|
35
|
public slots:
|
|
35
|
public slots:
|
|
36
|
void initTestCase();
|
|
36
|
void initTestCase();
|
|
37
|
void cleanupTestCase();
|
|
37
|
void cleanupTestCase();
|
|
38
|
void init();
|
|
38
|
void init();
|
|
39
|
void cleanup();
|
|
39
|
void cleanup();
|
|
40
|
|
|
40
|
|
|
41
|
private slots:
|
|
41
|
private slots:
|
|
42
|
void qlineseries_data();
|
|
42
|
void qlineseries_data();
|
|
43
|
void qlineseries();
|
|
43
|
void qlineseries();
|
|
44
|
void append_raw_data();
|
|
44
|
void append_raw_data();
|
|
45
|
void append_raw();
|
|
45
|
void append_raw();
|
|
46
|
void append_chart_data();
|
|
46
|
void append_chart_data();
|
|
47
|
void append_chart();
|
|
47
|
void append_chart();
|
|
48
|
void append_chart_animation_data();
|
|
48
|
void append_chart_animation_data();
|
|
49
|
void append_chart_animation();
|
|
49
|
void append_chart_animation();
|
|
50
|
void chart_append_data();
|
|
50
|
void chart_append_data();
|
|
51
|
void chart_append();
|
|
51
|
void chart_append();
|
|
52
|
void count_raw_data();
|
|
52
|
void count_raw_data();
|
|
53
|
void count_raw();
|
|
53
|
void count_raw();
|
|
54
|
void oper_data();
|
|
54
|
void oper_data();
|
|
55
|
void oper();
|
|
55
|
void oper();
|
|
56
|
void pen_data();
|
|
56
|
void pen_data();
|
|
57
|
void pen();
|
|
57
|
void pen();
|
|
58
|
void pointsVisible_raw_data();
|
|
58
|
void pointsVisible_raw_data();
|
|
59
|
void pointsVisible_raw();
|
|
59
|
void pointsVisible_raw();
|
|
60
|
void remove_raw_data();
|
|
60
|
void remove_raw_data();
|
|
61
|
void remove_raw();
|
|
61
|
void remove_raw();
|
|
62
|
void remove_chart_data();
|
|
62
|
void remove_chart_data();
|
|
63
|
void remove_chart();
|
|
63
|
void remove_chart();
|
|
64
|
void remove_chart_animation_data();
|
|
64
|
void remove_chart_animation_data();
|
|
65
|
void remove_chart_animation();
|
|
65
|
void remove_chart_animation();
|
|
66
|
void removeAll_raw_data();
|
|
66
|
void removeAll_raw_data();
|
|
67
|
void removeAll_raw();
|
|
67
|
void removeAll_raw();
|
|
68
|
void removeAll_chart_data();
|
|
68
|
void removeAll_chart_data();
|
|
69
|
void removeAll_chart();
|
|
69
|
void removeAll_chart();
|
|
70
|
void removeAll_chart_animation_data();
|
|
70
|
void removeAll_chart_animation_data();
|
|
71
|
void removeAll_chart_animation();
|
|
71
|
void removeAll_chart_animation();
|
|
72
|
void replace_raw_data();
|
|
72
|
void replace_raw_data();
|
|
73
|
void replace_raw();
|
|
73
|
void replace_raw();
|
|
74
|
void replace_chart_data();
|
|
74
|
void replace_chart_data();
|
|
75
|
void replace_chart();
|
|
75
|
void replace_chart();
|
|
76
|
void replace_chart_animation_data();
|
|
76
|
void replace_chart_animation_data();
|
|
77
|
void replace_chart_animation();
|
|
77
|
void replace_chart_animation();
|
|
78
|
void setModel_data();
|
|
78
|
void setModel_data();
|
|
79
|
void setModel();
|
|
79
|
void setModel();
|
|
80
|
void setModelMapping_data();
|
|
80
|
void setModelMapping_data();
|
|
81
|
void setModelMapping();
|
|
81
|
void setModelMapping();
|
|
82
|
void setModelMappingRange_data();
|
|
82
|
void setModelMappingRange_data();
|
|
83
|
void setModelMappingRange();
|
|
83
|
void setModelMappingRange();
|
|
84
|
void modelUpdated();
|
|
84
|
void modelUpdated();
|
|
85
|
void modelUpdatedCustomMapping();
|
|
85
|
void modelUpdatedCustomMapping();
|
|
86
|
private:
|
|
86
|
private:
|
|
87
|
void append_data();
|
|
87
|
void append_data();
|
|
88
|
void count_data();
|
|
88
|
void count_data();
|
|
89
|
void pointsVisible_data();
|
|
89
|
void pointsVisible_data();
|
|
90
|
|
|
90
|
|
|
91
|
private:
|
|
91
|
private:
|
|
92
|
QChartView* m_view;
|
|
92
|
QChartView* m_view;
|
|
93
|
QChart* m_chart;
|
|
93
|
QChart* m_chart;
|
|
94
|
QLineSeries* m_series;
|
|
94
|
QLineSeries* m_series;
|
|
95
|
};
|
|
95
|
};
|
|
96
|
|
|
96
|
|
|
97
|
void tst_QLineSeries::initTestCase()
|
|
97
|
void tst_QLineSeries::initTestCase()
|
|
98
|
{
|
|
98
|
{
|
|
99
|
}
|
|
99
|
}
|
|
100
|
|
|
100
|
|
|
101
|
void tst_QLineSeries::cleanupTestCase()
|
|
101
|
void tst_QLineSeries::cleanupTestCase()
|
|
102
|
{
|
|
102
|
{
|
|
103
|
}
|
|
103
|
}
|
|
104
|
|
|
104
|
|
|
105
|
void tst_QLineSeries::init()
|
|
105
|
void tst_QLineSeries::init()
|
|
106
|
{
|
|
106
|
{
|
|
107
|
m_view = new QChartView(new QChart());
|
|
107
|
m_view = new QChartView(new QChart());
|
|
108
|
m_chart = m_view->chart();
|
|
108
|
m_chart = m_view->chart();
|
|
109
|
m_series = new QLineSeries();
|
|
109
|
m_series = new QLineSeries();
|
|
110
|
}
|
|
110
|
}
|
|
111
|
|
|
111
|
|
|
112
|
void tst_QLineSeries::cleanup()
|
|
112
|
void tst_QLineSeries::cleanup()
|
|
113
|
{
|
|
113
|
{
|
|
114
|
delete m_series;
|
|
114
|
delete m_series;
|
|
115
|
delete m_view;
|
|
115
|
delete m_view;
|
|
116
|
m_view = 0;
|
|
116
|
m_view = 0;
|
|
117
|
m_chart = 0;
|
|
117
|
m_chart = 0;
|
|
118
|
m_series = 0;
|
|
118
|
m_series = 0;
|
|
119
|
}
|
|
119
|
}
|
|
120
|
|
|
120
|
|
|
121
|
void tst_QLineSeries::qlineseries_data()
|
|
121
|
void tst_QLineSeries::qlineseries_data()
|
|
122
|
{
|
|
122
|
{
|
|
123
|
|
|
123
|
|
|
124
|
}
|
|
124
|
}
|
|
125
|
|
|
125
|
|
|
126
|
void tst_QLineSeries::qlineseries()
|
|
126
|
void tst_QLineSeries::qlineseries()
|
|
127
|
{
|
|
127
|
{
|
|
128
|
// QLineSeries series;
|
|
128
|
// QLineSeries series;
|
|
129
|
|
|
129
|
|
|
130
|
// QCOMPARE(series.count(),0);
|
|
130
|
// QCOMPARE(series.count(),0);
|
|
131
|
// QCOMPARE(series.brush(), QBrush());
|
|
131
|
// QCOMPARE(series.brush(), QBrush());
|
|
132
|
// QCOMPARE(series.points(), QList<QPointF>());
|
|
132
|
// QCOMPARE(series.points(), QList<QPointF>());
|
|
133
|
// QCOMPARE(series.pen(), QPen());
|
|
133
|
// QCOMPARE(series.pen(), QPen());
|
|
134
|
// QCOMPARE(series.pointsVisible(), false);
|
|
134
|
// QCOMPARE(series.pointsVisible(), false);
|
|
135
|
|
|
135
|
|
|
136
|
// series.append(QList<QPointF>());
|
|
136
|
// series.append(QList<QPointF>());
|
|
137
|
// series.append(0.0,0.0);
|
|
137
|
// series.append(0.0,0.0);
|
|
138
|
// series.append(QPointF());
|
|
138
|
// series.append(QPointF());
|
|
139
|
|
|
139
|
|
|
140
|
// series.remove(0.0,0.0);
|
|
140
|
// series.remove(0.0,0.0);
|
|
141
|
// series.remove(QPointF());
|
|
141
|
// series.remove(QPointF());
|
|
142
|
// series.removeAll();
|
|
142
|
// series.removeAll();
|
|
143
|
|
|
143
|
|
|
144
|
// series.replace(QPointF(),QPointF());
|
|
144
|
// series.replace(QPointF(),QPointF());
|
|
145
|
// series.replace(0,0,0,0);
|
|
145
|
// series.replace(0,0,0,0);
|
|
146
|
// series.setBrush(QBrush());
|
|
146
|
// series.setBrush(QBrush());
|
|
147
|
|
|
147
|
|
|
148
|
// QCOMPARE(series.setModel((QAbstractItemModel*)0), false);
|
|
148
|
// QCOMPARE(series.setModel((QAbstractItemModel*)0), false);
|
|
149
|
|
|
149
|
|
|
150
|
// series.setModelMapping(-1, -1, Qt::Orientation(0));
|
|
150
|
// series.setModelMapping(-1, -1, Qt::Orientation(0));
|
|
151
|
|
|
151
|
|
|
152
|
// series.setPen(QPen());
|
|
152
|
// series.setPen(QPen());
|
|
153
|
// series.setPointsVisible(false);
|
|
153
|
// series.setPointsVisible(false);
|
|
154
|
|
|
154
|
|
|
155
|
// m_chart->addSeries(&series);
|
|
155
|
// m_chart->addSeries(&series);
|
|
156
|
// m_view->show();
|
|
156
|
// m_view->show();
|
|
157
|
// QTest::qWaitForWindowShown(m_view);
|
|
157
|
// QTest::qWaitForWindowShown(m_view);
|
|
158
|
}
|
|
158
|
}
|
|
159
|
|
|
159
|
|
|
160
|
void tst_QLineSeries::append_data()
|
|
160
|
void tst_QLineSeries::append_data()
|
|
161
|
{
|
|
161
|
{
|
|
162
|
QTest::addColumn< QList<QPointF> >("points");
|
|
162
|
QTest::addColumn< QList<QPointF> >("points");
|
|
163
|
QTest::newRow("0,0 1,1 2,2 3,3") << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3));
|
|
163
|
QTest::newRow("0,0 1,1 2,2 3,3") << (QList<QPointF>() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3));
|
|
164
|
QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3));
|
|
164
|
QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList<QPointF>() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3));
|
|
165
|
}
|
|
165
|
}
|
|
166
|
|
|
166
|
|
|
167
|
|
|
167
|
|
|
168
|
void tst_QLineSeries::append_raw_data()
|
|
168
|
void tst_QLineSeries::append_raw_data()
|
|
169
|
{
|
|
169
|
{
|
|
170
|
append_data();
|
|
170
|
append_data();
|
|
171
|
}
|
|
171
|
}
|
|
172
|
|
|
172
|
|
|
173
|
void tst_QLineSeries::append_raw()
|
|
173
|
void tst_QLineSeries::append_raw()
|
|
174
|
{
|
|
174
|
{
|
|
175
|
QFETCH(QList<QPointF>, points);
|
|
175
|
QFETCH(QList<QPointF>, points);
|
|
176
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
176
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
177
|
m_series->append(points);
|
|
177
|
m_series->append(points);
|
|
178
|
TRY_COMPARE(spy0.count(), 0);
|
|
178
|
TRY_COMPARE(spy0.count(), 0);
|
|
179
|
QCOMPARE(m_series->points(), points);
|
|
179
|
QCOMPARE(m_series->points(), points);
|
|
180
|
}
|
|
180
|
}
|
|
181
|
|
|
181
|
|
|
182
|
void tst_QLineSeries::chart_append_data()
|
|
182
|
void tst_QLineSeries::chart_append_data()
|
|
183
|
{
|
|
183
|
{
|
|
184
|
append_data();
|
|
184
|
append_data();
|
|
185
|
}
|
|
185
|
}
|
|
186
|
|
|
186
|
|
|
187
|
void tst_QLineSeries::chart_append()
|
|
187
|
void tst_QLineSeries::chart_append()
|
|
188
|
{
|
|
188
|
{
|
|
189
|
append_raw();
|
|
189
|
append_raw();
|
|
190
|
m_chart->addSeries(m_series);
|
|
190
|
m_chart->addSeries(m_series);
|
|
191
|
m_view->show();
|
|
191
|
m_view->show();
|
|
192
|
QTest::qWaitForWindowShown(m_view);
|
|
192
|
QTest::qWaitForWindowShown(m_view);
|
|
193
|
}
|
|
193
|
}
|
|
194
|
|
|
194
|
|
|
195
|
void tst_QLineSeries::append_chart_data()
|
|
195
|
void tst_QLineSeries::append_chart_data()
|
|
196
|
{
|
|
196
|
{
|
|
197
|
append_data();
|
|
197
|
append_data();
|
|
198
|
}
|
|
198
|
}
|
|
199
|
|
|
199
|
|
|
200
|
void tst_QLineSeries::append_chart()
|
|
200
|
void tst_QLineSeries::append_chart()
|
|
201
|
{
|
|
201
|
{
|
|
202
|
m_view->show();
|
|
202
|
m_view->show();
|
|
203
|
m_chart->addSeries(m_series);
|
|
203
|
m_chart->addSeries(m_series);
|
|
204
|
QTest::qWaitForWindowShown(m_view);
|
|
204
|
QTest::qWaitForWindowShown(m_view);
|
|
205
|
append_raw();
|
|
205
|
append_raw();
|
|
206
|
|
|
206
|
|
|
207
|
}
|
|
207
|
}
|
|
208
|
|
|
208
|
|
|
209
|
void tst_QLineSeries::append_chart_animation_data()
|
|
209
|
void tst_QLineSeries::append_chart_animation_data()
|
|
210
|
{
|
|
210
|
{
|
|
211
|
append_data();
|
|
211
|
append_data();
|
|
212
|
}
|
|
212
|
}
|
|
213
|
|
|
213
|
|
|
214
|
void tst_QLineSeries::append_chart_animation()
|
|
214
|
void tst_QLineSeries::append_chart_animation()
|
|
215
|
{
|
|
215
|
{
|
|
216
|
m_chart->setAnimationOptions(QChart::AllAnimations);
|
|
216
|
m_chart->setAnimationOptions(QChart::AllAnimations);
|
|
217
|
append_chart();
|
|
217
|
append_chart();
|
|
218
|
}
|
|
218
|
}
|
|
219
|
|
|
219
|
|
|
220
|
void tst_QLineSeries::count_data()
|
|
220
|
void tst_QLineSeries::count_data()
|
|
221
|
{
|
|
221
|
{
|
|
222
|
QTest::addColumn<int>("count");
|
|
222
|
QTest::addColumn<int>("count");
|
|
223
|
QTest::newRow("0") << 0;
|
|
223
|
QTest::newRow("0") << 0;
|
|
224
|
QTest::newRow("5") << 5;
|
|
224
|
QTest::newRow("5") << 5;
|
|
225
|
QTest::newRow("10") << 5;
|
|
225
|
QTest::newRow("10") << 5;
|
|
226
|
}
|
|
226
|
}
|
|
227
|
|
|
227
|
|
|
228
|
void tst_QLineSeries::count_raw_data()
|
|
228
|
void tst_QLineSeries::count_raw_data()
|
|
229
|
{
|
|
229
|
{
|
|
230
|
count_data();
|
|
230
|
count_data();
|
|
231
|
}
|
|
231
|
}
|
|
232
|
|
|
232
|
|
|
233
|
void tst_QLineSeries::count_raw()
|
|
233
|
void tst_QLineSeries::count_raw()
|
|
234
|
{
|
|
234
|
{
|
|
235
|
QFETCH(int, count);
|
|
235
|
QFETCH(int, count);
|
|
236
|
|
|
236
|
|
|
237
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
237
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
238
|
|
|
238
|
|
|
239
|
for(int i=0 ; i< count; ++i)
|
|
239
|
for(int i=0 ; i< count; ++i)
|
|
240
|
m_series->append(i,i);
|
|
240
|
m_series->append(i,i);
|
|
241
|
|
|
241
|
|
|
242
|
TRY_COMPARE(spy0.count(), 0);
|
|
242
|
TRY_COMPARE(spy0.count(), 0);
|
|
243
|
QCOMPARE(m_series->count(), count);
|
|
243
|
QCOMPARE(m_series->count(), count);
|
|
244
|
}
|
|
244
|
}
|
|
245
|
|
|
245
|
|
|
246
|
void tst_QLineSeries::oper_data()
|
|
246
|
void tst_QLineSeries::oper_data()
|
|
247
|
{
|
|
247
|
{
|
|
248
|
append_data();
|
|
248
|
append_data();
|
|
249
|
}
|
|
249
|
}
|
|
250
|
|
|
250
|
|
|
251
|
void tst_QLineSeries::oper()
|
|
251
|
void tst_QLineSeries::oper()
|
|
252
|
{
|
|
252
|
{
|
|
253
|
QFETCH(QList<QPointF>, points);
|
|
253
|
QFETCH(QList<QPointF>, points);
|
|
254
|
QLineSeries series;
|
|
254
|
QLineSeries series;
|
|
255
|
|
|
255
|
|
|
256
|
QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
|
|
256
|
QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
|
|
257
|
|
|
257
|
|
|
258
|
foreach(const QPointF& point,points)
|
|
258
|
foreach(const QPointF& point,points)
|
|
259
|
{
|
|
259
|
{
|
|
260
|
series<<point;
|
|
260
|
series<<point;
|
|
261
|
}
|
|
261
|
}
|
|
262
|
|
|
262
|
|
|
263
|
QCOMPARE(series.points(), points);
|
|
263
|
QCOMPARE(series.points(), points);
|
|
264
|
TRY_COMPARE(spy0.count(), 0);
|
|
264
|
TRY_COMPARE(spy0.count(), 0);
|
|
265
|
}
|
|
265
|
}
|
|
266
|
|
|
266
|
|
|
267
|
|
|
267
|
|
|
268
|
void tst_QLineSeries::pen_data()
|
|
268
|
void tst_QLineSeries::pen_data()
|
|
269
|
{
|
|
269
|
{
|
|
270
|
QTest::addColumn<QPen>("pen");
|
|
270
|
QTest::addColumn<QPen>("pen");
|
|
271
|
QTest::newRow("null") << QPen();
|
|
271
|
QTest::newRow("null") << QPen();
|
|
272
|
QTest::newRow("blue") << QPen(Qt::blue);
|
|
272
|
QTest::newRow("blue") << QPen(Qt::blue);
|
|
273
|
QTest::newRow("black") << QPen(Qt::black);
|
|
273
|
QTest::newRow("black") << QPen(Qt::black);
|
|
274
|
QTest::newRow("red") << QPen(Qt::red);
|
|
274
|
QTest::newRow("red") << QPen(Qt::red);
|
|
275
|
}
|
|
275
|
}
|
|
276
|
|
|
276
|
|
|
277
|
void tst_QLineSeries::pen()
|
|
277
|
void tst_QLineSeries::pen()
|
|
278
|
{
|
|
278
|
{
|
|
279
|
QFETCH(QPen, pen);
|
|
279
|
QFETCH(QPen, pen);
|
|
280
|
QLineSeries series;
|
|
280
|
QLineSeries series;
|
|
281
|
|
|
281
|
|
|
282
|
QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
|
|
282
|
QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&)));
|
|
283
|
series.setPen(pen);
|
|
283
|
series.setPen(pen);
|
|
284
|
|
|
284
|
|
|
285
|
TRY_COMPARE(spy0.count(), 0);
|
|
285
|
TRY_COMPARE(spy0.count(), 0);
|
|
286
|
QCOMPARE(series.pen(), pen);
|
|
286
|
QCOMPARE(series.pen(), pen);
|
|
287
|
|
|
287
|
|
|
288
|
m_chart->addSeries(&series);
|
|
288
|
m_chart->addSeries(&series);
|
|
289
|
|
|
289
|
|
|
290
|
if(pen!=QPen()) QCOMPARE(series.pen(), pen);
|
|
290
|
if(pen!=QPen()) QCOMPARE(series.pen(), pen);
|
|
291
|
|
|
291
|
|
|
292
|
m_chart->setTheme(QChart::ChartThemeDark);
|
|
292
|
m_chart->setTheme(QChart::ChartThemeDark);
|
|
293
|
|
|
293
|
|
|
294
|
if(pen!=QPen()) QCOMPARE(series.pen(), pen);
|
|
294
|
if(pen!=QPen()) QCOMPARE(series.pen(), pen);
|
|
295
|
}
|
|
295
|
}
|
|
296
|
|
|
296
|
|
|
297
|
void tst_QLineSeries::pointsVisible_data()
|
|
297
|
void tst_QLineSeries::pointsVisible_data()
|
|
298
|
{
|
|
298
|
{
|
|
299
|
QTest::addColumn<bool>("pointsVisible");
|
|
299
|
QTest::addColumn<bool>("pointsVisible");
|
|
300
|
QTest::newRow("true") << true;
|
|
300
|
QTest::newRow("true") << true;
|
|
301
|
QTest::newRow("false") << false;
|
|
301
|
QTest::newRow("false") << false;
|
|
302
|
}
|
|
302
|
}
|
|
303
|
|
|
303
|
|
|
304
|
void tst_QLineSeries::pointsVisible_raw_data()
|
|
304
|
void tst_QLineSeries::pointsVisible_raw_data()
|
|
305
|
{
|
|
305
|
{
|
|
306
|
pointsVisible_data();
|
|
306
|
pointsVisible_data();
|
|
307
|
}
|
|
307
|
}
|
|
308
|
|
|
308
|
|
|
309
|
void tst_QLineSeries::pointsVisible_raw()
|
|
309
|
void tst_QLineSeries::pointsVisible_raw()
|
|
310
|
{
|
|
310
|
{
|
|
311
|
QFETCH(bool, pointsVisible);
|
|
311
|
QFETCH(bool, pointsVisible);
|
|
312
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
312
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
313
|
m_series->setPointsVisible(pointsVisible);
|
|
313
|
m_series->setPointsVisible(pointsVisible);
|
|
314
|
TRY_COMPARE(spy0.count(), 0);
|
|
314
|
TRY_COMPARE(spy0.count(), 0);
|
|
315
|
QCOMPARE(m_series->pointsVisible(), pointsVisible);
|
|
315
|
QCOMPARE(m_series->pointsVisible(), pointsVisible);
|
|
316
|
}
|
|
316
|
}
|
|
317
|
|
|
317
|
|
|
318
|
void tst_QLineSeries::remove_raw_data()
|
|
318
|
void tst_QLineSeries::remove_raw_data()
|
|
319
|
{
|
|
319
|
{
|
|
320
|
append_data();
|
|
320
|
append_data();
|
|
321
|
}
|
|
321
|
}
|
|
322
|
|
|
322
|
|
|
323
|
void tst_QLineSeries::remove_raw()
|
|
323
|
void tst_QLineSeries::remove_raw()
|
|
324
|
{
|
|
324
|
{
|
|
325
|
QFETCH(QList<QPointF>, points);
|
|
325
|
QFETCH(QList<QPointF>, points);
|
|
326
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
326
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
327
|
m_series->append(points);
|
|
327
|
m_series->append(points);
|
|
328
|
TRY_COMPARE(spy0.count(), 0);
|
|
328
|
TRY_COMPARE(spy0.count(), 0);
|
|
329
|
QCOMPARE(m_series->points(), points);
|
|
329
|
QCOMPARE(m_series->points(), points);
|
|
330
|
|
|
330
|
|
|
331
|
foreach(const QPointF& point,points)
|
|
331
|
foreach(const QPointF& point,points)
|
|
332
|
m_series->remove(point);
|
|
332
|
m_series->remove(point);
|
|
333
|
|
|
333
|
|
|
334
|
TRY_COMPARE(spy0.count(), 0);
|
|
334
|
TRY_COMPARE(spy0.count(), 0);
|
|
335
|
QCOMPARE(m_series->points().count(), 0);
|
|
335
|
QCOMPARE(m_series->points().count(), 0);
|
|
336
|
}
|
|
336
|
}
|
|
337
|
|
|
337
|
|
|
338
|
void tst_QLineSeries::remove_chart_data()
|
|
338
|
void tst_QLineSeries::remove_chart_data()
|
|
339
|
{
|
|
339
|
{
|
|
340
|
append_data();
|
|
340
|
append_data();
|
|
341
|
}
|
|
341
|
}
|
|
342
|
|
|
342
|
|
|
343
|
void tst_QLineSeries::remove_chart()
|
|
343
|
void tst_QLineSeries::remove_chart()
|
|
344
|
{
|
|
344
|
{
|
|
345
|
m_view->show();
|
|
345
|
m_view->show();
|
|
346
|
m_chart->addSeries(m_series);
|
|
346
|
m_chart->addSeries(m_series);
|
|
347
|
QTest::qWaitForWindowShown(m_view);
|
|
347
|
QTest::qWaitForWindowShown(m_view);
|
|
348
|
remove_raw();
|
|
348
|
remove_raw();
|
|
349
|
}
|
|
349
|
}
|
|
350
|
|
|
350
|
|
|
351
|
void tst_QLineSeries::remove_chart_animation_data()
|
|
351
|
void tst_QLineSeries::remove_chart_animation_data()
|
|
352
|
{
|
|
352
|
{
|
|
353
|
append_data();
|
|
353
|
append_data();
|
|
354
|
}
|
|
354
|
}
|
|
355
|
|
|
355
|
|
|
356
|
void tst_QLineSeries::remove_chart_animation()
|
|
356
|
void tst_QLineSeries::remove_chart_animation()
|
|
357
|
{
|
|
357
|
{
|
|
358
|
m_chart->setAnimationOptions(QChart::AllAnimations);
|
|
358
|
m_chart->setAnimationOptions(QChart::AllAnimations);
|
|
359
|
remove_chart();
|
|
359
|
remove_chart();
|
|
360
|
}
|
|
360
|
}
|
|
361
|
|
|
361
|
|
|
362
|
|
|
362
|
|
|
363
|
void tst_QLineSeries::removeAll_raw_data()
|
|
363
|
void tst_QLineSeries::removeAll_raw_data()
|
|
364
|
{
|
|
364
|
{
|
|
365
|
append_data();
|
|
365
|
append_data();
|
|
366
|
}
|
|
366
|
}
|
|
367
|
|
|
367
|
|
|
368
|
void tst_QLineSeries::removeAll_raw()
|
|
368
|
void tst_QLineSeries::removeAll_raw()
|
|
369
|
{
|
|
369
|
{
|
|
370
|
QFETCH(QList<QPointF>, points);
|
|
370
|
QFETCH(QList<QPointF>, points);
|
|
371
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
371
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
372
|
m_series->append(points);
|
|
372
|
m_series->append(points);
|
|
373
|
TRY_COMPARE(spy0.count(), 0);
|
|
373
|
TRY_COMPARE(spy0.count(), 0);
|
|
374
|
QCOMPARE(m_series->points(), points);
|
|
374
|
QCOMPARE(m_series->points(), points);
|
|
375
|
m_series->removeAll();
|
|
375
|
m_series->removeAll();
|
|
376
|
TRY_COMPARE(spy0.count(), 0);
|
|
376
|
TRY_COMPARE(spy0.count(), 0);
|
|
377
|
QCOMPARE(m_series->points().count(), 0);
|
|
377
|
QCOMPARE(m_series->points().count(), 0);
|
|
378
|
}
|
|
378
|
}
|
|
379
|
|
|
379
|
|
|
380
|
void tst_QLineSeries::removeAll_chart_data()
|
|
380
|
void tst_QLineSeries::removeAll_chart_data()
|
|
381
|
{
|
|
381
|
{
|
|
382
|
append_data();
|
|
382
|
append_data();
|
|
383
|
}
|
|
383
|
}
|
|
384
|
|
|
384
|
|
|
385
|
void tst_QLineSeries::removeAll_chart()
|
|
385
|
void tst_QLineSeries::removeAll_chart()
|
|
386
|
{
|
|
386
|
{
|
|
387
|
m_view->show();
|
|
387
|
m_view->show();
|
|
388
|
m_chart->addSeries(m_series);
|
|
388
|
m_chart->addSeries(m_series);
|
|
389
|
QTest::qWaitForWindowShown(m_view);
|
|
389
|
QTest::qWaitForWindowShown(m_view);
|
|
390
|
removeAll_raw();
|
|
390
|
removeAll_raw();
|
|
391
|
}
|
|
391
|
}
|
|
392
|
|
|
392
|
|
|
393
|
void tst_QLineSeries::removeAll_chart_animation_data()
|
|
393
|
void tst_QLineSeries::removeAll_chart_animation_data()
|
|
394
|
{
|
|
394
|
{
|
|
395
|
append_data();
|
|
395
|
append_data();
|
|
396
|
}
|
|
396
|
}
|
|
397
|
|
|
397
|
|
|
398
|
void tst_QLineSeries::removeAll_chart_animation()
|
|
398
|
void tst_QLineSeries::removeAll_chart_animation()
|
|
399
|
{
|
|
399
|
{
|
|
400
|
m_chart->setAnimationOptions(QChart::AllAnimations);
|
|
400
|
m_chart->setAnimationOptions(QChart::AllAnimations);
|
|
401
|
removeAll_chart();
|
|
401
|
removeAll_chart();
|
|
402
|
}
|
|
402
|
}
|
|
403
|
|
|
403
|
|
|
404
|
void tst_QLineSeries::replace_raw_data()
|
|
404
|
void tst_QLineSeries::replace_raw_data()
|
|
405
|
{
|
|
405
|
{
|
|
406
|
append_data();
|
|
406
|
append_data();
|
|
407
|
}
|
|
407
|
}
|
|
408
|
|
|
408
|
|
|
409
|
void tst_QLineSeries::replace_raw()
|
|
409
|
void tst_QLineSeries::replace_raw()
|
|
410
|
{
|
|
410
|
{
|
|
411
|
QFETCH(QList<QPointF>, points);
|
|
411
|
QFETCH(QList<QPointF>, points);
|
|
412
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
412
|
QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&)));
|
|
413
|
m_series->append(points);
|
|
413
|
m_series->append(points);
|
|
414
|
TRY_COMPARE(spy0.count(), 0);
|
|
414
|
TRY_COMPARE(spy0.count(), 0);
|
|
415
|
QCOMPARE(m_series->points(), points);
|
|
415
|
QCOMPARE(m_series->points(), points);
|
|
416
|
|
|
416
|
|
|
417
|
foreach(const QPointF& point,points)
|
|
417
|
foreach(const QPointF& point,points)
|
|
418
|
m_series->replace(point.x(),point.y(),point.x(),0);
|
|
418
|
m_series->replace(point.x(),point.y(),point.x(),0);
|
|
419
|
|
|
419
|
|
|
420
|
QList<QPointF> newPoints = m_series->points();
|
|
420
|
QList<QPointF> newPoints = m_series->points();
|
|
421
|
|
|
421
|
|
|
422
|
QCOMPARE(newPoints.count(), points.count());
|
|
422
|
QCOMPARE(newPoints.count(), points.count());
|
|
423
|
|
|
423
|
|
|
424
|
for(int i =0 ; i<points.count() ; ++i) {
|
|
424
|
for(int i =0 ; i<points.count() ; ++i) {
|
|
425
|
QCOMPARE(points[i].x(), newPoints[i].x());
|
|
425
|
QCOMPARE(points[i].x(), newPoints[i].x());
|
|
426
|
QCOMPARE(newPoints[i].y(), 0.0);
|
|
426
|
QCOMPARE(newPoints[i].y(), 0.0);
|
|
427
|
}
|
|
427
|
}
|
|
428
|
}
|
|
428
|
}
|
|
429
|
|
|
429
|
|
|
430
|
|
|
430
|
|
|
431
|
void tst_QLineSeries::replace_chart_data()
|
|
431
|
void tst_QLineSeries::replace_chart_data()
|
|
432
|
{
|
|
432
|
{
|
|
433
|
append_data();
|
|
433
|
append_data();
|
|
434
|
}
|
|
434
|
}
|
|
435
|
|
|
435
|
|
|
436
|
void tst_QLineSeries::replace_chart()
|
|
436
|
void tst_QLineSeries::replace_chart()
|
|
437
|
{
|
|
437
|
{
|
|
438
|
m_view->show();
|
|
438
|
m_view->show();
|
|
439
|
m_chart->addSeries(m_series);
|
|
439
|
m_chart->addSeries(m_series);
|
|
440
|
QTest::qWaitForWindowShown(m_view);
|
|
440
|
QTest::qWaitForWindowShown(m_view);
|
|
441
|
replace_raw();
|
|
441
|
replace_raw();
|
|
442
|
}
|
|
442
|
}
|
|
443
|
|
|
443
|
|
|
444
|
void tst_QLineSeries::replace_chart_animation_data()
|
|
444
|
void tst_QLineSeries::replace_chart_animation_data()
|
|
445
|
{
|
|
445
|
{
|
|
446
|
append_data();
|
|
446
|
append_data();
|
|
447
|
}
|
|
447
|
}
|
|
448
|
|
|
448
|
|
|
449
|
void tst_QLineSeries::replace_chart_animation()
|
|
449
|
void tst_QLineSeries::replace_chart_animation()
|
|
450
|
{
|
|
450
|
{
|
|
451
|
m_chart->setAnimationOptions(QChart::AllAnimations);
|
|
451
|
m_chart->setAnimationOptions(QChart::AllAnimations);
|
|
452
|
replace_chart();
|
|
452
|
replace_chart();
|
|
453
|
}
|
|
453
|
}
|
|
454
|
|
|
454
|
|
|
455
|
void tst_QLineSeries::setModel_data()
|
|
455
|
void tst_QLineSeries::setModel_data()
|
|
456
|
{
|
|
456
|
{
|
|
457
|
|
|
457
|
|
|
458
|
}
|
|
458
|
}
|
|
459
|
|
|
459
|
|
|
460
|
void tst_QLineSeries::setModel()
|
|
460
|
void tst_QLineSeries::setModel()
|
|
461
|
{
|
|
461
|
{
|
|
462
|
QLineSeries series;
|
|
462
|
QLineSeries series;
|
|
463
|
series.setModel(0);
|
|
463
|
series.setModel(0);
|
|
464
|
QVERIFY2(series.model() == 0, "Model should be unset");
|
|
464
|
QVERIFY2(series.model() == 0, "Model should be unset");
|
|
465
|
|
|
465
|
|
|
466
|
QStandardItemModel *stdModel = new QStandardItemModel();
|
|
466
|
QStandardItemModel *stdModel = new QStandardItemModel();
|
|
467
|
series.setModel(stdModel);
|
|
467
|
series.setModel(stdModel);
|
|
468
|
QVERIFY2((series.model()) == stdModel, "Model should be stdModel");
|
|
468
|
QVERIFY2((series.model()) == stdModel, "Model should be stdModel");
|
|
469
|
|
|
469
|
|
|
470
|
// unset the model
|
|
470
|
// unset the model
|
|
471
|
series.setModel(0);
|
|
471
|
series.setModel(0);
|
|
472
|
QVERIFY2(series.model() == 0, "Model should be unset");
|
|
472
|
QVERIFY2(series.model() == 0, "Model should be unset");
|
|
473
|
|
|
473
|
|
|
474
|
}
|
|
474
|
}
|
|
475
|
|
|
475
|
|
|
476
|
Q_DECLARE_METATYPE(Qt::Orientation)
|
|
476
|
Q_DECLARE_METATYPE(Qt::Orientation)
|
|
477
|
void tst_QLineSeries::setModelMapping_data()
|
|
477
|
void tst_QLineSeries::setModelMapping_data()
|
|
478
|
{
|
|
478
|
{
|
|
479
|
QTest::addColumn<int>("modelX");
|
|
479
|
QTest::addColumn<int>("modelX");
|
|
480
|
QTest::addColumn<int>("modelY");
|
|
480
|
QTest::addColumn<int>("modelY");
|
|
481
|
QTest::addColumn<Qt::Orientation>("orientation");
|
|
481
|
QTest::addColumn<Qt::Orientation>("orientation");
|
|
482
|
QTest::newRow("different x and y, vertical") << 0 << 1 << Qt::Vertical;
|
|
482
|
QTest::newRow("different x and y, vertical") << 0 << 1 << Qt::Vertical;
|
|
483
|
QTest::newRow("same x and y, vertical") << 0 << 0 << Qt::Vertical;
|
|
483
|
QTest::newRow("same x and y, vertical") << 0 << 0 << Qt::Vertical;
|
|
484
|
QTest::newRow("invalid x, corrent y, vertical") << -1 << 1 << Qt::Vertical;
|
|
484
|
QTest::newRow("invalid x, corrent y, vertical") << -1 << 1 << Qt::Vertical;
|
|
485
|
|
|
485
|
|
|
486
|
QTest::newRow("different x and y, horizontal") << 0 << 1 << Qt::Horizontal;
|
|
486
|
QTest::newRow("different x and y, horizontal") << 0 << 1 << Qt::Horizontal;
|
|
487
|
QTest::newRow("same x and y, horizontal") << 0 << 0 << Qt::Horizontal;
|
|
487
|
QTest::newRow("same x and y, horizontal") << 0 << 0 << Qt::Horizontal;
|
|
488
|
QTest::newRow("invalid x, corrent y, horizontal") << -1 << 1 << Qt::Horizontal;
|
|
488
|
QTest::newRow("invalid x, corrent y, horizontal") << -1 << 1 << Qt::Horizontal;
|
|
489
|
}
|
|
489
|
}
|
|
490
|
|
|
490
|
|
|
491
|
void tst_QLineSeries::setModelMapping()
|
|
491
|
void tst_QLineSeries::setModelMapping()
|
|
492
|
{
|
|
492
|
{
|
|
493
|
QSKIP("Model mapping has been rewriten, test case needs update", SkipAll);
|
|
493
|
QSKIP("Model mapping has been rewriten, test case needs update", SkipAll);
|
|
494
|
|
|
494
|
|
|
495
|
QFETCH(int, modelX);
|
|
495
|
// QFETCH(int, modelX);
|
|
496
|
QFETCH(int, modelY);
|
|
496
|
// QFETCH(int, modelY);
|
|
497
|
QFETCH(Qt::Orientation, orientation);
|
|
497
|
// QFETCH(Qt::Orientation, orientation);
|
|
498
|
|
|
498
|
|
|
499
|
// QLineSeries series;
|
|
499
|
// QLineSeries series;
|
|
500
|
|
|
500
|
|
|
501
|
// // model has not been set so setting mapping should do nothing
|
|
501
|
// // model has not been set so setting mapping should do nothing
|
|
502
|
// series.setModelMapping(modelX, modelY, orientation);
|
|
502
|
// series.setModelMapping(modelX, modelY, orientation);
|
|
503
|
// QCOMPARE(series.mapX(), -1);
|
|
503
|
// QCOMPARE(series.mapX(), -1);
|
|
504
|
// QCOMPARE(series.mapY(), -1);
|
|
504
|
// QCOMPARE(series.mapY(), -1);
|
|
505
|
// QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical");
|
|
505
|
// QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical");
|
|
506
|
|
|
506
|
|
|
507
|
// // now let us set the model
|
|
507
|
// // now let us set the model
|
|
508
|
// series.setModel(new QStandardItemModel());
|
|
508
|
// series.setModel(new QStandardItemModel());
|
|
509
|
// series.setModelMapping(modelX, modelY, orientation);
|
|
509
|
// series.setModelMapping(modelX, modelY, orientation);
|
|
510
|
// QCOMPARE(series.mapX(), modelX);
|
|
510
|
// QCOMPARE(series.mapX(), modelX);
|
|
511
|
// QCOMPARE(series.mapY(), modelY);
|
|
511
|
// QCOMPARE(series.mapY(), modelY);
|
|
512
|
// QVERIFY2(series.mapOrientation() == orientation, "not good");
|
|
512
|
// QVERIFY2(series.mapOrientation() == orientation, "not good");
|
|
513
|
|
|
513
|
|
|
514
|
// // now let us remove the model, the values should go back to default ones.
|
|
514
|
// // now let us remove the model, the values should go back to default ones.
|
|
515
|
// series.setModel(0);
|
|
515
|
// series.setModel(0);
|
|
516
|
// QCOMPARE(series.mapX(), -1);
|
|
516
|
// QCOMPARE(series.mapX(), -1);
|
|
517
|
// QCOMPARE(series.mapY(), -1);
|
|
517
|
// QCOMPARE(series.mapY(), -1);
|
|
518
|
// QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical");
|
|
518
|
// QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical");
|
|
519
|
}
|
|
519
|
}
|
|
520
|
|
|
520
|
|
|
521
|
void tst_QLineSeries::setModelMappingRange_data()
|
|
521
|
void tst_QLineSeries::setModelMappingRange_data()
|
|
522
|
{
|
|
522
|
{
|
|
523
|
QTest::addColumn<int>("first");
|
|
523
|
QTest::addColumn<int>("first");
|
|
524
|
QTest::addColumn<int>("count");
|
|
524
|
QTest::addColumn<int>("count");
|
|
525
|
QTest::newRow("first: 0, count: unlimited") << 0 << -1;
|
|
525
|
QTest::newRow("first: 0, count: unlimited") << 0 << -1;
|
|
526
|
QTest::newRow("first: 0, count: 5") << 0 << 5;
|
|
526
|
QTest::newRow("first: 0, count: 5") << 0 << 5;
|
|
527
|
QTest::newRow("first: 3, count: unlimited") << 3 << -1;
|
|
527
|
QTest::newRow("first: 3, count: unlimited") << 3 << -1;
|
|
528
|
QTest::newRow("first: 3, count: 5") << 3 << 5;
|
|
528
|
QTest::newRow("first: 3, count: 5") << 3 << 5;
|
|
529
|
QTest::newRow("first: -3, count: 5") << -3 << 5;
|
|
529
|
QTest::newRow("first: -3, count: 5") << -3 << 5;
|
|
530
|
QTest::newRow("first: 3, count: -5") << 3 << -5;
|
|
530
|
QTest::newRow("first: 3, count: -5") << 3 << -5;
|
|
531
|
QTest::newRow("first: -3, count: -5") << 3 << -5;
|
|
531
|
QTest::newRow("first: -3, count: -5") << 3 << -5;
|
|
532
|
QTest::newRow("first: -3, count: 0") << -3 << 0;
|
|
532
|
QTest::newRow("first: -3, count: 0") << -3 << 0;
|
|
533
|
QTest::newRow("first: 0, count: -5") << 0 << -5;
|
|
533
|
QTest::newRow("first: 0, count: -5") << 0 << -5;
|
|
534
|
QTest::newRow("first: 0, count: 0") << 0 << 0;
|
|
534
|
QTest::newRow("first: 0, count: 0") << 0 << 0;
|
|
535
|
}
|
|
535
|
}
|
|
536
|
|
|
536
|
|
|
537
|
void tst_QLineSeries::setModelMappingRange()
|
|
537
|
void tst_QLineSeries::setModelMappingRange()
|
|
538
|
{
|
|
538
|
{
|
|
539
|
QSKIP("Model mapping has been rewriten, test case needs update", SkipAll);
|
|
539
|
QSKIP("Model mapping has been rewriten, test case needs update", SkipAll);
|
|
540
|
|
|
540
|
|
|
541
|
QFETCH(int, first);
|
|
541
|
// QFETCH(int, first);
|
|
542
|
QFETCH(int, count);
|
|
542
|
// QFETCH(int, count);
|
|
543
|
QLineSeries series;
|
|
543
|
// QLineSeries series;
|
|
544
|
|
|
544
|
|
|
545
|
QStandardItemModel *model = new QStandardItemModel(0, 2);
|
|
545
|
// QStandardItemModel *model = new QStandardItemModel(0, 2);
|
|
546
|
series.setModel(model);
|
|
546
|
// series.setModel(model);
|
|
547
|
// series.setModelMapping(0, 1);
|
|
547
|
// series.setModelMapping(0, 1);
|
|
548
|
// series.setModelMappingRange(first, count);
|
|
548
|
// series.setModelMappingRange(first, count);
|
|
549
|
|
|
549
|
|
|
550
|
// QCOMPARE(series.mapFirst(), qMax(first, 0)); // regardles of what value was used to set the range, first should not be less than 0
|
|
550
|
// QCOMPARE(series.mapFirst(), qMax(first, 0)); // regardles of what value was used to set the range, first should not be less than 0
|
|
551
|
// QCOMPARE(series.mapCount(), qMax(count, -1)); // regardles of what value was used to set the range, first should not be less than 0
|
|
551
|
// QCOMPARE(series.mapCount(), qMax(count, -1)); // regardles of what value was used to set the range, first should not be less than 0
|
|
552
|
// QVERIFY2(series.count() == 0, "No rows in the model, count should be 0");
|
|
552
|
// QVERIFY2(series.count() == 0, "No rows in the model, count should be 0");
|
|
553
|
|
|
553
|
|
|
554
|
// for (int row = 0; row < 3; ++row) {
|
|
554
|
// for (int row = 0; row < 3; ++row) {
|
|
555
|
// for (int column = 0; column < 2; column++) {
|
|
555
|
// for (int column = 0; column < 2; column++) {
|
|
556
|
// QStandardItem *item = new QStandardItem(row * column);
|
|
556
|
// QStandardItem *item = new QStandardItem(row * column);
|
|
557
|
// model->setItem(row, column, item);
|
|
557
|
// model->setItem(row, column, item);
|
|
558
|
// }
|
|
558
|
// }
|
|
559
|
// }
|
|
559
|
// }
|
|
560
|
// if (qMax(count, -1) != -1)
|
|
560
|
// if (qMax(count, -1) != -1)
|
|
561
|
// QVERIFY2(series.count() == qMin(model->rowCount() - qMax(first, 0), qMax(count, -1)), "Count should be the number of items in a model after first item, but not more than count and not less than 0");
|
|
561
|
// QVERIFY2(series.count() == qMin(model->rowCount() - qMax(first, 0), qMax(count, -1)), "Count should be the number of items in a model after first item, but not more than count and not less than 0");
|
|
562
|
// else
|
|
562
|
// else
|
|
563
|
// QVERIFY2(series.count() == model->rowCount() - qMax(first, 0), "Count should be the number of items in a model after first item, but not less then 0");
|
|
563
|
// QVERIFY2(series.count() == model->rowCount() - qMax(first, 0), "Count should be the number of items in a model after first item, but not less then 0");
|
|
564
|
|
|
564
|
|
|
565
|
// // let's add few more rows to the model
|
|
565
|
// // let's add few more rows to the model
|
|
566
|
// for (int row = 0; row < 10; ++row) {
|
|
566
|
// for (int row = 0; row < 10; ++row) {
|
|
567
|
// QList<QStandardItem *> newRow;
|
|
567
|
// QList<QStandardItem *> newRow;
|
|
568
|
// for (int column = 0; column < 2; column++) {
|
|
568
|
// for (int column = 0; column < 2; column++) {
|
|
569
|
// newRow.append(new QStandardItem(row * column));
|
|
569
|
// newRow.append(new QStandardItem(row * column));
|
|
570
|
// }
|
|
570
|
// }
|
|
571
|
// model->appendRow(newRow);
|
|
571
|
// model->appendRow(newRow);
|
|
572
|
// }
|
|
572
|
// }
|
|
573
|
// if (qMax(count, -1) != -1)
|
|
573
|
// if (qMax(count, -1) != -1)
|
|
574
|
// QVERIFY2(series.count() == qMin(model->rowCount() - qMax(first, 0), qMax(count, -1)), "Count should be the number of items in a model after first item, but not more than count, but not more than count and not less than 0");
|
|
574
|
// QVERIFY2(series.count() == qMin(model->rowCount() - qMax(first, 0), qMax(count, -1)), "Count should be the number of items in a model after first item, but not more than count, but not more than count and not less than 0");
|
|
575
|
// else
|
|
575
|
// else
|
|
576
|
// QVERIFY2(series.count() == model->rowCount() - qMax(first, 0), "Count should be the number of items in a model after first item, but not less then 0");
|
|
576
|
// QVERIFY2(series.count() == model->rowCount() - qMax(first, 0), "Count should be the number of items in a model after first item, but not less then 0");
|
|
577
|
|
|
577
|
|
|
578
|
// // unset the model, values should be default
|
|
578
|
// // unset the model, values should be default
|
|
579
|
// series.setModel(0);
|
|
579
|
// series.setModel(0);
|
|
580
|
// QCOMPARE(series.mapFirst(), 0);
|
|
580
|
// QCOMPARE(series.mapFirst(), 0);
|
|
581
|
// QCOMPARE(series.mapCount(), -1);
|
|
581
|
// QCOMPARE(series.mapCount(), -1);
|
|
582
|
// QVERIFY2(series.count() == 0, "No rows in the model, count should be 0");
|
|
582
|
// QVERIFY2(series.count() == 0, "No rows in the model, count should be 0");
|
|
583
|
}
|
|
583
|
}
|
|
584
|
|
|
584
|
|
|
585
|
void tst_QLineSeries::modelUpdated()
|
|
585
|
void tst_QLineSeries::modelUpdated()
|
|
586
|
{
|
|
586
|
{
|
|
587
|
QSKIP("Model mapping has been rewriten, test case needs update", SkipAll);
|
|
587
|
QSKIP("Model mapping has been rewriten, test case needs update", SkipAll);
|
|
588
|
|
|
588
|
|
|
589
|
// QStandardItemModel *model = new QStandardItemModel;
|
|
589
|
// QStandardItemModel *model = new QStandardItemModel;
|
|
590
|
// for (int row = 0; row < 10; ++row) {
|
|
590
|
// for (int row = 0; row < 10; ++row) {
|
|
591
|
// QList<QStandardItem *> newRow;
|
|
591
|
// QList<QStandardItem *> newRow;
|
|
592
|
// for (int column = 0; column < 2; column++) {
|
|
592
|
// for (int column = 0; column < 2; column++) {
|
|
593
|
// newRow.append(new QStandardItem(row * column));
|
|
593
|
// newRow.append(new QStandardItem(row * column));
|
|
594
|
// }
|
|
594
|
// }
|
|
595
|
// model->appendRow(newRow);
|
|
595
|
// model->appendRow(newRow);
|
|
596
|
// }
|
|
596
|
// }
|
|
597
|
|
|
597
|
|
|
598
|
// QLineSeries series;
|
|
598
|
// QLineSeries series;
|
|
599
|
// series.setModel(model);
|
|
599
|
// series.setModel(model);
|
|
600
|
// series.setModelMapping(0, 1);
|
|
600
|
// series.setModelMapping(0, 1);
|
|
601
|
|
|
601
|
|
|
602
|
// model->setData(model->index(3, 1), 34);
|
|
602
|
// model->setData(model->index(3, 1), 34);
|
|
603
|
// // check that the update data is correctly taken from the model
|
|
603
|
// // check that the update data is correctly taken from the model
|
|
604
|
// QVERIFY(qFuzzyCompare(series.points().at(3).y(), 34));
|
|
604
|
// QVERIFY(qFuzzyCompare(series.points().at(3).y(), 34));
|
|
605
|
}
|
|
605
|
}
|
|
606
|
|
|
606
|
|
|
607
|
void tst_QLineSeries::modelUpdatedCustomMapping()
|
|
607
|
void tst_QLineSeries::modelUpdatedCustomMapping()
|
|
608
|
{
|
|
608
|
{
|
|
609
|
QSKIP("Model mapping has been rewriten, test case needs update", SkipAll);
|
|
609
|
QSKIP("Model mapping has been rewriten, test case needs update", SkipAll);
|
|
610
|
// QStandardItemModel *model = new QStandardItemModel;
|
|
610
|
// QStandardItemModel *model = new QStandardItemModel;
|
|
611
|
// for (int row = 0; row < 10; ++row) {
|
|
611
|
// for (int row = 0; row < 10; ++row) {
|
|
612
|
// QList<QStandardItem *> newRow;
|
|
612
|
// QList<QStandardItem *> newRow;
|
|
613
|
// for (int column = 0; column < 2; column++) {
|
|
613
|
// for (int column = 0; column < 2; column++) {
|
|
614
|
// newRow.append(new QStandardItem(row * column));
|
|
614
|
// newRow.append(new QStandardItem(row * column));
|
|
615
|
// }
|
|
615
|
// }
|
|
616
|
// model->appendRow(newRow);
|
|
616
|
// model->appendRow(newRow);
|
|
617
|
// }
|
|
617
|
// }
|
|
618
|
|
|
618
|
|
|
619
|
// QLineSeries series;
|
|
619
|
// QLineSeries series;
|
|
620
|
// series.setModel(model);
|
|
620
|
// series.setModel(model);
|
|
621
|
// series.setModelMapping(0, 1);
|
|
621
|
// series.setModelMapping(0, 1);
|
|
622
|
// series.setModelMappingRange(3, 4);
|
|
622
|
// series.setModelMappingRange(3, 4);
|
|
623
|
|
|
623
|
|
|
624
|
// model->setData(model->index(3, 1), 34);
|
|
624
|
// model->setData(model->index(3, 1), 34);
|
|
625
|
// QVERIFY(qFuzzyCompare(series.points().at(0).y(), 34));
|
|
625
|
// QVERIFY(qFuzzyCompare(series.points().at(0).y(), 34));
|
|
626
|
}
|
|
626
|
}
|
|
627
|
|
|
627
|
|
|
628
|
QTEST_MAIN(tst_QLineSeries)
|
|
628
|
QTEST_MAIN(tst_QLineSeries)
|
|
629
|
|
|
629
|
|
|
630
|
#include "tst_qlineseries.moc"
|
|
630
|
#include "tst_qlineseries.moc"
|
|
631
|
|
|
631
|
|