@@ -1,570 +1,570 | |||||
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 <qchartaxis.h> |
|
22 | #include <qchartaxis.h> | |
23 | #include <qlineseries.h> |
|
23 | #include <qlineseries.h> | |
24 | #include <private/chartdataset_p.h> |
|
24 | #include <private/chartdataset_p.h> | |
25 | #include <private/domain_p.h> |
|
25 | #include <private/domain_p.h> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
28 | |||
29 | Q_DECLARE_METATYPE(Domain *) |
|
29 | Q_DECLARE_METATYPE(Domain *) | |
30 | Q_DECLARE_METATYPE(QChartAxis *) |
|
30 | Q_DECLARE_METATYPE(QChartAxis *) | |
31 | Q_DECLARE_METATYPE(QAbstractSeries *) |
|
31 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
32 | Q_DECLARE_METATYPE(QLineSeries *) |
|
32 | Q_DECLARE_METATYPE(QLineSeries *) | |
33 |
|
33 | |||
34 | class tst_ChartDataSet: public QObject { |
|
34 | class tst_ChartDataSet: public QObject { | |
35 |
|
35 | |||
36 | Q_OBJECT |
|
36 | Q_OBJECT | |
37 |
|
37 | |||
38 | public Q_SLOTS: |
|
38 | public Q_SLOTS: | |
39 | void initTestCase(); |
|
39 | void initTestCase(); | |
40 | void cleanupTestCase(); |
|
40 | void cleanupTestCase(); | |
41 | void init(); |
|
41 | void init(); | |
42 | void cleanup(); |
|
42 | void cleanup(); | |
43 |
|
43 | |||
44 | private Q_SLOTS: |
|
44 | private Q_SLOTS: | |
45 | void chartdataset_data(); |
|
45 | void chartdataset_data(); | |
46 | void chartdataset(); |
|
46 | void chartdataset(); | |
47 | void addSeries_data(); |
|
47 | void addSeries_data(); | |
48 | void addSeries(); |
|
48 | void addSeries(); | |
49 | void removeSeries_data(); |
|
49 | void removeSeries_data(); | |
50 | void removeSeries(); |
|
50 | void removeSeries(); | |
51 | void removeAllSeries_data(); |
|
51 | void removeAllSeries_data(); | |
52 | void removeAllSeries(); |
|
52 | void removeAllSeries(); | |
53 | void axisY_data(); |
|
53 | void axisY_data(); | |
54 | void axisY(); |
|
54 | void axisY(); | |
55 | void seriesCount_data(); |
|
55 | void seriesCount_data(); | |
56 | void seriesCount(); |
|
56 | void seriesCount(); | |
57 | void seriesIndex_data(); |
|
57 | void seriesIndex_data(); | |
58 | void seriesIndex(); |
|
58 | void seriesIndex(); | |
59 | void domain_data(); |
|
59 | void domain_data(); | |
60 | void domain(); |
|
60 | void domain(); | |
61 | void zoomInDomain_data(); |
|
61 | void zoomInDomain_data(); | |
62 | void zoomInDomain(); |
|
62 | void zoomInDomain(); | |
63 | void zoomOutDomain_data(); |
|
63 | void zoomOutDomain_data(); | |
64 | void zoomOutDomain(); |
|
64 | void zoomOutDomain(); | |
65 | void scrollDomain_data(); |
|
65 | void scrollDomain_data(); | |
66 | void scrollDomain(); |
|
66 | void scrollDomain(); | |
67 | }; |
|
67 | }; | |
68 |
|
68 | |||
69 | void tst_ChartDataSet::initTestCase() |
|
69 | void tst_ChartDataSet::initTestCase() | |
70 | { |
|
70 | { | |
71 | qRegisterMetaType<Domain*>(); |
|
71 | qRegisterMetaType<Domain*>(); | |
72 | qRegisterMetaType<QChartAxis*>(); |
|
72 | qRegisterMetaType<QChartAxis*>(); | |
73 |
|
|
73 | qRegisterMetaType<QAbstractSeries*>(); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | void tst_ChartDataSet::cleanupTestCase() |
|
76 | void tst_ChartDataSet::cleanupTestCase() | |
77 | { |
|
77 | { | |
78 | } |
|
78 | } | |
79 |
|
79 | |||
80 | void tst_ChartDataSet::init() |
|
80 | void tst_ChartDataSet::init() | |
81 | { |
|
81 | { | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void tst_ChartDataSet::cleanup() |
|
84 | void tst_ChartDataSet::cleanup() | |
85 | { |
|
85 | { | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void tst_ChartDataSet::chartdataset_data() |
|
88 | void tst_ChartDataSet::chartdataset_data() | |
89 | { |
|
89 | { | |
90 | } |
|
90 | } | |
91 |
|
91 | |||
92 | void tst_ChartDataSet::chartdataset() |
|
92 | void tst_ChartDataSet::chartdataset() | |
93 | { |
|
93 | { | |
94 | ChartDataSet dataSet; |
|
94 | ChartDataSet dataSet; | |
95 | QVERIFY2(dataSet.axisX(), "Missing axisX."); |
|
95 | QVERIFY2(dataSet.axisX(), "Missing axisX."); | |
96 | QVERIFY2(dataSet.axisY(), "Missing axisY."); |
|
96 | QVERIFY2(dataSet.axisY(), "Missing axisY."); | |
97 | //check if not dangling pointer |
|
97 | //check if not dangling pointer | |
98 | dataSet.axisX()->objectName(); |
|
98 | dataSet.axisX()->objectName(); | |
99 | dataSet.axisY()->objectName(); |
|
99 | dataSet.axisY()->objectName(); | |
100 | QLineSeries* series = new QLineSeries(this); |
|
100 | QLineSeries* series = new QLineSeries(this); | |
101 | QCOMPARE(dataSet.seriesIndex(series),-1); |
|
101 | QCOMPARE(dataSet.seriesIndex(series),-1); | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | void tst_ChartDataSet::addSeries_data() |
|
104 | void tst_ChartDataSet::addSeries_data() | |
105 | { |
|
105 | { | |
106 | QTest::addColumn<QLineSeries*>("series0"); |
|
106 | QTest::addColumn<QLineSeries*>("series0"); | |
107 | QTest::addColumn<QChartAxis*>("axis0"); |
|
107 | QTest::addColumn<QChartAxis*>("axis0"); | |
108 | QTest::addColumn<QLineSeries*>("series1"); |
|
108 | QTest::addColumn<QLineSeries*>("series1"); | |
109 | QTest::addColumn<QChartAxis*>("axis1"); |
|
109 | QTest::addColumn<QChartAxis*>("axis1"); | |
110 | QTest::addColumn<QLineSeries*>("series2"); |
|
110 | QTest::addColumn<QLineSeries*>("series2"); | |
111 | QTest::addColumn<QChartAxis*>("axis2"); |
|
111 | QTest::addColumn<QChartAxis*>("axis2"); | |
112 | QTest::addColumn<int>("axisCount"); |
|
112 | QTest::addColumn<int>("axisCount"); | |
113 |
|
113 | |||
114 | QLineSeries* series0 = new QLineSeries(this); |
|
114 | QLineSeries* series0 = new QLineSeries(this); | |
115 | QLineSeries* series1 = new QLineSeries(this); |
|
115 | QLineSeries* series1 = new QLineSeries(this); | |
116 | QLineSeries* series2 = new QLineSeries(this); |
|
116 | QLineSeries* series2 = new QLineSeries(this); | |
117 |
|
117 | |||
118 | QChartAxis* axis0 = new QChartAxis(this); |
|
118 | QChartAxis* axis0 = new QChartAxis(this); | |
119 | QChartAxis* axis1 = new QChartAxis(this); |
|
119 | QChartAxis* axis1 = new QChartAxis(this); | |
120 | QChartAxis* axis2 = new QChartAxis(this); |
|
120 | QChartAxis* axis2 = new QChartAxis(this); | |
121 |
|
121 | |||
122 | QTest::newRow("default axis Y: series0,series1,series2") << series0 << (QChartAxis*)0 << series1 << (QChartAxis*)0 << series2 << (QChartAxis*)0 << 2; |
|
122 | QTest::newRow("default axis Y: series0,series1,series2") << series0 << (QChartAxis*)0 << series1 << (QChartAxis*)0 << series2 << (QChartAxis*)0 << 2; | |
123 | QTest::newRow("default axis Y: series0, axis 0: series1,series2") << series0 << (QChartAxis*)0 << series1 << axis0 << series2 << axis0 << 3; |
|
123 | QTest::newRow("default axis Y: series0, axis 0: series1,series2") << series0 << (QChartAxis*)0 << series1 << axis0 << series2 << axis0 << 3; | |
124 | QTest::newRow("axis0: series0, axis1: series1, axis2: series2") << series0 << axis0 << series1 << axis1 << series2 << axis2 << 4; |
|
124 | QTest::newRow("axis0: series0, axis1: series1, axis2: series2") << series0 << axis0 << series1 << axis1 << series2 << axis2 << 4; | |
125 | } |
|
125 | } | |
126 |
|
126 | |||
127 | void tst_ChartDataSet::addSeries() |
|
127 | void tst_ChartDataSet::addSeries() | |
128 | { |
|
128 | { | |
129 | QFETCH(QLineSeries*, series0); |
|
129 | QFETCH(QLineSeries*, series0); | |
130 | QFETCH(QChartAxis*, axis0); |
|
130 | QFETCH(QChartAxis*, axis0); | |
131 | QFETCH(QLineSeries*, series1); |
|
131 | QFETCH(QLineSeries*, series1); | |
132 | QFETCH(QChartAxis*, axis1); |
|
132 | QFETCH(QChartAxis*, axis1); | |
133 | QFETCH(QLineSeries*, series2); |
|
133 | QFETCH(QLineSeries*, series2); | |
134 | QFETCH(QChartAxis*, axis2); |
|
134 | QFETCH(QChartAxis*, axis2); | |
135 | QFETCH(int, axisCount); |
|
135 | QFETCH(int, axisCount); | |
136 |
|
136 | |||
137 | ChartDataSet dataSet; |
|
137 | ChartDataSet dataSet; | |
138 |
|
138 | |||
139 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); |
|
139 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); | |
140 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); |
|
140 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); | |
141 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); |
|
141 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); | |
142 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
142 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
143 |
|
143 | |||
144 | dataSet.addSeries(series0,axis0); |
|
144 | dataSet.addSeries(series0,axis0); | |
145 | dataSet.addSeries(series1,axis1); |
|
145 | dataSet.addSeries(series1,axis1); | |
146 | dataSet.addSeries(series2,axis2); |
|
146 | dataSet.addSeries(series2,axis2); | |
147 |
|
147 | |||
148 | QCOMPARE(spy0.count(), axisCount); |
|
148 | QCOMPARE(spy0.count(), axisCount); | |
149 | QCOMPARE(spy1.count(), 0); |
|
149 | QCOMPARE(spy1.count(), 0); | |
150 | QCOMPARE(spy2.count(), 3); |
|
150 | QCOMPARE(spy2.count(), 3); | |
151 | QCOMPARE(spy3.count(), 0); |
|
151 | QCOMPARE(spy3.count(), 0); | |
152 |
|
152 | |||
153 | if(axis0==0) axis0 = dataSet.axisY(); |
|
153 | if(axis0==0) axis0 = dataSet.axisY(); | |
154 | if(axis1==0) axis1 = dataSet.axisY(); |
|
154 | if(axis1==0) axis1 = dataSet.axisY(); | |
155 | if(axis2==0) axis2 = dataSet.axisY(); |
|
155 | if(axis2==0) axis2 = dataSet.axisY(); | |
156 |
|
156 | |||
157 | QVERIFY(axis0 == dataSet.removeSeries(series0)); |
|
157 | QVERIFY(axis0 == dataSet.removeSeries(series0)); | |
158 | QVERIFY(axis1 == dataSet.removeSeries(series1)); |
|
158 | QVERIFY(axis1 == dataSet.removeSeries(series1)); | |
159 | QVERIFY(axis2 == dataSet.removeSeries(series2)); |
|
159 | QVERIFY(axis2 == dataSet.removeSeries(series2)); | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | void tst_ChartDataSet::removeSeries_data() |
|
162 | void tst_ChartDataSet::removeSeries_data() | |
163 | { |
|
163 | { | |
164 | addSeries_data(); |
|
164 | addSeries_data(); | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | void tst_ChartDataSet::removeSeries() |
|
167 | void tst_ChartDataSet::removeSeries() | |
168 | { |
|
168 | { | |
169 | QFETCH(QLineSeries*, series0); |
|
169 | QFETCH(QLineSeries*, series0); | |
170 | QFETCH(QChartAxis*, axis0); |
|
170 | QFETCH(QChartAxis*, axis0); | |
171 | QFETCH(QLineSeries*, series1); |
|
171 | QFETCH(QLineSeries*, series1); | |
172 | QFETCH(QChartAxis*, axis1); |
|
172 | QFETCH(QChartAxis*, axis1); | |
173 | QFETCH(QLineSeries*, series2); |
|
173 | QFETCH(QLineSeries*, series2); | |
174 | QFETCH(QChartAxis*, axis2); |
|
174 | QFETCH(QChartAxis*, axis2); | |
175 | QFETCH(int, axisCount); |
|
175 | QFETCH(int, axisCount); | |
176 |
|
176 | |||
177 | ChartDataSet dataSet; |
|
177 | ChartDataSet dataSet; | |
178 |
|
178 | |||
179 | dataSet.addSeries(series0,axis0); |
|
179 | dataSet.addSeries(series0,axis0); | |
180 | dataSet.addSeries(series1,axis1); |
|
180 | dataSet.addSeries(series1,axis1); | |
181 | dataSet.addSeries(series2,axis2); |
|
181 | dataSet.addSeries(series2,axis2); | |
182 |
|
182 | |||
183 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); |
|
183 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); | |
184 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); |
|
184 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); | |
185 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); |
|
185 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
186 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
186 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
187 |
|
187 | |||
188 | dataSet.removeSeries(series0); |
|
188 | dataSet.removeSeries(series0); | |
189 | dataSet.removeSeries(series1); |
|
189 | dataSet.removeSeries(series1); | |
190 | dataSet.removeSeries(series2); |
|
190 | dataSet.removeSeries(series2); | |
191 |
|
191 | |||
192 | QCOMPARE(spy0.count(), 0); |
|
192 | QCOMPARE(spy0.count(), 0); | |
193 | QCOMPARE(spy1.count(), axisCount); |
|
193 | QCOMPARE(spy1.count(), axisCount); | |
194 | QCOMPARE(spy2.count(), 0); |
|
194 | QCOMPARE(spy2.count(), 0); | |
195 | QCOMPARE(spy3.count(), 3); |
|
195 | QCOMPARE(spy3.count(), 3); | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | void tst_ChartDataSet::removeAllSeries_data() |
|
198 | void tst_ChartDataSet::removeAllSeries_data() | |
199 | { |
|
199 | { | |
200 |
|
200 | |||
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | void tst_ChartDataSet::removeAllSeries() |
|
203 | void tst_ChartDataSet::removeAllSeries() | |
204 | { |
|
204 | { | |
205 | QLineSeries* series0 = new QLineSeries(this); |
|
205 | QLineSeries* series0 = new QLineSeries(this); | |
206 | QLineSeries* series1 = new QLineSeries(this); |
|
206 | QLineSeries* series1 = new QLineSeries(this); | |
207 | QLineSeries* series2 = new QLineSeries(this); |
|
207 | QLineSeries* series2 = new QLineSeries(this); | |
208 |
|
208 | |||
209 | QChartAxis* axis0 = new QChartAxis(this); |
|
209 | QChartAxis* axis0 = new QChartAxis(this); | |
210 | QChartAxis* axis1 = new QChartAxis(this); |
|
210 | QChartAxis* axis1 = new QChartAxis(this); | |
211 | QChartAxis* axis2 = new QChartAxis(this); |
|
211 | QChartAxis* axis2 = new QChartAxis(this); | |
212 |
|
212 | |||
213 |
|
213 | |||
214 | ChartDataSet dataSet; |
|
214 | ChartDataSet dataSet; | |
215 |
|
215 | |||
216 | dataSet.addSeries(series0, axis0); |
|
216 | dataSet.addSeries(series0, axis0); | |
217 | dataSet.addSeries(series1, axis1); |
|
217 | dataSet.addSeries(series1, axis1); | |
218 | dataSet.addSeries(series2, axis2); |
|
218 | dataSet.addSeries(series2, axis2); | |
219 |
|
219 | |||
220 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); |
|
220 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); | |
221 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); |
|
221 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); | |
222 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); |
|
222 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
223 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
223 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
224 |
|
224 | |||
225 | dataSet.removeAllSeries(); |
|
225 | dataSet.removeAllSeries(); | |
226 |
|
226 | |||
227 | QCOMPARE(spy0.count(), 0); |
|
227 | QCOMPARE(spy0.count(), 0); | |
228 | QCOMPARE(spy1.count(), 4); |
|
228 | QCOMPARE(spy1.count(), 4); | |
229 | QCOMPARE(spy2.count(), 0); |
|
229 | QCOMPARE(spy2.count(), 0); | |
230 | QCOMPARE(spy3.count(), 3); |
|
230 | QCOMPARE(spy3.count(), 3); | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 |
|
233 | |||
234 | void tst_ChartDataSet::axisY_data() |
|
234 | void tst_ChartDataSet::axisY_data() | |
235 | { |
|
235 | { | |
236 | QTest::addColumn<QChartAxis*>("axis0"); |
|
236 | QTest::addColumn<QChartAxis*>("axis0"); | |
237 | QTest::addColumn<QChartAxis*>("axis1"); |
|
237 | QTest::addColumn<QChartAxis*>("axis1"); | |
238 | QTest::addColumn<QChartAxis*>("axis2"); |
|
238 | QTest::addColumn<QChartAxis*>("axis2"); | |
239 | QTest::newRow("1 defualt, 2 optional") << (QChartAxis*)0 << new QChartAxis() << new QChartAxis(); |
|
239 | QTest::newRow("1 defualt, 2 optional") << (QChartAxis*)0 << new QChartAxis() << new QChartAxis(); | |
240 | QTest::newRow("3 optional") << new QChartAxis() << new QChartAxis() << new QChartAxis(); |
|
240 | QTest::newRow("3 optional") << new QChartAxis() << new QChartAxis() << new QChartAxis(); | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | void tst_ChartDataSet::axisY() |
|
243 | void tst_ChartDataSet::axisY() | |
244 | { |
|
244 | { | |
245 | QFETCH(QChartAxis*, axis0); |
|
245 | QFETCH(QChartAxis*, axis0); | |
246 | QFETCH(QChartAxis*, axis1); |
|
246 | QFETCH(QChartAxis*, axis1); | |
247 | QFETCH(QChartAxis*, axis2); |
|
247 | QFETCH(QChartAxis*, axis2); | |
248 |
|
248 | |||
249 | ChartDataSet dataSet; |
|
249 | ChartDataSet dataSet; | |
250 |
|
250 | |||
251 | QChartAxis* defaultAxisY = dataSet.axisY(); |
|
251 | QChartAxis* defaultAxisY = dataSet.axisY(); | |
252 |
|
252 | |||
253 | QVERIFY2(defaultAxisY, "Missing axisY."); |
|
253 | QVERIFY2(defaultAxisY, "Missing axisY."); | |
254 |
|
254 | |||
255 | QLineSeries* series0 = new QLineSeries(); |
|
255 | QLineSeries* series0 = new QLineSeries(); | |
256 | dataSet.addSeries(series0,axis0); |
|
256 | dataSet.addSeries(series0,axis0); | |
257 |
|
257 | |||
258 | QLineSeries* series1 = new QLineSeries(); |
|
258 | QLineSeries* series1 = new QLineSeries(); | |
259 | dataSet.addSeries(series1,axis1); |
|
259 | dataSet.addSeries(series1,axis1); | |
260 |
|
260 | |||
261 | QLineSeries* series2 = new QLineSeries(); |
|
261 | QLineSeries* series2 = new QLineSeries(); | |
262 | dataSet.addSeries(series2,axis2); |
|
262 | dataSet.addSeries(series2,axis2); | |
263 |
|
263 | |||
264 | if(!axis0) axis0=defaultAxisY ; |
|
264 | if(!axis0) axis0=defaultAxisY ; | |
265 | if(!axis1) axis1=defaultAxisY ; |
|
265 | if(!axis1) axis1=defaultAxisY ; | |
266 | if(!axis2) axis2=defaultAxisY ; |
|
266 | if(!axis2) axis2=defaultAxisY ; | |
267 |
|
267 | |||
268 | QVERIFY(dataSet.axisY(series0) == axis0); |
|
268 | QVERIFY(dataSet.axisY(series0) == axis0); | |
269 | QVERIFY(dataSet.axisY(series1) == axis1); |
|
269 | QVERIFY(dataSet.axisY(series1) == axis1); | |
270 | QVERIFY(dataSet.axisY(series2) == axis2); |
|
270 | QVERIFY(dataSet.axisY(series2) == axis2); | |
271 |
|
271 | |||
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | void tst_ChartDataSet::seriesCount_data() |
|
274 | void tst_ChartDataSet::seriesCount_data() | |
275 | { |
|
275 | { | |
276 | addSeries_data(); |
|
276 | addSeries_data(); | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
279 | void tst_ChartDataSet::seriesCount() |
|
279 | void tst_ChartDataSet::seriesCount() | |
280 | { |
|
280 | { | |
281 | QFETCH(QLineSeries*, series0); |
|
281 | QFETCH(QLineSeries*, series0); | |
282 | QFETCH(QChartAxis*, axis0); |
|
282 | QFETCH(QChartAxis*, axis0); | |
283 | QFETCH(QLineSeries*, series1); |
|
283 | QFETCH(QLineSeries*, series1); | |
284 | QFETCH(QChartAxis*, axis1); |
|
284 | QFETCH(QChartAxis*, axis1); | |
285 | QFETCH(QLineSeries*, series2); |
|
285 | QFETCH(QLineSeries*, series2); | |
286 | QFETCH(QChartAxis*, axis2); |
|
286 | QFETCH(QChartAxis*, axis2); | |
287 | QFETCH(int, axisCount); |
|
287 | QFETCH(int, axisCount); | |
288 | Q_UNUSED(axisCount); |
|
288 | Q_UNUSED(axisCount); | |
289 |
|
289 | |||
290 | ChartDataSet dataSet; |
|
290 | ChartDataSet dataSet; | |
291 |
|
291 | |||
292 | dataSet.addSeries(series0, axis0); |
|
292 | dataSet.addSeries(series0, axis0); | |
293 | dataSet.addSeries(series1, axis1); |
|
293 | dataSet.addSeries(series1, axis1); | |
294 | dataSet.addSeries(series2, axis2); |
|
294 | dataSet.addSeries(series2, axis2); | |
295 |
|
295 | |||
296 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); |
|
296 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); | |
297 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); |
|
297 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); | |
298 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); |
|
298 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
299 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
299 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
300 |
|
300 | |||
301 | QCOMPARE(dataSet.seriesCount(series0->type()),3); |
|
301 | QCOMPARE(dataSet.seriesCount(series0->type()),3); | |
302 | QCOMPARE(spy0.count(), 0); |
|
302 | QCOMPARE(spy0.count(), 0); | |
303 | QCOMPARE(spy1.count(), 0); |
|
303 | QCOMPARE(spy1.count(), 0); | |
304 | QCOMPARE(spy2.count(), 0); |
|
304 | QCOMPARE(spy2.count(), 0); | |
305 | QCOMPARE(spy3.count(), 0); |
|
305 | QCOMPARE(spy3.count(), 0); | |
306 |
|
306 | |||
307 | dataSet.removeSeries(series0); |
|
307 | dataSet.removeSeries(series0); | |
308 | dataSet.removeSeries(series1); |
|
308 | dataSet.removeSeries(series1); | |
309 | dataSet.removeSeries(series2); |
|
309 | dataSet.removeSeries(series2); | |
310 | } |
|
310 | } | |
311 |
|
311 | |||
312 | void tst_ChartDataSet::seriesIndex_data() |
|
312 | void tst_ChartDataSet::seriesIndex_data() | |
313 | { |
|
313 | { | |
314 | addSeries_data(); |
|
314 | addSeries_data(); | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | void tst_ChartDataSet::seriesIndex() |
|
317 | void tst_ChartDataSet::seriesIndex() | |
318 | { |
|
318 | { | |
319 | //TODO: rewrite this series_index_data to match better |
|
319 | //TODO: rewrite this series_index_data to match better | |
320 |
|
320 | |||
321 | QFETCH(QLineSeries*, series0); |
|
321 | QFETCH(QLineSeries*, series0); | |
322 | QFETCH(QChartAxis*, axis0); |
|
322 | QFETCH(QChartAxis*, axis0); | |
323 | QFETCH(QLineSeries*, series1); |
|
323 | QFETCH(QLineSeries*, series1); | |
324 | QFETCH(QChartAxis*, axis1); |
|
324 | QFETCH(QChartAxis*, axis1); | |
325 | QFETCH(QLineSeries*, series2); |
|
325 | QFETCH(QLineSeries*, series2); | |
326 | QFETCH(QChartAxis*, axis2); |
|
326 | QFETCH(QChartAxis*, axis2); | |
327 | QFETCH(int, axisCount); |
|
327 | QFETCH(int, axisCount); | |
328 | Q_UNUSED(axisCount); |
|
328 | Q_UNUSED(axisCount); | |
329 |
|
329 | |||
330 | ChartDataSet dataSet; |
|
330 | ChartDataSet dataSet; | |
331 |
|
331 | |||
332 | dataSet.addSeries(series0, axis0); |
|
332 | dataSet.addSeries(series0, axis0); | |
333 | dataSet.addSeries(series1, axis1); |
|
333 | dataSet.addSeries(series1, axis1); | |
334 | dataSet.addSeries(series2, axis2); |
|
334 | dataSet.addSeries(series2, axis2); | |
335 |
|
335 | |||
336 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); |
|
336 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis*,Domain*))); | |
337 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); |
|
337 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis*))); | |
338 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); |
|
338 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QSeries*,Domain*))); | |
339 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); |
|
339 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QSeries*))); | |
340 |
|
340 | |||
341 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
341 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
342 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
342 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
343 | QCOMPARE(dataSet.seriesIndex(series2),2); |
|
343 | QCOMPARE(dataSet.seriesIndex(series2),2); | |
344 |
|
344 | |||
345 | QCOMPARE(spy0.count(), 0); |
|
345 | QCOMPARE(spy0.count(), 0); | |
346 | QCOMPARE(spy1.count(), 0); |
|
346 | QCOMPARE(spy1.count(), 0); | |
347 | QCOMPARE(spy2.count(), 0); |
|
347 | QCOMPARE(spy2.count(), 0); | |
348 | QCOMPARE(spy3.count(), 0); |
|
348 | QCOMPARE(spy3.count(), 0); | |
349 |
|
349 | |||
350 | dataSet.removeSeries(series0); |
|
350 | dataSet.removeSeries(series0); | |
351 | dataSet.removeSeries(series1); |
|
351 | dataSet.removeSeries(series1); | |
352 | dataSet.removeSeries(series2); |
|
352 | dataSet.removeSeries(series2); | |
353 |
|
353 | |||
354 | QCOMPARE(dataSet.seriesIndex(series0),-1); |
|
354 | QCOMPARE(dataSet.seriesIndex(series0),-1); | |
355 | QCOMPARE(dataSet.seriesIndex(series1),-1); |
|
355 | QCOMPARE(dataSet.seriesIndex(series1),-1); | |
356 | QCOMPARE(dataSet.seriesIndex(series2),-1); |
|
356 | QCOMPARE(dataSet.seriesIndex(series2),-1); | |
357 |
|
357 | |||
358 | dataSet.addSeries(series0, axis0); |
|
358 | dataSet.addSeries(series0, axis0); | |
359 | dataSet.addSeries(series1, axis1); |
|
359 | dataSet.addSeries(series1, axis1); | |
360 | dataSet.addSeries(series2, axis2); |
|
360 | dataSet.addSeries(series2, axis2); | |
361 |
|
361 | |||
362 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
362 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
363 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
363 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
364 | QCOMPARE(dataSet.seriesIndex(series2),2); |
|
364 | QCOMPARE(dataSet.seriesIndex(series2),2); | |
365 |
|
365 | |||
366 | dataSet.removeSeries(series1); |
|
366 | dataSet.removeSeries(series1); | |
367 |
|
367 | |||
368 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
368 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
369 | QCOMPARE(dataSet.seriesIndex(series1),-1); |
|
369 | QCOMPARE(dataSet.seriesIndex(series1),-1); | |
370 | QCOMPARE(dataSet.seriesIndex(series2),2); |
|
370 | QCOMPARE(dataSet.seriesIndex(series2),2); | |
371 |
|
371 | |||
372 | dataSet.addSeries(series1, axis1); |
|
372 | dataSet.addSeries(series1, axis1); | |
373 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
373 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
374 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
374 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
375 | QCOMPARE(dataSet.seriesIndex(series2),2); |
|
375 | QCOMPARE(dataSet.seriesIndex(series2),2); | |
376 |
|
376 | |||
377 | dataSet.removeSeries(series2); |
|
377 | dataSet.removeSeries(series2); | |
378 | QCOMPARE(dataSet.seriesIndex(series0),0); |
|
378 | QCOMPARE(dataSet.seriesIndex(series0),0); | |
379 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
379 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
380 | QCOMPARE(dataSet.seriesIndex(series2),-1); |
|
380 | QCOMPARE(dataSet.seriesIndex(series2),-1); | |
381 |
|
381 | |||
382 | dataSet.removeSeries(series0); |
|
382 | dataSet.removeSeries(series0); | |
383 | QCOMPARE(dataSet.seriesIndex(series0),-1); |
|
383 | QCOMPARE(dataSet.seriesIndex(series0),-1); | |
384 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
384 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
385 | QCOMPARE(dataSet.seriesIndex(series2),-1); |
|
385 | QCOMPARE(dataSet.seriesIndex(series2),-1); | |
386 |
|
386 | |||
387 | dataSet.addSeries(series2); |
|
387 | dataSet.addSeries(series2); | |
388 | QCOMPARE(dataSet.seriesIndex(series0),-1); |
|
388 | QCOMPARE(dataSet.seriesIndex(series0),-1); | |
389 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
389 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
390 | QCOMPARE(dataSet.seriesIndex(series2),0); |
|
390 | QCOMPARE(dataSet.seriesIndex(series2),0); | |
391 |
|
391 | |||
392 | dataSet.addSeries(series0); |
|
392 | dataSet.addSeries(series0); | |
393 | QCOMPARE(dataSet.seriesIndex(series0),2); |
|
393 | QCOMPARE(dataSet.seriesIndex(series0),2); | |
394 | QCOMPARE(dataSet.seriesIndex(series1),1); |
|
394 | QCOMPARE(dataSet.seriesIndex(series1),1); | |
395 | QCOMPARE(dataSet.seriesIndex(series2),0); |
|
395 | QCOMPARE(dataSet.seriesIndex(series2),0); | |
396 |
|
396 | |||
397 | dataSet.removeSeries(series0); |
|
397 | dataSet.removeSeries(series0); | |
398 | dataSet.removeSeries(series1); |
|
398 | dataSet.removeSeries(series1); | |
399 | dataSet.removeSeries(series2); |
|
399 | dataSet.removeSeries(series2); | |
400 |
|
400 | |||
401 | } |
|
401 | } | |
402 |
|
402 | |||
403 | void tst_ChartDataSet::domain_data() |
|
403 | void tst_ChartDataSet::domain_data() | |
404 | { |
|
404 | { | |
405 | addSeries_data(); |
|
405 | addSeries_data(); | |
406 | } |
|
406 | } | |
407 |
|
407 | |||
408 | void tst_ChartDataSet::domain() |
|
408 | void tst_ChartDataSet::domain() | |
409 | { |
|
409 | { | |
410 | QFETCH(QLineSeries*, series0); |
|
410 | QFETCH(QLineSeries*, series0); | |
411 | QFETCH(QChartAxis*, axis0); |
|
411 | QFETCH(QChartAxis*, axis0); | |
412 | QFETCH(QLineSeries*, series1); |
|
412 | QFETCH(QLineSeries*, series1); | |
413 | QFETCH(QChartAxis*, axis1); |
|
413 | QFETCH(QChartAxis*, axis1); | |
414 | QFETCH(QLineSeries*, series2); |
|
414 | QFETCH(QLineSeries*, series2); | |
415 | QFETCH(QChartAxis*, axis2); |
|
415 | QFETCH(QChartAxis*, axis2); | |
416 | QFETCH(int, axisCount); |
|
416 | QFETCH(int, axisCount); | |
417 | Q_UNUSED(axisCount); |
|
417 | Q_UNUSED(axisCount); | |
418 |
|
418 | |||
419 | ChartDataSet dataSet; |
|
419 | ChartDataSet dataSet; | |
420 |
|
420 | |||
421 | dataSet.addSeries(series0, axis0); |
|
421 | dataSet.addSeries(series0, axis0); | |
422 | dataSet.addSeries(series1, axis1); |
|
422 | dataSet.addSeries(series1, axis1); | |
423 | dataSet.addSeries(series2, axis2); |
|
423 | dataSet.addSeries(series2, axis2); | |
424 |
|
424 | |||
425 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); |
|
425 | QSignalSpy spy0(&dataSet, SIGNAL(axisAdded(QChartAxis *, Domain *))); | |
426 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); |
|
426 | QSignalSpy spy1(&dataSet, SIGNAL(axisRemoved(QChartAxis *))); | |
427 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); |
|
427 | QSignalSpy spy2(&dataSet, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
428 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
428 | QSignalSpy spy3(&dataSet, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
429 |
|
429 | |||
430 | QVERIFY(dataSet.domain(axis0)==dataSet.domain(series0)); |
|
430 | QVERIFY(dataSet.domain(axis0)==dataSet.domain(series0)); | |
431 | QVERIFY(dataSet.domain(axis1)==dataSet.domain(series1)); |
|
431 | QVERIFY(dataSet.domain(axis1)==dataSet.domain(series1)); | |
432 | QVERIFY(dataSet.domain(axis2)==dataSet.domain(series2)); |
|
432 | QVERIFY(dataSet.domain(axis2)==dataSet.domain(series2)); | |
433 | QCOMPARE(spy0.count(), 0); |
|
433 | QCOMPARE(spy0.count(), 0); | |
434 | QCOMPARE(spy1.count(), 0); |
|
434 | QCOMPARE(spy1.count(), 0); | |
435 | QCOMPARE(spy2.count(), 0); |
|
435 | QCOMPARE(spy2.count(), 0); | |
436 | QCOMPARE(spy3.count(), 0); |
|
436 | QCOMPARE(spy3.count(), 0); | |
437 |
|
437 | |||
438 | dataSet.removeSeries(series0); |
|
438 | dataSet.removeSeries(series0); | |
439 | dataSet.removeSeries(series1); |
|
439 | dataSet.removeSeries(series1); | |
440 | dataSet.removeSeries(series2); |
|
440 | dataSet.removeSeries(series2); | |
441 | } |
|
441 | } | |
442 |
|
442 | |||
443 | void tst_ChartDataSet::zoomInDomain_data() |
|
443 | void tst_ChartDataSet::zoomInDomain_data() | |
444 | { |
|
444 | { | |
445 | addSeries_data(); |
|
445 | addSeries_data(); | |
446 | } |
|
446 | } | |
447 |
|
447 | |||
448 | void tst_ChartDataSet::zoomInDomain() |
|
448 | void tst_ChartDataSet::zoomInDomain() | |
449 | { |
|
449 | { | |
450 | QFETCH(QLineSeries*, series0); |
|
450 | QFETCH(QLineSeries*, series0); | |
451 | QFETCH(QChartAxis*, axis0); |
|
451 | QFETCH(QChartAxis*, axis0); | |
452 | QFETCH(QLineSeries*, series1); |
|
452 | QFETCH(QLineSeries*, series1); | |
453 | QFETCH(QChartAxis*, axis1); |
|
453 | QFETCH(QChartAxis*, axis1); | |
454 | QFETCH(QLineSeries*, series2); |
|
454 | QFETCH(QLineSeries*, series2); | |
455 | QFETCH(QChartAxis*, axis2); |
|
455 | QFETCH(QChartAxis*, axis2); | |
456 | QFETCH(int, axisCount); |
|
456 | QFETCH(int, axisCount); | |
457 |
|
457 | |||
458 | Q_UNUSED(axisCount); |
|
458 | Q_UNUSED(axisCount); | |
459 | ChartDataSet dataSet; |
|
459 | ChartDataSet dataSet; | |
460 |
|
460 | |||
461 | dataSet.addSeries(series0, axis0); |
|
461 | dataSet.addSeries(series0, axis0); | |
462 | dataSet.addSeries(series1, axis1); |
|
462 | dataSet.addSeries(series1, axis1); | |
463 | dataSet.addSeries(series2, axis2); |
|
463 | dataSet.addSeries(series2, axis2); | |
464 |
|
464 | |||
465 | Domain* domain0 = dataSet.domain(series0); |
|
465 | Domain* domain0 = dataSet.domain(series0); | |
466 | Domain* domain1 = dataSet.domain(series1); |
|
466 | Domain* domain1 = dataSet.domain(series1); | |
467 | Domain* domain2 = dataSet.domain(series2); |
|
467 | Domain* domain2 = dataSet.domain(series2); | |
468 |
|
468 | |||
469 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
469 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
470 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
470 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
471 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
471 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
472 |
|
472 | |||
473 | dataSet.zoomInDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
473 | dataSet.zoomInDomain(QRect(0,0,100,100),QSize(1000,1000)); | |
474 |
|
474 | |||
475 | QCOMPARE(spy0.count(), 1); |
|
475 | QCOMPARE(spy0.count(), 1); | |
476 | QCOMPARE(spy1.count(), 1); |
|
476 | QCOMPARE(spy1.count(), 1); | |
477 | QCOMPARE(spy2.count(), 1); |
|
477 | QCOMPARE(spy2.count(), 1); | |
478 |
|
478 | |||
479 | dataSet.removeSeries(series0); |
|
479 | dataSet.removeSeries(series0); | |
480 | dataSet.removeSeries(series1); |
|
480 | dataSet.removeSeries(series1); | |
481 | dataSet.removeSeries(series2); |
|
481 | dataSet.removeSeries(series2); | |
482 | } |
|
482 | } | |
483 |
|
483 | |||
484 | void tst_ChartDataSet::zoomOutDomain_data() |
|
484 | void tst_ChartDataSet::zoomOutDomain_data() | |
485 | { |
|
485 | { | |
486 | addSeries_data(); |
|
486 | addSeries_data(); | |
487 | } |
|
487 | } | |
488 |
|
488 | |||
489 | void tst_ChartDataSet::zoomOutDomain() |
|
489 | void tst_ChartDataSet::zoomOutDomain() | |
490 | { |
|
490 | { | |
491 | QFETCH(QLineSeries*, series0); |
|
491 | QFETCH(QLineSeries*, series0); | |
492 | QFETCH(QChartAxis*, axis0); |
|
492 | QFETCH(QChartAxis*, axis0); | |
493 | QFETCH(QLineSeries*, series1); |
|
493 | QFETCH(QLineSeries*, series1); | |
494 | QFETCH(QChartAxis*, axis1); |
|
494 | QFETCH(QChartAxis*, axis1); | |
495 | QFETCH(QLineSeries*, series2); |
|
495 | QFETCH(QLineSeries*, series2); | |
496 | QFETCH(QChartAxis*, axis2); |
|
496 | QFETCH(QChartAxis*, axis2); | |
497 | QFETCH(int, axisCount); |
|
497 | QFETCH(int, axisCount); | |
498 |
|
498 | |||
499 | Q_UNUSED(axisCount); |
|
499 | Q_UNUSED(axisCount); | |
500 |
|
500 | |||
501 | ChartDataSet dataSet; |
|
501 | ChartDataSet dataSet; | |
502 |
|
502 | |||
503 | dataSet.addSeries(series0, axis0); |
|
503 | dataSet.addSeries(series0, axis0); | |
504 | dataSet.addSeries(series1, axis1); |
|
504 | dataSet.addSeries(series1, axis1); | |
505 | dataSet.addSeries(series2, axis2); |
|
505 | dataSet.addSeries(series2, axis2); | |
506 |
|
506 | |||
507 | Domain* domain0 = dataSet.domain(series0); |
|
507 | Domain* domain0 = dataSet.domain(series0); | |
508 | Domain* domain1 = dataSet.domain(series1); |
|
508 | Domain* domain1 = dataSet.domain(series1); | |
509 | Domain* domain2 = dataSet.domain(series2); |
|
509 | Domain* domain2 = dataSet.domain(series2); | |
510 |
|
510 | |||
511 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
511 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
512 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
512 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
513 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
513 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
514 |
|
514 | |||
515 | dataSet.zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
515 | dataSet.zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); | |
516 |
|
516 | |||
517 | QCOMPARE(spy0.count(), 1); |
|
517 | QCOMPARE(spy0.count(), 1); | |
518 | QCOMPARE(spy1.count(), 1); |
|
518 | QCOMPARE(spy1.count(), 1); | |
519 | QCOMPARE(spy2.count(), 1); |
|
519 | QCOMPARE(spy2.count(), 1); | |
520 |
|
520 | |||
521 | dataSet.removeSeries(series0); |
|
521 | dataSet.removeSeries(series0); | |
522 | dataSet.removeSeries(series1); |
|
522 | dataSet.removeSeries(series1); | |
523 | dataSet.removeSeries(series2); |
|
523 | dataSet.removeSeries(series2); | |
524 | } |
|
524 | } | |
525 |
|
525 | |||
526 | void tst_ChartDataSet::scrollDomain_data() |
|
526 | void tst_ChartDataSet::scrollDomain_data() | |
527 | { |
|
527 | { | |
528 | addSeries_data(); |
|
528 | addSeries_data(); | |
529 | } |
|
529 | } | |
530 |
|
530 | |||
531 | void tst_ChartDataSet::scrollDomain() |
|
531 | void tst_ChartDataSet::scrollDomain() | |
532 | { |
|
532 | { | |
533 | QFETCH(QLineSeries*, series0); |
|
533 | QFETCH(QLineSeries*, series0); | |
534 | QFETCH(QChartAxis*, axis0); |
|
534 | QFETCH(QChartAxis*, axis0); | |
535 | QFETCH(QLineSeries*, series1); |
|
535 | QFETCH(QLineSeries*, series1); | |
536 | QFETCH(QChartAxis*, axis1); |
|
536 | QFETCH(QChartAxis*, axis1); | |
537 | QFETCH(QLineSeries*, series2); |
|
537 | QFETCH(QLineSeries*, series2); | |
538 | QFETCH(QChartAxis*, axis2); |
|
538 | QFETCH(QChartAxis*, axis2); | |
539 | QFETCH(int, axisCount); |
|
539 | QFETCH(int, axisCount); | |
540 |
|
540 | |||
541 | Q_UNUSED(axisCount); |
|
541 | Q_UNUSED(axisCount); | |
542 |
|
542 | |||
543 | ChartDataSet dataSet; |
|
543 | ChartDataSet dataSet; | |
544 |
|
544 | |||
545 | dataSet.addSeries(series0, axis0); |
|
545 | dataSet.addSeries(series0, axis0); | |
546 | dataSet.addSeries(series1, axis1); |
|
546 | dataSet.addSeries(series1, axis1); | |
547 | dataSet.addSeries(series2, axis2); |
|
547 | dataSet.addSeries(series2, axis2); | |
548 |
|
548 | |||
549 | Domain* domain0 = dataSet.domain(series0); |
|
549 | Domain* domain0 = dataSet.domain(series0); | |
550 | Domain* domain1 = dataSet.domain(series1); |
|
550 | Domain* domain1 = dataSet.domain(series1); | |
551 | Domain* domain2 = dataSet.domain(series2); |
|
551 | Domain* domain2 = dataSet.domain(series2); | |
552 |
|
552 | |||
553 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
553 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
554 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
554 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
555 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
555 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
556 |
|
556 | |||
557 | dataSet.scrollDomain(10,10,QSize(1000,1000)); |
|
557 | dataSet.scrollDomain(10,10,QSize(1000,1000)); | |
558 |
|
558 | |||
559 | QCOMPARE(spy0.count(), 1); |
|
559 | QCOMPARE(spy0.count(), 1); | |
560 | QCOMPARE(spy1.count(), 1); |
|
560 | QCOMPARE(spy1.count(), 1); | |
561 | QCOMPARE(spy2.count(), 1); |
|
561 | QCOMPARE(spy2.count(), 1); | |
562 |
|
562 | |||
563 | dataSet.removeSeries(series0); |
|
563 | dataSet.removeSeries(series0); | |
564 | dataSet.removeSeries(series1); |
|
564 | dataSet.removeSeries(series1); | |
565 | dataSet.removeSeries(series2); |
|
565 | dataSet.removeSeries(series2); | |
566 | } |
|
566 | } | |
567 |
|
567 | |||
568 | QTEST_MAIN(tst_ChartDataSet) |
|
568 | QTEST_MAIN(tst_ChartDataSet) | |
569 | #include "tst_chartdataset.moc" |
|
569 | #include "tst_chartdataset.moc" | |
570 |
|
570 |
General Comments 0
You need to be logged in to leave comments.
Login now