@@ -0,0 +1,38 | |||||
|
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 | ||||
|
21 | #ifndef TST_DEFINITIONS_H | |||
|
22 | #define TST_DEFINITIONS_H | |||
|
23 | ||||
|
24 | #include <QtTest/QtTest> | |||
|
25 | ||||
|
26 | #define TRY_COMPARE(actual, expected) { \ | |||
|
27 | do { \ | |||
|
28 | const int timeout(1000); \ | |||
|
29 | const int waitStep(30); \ | |||
|
30 | /* always wait before comparing to catch possible extra signals */ \ | |||
|
31 | QTest::qWait(waitStep); \ | |||
|
32 | for (int time(0); actual != expected && time < timeout; time += waitStep) \ | |||
|
33 | QTest::qWait(waitStep); \ | |||
|
34 | QCOMPARE(actual, expected); \ | |||
|
35 | } while (0); \ | |||
|
36 | } | |||
|
37 | ||||
|
38 | #endif // TST_DEFINITIONS_H |
@@ -1,6 +1,9 | |||||
1 | !include( ../test.pri ) { |
|
1 | !include( ../test.pri ) { | |
2 | error( "Couldn't find the test.pri file!" ) |
|
2 | error( "Couldn't find the test.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | CONFIG += qtestlib |
|
5 | CONFIG += qtestlib | |
6 | !contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_") |
|
6 | !contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_") | |
|
7 | ||||
|
8 | INCLUDEPATH += ../inc | |||
|
9 | HEADERS += ../inc/tst_definitions.h |
@@ -1,532 +1,533 | |||||
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 <qaxis.h> |
|
22 | #include <qaxis.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 | #include <tst_definitions.h> | |||
26 |
|
27 | |||
27 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
28 | QTCOMMERCIALCHART_USE_NAMESPACE | |
28 |
|
29 | |||
29 | Q_DECLARE_METATYPE(Domain *) |
|
30 | Q_DECLARE_METATYPE(Domain *) | |
30 | Q_DECLARE_METATYPE(QAxis *) |
|
31 | Q_DECLARE_METATYPE(QAxis *) | |
31 | Q_DECLARE_METATYPE(QAbstractSeries *) |
|
32 | Q_DECLARE_METATYPE(QAbstractSeries *) | |
32 | Q_DECLARE_METATYPE(QLineSeries *) |
|
33 | Q_DECLARE_METATYPE(QLineSeries *) | |
33 |
|
34 | |||
34 | class tst_ChartDataSet: public QObject { |
|
35 | class tst_ChartDataSet: public QObject { | |
35 |
|
36 | |||
36 | Q_OBJECT |
|
37 | Q_OBJECT | |
37 |
|
38 | |||
38 | public Q_SLOTS: |
|
39 | public Q_SLOTS: | |
39 | void initTestCase(); |
|
40 | void initTestCase(); | |
40 | void cleanupTestCase(); |
|
41 | void cleanupTestCase(); | |
41 | void init(); |
|
42 | void init(); | |
42 | void cleanup(); |
|
43 | void cleanup(); | |
43 |
|
44 | |||
44 | private Q_SLOTS: |
|
45 | private Q_SLOTS: | |
45 | void chartdataset_data(); |
|
46 | void chartdataset_data(); | |
46 | void chartdataset(); |
|
47 | void chartdataset(); | |
47 | void addSeries_data(); |
|
48 | void addSeries_data(); | |
48 | void addSeries(); |
|
49 | void addSeries(); | |
49 | void removeSeries_data(); |
|
50 | void removeSeries_data(); | |
50 | void removeSeries(); |
|
51 | void removeSeries(); | |
51 | void removeAllSeries_data(); |
|
52 | void removeAllSeries_data(); | |
52 | void removeAllSeries(); |
|
53 | void removeAllSeries(); | |
53 | void axisY_data(); |
|
54 | void axisY_data(); | |
54 | void axisY(); |
|
55 | void axisY(); | |
55 | void seriesCount_data(); |
|
56 | void seriesCount_data(); | |
56 | void seriesCount(); |
|
57 | void seriesCount(); | |
57 | void seriesIndex_data(); |
|
58 | void seriesIndex_data(); | |
58 | void seriesIndex(); |
|
59 | void seriesIndex(); | |
59 | void domain_data(); |
|
60 | void domain_data(); | |
60 | void domain(); |
|
61 | void domain(); | |
61 | void zoomInDomain_data(); |
|
62 | void zoomInDomain_data(); | |
62 | void zoomInDomain(); |
|
63 | void zoomInDomain(); | |
63 | void zoomOutDomain_data(); |
|
64 | void zoomOutDomain_data(); | |
64 | void zoomOutDomain(); |
|
65 | void zoomOutDomain(); | |
65 | void scrollDomain_data(); |
|
66 | void scrollDomain_data(); | |
66 | void scrollDomain(); |
|
67 | void scrollDomain(); | |
67 | private: |
|
68 | private: | |
68 | ChartDataSet* m_dataset; |
|
69 | ChartDataSet* m_dataset; | |
69 | }; |
|
70 | }; | |
70 |
|
71 | |||
71 | void tst_ChartDataSet::initTestCase() |
|
72 | void tst_ChartDataSet::initTestCase() | |
72 | { |
|
73 | { | |
73 | qRegisterMetaType<Domain*>(); |
|
74 | qRegisterMetaType<Domain*>(); | |
74 | qRegisterMetaType<QAxis*>(); |
|
75 | qRegisterMetaType<QAxis*>(); | |
75 | qRegisterMetaType<QAbstractSeries*>(); |
|
76 | qRegisterMetaType<QAbstractSeries*>(); | |
76 | } |
|
77 | } | |
77 |
|
78 | |||
78 | void tst_ChartDataSet::cleanupTestCase() |
|
79 | void tst_ChartDataSet::cleanupTestCase() | |
79 | { |
|
80 | { | |
80 | } |
|
81 | } | |
81 |
|
82 | |||
82 | void tst_ChartDataSet::init() |
|
83 | void tst_ChartDataSet::init() | |
83 | { |
|
84 | { | |
84 | m_dataset = new ChartDataSet(); |
|
85 | m_dataset = new ChartDataSet(); | |
85 | } |
|
86 | } | |
86 |
|
87 | |||
87 |
|
88 | |||
88 | void tst_ChartDataSet::cleanup() |
|
89 | void tst_ChartDataSet::cleanup() | |
89 | { |
|
90 | { | |
90 | QList<QAbstractSeries*> series = m_dataset->series(); |
|
91 | QList<QAbstractSeries*> series = m_dataset->series(); | |
91 | foreach(QAbstractSeries* serie, series) |
|
92 | foreach(QAbstractSeries* serie, series) | |
92 | { |
|
93 | { | |
93 | m_dataset->removeSeries(serie); |
|
94 | m_dataset->removeSeries(serie); | |
94 | } |
|
95 | } | |
95 | } |
|
96 | } | |
96 |
|
97 | |||
97 | void tst_ChartDataSet::chartdataset_data() |
|
98 | void tst_ChartDataSet::chartdataset_data() | |
98 | { |
|
99 | { | |
99 | } |
|
100 | } | |
100 |
|
101 | |||
101 | void tst_ChartDataSet::chartdataset() |
|
102 | void tst_ChartDataSet::chartdataset() | |
102 | { |
|
103 | { | |
103 | QVERIFY2(m_dataset->axisX(), "Missing axisX."); |
|
104 | QVERIFY2(m_dataset->axisX(), "Missing axisX."); | |
104 | QVERIFY2(m_dataset->axisY(), "Missing axisY."); |
|
105 | QVERIFY2(m_dataset->axisY(), "Missing axisY."); | |
105 | //check if not dangling pointer |
|
106 | //check if not dangling pointer | |
106 | m_dataset->axisX()->objectName(); |
|
107 | m_dataset->axisX()->objectName(); | |
107 | m_dataset->axisY()->objectName(); |
|
108 | m_dataset->axisY()->objectName(); | |
108 | QLineSeries* series = new QLineSeries(this); |
|
109 | QLineSeries* series = new QLineSeries(this); | |
109 | QCOMPARE(m_dataset->seriesIndex(series),-1); |
|
110 | QCOMPARE(m_dataset->seriesIndex(series),-1); | |
110 | } |
|
111 | } | |
111 |
|
112 | |||
112 | void tst_ChartDataSet::addSeries_data() |
|
113 | void tst_ChartDataSet::addSeries_data() | |
113 | { |
|
114 | { | |
114 | QTest::addColumn<QLineSeries*>("series0"); |
|
115 | QTest::addColumn<QLineSeries*>("series0"); | |
115 | QTest::addColumn<QAxis*>("axis0"); |
|
116 | QTest::addColumn<QAxis*>("axis0"); | |
116 | QTest::addColumn<QLineSeries*>("series1"); |
|
117 | QTest::addColumn<QLineSeries*>("series1"); | |
117 | QTest::addColumn<QAxis*>("axis1"); |
|
118 | QTest::addColumn<QAxis*>("axis1"); | |
118 | QTest::addColumn<QLineSeries*>("series2"); |
|
119 | QTest::addColumn<QLineSeries*>("series2"); | |
119 | QTest::addColumn<QAxis*>("axis2"); |
|
120 | QTest::addColumn<QAxis*>("axis2"); | |
120 | QTest::addColumn<int>("axisCount"); |
|
121 | QTest::addColumn<int>("axisCount"); | |
121 |
|
122 | |||
122 | QLineSeries* series0 = new QLineSeries(this); |
|
123 | QLineSeries* series0 = new QLineSeries(this); | |
123 | QLineSeries* series1 = new QLineSeries(this); |
|
124 | QLineSeries* series1 = new QLineSeries(this); | |
124 | QLineSeries* series2 = new QLineSeries(this); |
|
125 | QLineSeries* series2 = new QLineSeries(this); | |
125 |
|
126 | |||
126 | QAxis* axis0 = new QAxis(this); |
|
127 | QAxis* axis0 = new QAxis(this); | |
127 | QAxis* axis1 = new QAxis(this); |
|
128 | QAxis* axis1 = new QAxis(this); | |
128 | QAxis* axis2 = new QAxis(this); |
|
129 | QAxis* axis2 = new QAxis(this); | |
129 |
|
130 | |||
130 | QTest::newRow("default axis Y: series0,series1,series2") << series0 << (QAxis*)0 << series1 << (QAxis*)0 << series2 << (QAxis*)0 << 2; |
|
131 | QTest::newRow("default axis Y: series0,series1,series2") << series0 << (QAxis*)0 << series1 << (QAxis*)0 << series2 << (QAxis*)0 << 2; | |
131 | QTest::newRow("default axis Y: series0, axis0: series1,series2") << series0 << (QAxis*)0 << series1 << axis0 << series2 << axis0 << 3; |
|
132 | QTest::newRow("default axis Y: series0, axis0: series1,series2") << series0 << (QAxis*)0 << series1 << axis0 << series2 << axis0 << 3; | |
132 | QTest::newRow("axis0: series0, axis1: series1, axis2: series2") << series0 << axis0 << series1 << axis1 << series2 << axis2 << 4; |
|
133 | QTest::newRow("axis0: series0, axis1: series1, axis2: series2") << series0 << axis0 << series1 << axis1 << series2 << axis2 << 4; | |
133 | } |
|
134 | } | |
134 |
|
135 | |||
135 | void tst_ChartDataSet::addSeries() |
|
136 | void tst_ChartDataSet::addSeries() | |
136 | { |
|
137 | { | |
137 | QFETCH(QLineSeries*, series0); |
|
138 | QFETCH(QLineSeries*, series0); | |
138 | QFETCH(QAxis*, axis0); |
|
139 | QFETCH(QAxis*, axis0); | |
139 | QFETCH(QLineSeries*, series1); |
|
140 | QFETCH(QLineSeries*, series1); | |
140 | QFETCH(QAxis*, axis1); |
|
141 | QFETCH(QAxis*, axis1); | |
141 | QFETCH(QLineSeries*, series2); |
|
142 | QFETCH(QLineSeries*, series2); | |
142 | QFETCH(QAxis*, axis2); |
|
143 | QFETCH(QAxis*, axis2); | |
143 | QFETCH(int, axisCount); |
|
144 | QFETCH(int, axisCount); | |
144 |
|
145 | |||
145 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis*,Domain*))); |
|
146 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis*,Domain*))); | |
146 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis*))); |
|
147 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis*))); | |
147 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); |
|
148 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); | |
148 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
149 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
149 |
|
150 | |||
150 | m_dataset->addSeries(series0,axis0); |
|
151 | m_dataset->addSeries(series0,axis0); | |
151 | m_dataset->addSeries(series1,axis1); |
|
152 | m_dataset->addSeries(series1,axis1); | |
152 | m_dataset->addSeries(series2,axis2); |
|
153 | m_dataset->addSeries(series2,axis2); | |
153 |
|
154 | |||
154 |
|
|
155 | TRY_COMPARE(spy0.count(), axisCount); | |
155 |
|
|
156 | TRY_COMPARE(spy1.count(), 0); | |
156 |
|
|
157 | TRY_COMPARE(spy2.count(), 3); | |
157 |
|
|
158 | TRY_COMPARE(spy3.count(), 0); | |
158 |
|
159 | |||
159 | if(axis0==0) axis0 = m_dataset->axisY(); |
|
160 | if(axis0==0) axis0 = m_dataset->axisY(); | |
160 | if(axis1==0) axis1 = m_dataset->axisY(); |
|
161 | if(axis1==0) axis1 = m_dataset->axisY(); | |
161 | if(axis2==0) axis2 = m_dataset->axisY(); |
|
162 | if(axis2==0) axis2 = m_dataset->axisY(); | |
162 |
|
163 | |||
163 | QVERIFY(axis0 == m_dataset->removeSeries(series0)); |
|
164 | QVERIFY(axis0 == m_dataset->removeSeries(series0)); | |
164 | QVERIFY(axis1 == m_dataset->removeSeries(series1)); |
|
165 | QVERIFY(axis1 == m_dataset->removeSeries(series1)); | |
165 | QVERIFY(axis2 == m_dataset->removeSeries(series2)); |
|
166 | QVERIFY(axis2 == m_dataset->removeSeries(series2)); | |
166 | } |
|
167 | } | |
167 |
|
168 | |||
168 | void tst_ChartDataSet::removeSeries_data() |
|
169 | void tst_ChartDataSet::removeSeries_data() | |
169 | { |
|
170 | { | |
170 | addSeries_data(); |
|
171 | addSeries_data(); | |
171 | } |
|
172 | } | |
172 |
|
173 | |||
173 | void tst_ChartDataSet::removeSeries() |
|
174 | void tst_ChartDataSet::removeSeries() | |
174 | { |
|
175 | { | |
175 | QFETCH(QLineSeries*, series0); |
|
176 | QFETCH(QLineSeries*, series0); | |
176 | QFETCH(QAxis*, axis0); |
|
177 | QFETCH(QAxis*, axis0); | |
177 | QFETCH(QLineSeries*, series1); |
|
178 | QFETCH(QLineSeries*, series1); | |
178 | QFETCH(QAxis*, axis1); |
|
179 | QFETCH(QAxis*, axis1); | |
179 | QFETCH(QLineSeries*, series2); |
|
180 | QFETCH(QLineSeries*, series2); | |
180 | QFETCH(QAxis*, axis2); |
|
181 | QFETCH(QAxis*, axis2); | |
181 | QFETCH(int, axisCount); |
|
182 | QFETCH(int, axisCount); | |
182 |
|
183 | |||
183 | m_dataset->addSeries(series0,axis0); |
|
184 | m_dataset->addSeries(series0,axis0); | |
184 | m_dataset->addSeries(series1,axis1); |
|
185 | m_dataset->addSeries(series1,axis1); | |
185 | m_dataset->addSeries(series2,axis2); |
|
186 | m_dataset->addSeries(series2,axis2); | |
186 |
|
187 | |||
187 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis *, Domain *))); |
|
188 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis *, Domain *))); | |
188 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis *))); |
|
189 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis *))); | |
189 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); |
|
190 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
190 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
191 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
191 |
|
192 | |||
192 | m_dataset->removeSeries(series0); |
|
193 | m_dataset->removeSeries(series0); | |
193 | m_dataset->removeSeries(series1); |
|
194 | m_dataset->removeSeries(series1); | |
194 | m_dataset->removeSeries(series2); |
|
195 | m_dataset->removeSeries(series2); | |
195 |
|
196 | |||
196 |
|
|
197 | TRY_COMPARE(spy0.count(), 0); | |
197 |
|
|
198 | TRY_COMPARE(spy1.count(), axisCount); | |
198 |
|
|
199 | TRY_COMPARE(spy2.count(), 0); | |
199 |
|
|
200 | TRY_COMPARE(spy3.count(), 3); | |
200 | } |
|
201 | } | |
201 |
|
202 | |||
202 | void tst_ChartDataSet::removeAllSeries_data() |
|
203 | void tst_ChartDataSet::removeAllSeries_data() | |
203 | { |
|
204 | { | |
204 |
|
205 | |||
205 | } |
|
206 | } | |
206 |
|
207 | |||
207 | void tst_ChartDataSet::removeAllSeries() |
|
208 | void tst_ChartDataSet::removeAllSeries() | |
208 | { |
|
209 | { | |
209 | QLineSeries* series0 = new QLineSeries(this); |
|
210 | QLineSeries* series0 = new QLineSeries(this); | |
210 | QLineSeries* series1 = new QLineSeries(this); |
|
211 | QLineSeries* series1 = new QLineSeries(this); | |
211 | QLineSeries* series2 = new QLineSeries(this); |
|
212 | QLineSeries* series2 = new QLineSeries(this); | |
212 |
|
213 | |||
213 | QAxis* axis0 = new QAxis(this); |
|
214 | QAxis* axis0 = new QAxis(this); | |
214 | QAxis* axis1 = new QAxis(this); |
|
215 | QAxis* axis1 = new QAxis(this); | |
215 | QAxis* axis2 = new QAxis(this); |
|
216 | QAxis* axis2 = new QAxis(this); | |
216 |
|
217 | |||
217 | m_dataset->addSeries(series0, axis0); |
|
218 | m_dataset->addSeries(series0, axis0); | |
218 | m_dataset->addSeries(series1, axis1); |
|
219 | m_dataset->addSeries(series1, axis1); | |
219 | m_dataset->addSeries(series2, axis2); |
|
220 | m_dataset->addSeries(series2, axis2); | |
220 |
|
221 | |||
221 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis *, Domain *))); |
|
222 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis *, Domain *))); | |
222 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis *))); |
|
223 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis *))); | |
223 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); |
|
224 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
224 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
225 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
225 |
|
226 | |||
226 | m_dataset->removeAllSeries(); |
|
227 | m_dataset->removeAllSeries(); | |
227 |
|
228 | |||
228 |
|
|
229 | TRY_COMPARE(spy0.count(), 0); | |
229 |
|
|
230 | TRY_COMPARE(spy1.count(), 4); | |
230 |
|
|
231 | TRY_COMPARE(spy2.count(), 0); | |
231 |
|
|
232 | TRY_COMPARE(spy3.count(), 3); | |
232 | } |
|
233 | } | |
233 |
|
234 | |||
234 |
|
235 | |||
235 | void tst_ChartDataSet::axisY_data() |
|
236 | void tst_ChartDataSet::axisY_data() | |
236 | { |
|
237 | { | |
237 | QTest::addColumn<QAxis*>("axis0"); |
|
238 | QTest::addColumn<QAxis*>("axis0"); | |
238 | QTest::addColumn<QAxis*>("axis1"); |
|
239 | QTest::addColumn<QAxis*>("axis1"); | |
239 | QTest::addColumn<QAxis*>("axis2"); |
|
240 | QTest::addColumn<QAxis*>("axis2"); | |
240 | QTest::newRow("1 defualt, 2 optional") << (QAxis*)0 << new QAxis() << new QAxis(); |
|
241 | QTest::newRow("1 defualt, 2 optional") << (QAxis*)0 << new QAxis() << new QAxis(); | |
241 | QTest::newRow("3 optional") << new QAxis() << new QAxis() << new QAxis(); |
|
242 | QTest::newRow("3 optional") << new QAxis() << new QAxis() << new QAxis(); | |
242 | } |
|
243 | } | |
243 |
|
244 | |||
244 | void tst_ChartDataSet::axisY() |
|
245 | void tst_ChartDataSet::axisY() | |
245 | { |
|
246 | { | |
246 | QFETCH(QAxis*, axis0); |
|
247 | QFETCH(QAxis*, axis0); | |
247 | QFETCH(QAxis*, axis1); |
|
248 | QFETCH(QAxis*, axis1); | |
248 | QFETCH(QAxis*, axis2); |
|
249 | QFETCH(QAxis*, axis2); | |
249 |
|
250 | |||
250 | QAxis* defaultAxisY = m_dataset->axisY(); |
|
251 | QAxis* defaultAxisY = m_dataset->axisY(); | |
251 |
|
252 | |||
252 | QVERIFY2(defaultAxisY, "Missing axisY."); |
|
253 | QVERIFY2(defaultAxisY, "Missing axisY."); | |
253 |
|
254 | |||
254 | QLineSeries* series0 = new QLineSeries(); |
|
255 | QLineSeries* series0 = new QLineSeries(); | |
255 | m_dataset->addSeries(series0,axis0); |
|
256 | m_dataset->addSeries(series0,axis0); | |
256 |
|
257 | |||
257 | QLineSeries* series1 = new QLineSeries(); |
|
258 | QLineSeries* series1 = new QLineSeries(); | |
258 | m_dataset->addSeries(series1,axis1); |
|
259 | m_dataset->addSeries(series1,axis1); | |
259 |
|
260 | |||
260 | QLineSeries* series2 = new QLineSeries(); |
|
261 | QLineSeries* series2 = new QLineSeries(); | |
261 | m_dataset->addSeries(series2,axis2); |
|
262 | m_dataset->addSeries(series2,axis2); | |
262 |
|
263 | |||
263 | if(!axis0) axis0=defaultAxisY ; |
|
264 | if(!axis0) axis0=defaultAxisY ; | |
264 | if(!axis1) axis1=defaultAxisY ; |
|
265 | if(!axis1) axis1=defaultAxisY ; | |
265 | if(!axis2) axis2=defaultAxisY ; |
|
266 | if(!axis2) axis2=defaultAxisY ; | |
266 |
|
267 | |||
267 | QVERIFY(m_dataset->axisY(series0) == axis0); |
|
268 | QVERIFY(m_dataset->axisY(series0) == axis0); | |
268 | QVERIFY(m_dataset->axisY(series1) == axis1); |
|
269 | QVERIFY(m_dataset->axisY(series1) == axis1); | |
269 | QVERIFY(m_dataset->axisY(series2) == axis2); |
|
270 | QVERIFY(m_dataset->axisY(series2) == axis2); | |
270 |
|
271 | |||
271 | } |
|
272 | } | |
272 |
|
273 | |||
273 | void tst_ChartDataSet::seriesCount_data() |
|
274 | void tst_ChartDataSet::seriesCount_data() | |
274 | { |
|
275 | { | |
275 | addSeries_data(); |
|
276 | addSeries_data(); | |
276 | } |
|
277 | } | |
277 |
|
278 | |||
278 | void tst_ChartDataSet::seriesCount() |
|
279 | void tst_ChartDataSet::seriesCount() | |
279 | { |
|
280 | { | |
280 | QFETCH(QLineSeries*, series0); |
|
281 | QFETCH(QLineSeries*, series0); | |
281 | QFETCH(QAxis*, axis0); |
|
282 | QFETCH(QAxis*, axis0); | |
282 | QFETCH(QLineSeries*, series1); |
|
283 | QFETCH(QLineSeries*, series1); | |
283 | QFETCH(QAxis*, axis1); |
|
284 | QFETCH(QAxis*, axis1); | |
284 | QFETCH(QLineSeries*, series2); |
|
285 | QFETCH(QLineSeries*, series2); | |
285 | QFETCH(QAxis*, axis2); |
|
286 | QFETCH(QAxis*, axis2); | |
286 | QFETCH(int, axisCount); |
|
287 | QFETCH(int, axisCount); | |
287 | Q_UNUSED(axisCount); |
|
288 | Q_UNUSED(axisCount); | |
288 |
|
289 | |||
289 | m_dataset->addSeries(series0, axis0); |
|
290 | m_dataset->addSeries(series0, axis0); | |
290 | m_dataset->addSeries(series1, axis1); |
|
291 | m_dataset->addSeries(series1, axis1); | |
291 | m_dataset->addSeries(series2, axis2); |
|
292 | m_dataset->addSeries(series2, axis2); | |
292 |
|
293 | |||
293 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis *, Domain *))); |
|
294 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis *, Domain *))); | |
294 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis *))); |
|
295 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis *))); | |
295 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); |
|
296 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
296 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
297 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
297 |
|
298 | |||
298 | QCOMPARE(m_dataset->seriesCount(series0->type()),3); |
|
299 | QCOMPARE(m_dataset->seriesCount(series0->type()),3); | |
299 |
|
|
300 | TRY_COMPARE(spy0.count(), 0); | |
300 |
|
|
301 | TRY_COMPARE(spy1.count(), 0); | |
301 |
|
|
302 | TRY_COMPARE(spy2.count(), 0); | |
302 |
|
|
303 | TRY_COMPARE(spy3.count(), 0); | |
303 | } |
|
304 | } | |
304 |
|
305 | |||
305 | void tst_ChartDataSet::seriesIndex_data() |
|
306 | void tst_ChartDataSet::seriesIndex_data() | |
306 | { |
|
307 | { | |
307 | addSeries_data(); |
|
308 | addSeries_data(); | |
308 | } |
|
309 | } | |
309 |
|
310 | |||
310 | void tst_ChartDataSet::seriesIndex() |
|
311 | void tst_ChartDataSet::seriesIndex() | |
311 | { |
|
312 | { | |
312 | //TODO: rewrite this series_index_data to match better |
|
313 | //TODO: rewrite this series_index_data to match better | |
313 |
|
314 | |||
314 | QFETCH(QLineSeries*, series0); |
|
315 | QFETCH(QLineSeries*, series0); | |
315 | QFETCH(QAxis*, axis0); |
|
316 | QFETCH(QAxis*, axis0); | |
316 | QFETCH(QLineSeries*, series1); |
|
317 | QFETCH(QLineSeries*, series1); | |
317 | QFETCH(QAxis*, axis1); |
|
318 | QFETCH(QAxis*, axis1); | |
318 | QFETCH(QLineSeries*, series2); |
|
319 | QFETCH(QLineSeries*, series2); | |
319 | QFETCH(QAxis*, axis2); |
|
320 | QFETCH(QAxis*, axis2); | |
320 | QFETCH(int, axisCount); |
|
321 | QFETCH(int, axisCount); | |
321 | Q_UNUSED(axisCount); |
|
322 | Q_UNUSED(axisCount); | |
322 |
|
323 | |||
323 | m_dataset->addSeries(series0, axis0); |
|
324 | m_dataset->addSeries(series0, axis0); | |
324 | m_dataset->addSeries(series1, axis1); |
|
325 | m_dataset->addSeries(series1, axis1); | |
325 | m_dataset->addSeries(series2, axis2); |
|
326 | m_dataset->addSeries(series2, axis2); | |
326 |
|
327 | |||
327 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis*,Domain*))); |
|
328 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis*,Domain*))); | |
328 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis*))); |
|
329 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis*))); | |
329 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); |
|
330 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); | |
330 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); |
|
331 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); | |
331 |
|
332 | |||
332 | QCOMPARE(m_dataset->seriesIndex(series0),0); |
|
333 | QCOMPARE(m_dataset->seriesIndex(series0),0); | |
333 | QCOMPARE(m_dataset->seriesIndex(series1),1); |
|
334 | QCOMPARE(m_dataset->seriesIndex(series1),1); | |
334 | QCOMPARE(m_dataset->seriesIndex(series2),2); |
|
335 | QCOMPARE(m_dataset->seriesIndex(series2),2); | |
335 |
|
336 | |||
336 |
|
|
337 | TRY_COMPARE(spy0.count(), 0); | |
337 |
|
|
338 | TRY_COMPARE(spy1.count(), 0); | |
338 |
|
|
339 | TRY_COMPARE(spy2.count(), 0); | |
339 |
|
|
340 | TRY_COMPARE(spy3.count(), 0); | |
340 |
|
341 | |||
341 | m_dataset->removeSeries(series0); |
|
342 | m_dataset->removeSeries(series0); | |
342 | m_dataset->removeSeries(series1); |
|
343 | m_dataset->removeSeries(series1); | |
343 | m_dataset->removeSeries(series2); |
|
344 | m_dataset->removeSeries(series2); | |
344 |
|
345 | |||
345 | QCOMPARE(m_dataset->seriesIndex(series0),-1); |
|
346 | QCOMPARE(m_dataset->seriesIndex(series0),-1); | |
346 | QCOMPARE(m_dataset->seriesIndex(series1),-1); |
|
347 | QCOMPARE(m_dataset->seriesIndex(series1),-1); | |
347 | QCOMPARE(m_dataset->seriesIndex(series2),-1); |
|
348 | QCOMPARE(m_dataset->seriesIndex(series2),-1); | |
348 |
|
349 | |||
349 | m_dataset->addSeries(series0, axis0); |
|
350 | m_dataset->addSeries(series0, axis0); | |
350 | m_dataset->addSeries(series1, axis1); |
|
351 | m_dataset->addSeries(series1, axis1); | |
351 | m_dataset->addSeries(series2, axis2); |
|
352 | m_dataset->addSeries(series2, axis2); | |
352 |
|
353 | |||
353 | QCOMPARE(m_dataset->seriesIndex(series0),0); |
|
354 | QCOMPARE(m_dataset->seriesIndex(series0),0); | |
354 | QCOMPARE(m_dataset->seriesIndex(series1),1); |
|
355 | QCOMPARE(m_dataset->seriesIndex(series1),1); | |
355 | QCOMPARE(m_dataset->seriesIndex(series2),2); |
|
356 | QCOMPARE(m_dataset->seriesIndex(series2),2); | |
356 |
|
357 | |||
357 | m_dataset->removeSeries(series1); |
|
358 | m_dataset->removeSeries(series1); | |
358 |
|
359 | |||
359 | QCOMPARE(m_dataset->seriesIndex(series0),0); |
|
360 | QCOMPARE(m_dataset->seriesIndex(series0),0); | |
360 | QCOMPARE(m_dataset->seriesIndex(series1),-1); |
|
361 | QCOMPARE(m_dataset->seriesIndex(series1),-1); | |
361 | QCOMPARE(m_dataset->seriesIndex(series2),2); |
|
362 | QCOMPARE(m_dataset->seriesIndex(series2),2); | |
362 |
|
363 | |||
363 | m_dataset->addSeries(series1, axis1); |
|
364 | m_dataset->addSeries(series1, axis1); | |
364 | QCOMPARE(m_dataset->seriesIndex(series0),0); |
|
365 | QCOMPARE(m_dataset->seriesIndex(series0),0); | |
365 | QCOMPARE(m_dataset->seriesIndex(series1),1); |
|
366 | QCOMPARE(m_dataset->seriesIndex(series1),1); | |
366 | QCOMPARE(m_dataset->seriesIndex(series2),2); |
|
367 | QCOMPARE(m_dataset->seriesIndex(series2),2); | |
367 |
|
368 | |||
368 | m_dataset->removeSeries(series2); |
|
369 | m_dataset->removeSeries(series2); | |
369 | QCOMPARE(m_dataset->seriesIndex(series0),0); |
|
370 | QCOMPARE(m_dataset->seriesIndex(series0),0); | |
370 | QCOMPARE(m_dataset->seriesIndex(series1),1); |
|
371 | QCOMPARE(m_dataset->seriesIndex(series1),1); | |
371 | QCOMPARE(m_dataset->seriesIndex(series2),-1); |
|
372 | QCOMPARE(m_dataset->seriesIndex(series2),-1); | |
372 |
|
373 | |||
373 | m_dataset->removeSeries(series0); |
|
374 | m_dataset->removeSeries(series0); | |
374 | QCOMPARE(m_dataset->seriesIndex(series0),-1); |
|
375 | QCOMPARE(m_dataset->seriesIndex(series0),-1); | |
375 | QCOMPARE(m_dataset->seriesIndex(series1),1); |
|
376 | QCOMPARE(m_dataset->seriesIndex(series1),1); | |
376 | QCOMPARE(m_dataset->seriesIndex(series2),-1); |
|
377 | QCOMPARE(m_dataset->seriesIndex(series2),-1); | |
377 |
|
378 | |||
378 | m_dataset->addSeries(series2); |
|
379 | m_dataset->addSeries(series2); | |
379 | QCOMPARE(m_dataset->seriesIndex(series0),-1); |
|
380 | QCOMPARE(m_dataset->seriesIndex(series0),-1); | |
380 | QCOMPARE(m_dataset->seriesIndex(series1),1); |
|
381 | QCOMPARE(m_dataset->seriesIndex(series1),1); | |
381 | QCOMPARE(m_dataset->seriesIndex(series2),0); |
|
382 | QCOMPARE(m_dataset->seriesIndex(series2),0); | |
382 |
|
383 | |||
383 | m_dataset->addSeries(series0); |
|
384 | m_dataset->addSeries(series0); | |
384 | QCOMPARE(m_dataset->seriesIndex(series0),2); |
|
385 | QCOMPARE(m_dataset->seriesIndex(series0),2); | |
385 | QCOMPARE(m_dataset->seriesIndex(series1),1); |
|
386 | QCOMPARE(m_dataset->seriesIndex(series1),1); | |
386 | QCOMPARE(m_dataset->seriesIndex(series2),0); |
|
387 | QCOMPARE(m_dataset->seriesIndex(series2),0); | |
387 | } |
|
388 | } | |
388 |
|
389 | |||
389 | void tst_ChartDataSet::domain_data() |
|
390 | void tst_ChartDataSet::domain_data() | |
390 | { |
|
391 | { | |
391 | addSeries_data(); |
|
392 | addSeries_data(); | |
392 | } |
|
393 | } | |
393 |
|
394 | |||
394 | void tst_ChartDataSet::domain() |
|
395 | void tst_ChartDataSet::domain() | |
395 | { |
|
396 | { | |
396 | QFETCH(QLineSeries*, series0); |
|
397 | QFETCH(QLineSeries*, series0); | |
397 | QFETCH(QAxis*, axis0); |
|
398 | QFETCH(QAxis*, axis0); | |
398 | QFETCH(QLineSeries*, series1); |
|
399 | QFETCH(QLineSeries*, series1); | |
399 | QFETCH(QAxis*, axis1); |
|
400 | QFETCH(QAxis*, axis1); | |
400 | QFETCH(QLineSeries*, series2); |
|
401 | QFETCH(QLineSeries*, series2); | |
401 | QFETCH(QAxis*, axis2); |
|
402 | QFETCH(QAxis*, axis2); | |
402 | QFETCH(int, axisCount); |
|
403 | QFETCH(int, axisCount); | |
403 | Q_UNUSED(axisCount); |
|
404 | Q_UNUSED(axisCount); | |
404 |
|
405 | |||
405 | m_dataset->addSeries(series0, axis0); |
|
406 | m_dataset->addSeries(series0, axis0); | |
406 | m_dataset->addSeries(series1, axis1); |
|
407 | m_dataset->addSeries(series1, axis1); | |
407 | m_dataset->addSeries(series2, axis2); |
|
408 | m_dataset->addSeries(series2, axis2); | |
408 |
|
409 | |||
409 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis *, Domain *))); |
|
410 | QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAxis *, Domain *))); | |
410 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis *))); |
|
411 | QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAxis *))); | |
411 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); |
|
412 | QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); | |
412 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); |
|
413 | QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); | |
413 |
|
414 | |||
414 | QVERIFY(m_dataset->domain(axis0)==m_dataset->domain(series0)); |
|
415 | QVERIFY(m_dataset->domain(axis0)==m_dataset->domain(series0)); | |
415 | QVERIFY(m_dataset->domain(axis1)==m_dataset->domain(series1)); |
|
416 | QVERIFY(m_dataset->domain(axis1)==m_dataset->domain(series1)); | |
416 | QVERIFY(m_dataset->domain(axis2)==m_dataset->domain(series2)); |
|
417 | QVERIFY(m_dataset->domain(axis2)==m_dataset->domain(series2)); | |
417 |
|
|
418 | TRY_COMPARE(spy0.count(), 0); | |
418 |
|
|
419 | TRY_COMPARE(spy1.count(), 0); | |
419 |
|
|
420 | TRY_COMPARE(spy2.count(), 0); | |
420 |
|
|
421 | TRY_COMPARE(spy3.count(), 0); | |
421 | } |
|
422 | } | |
422 |
|
423 | |||
423 | void tst_ChartDataSet::zoomInDomain_data() |
|
424 | void tst_ChartDataSet::zoomInDomain_data() | |
424 | { |
|
425 | { | |
425 | addSeries_data(); |
|
426 | addSeries_data(); | |
426 | } |
|
427 | } | |
427 |
|
428 | |||
428 | void tst_ChartDataSet::zoomInDomain() |
|
429 | void tst_ChartDataSet::zoomInDomain() | |
429 | { |
|
430 | { | |
430 | QFETCH(QLineSeries*, series0); |
|
431 | QFETCH(QLineSeries*, series0); | |
431 | QFETCH(QAxis*, axis0); |
|
432 | QFETCH(QAxis*, axis0); | |
432 | QFETCH(QLineSeries*, series1); |
|
433 | QFETCH(QLineSeries*, series1); | |
433 | QFETCH(QAxis*, axis1); |
|
434 | QFETCH(QAxis*, axis1); | |
434 | QFETCH(QLineSeries*, series2); |
|
435 | QFETCH(QLineSeries*, series2); | |
435 | QFETCH(QAxis*, axis2); |
|
436 | QFETCH(QAxis*, axis2); | |
436 | QFETCH(int, axisCount); |
|
437 | QFETCH(int, axisCount); | |
437 | Q_UNUSED(axisCount); |
|
438 | Q_UNUSED(axisCount); | |
438 |
|
439 | |||
439 | m_dataset->addSeries(series0, axis0); |
|
440 | m_dataset->addSeries(series0, axis0); | |
440 | m_dataset->addSeries(series1, axis1); |
|
441 | m_dataset->addSeries(series1, axis1); | |
441 | m_dataset->addSeries(series2, axis2); |
|
442 | m_dataset->addSeries(series2, axis2); | |
442 |
|
443 | |||
443 | Domain* domain0 = m_dataset->domain(series0); |
|
444 | Domain* domain0 = m_dataset->domain(series0); | |
444 | Domain* domain1 = m_dataset->domain(series1); |
|
445 | Domain* domain1 = m_dataset->domain(series1); | |
445 | Domain* domain2 = m_dataset->domain(series2); |
|
446 | Domain* domain2 = m_dataset->domain(series2); | |
446 |
|
447 | |||
447 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
448 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
448 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
449 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
449 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
450 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
450 |
|
451 | |||
451 | m_dataset->zoomInDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
452 | m_dataset->zoomInDomain(QRect(0,0,100,100),QSize(1000,1000)); | |
452 |
|
453 | |||
453 |
|
|
454 | TRY_COMPARE(spy0.count(), 1); | |
454 |
|
|
455 | TRY_COMPARE(spy1.count(), 1); | |
455 |
|
|
456 | TRY_COMPARE(spy2.count(), 1); | |
456 | } |
|
457 | } | |
457 |
|
458 | |||
458 | void tst_ChartDataSet::zoomOutDomain_data() |
|
459 | void tst_ChartDataSet::zoomOutDomain_data() | |
459 | { |
|
460 | { | |
460 | addSeries_data(); |
|
461 | addSeries_data(); | |
461 | } |
|
462 | } | |
462 |
|
463 | |||
463 | void tst_ChartDataSet::zoomOutDomain() |
|
464 | void tst_ChartDataSet::zoomOutDomain() | |
464 | { |
|
465 | { | |
465 | QFETCH(QLineSeries*, series0); |
|
466 | QFETCH(QLineSeries*, series0); | |
466 | QFETCH(QAxis*, axis0); |
|
467 | QFETCH(QAxis*, axis0); | |
467 | QFETCH(QLineSeries*, series1); |
|
468 | QFETCH(QLineSeries*, series1); | |
468 | QFETCH(QAxis*, axis1); |
|
469 | QFETCH(QAxis*, axis1); | |
469 | QFETCH(QLineSeries*, series2); |
|
470 | QFETCH(QLineSeries*, series2); | |
470 | QFETCH(QAxis*, axis2); |
|
471 | QFETCH(QAxis*, axis2); | |
471 | QFETCH(int, axisCount); |
|
472 | QFETCH(int, axisCount); | |
472 |
|
473 | |||
473 | Q_UNUSED(axisCount); |
|
474 | Q_UNUSED(axisCount); | |
474 |
|
475 | |||
475 | m_dataset->addSeries(series0, axis0); |
|
476 | m_dataset->addSeries(series0, axis0); | |
476 | m_dataset->addSeries(series1, axis1); |
|
477 | m_dataset->addSeries(series1, axis1); | |
477 | m_dataset->addSeries(series2, axis2); |
|
478 | m_dataset->addSeries(series2, axis2); | |
478 |
|
479 | |||
479 | Domain* domain0 = m_dataset->domain(series0); |
|
480 | Domain* domain0 = m_dataset->domain(series0); | |
480 | Domain* domain1 = m_dataset->domain(series1); |
|
481 | Domain* domain1 = m_dataset->domain(series1); | |
481 | Domain* domain2 = m_dataset->domain(series2); |
|
482 | Domain* domain2 = m_dataset->domain(series2); | |
482 |
|
483 | |||
483 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
484 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
484 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
485 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
485 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
486 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
486 |
|
487 | |||
487 | m_dataset->zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); |
|
488 | m_dataset->zoomOutDomain(QRect(0,0,100,100),QSize(1000,1000)); | |
488 |
|
489 | |||
489 |
|
|
490 | TRY_COMPARE(spy0.count(), 1); | |
490 |
|
|
491 | TRY_COMPARE(spy1.count(), 1); | |
491 |
|
|
492 | TRY_COMPARE(spy2.count(), 1); | |
492 | } |
|
493 | } | |
493 |
|
494 | |||
494 | void tst_ChartDataSet::scrollDomain_data() |
|
495 | void tst_ChartDataSet::scrollDomain_data() | |
495 | { |
|
496 | { | |
496 | addSeries_data(); |
|
497 | addSeries_data(); | |
497 | } |
|
498 | } | |
498 |
|
499 | |||
499 | void tst_ChartDataSet::scrollDomain() |
|
500 | void tst_ChartDataSet::scrollDomain() | |
500 | { |
|
501 | { | |
501 | QFETCH(QLineSeries*, series0); |
|
502 | QFETCH(QLineSeries*, series0); | |
502 | QFETCH(QAxis*, axis0); |
|
503 | QFETCH(QAxis*, axis0); | |
503 | QFETCH(QLineSeries*, series1); |
|
504 | QFETCH(QLineSeries*, series1); | |
504 | QFETCH(QAxis*, axis1); |
|
505 | QFETCH(QAxis*, axis1); | |
505 | QFETCH(QLineSeries*, series2); |
|
506 | QFETCH(QLineSeries*, series2); | |
506 | QFETCH(QAxis*, axis2); |
|
507 | QFETCH(QAxis*, axis2); | |
507 | QFETCH(int, axisCount); |
|
508 | QFETCH(int, axisCount); | |
508 |
|
509 | |||
509 | Q_UNUSED(axisCount); |
|
510 | Q_UNUSED(axisCount); | |
510 |
|
511 | |||
511 | m_dataset->addSeries(series0, axis0); |
|
512 | m_dataset->addSeries(series0, axis0); | |
512 | m_dataset->addSeries(series1, axis1); |
|
513 | m_dataset->addSeries(series1, axis1); | |
513 | m_dataset->addSeries(series2, axis2); |
|
514 | m_dataset->addSeries(series2, axis2); | |
514 |
|
515 | |||
515 | Domain* domain0 = m_dataset->domain(series0); |
|
516 | Domain* domain0 = m_dataset->domain(series0); | |
516 | Domain* domain1 = m_dataset->domain(series1); |
|
517 | Domain* domain1 = m_dataset->domain(series1); | |
517 | Domain* domain2 = m_dataset->domain(series2); |
|
518 | Domain* domain2 = m_dataset->domain(series2); | |
518 |
|
519 | |||
519 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
520 | QSignalSpy spy0(domain0, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
520 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
521 | QSignalSpy spy1(domain1, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
521 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
522 | QSignalSpy spy2(domain2, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
522 |
|
523 | |||
523 | m_dataset->scrollDomain(10,10,QSize(1000,1000)); |
|
524 | m_dataset->scrollDomain(10,10,QSize(1000,1000)); | |
524 |
|
525 | |||
525 |
|
|
526 | TRY_COMPARE(spy0.count(), 1); | |
526 |
|
|
527 | TRY_COMPARE(spy1.count(), 1); | |
527 |
|
|
528 | TRY_COMPARE(spy2.count(), 1); | |
528 | } |
|
529 | } | |
529 |
|
530 | |||
530 | QTEST_MAIN(tst_ChartDataSet) |
|
531 | QTEST_MAIN(tst_ChartDataSet) | |
531 | #include "tst_chartdataset.moc" |
|
532 | #include "tst_chartdataset.moc" | |
532 |
|
533 |
@@ -1,712 +1,713 | |||||
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 <private/domain_p.h> |
|
22 | #include <private/domain_p.h> | |
23 | #include <qaxis.h> |
|
23 | #include <qaxis.h> | |
|
24 | #include <tst_definitions.h> | |||
24 |
|
25 | |||
25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
26 |
|
27 | |||
27 | Q_DECLARE_METATYPE(Domain*) |
|
28 | Q_DECLARE_METATYPE(Domain*) | |
28 | Q_DECLARE_METATYPE(QSizeF) |
|
29 | Q_DECLARE_METATYPE(QSizeF) | |
29 |
|
30 | |||
30 | class tst_Domain: public QObject |
|
31 | class tst_Domain: public QObject | |
31 | { |
|
32 | { | |
32 | Q_OBJECT |
|
33 | Q_OBJECT | |
33 |
|
34 | |||
34 | public Q_SLOTS: |
|
35 | public Q_SLOTS: | |
35 | void initTestCase(); |
|
36 | void initTestCase(); | |
36 | void cleanupTestCase(); |
|
37 | void cleanupTestCase(); | |
37 | void init(); |
|
38 | void init(); | |
38 | void cleanup(); |
|
39 | void cleanup(); | |
39 |
|
40 | |||
40 | private Q_SLOTS: |
|
41 | private Q_SLOTS: | |
41 | void domain(); |
|
42 | void domain(); | |
42 | void handleAxisRangeXChanged_data(); |
|
43 | void handleAxisRangeXChanged_data(); | |
43 | void handleAxisRangeXChanged(); |
|
44 | void handleAxisRangeXChanged(); | |
44 | void handleAxisRangeYChanged_data(); |
|
45 | void handleAxisRangeYChanged_data(); | |
45 | void handleAxisRangeYChanged(); |
|
46 | void handleAxisRangeYChanged(); | |
46 | void isEmpty_data(); |
|
47 | void isEmpty_data(); | |
47 | void isEmpty(); |
|
48 | void isEmpty(); | |
48 | void maxX_data(); |
|
49 | void maxX_data(); | |
49 | void maxX(); |
|
50 | void maxX(); | |
50 | void maxY_data(); |
|
51 | void maxY_data(); | |
51 | void maxY(); |
|
52 | void maxY(); | |
52 | void minX_data(); |
|
53 | void minX_data(); | |
53 | void minX(); |
|
54 | void minX(); | |
54 | void minY_data(); |
|
55 | void minY_data(); | |
55 | void minY(); |
|
56 | void minY(); | |
56 | void operatorEquals_data(); |
|
57 | void operatorEquals_data(); | |
57 | void operatorEquals(); |
|
58 | void operatorEquals(); | |
58 | void setRange_data(); |
|
59 | void setRange_data(); | |
59 | void setRange(); |
|
60 | void setRange(); | |
60 | void setRangeX_data(); |
|
61 | void setRangeX_data(); | |
61 | void setRangeX(); |
|
62 | void setRangeX(); | |
62 | void setRangeY_data(); |
|
63 | void setRangeY_data(); | |
63 | void setRangeY(); |
|
64 | void setRangeY(); | |
64 | void spanX_data(); |
|
65 | void spanX_data(); | |
65 | void spanX(); |
|
66 | void spanX(); | |
66 | void spanY_data(); |
|
67 | void spanY_data(); | |
67 | void spanY(); |
|
68 | void spanY(); | |
68 | void zoom_data(); |
|
69 | void zoom_data(); | |
69 | void zoom(); |
|
70 | void zoom(); | |
70 | void move_data(); |
|
71 | void move_data(); | |
71 | void move(); |
|
72 | void move(); | |
72 | void handleAxisXChanged_data(); |
|
73 | void handleAxisXChanged_data(); | |
73 | void handleAxisXChanged(); |
|
74 | void handleAxisXChanged(); | |
74 | void handleAxisYChanged_data(); |
|
75 | void handleAxisYChanged_data(); | |
75 | void handleAxisYChanged(); |
|
76 | void handleAxisYChanged(); | |
76 | }; |
|
77 | }; | |
77 |
|
78 | |||
78 | void tst_Domain::initTestCase() |
|
79 | void tst_Domain::initTestCase() | |
79 | { |
|
80 | { | |
80 | } |
|
81 | } | |
81 |
|
82 | |||
82 | void tst_Domain::cleanupTestCase() |
|
83 | void tst_Domain::cleanupTestCase() | |
83 | { |
|
84 | { | |
84 | } |
|
85 | } | |
85 |
|
86 | |||
86 | void tst_Domain::init() |
|
87 | void tst_Domain::init() | |
87 | { |
|
88 | { | |
88 | } |
|
89 | } | |
89 |
|
90 | |||
90 | void tst_Domain::cleanup() |
|
91 | void tst_Domain::cleanup() | |
91 | { |
|
92 | { | |
92 | } |
|
93 | } | |
93 |
|
94 | |||
94 | void tst_Domain::domain() |
|
95 | void tst_Domain::domain() | |
95 | { |
|
96 | { | |
96 | Domain domain; |
|
97 | Domain domain; | |
97 |
|
98 | |||
98 | QCOMPARE(domain.isEmpty(), true); |
|
99 | QCOMPARE(domain.isEmpty(), true); | |
99 | QCOMPARE(domain.maxX(), 0.0); |
|
100 | QCOMPARE(domain.maxX(), 0.0); | |
100 | QCOMPARE(domain.maxY(), 0.0); |
|
101 | QCOMPARE(domain.maxY(), 0.0); | |
101 | QCOMPARE(domain.minX(), 0.0); |
|
102 | QCOMPARE(domain.minX(), 0.0); | |
102 | QCOMPARE(domain.minY(), 0.0); |
|
103 | QCOMPARE(domain.minY(), 0.0); | |
103 | } |
|
104 | } | |
104 |
|
105 | |||
105 | void tst_Domain::handleAxisRangeXChanged_data() |
|
106 | void tst_Domain::handleAxisRangeXChanged_data() | |
106 | { |
|
107 | { | |
107 | QTest::addColumn<qreal>("min"); |
|
108 | QTest::addColumn<qreal>("min"); | |
108 | QTest::addColumn<qreal>("max"); |
|
109 | QTest::addColumn<qreal>("max"); | |
109 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
110 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
110 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
111 | QTest::newRow("0 1") << 0.0 << 1.0; | |
111 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
112 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
112 | } |
|
113 | } | |
113 |
|
114 | |||
114 | void tst_Domain::handleAxisRangeXChanged() |
|
115 | void tst_Domain::handleAxisRangeXChanged() | |
115 | { |
|
116 | { | |
116 | QFETCH(qreal, min); |
|
117 | QFETCH(qreal, min); | |
117 | QFETCH(qreal, max); |
|
118 | QFETCH(qreal, max); | |
118 |
|
119 | |||
119 | Domain domain; |
|
120 | Domain domain; | |
120 |
|
121 | |||
121 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
122 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
122 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
123 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
123 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
124 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
124 |
|
125 | |||
125 | domain.handleAxisXChanged(min, max); |
|
126 | domain.handleAxisXChanged(min, max); | |
126 |
|
127 | |||
127 | QList<QVariant> arg0 = spy0.first(); |
|
128 | QList<QVariant> arg0 = spy0.first(); | |
128 | QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min)); |
|
129 | QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min)); | |
129 | QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max)); |
|
130 | QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max)); | |
130 |
|
131 | |||
131 | QList<QVariant> arg1 = spy1.first(); |
|
132 | QList<QVariant> arg1 = spy1.first(); | |
132 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
133 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
133 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
134 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
134 |
|
135 | |||
135 |
|
|
136 | TRY_COMPARE(spy0.count(), 1); | |
136 |
|
|
137 | TRY_COMPARE(spy1.count(), 1); | |
137 |
|
|
138 | TRY_COMPARE(spy2.count(), 0); | |
138 |
|
139 | |||
139 | } |
|
140 | } | |
140 |
|
141 | |||
141 | void tst_Domain::handleAxisRangeYChanged_data() |
|
142 | void tst_Domain::handleAxisRangeYChanged_data() | |
142 | { |
|
143 | { | |
143 | QTest::addColumn<qreal>("min"); |
|
144 | QTest::addColumn<qreal>("min"); | |
144 | QTest::addColumn<qreal>("max"); |
|
145 | QTest::addColumn<qreal>("max"); | |
145 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
146 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
146 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
147 | QTest::newRow("0 1") << 0.0 << 1.0; | |
147 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
148 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
148 | } |
|
149 | } | |
149 |
|
150 | |||
150 | void tst_Domain::handleAxisRangeYChanged() |
|
151 | void tst_Domain::handleAxisRangeYChanged() | |
151 | { |
|
152 | { | |
152 | QFETCH(qreal, min); |
|
153 | QFETCH(qreal, min); | |
153 | QFETCH(qreal, max); |
|
154 | QFETCH(qreal, max); | |
154 |
|
155 | |||
155 | Domain domain; |
|
156 | Domain domain; | |
156 |
|
157 | |||
157 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
158 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
158 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
159 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
159 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
160 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
160 |
|
161 | |||
161 | domain.handleAxisYChanged(min, max, 5); |
|
162 | domain.handleAxisYChanged(min, max, 5); | |
162 |
|
163 | |||
163 | QList<QVariant> arg0 = spy0.first(); |
|
164 | QList<QVariant> arg0 = spy0.first(); | |
164 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); |
|
165 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); | |
165 | QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max)); |
|
166 | QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max)); | |
166 |
|
167 | |||
167 | QList<QVariant> arg1 = spy2.first(); |
|
168 | QList<QVariant> arg1 = spy2.first(); | |
168 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
169 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
169 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
170 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
170 |
|
171 | |||
171 |
|
|
172 | TRY_COMPARE(spy0.count(), 1); | |
172 |
|
|
173 | TRY_COMPARE(spy1.count(), 0); | |
173 |
|
|
174 | TRY_COMPARE(spy2.count(), 1); | |
174 | } |
|
175 | } | |
175 |
|
176 | |||
176 | void tst_Domain::isEmpty_data() |
|
177 | void tst_Domain::isEmpty_data() | |
177 | { |
|
178 | { | |
178 | QTest::addColumn<qreal>("minX"); |
|
179 | QTest::addColumn<qreal>("minX"); | |
179 | QTest::addColumn<qreal>("maxX"); |
|
180 | QTest::addColumn<qreal>("maxX"); | |
180 | QTest::addColumn<qreal>("minY"); |
|
181 | QTest::addColumn<qreal>("minY"); | |
181 | QTest::addColumn<qreal>("maxY"); |
|
182 | QTest::addColumn<qreal>("maxY"); | |
182 | QTest::addColumn<bool>("isEmpty"); |
|
183 | QTest::addColumn<bool>("isEmpty"); | |
183 | QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true; |
|
184 | QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true; | |
184 | QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true; |
|
185 | QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true; | |
185 | QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true; |
|
186 | QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true; | |
186 | QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false; |
|
187 | QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false; | |
187 | } |
|
188 | } | |
188 |
|
189 | |||
189 | void tst_Domain::isEmpty() |
|
190 | void tst_Domain::isEmpty() | |
190 | { |
|
191 | { | |
191 | QFETCH(qreal, minX); |
|
192 | QFETCH(qreal, minX); | |
192 | QFETCH(qreal, maxX); |
|
193 | QFETCH(qreal, maxX); | |
193 | QFETCH(qreal, minY); |
|
194 | QFETCH(qreal, minY); | |
194 | QFETCH(qreal, maxY); |
|
195 | QFETCH(qreal, maxY); | |
195 | QFETCH(bool, isEmpty); |
|
196 | QFETCH(bool, isEmpty); | |
196 |
|
197 | |||
197 | Domain domain; |
|
198 | Domain domain; | |
198 | domain.setRange(minX, maxX, minY, maxY); |
|
199 | domain.setRange(minX, maxX, minY, maxY); | |
199 | QCOMPARE(domain.isEmpty(), isEmpty); |
|
200 | QCOMPARE(domain.isEmpty(), isEmpty); | |
200 | } |
|
201 | } | |
201 |
|
202 | |||
202 | void tst_Domain::maxX_data() |
|
203 | void tst_Domain::maxX_data() | |
203 | { |
|
204 | { | |
204 | QTest::addColumn<qreal>("maxX1"); |
|
205 | QTest::addColumn<qreal>("maxX1"); | |
205 | QTest::addColumn<qreal>("maxX2"); |
|
206 | QTest::addColumn<qreal>("maxX2"); | |
206 | QTest::addColumn<int>("count"); |
|
207 | QTest::addColumn<int>("count"); | |
207 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
208 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
208 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
209 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
209 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
210 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
210 | } |
|
211 | } | |
211 |
|
212 | |||
212 | void tst_Domain::maxX() |
|
213 | void tst_Domain::maxX() | |
213 | { |
|
214 | { | |
214 | QFETCH(qreal, maxX1); |
|
215 | QFETCH(qreal, maxX1); | |
215 | QFETCH(qreal, maxX2); |
|
216 | QFETCH(qreal, maxX2); | |
216 | QFETCH(int, count); |
|
217 | QFETCH(int, count); | |
217 |
|
218 | |||
218 | Domain domain; |
|
219 | Domain domain; | |
219 |
|
220 | |||
220 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
221 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
221 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
222 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
222 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
223 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
223 |
|
224 | |||
224 | domain.setMaxX(maxX1); |
|
225 | domain.setMaxX(maxX1); | |
225 | QCOMPARE(domain.maxX(), maxX1); |
|
226 | QCOMPARE(domain.maxX(), maxX1); | |
226 | domain.setMaxX(maxX2); |
|
227 | domain.setMaxX(maxX2); | |
227 | QCOMPARE(domain.maxX(), maxX2); |
|
228 | QCOMPARE(domain.maxX(), maxX2); | |
228 |
|
229 | |||
229 |
|
|
230 | TRY_COMPARE(spy0.count(), count); | |
230 |
|
|
231 | TRY_COMPARE(spy1.count(), count); | |
231 |
|
|
232 | TRY_COMPARE(spy2.count(), 0); | |
232 |
|
233 | |||
233 | } |
|
234 | } | |
234 |
|
235 | |||
235 | void tst_Domain::maxY_data() |
|
236 | void tst_Domain::maxY_data() | |
236 | { |
|
237 | { | |
237 | QTest::addColumn<qreal>("maxY1"); |
|
238 | QTest::addColumn<qreal>("maxY1"); | |
238 | QTest::addColumn<qreal>("maxY2"); |
|
239 | QTest::addColumn<qreal>("maxY2"); | |
239 | QTest::addColumn<int>("count"); |
|
240 | QTest::addColumn<int>("count"); | |
240 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
241 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
241 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
242 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
242 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
243 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
243 | } |
|
244 | } | |
244 |
|
245 | |||
245 | void tst_Domain::maxY() |
|
246 | void tst_Domain::maxY() | |
246 | { |
|
247 | { | |
247 | QFETCH(qreal, maxY1); |
|
248 | QFETCH(qreal, maxY1); | |
248 | QFETCH(qreal, maxY2); |
|
249 | QFETCH(qreal, maxY2); | |
249 | QFETCH(int, count); |
|
250 | QFETCH(int, count); | |
250 |
|
251 | |||
251 | Domain domain; |
|
252 | Domain domain; | |
252 |
|
253 | |||
253 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
254 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
254 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
255 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
255 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
256 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
256 |
|
257 | |||
257 | domain.setMaxY(maxY1); |
|
258 | domain.setMaxY(maxY1); | |
258 | QCOMPARE(domain.maxY(), maxY1); |
|
259 | QCOMPARE(domain.maxY(), maxY1); | |
259 | domain.setMaxY(maxY2); |
|
260 | domain.setMaxY(maxY2); | |
260 | QCOMPARE(domain.maxY(), maxY2); |
|
261 | QCOMPARE(domain.maxY(), maxY2); | |
261 |
|
262 | |||
262 |
|
|
263 | TRY_COMPARE(spy0.count(), count); | |
263 |
|
|
264 | TRY_COMPARE(spy1.count(), 0); | |
264 |
|
|
265 | TRY_COMPARE(spy2.count(), count); | |
265 | } |
|
266 | } | |
266 |
|
267 | |||
267 | void tst_Domain::minX_data() |
|
268 | void tst_Domain::minX_data() | |
268 | { |
|
269 | { | |
269 | QTest::addColumn<qreal>("minX1"); |
|
270 | QTest::addColumn<qreal>("minX1"); | |
270 | QTest::addColumn<qreal>("minX2"); |
|
271 | QTest::addColumn<qreal>("minX2"); | |
271 | QTest::addColumn<int>("count"); |
|
272 | QTest::addColumn<int>("count"); | |
272 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
273 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
273 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
274 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
274 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
275 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
275 | } |
|
276 | } | |
276 |
|
277 | |||
277 | void tst_Domain::minX() |
|
278 | void tst_Domain::minX() | |
278 | { |
|
279 | { | |
279 | QFETCH(qreal, minX1); |
|
280 | QFETCH(qreal, minX1); | |
280 | QFETCH(qreal, minX2); |
|
281 | QFETCH(qreal, minX2); | |
281 | QFETCH(int, count); |
|
282 | QFETCH(int, count); | |
282 |
|
283 | |||
283 | Domain domain; |
|
284 | Domain domain; | |
284 |
|
285 | |||
285 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
286 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
286 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
287 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
287 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
288 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
288 |
|
289 | |||
289 | domain.setMinX(minX1); |
|
290 | domain.setMinX(minX1); | |
290 | QCOMPARE(domain.minX(), minX1); |
|
291 | QCOMPARE(domain.minX(), minX1); | |
291 | domain.setMinX(minX2); |
|
292 | domain.setMinX(minX2); | |
292 | QCOMPARE(domain.minX(), minX2); |
|
293 | QCOMPARE(domain.minX(), minX2); | |
293 |
|
294 | |||
294 |
|
|
295 | TRY_COMPARE(spy0.count(), count); | |
295 |
|
|
296 | TRY_COMPARE(spy1.count(), count); | |
296 |
|
|
297 | TRY_COMPARE(spy2.count(), 0); | |
297 | } |
|
298 | } | |
298 |
|
299 | |||
299 | void tst_Domain::minY_data() |
|
300 | void tst_Domain::minY_data() | |
300 | { |
|
301 | { | |
301 | QTest::addColumn<qreal>("minY1"); |
|
302 | QTest::addColumn<qreal>("minY1"); | |
302 | QTest::addColumn<qreal>("minY2"); |
|
303 | QTest::addColumn<qreal>("minY2"); | |
303 | QTest::addColumn<int>("count"); |
|
304 | QTest::addColumn<int>("count"); | |
304 | QTest::newRow("1") << 0.0 << 1.0 << 1; |
|
305 | QTest::newRow("1") << 0.0 << 1.0 << 1; | |
305 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; |
|
306 | QTest::newRow("1.0") << 1.0 << 1.0 << 1; | |
306 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; |
|
307 | QTest::newRow("2.0") << 1.0 << 0.0 << 2; | |
307 | } |
|
308 | } | |
308 |
|
309 | |||
309 | void tst_Domain::minY() |
|
310 | void tst_Domain::minY() | |
310 | { |
|
311 | { | |
311 | QFETCH(qreal, minY1); |
|
312 | QFETCH(qreal, minY1); | |
312 | QFETCH(qreal, minY2); |
|
313 | QFETCH(qreal, minY2); | |
313 | QFETCH(int, count); |
|
314 | QFETCH(int, count); | |
314 |
|
315 | |||
315 | Domain domain; |
|
316 | Domain domain; | |
316 |
|
317 | |||
317 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
318 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
318 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
319 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
319 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
320 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
320 |
|
321 | |||
321 | domain.setMinY(minY1); |
|
322 | domain.setMinY(minY1); | |
322 | QCOMPARE(domain.minY(), minY1); |
|
323 | QCOMPARE(domain.minY(), minY1); | |
323 | domain.setMinY(minY2); |
|
324 | domain.setMinY(minY2); | |
324 | QCOMPARE(domain.minY(), minY2); |
|
325 | QCOMPARE(domain.minY(), minY2); | |
325 |
|
326 | |||
326 |
|
|
327 | TRY_COMPARE(spy0.count(), count); | |
327 |
|
|
328 | TRY_COMPARE(spy1.count(), 0); | |
328 |
|
|
329 | TRY_COMPARE(spy2.count(), count); | |
329 | } |
|
330 | } | |
330 |
|
331 | |||
331 | void tst_Domain::operatorEquals_data() |
|
332 | void tst_Domain::operatorEquals_data() | |
332 | { |
|
333 | { | |
333 |
|
334 | |||
334 | QTest::addColumn<Domain*>("domain1"); |
|
335 | QTest::addColumn<Domain*>("domain1"); | |
335 | QTest::addColumn<Domain*>("domain2"); |
|
336 | QTest::addColumn<Domain*>("domain2"); | |
336 | QTest::addColumn<bool>("equals"); |
|
337 | QTest::addColumn<bool>("equals"); | |
337 | QTest::addColumn<bool>("notEquals"); |
|
338 | QTest::addColumn<bool>("notEquals"); | |
338 | Domain* a; |
|
339 | Domain* a; | |
339 | Domain* b; |
|
340 | Domain* b; | |
340 | a = new Domain(); |
|
341 | a = new Domain(); | |
341 | a->setRange(0, 100, 0, 100); |
|
342 | a->setRange(0, 100, 0, 100); | |
342 | b = new Domain(); |
|
343 | b = new Domain(); | |
343 | b->setRange(0, 100, 0, 100); |
|
344 | b->setRange(0, 100, 0, 100); | |
344 | QTest::newRow("equals") << a << b << true << false; |
|
345 | QTest::newRow("equals") << a << b << true << false; | |
345 | a = new Domain(); |
|
346 | a = new Domain(); | |
346 | a->setRange(0, 100, 0, 100); |
|
347 | a->setRange(0, 100, 0, 100); | |
347 | b = new Domain(); |
|
348 | b = new Domain(); | |
348 | b->setRange(0, 100, 0, 1); |
|
349 | b->setRange(0, 100, 0, 1); | |
349 | QTest::newRow("equals") << a << b << false << true; |
|
350 | QTest::newRow("equals") << a << b << false << true; | |
350 | a = new Domain(); |
|
351 | a = new Domain(); | |
351 | a->setRange(0, 100, 0, 100); |
|
352 | a->setRange(0, 100, 0, 100); | |
352 | b = new Domain(); |
|
353 | b = new Domain(); | |
353 | b->setRange(0, 1, 0, 100); |
|
354 | b->setRange(0, 1, 0, 100); | |
354 | QTest::newRow("equals") << a << b << false << true; |
|
355 | QTest::newRow("equals") << a << b << false << true; | |
355 |
|
356 | |||
356 | } |
|
357 | } | |
357 |
|
358 | |||
358 | void tst_Domain::operatorEquals() |
|
359 | void tst_Domain::operatorEquals() | |
359 | { |
|
360 | { | |
360 | QFETCH(Domain*, domain1); |
|
361 | QFETCH(Domain*, domain1); | |
361 | QFETCH(Domain*, domain2); |
|
362 | QFETCH(Domain*, domain2); | |
362 | QFETCH(bool, equals); |
|
363 | QFETCH(bool, equals); | |
363 | QFETCH(bool, notEquals); |
|
364 | QFETCH(bool, notEquals); | |
364 |
|
365 | |||
365 | Domain domain; |
|
366 | Domain domain; | |
366 |
|
367 | |||
367 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
368 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
368 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
369 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
369 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
370 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
370 |
|
371 | |||
371 | QCOMPARE(*domain1==*domain2, equals); |
|
372 | QCOMPARE(*domain1==*domain2, equals); | |
372 | QCOMPARE(*domain1!=*domain2, notEquals); |
|
373 | QCOMPARE(*domain1!=*domain2, notEquals); | |
373 |
|
374 | |||
374 |
|
|
375 | TRY_COMPARE(spy0.count(), 0); | |
375 |
|
|
376 | TRY_COMPARE(spy1.count(), 0); | |
376 |
|
|
377 | TRY_COMPARE(spy2.count(), 0); | |
377 | } |
|
378 | } | |
378 |
|
379 | |||
379 | void tst_Domain::setRange_data() |
|
380 | void tst_Domain::setRange_data() | |
380 | { |
|
381 | { | |
381 | QTest::addColumn<qreal>("minX"); |
|
382 | QTest::addColumn<qreal>("minX"); | |
382 | QTest::addColumn<qreal>("maxX"); |
|
383 | QTest::addColumn<qreal>("maxX"); | |
383 | QTest::addColumn<qreal>("minY"); |
|
384 | QTest::addColumn<qreal>("minY"); | |
384 | QTest::addColumn<qreal>("maxY"); |
|
385 | QTest::addColumn<qreal>("maxY"); | |
385 | QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0; |
|
386 | QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0; | |
386 | QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0; |
|
387 | QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0; | |
387 | QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0; |
|
388 | QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0; | |
388 | } |
|
389 | } | |
389 |
|
390 | |||
390 | void tst_Domain::setRange() |
|
391 | void tst_Domain::setRange() | |
391 | { |
|
392 | { | |
392 | QFETCH(qreal, minX); |
|
393 | QFETCH(qreal, minX); | |
393 | QFETCH(qreal, maxX); |
|
394 | QFETCH(qreal, maxX); | |
394 | QFETCH(qreal, minY); |
|
395 | QFETCH(qreal, minY); | |
395 | QFETCH(qreal, maxY); |
|
396 | QFETCH(qreal, maxY); | |
396 |
|
397 | |||
397 | Domain domain; |
|
398 | Domain domain; | |
398 |
|
399 | |||
399 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
400 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
400 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
401 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
401 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
402 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
402 |
|
403 | |||
403 | domain.setRange(minX, maxX, minY, maxY); |
|
404 | domain.setRange(minX, maxX, minY, maxY); | |
404 |
|
405 | |||
405 | QCOMPARE(domain.minX(), minX); |
|
406 | QCOMPARE(domain.minX(), minX); | |
406 | QCOMPARE(domain.maxX(), maxX); |
|
407 | QCOMPARE(domain.maxX(), maxX); | |
407 | QCOMPARE(domain.minY(), minY); |
|
408 | QCOMPARE(domain.minY(), minY); | |
408 | QCOMPARE(domain.maxY(), maxY); |
|
409 | QCOMPARE(domain.maxY(), maxY); | |
409 |
|
410 | |||
410 |
|
|
411 | TRY_COMPARE(spy0.count(), 1); | |
411 |
|
|
412 | TRY_COMPARE(spy1.count(), 1); | |
412 |
|
|
413 | TRY_COMPARE(spy2.count(), 1); | |
413 |
|
414 | |||
414 | } |
|
415 | } | |
415 |
|
416 | |||
416 | void tst_Domain::setRangeX_data() |
|
417 | void tst_Domain::setRangeX_data() | |
417 | { |
|
418 | { | |
418 | QTest::addColumn<qreal>("min"); |
|
419 | QTest::addColumn<qreal>("min"); | |
419 | QTest::addColumn<qreal>("max"); |
|
420 | QTest::addColumn<qreal>("max"); | |
420 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
421 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
421 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
422 | QTest::newRow("0 1") << 0.0 << 1.0; | |
422 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
423 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
423 | } |
|
424 | } | |
424 |
|
425 | |||
425 | void tst_Domain::setRangeX() |
|
426 | void tst_Domain::setRangeX() | |
426 | { |
|
427 | { | |
427 | QFETCH(qreal, min); |
|
428 | QFETCH(qreal, min); | |
428 | QFETCH(qreal, max); |
|
429 | QFETCH(qreal, max); | |
429 |
|
430 | |||
430 | Domain domain; |
|
431 | Domain domain; | |
431 |
|
432 | |||
432 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
433 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
433 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
434 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
434 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
435 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
435 |
|
436 | |||
436 | domain.setRangeX(min, max); |
|
437 | domain.setRangeX(min, max); | |
437 |
|
438 | |||
438 | QList<QVariant> arg0 = spy0.first(); |
|
439 | QList<QVariant> arg0 = spy0.first(); | |
439 | QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min)); |
|
440 | QVERIFY(qFuzzyIsNull(arg0.at(0).toReal() - min)); | |
440 | QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max)); |
|
441 | QVERIFY(qFuzzyIsNull(arg0.at(1).toReal() - max)); | |
441 |
|
442 | |||
442 | QList<QVariant> arg1 = spy1.first(); |
|
443 | QList<QVariant> arg1 = spy1.first(); | |
443 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
444 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
444 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
445 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
445 |
|
446 | |||
446 |
|
|
447 | TRY_COMPARE(spy0.count(), 1); | |
447 |
|
|
448 | TRY_COMPARE(spy1.count(), 1); | |
448 |
|
|
449 | TRY_COMPARE(spy2.count(), 0); | |
449 | } |
|
450 | } | |
450 |
|
451 | |||
451 | void tst_Domain::setRangeY_data() |
|
452 | void tst_Domain::setRangeY_data() | |
452 | { |
|
453 | { | |
453 | QTest::addColumn<qreal>("min"); |
|
454 | QTest::addColumn<qreal>("min"); | |
454 | QTest::addColumn<qreal>("max"); |
|
455 | QTest::addColumn<qreal>("max"); | |
455 | QTest::newRow("-1 1") << -1.0 << 1.0; |
|
456 | QTest::newRow("-1 1") << -1.0 << 1.0; | |
456 | QTest::newRow("0 1") << 0.0 << 1.0; |
|
457 | QTest::newRow("0 1") << 0.0 << 1.0; | |
457 | QTest::newRow("-1 0") << -1.0 << 0.0; |
|
458 | QTest::newRow("-1 0") << -1.0 << 0.0; | |
458 | } |
|
459 | } | |
459 |
|
460 | |||
460 | void tst_Domain::setRangeY() |
|
461 | void tst_Domain::setRangeY() | |
461 | { |
|
462 | { | |
462 | QFETCH(qreal, min); |
|
463 | QFETCH(qreal, min); | |
463 | QFETCH(qreal, max); |
|
464 | QFETCH(qreal, max); | |
464 |
|
465 | |||
465 | Domain domain; |
|
466 | Domain domain; | |
466 |
|
467 | |||
467 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
468 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
468 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
469 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
469 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
470 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
470 |
|
471 | |||
471 | domain.setRangeY(min, max); |
|
472 | domain.setRangeY(min, max); | |
472 |
|
473 | |||
473 | QList<QVariant> arg0 = spy0.first(); |
|
474 | QList<QVariant> arg0 = spy0.first(); | |
474 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); |
|
475 | QVERIFY(qFuzzyIsNull(arg0.at(2).toReal() - min)); | |
475 | QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max)); |
|
476 | QVERIFY(qFuzzyIsNull(arg0.at(3).toReal() - max)); | |
476 |
|
477 | |||
477 | QList<QVariant> arg1 = spy2.first(); |
|
478 | QList<QVariant> arg1 = spy2.first(); | |
478 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); |
|
479 | QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); | |
479 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); |
|
480 | QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); | |
480 |
|
481 | |||
481 |
|
|
482 | TRY_COMPARE(spy0.count(), 1); | |
482 |
|
|
483 | TRY_COMPARE(spy1.count(), 0); | |
483 |
|
|
484 | TRY_COMPARE(spy2.count(), 1); | |
484 | } |
|
485 | } | |
485 |
|
486 | |||
486 | void tst_Domain::spanX_data() |
|
487 | void tst_Domain::spanX_data() | |
487 | { |
|
488 | { | |
488 | QTest::addColumn<qreal>("minX"); |
|
489 | QTest::addColumn<qreal>("minX"); | |
489 | QTest::addColumn<qreal>("maxX"); |
|
490 | QTest::addColumn<qreal>("maxX"); | |
490 | QTest::addColumn<qreal>("spanX"); |
|
491 | QTest::addColumn<qreal>("spanX"); | |
491 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; |
|
492 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
492 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; |
|
493 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
493 | } |
|
494 | } | |
494 |
|
495 | |||
495 | void tst_Domain::spanX() |
|
496 | void tst_Domain::spanX() | |
496 | { |
|
497 | { | |
497 | QFETCH(qreal, minX); |
|
498 | QFETCH(qreal, minX); | |
498 | QFETCH(qreal, maxX); |
|
499 | QFETCH(qreal, maxX); | |
499 | QFETCH(qreal, spanX); |
|
500 | QFETCH(qreal, spanX); | |
500 |
|
501 | |||
501 | Domain domain; |
|
502 | Domain domain; | |
502 |
|
503 | |||
503 | domain.setRangeX(minX, maxX); |
|
504 | domain.setRangeX(minX, maxX); | |
504 |
|
505 | |||
505 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
506 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
506 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
507 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
507 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
508 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
508 |
|
509 | |||
509 | QCOMPARE(domain.spanX(), spanX); |
|
510 | QCOMPARE(domain.spanX(), spanX); | |
510 |
|
511 | |||
511 |
|
|
512 | TRY_COMPARE(spy0.count(), 0); | |
512 |
|
|
513 | TRY_COMPARE(spy1.count(), 0); | |
513 |
|
|
514 | TRY_COMPARE(spy2.count(), 0); | |
514 | } |
|
515 | } | |
515 |
|
516 | |||
516 | void tst_Domain::spanY_data() |
|
517 | void tst_Domain::spanY_data() | |
517 | { |
|
518 | { | |
518 | QTest::addColumn<qreal>("minY"); |
|
519 | QTest::addColumn<qreal>("minY"); | |
519 | QTest::addColumn<qreal>("maxY"); |
|
520 | QTest::addColumn<qreal>("maxY"); | |
520 | QTest::addColumn<qreal>("spanY"); |
|
521 | QTest::addColumn<qreal>("spanY"); | |
521 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; |
|
522 | QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; | |
522 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; |
|
523 | QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; | |
523 | } |
|
524 | } | |
524 |
|
525 | |||
525 | void tst_Domain::spanY() |
|
526 | void tst_Domain::spanY() | |
526 | { |
|
527 | { | |
527 | QFETCH(qreal, minY); |
|
528 | QFETCH(qreal, minY); | |
528 | QFETCH(qreal, maxY); |
|
529 | QFETCH(qreal, maxY); | |
529 | QFETCH(qreal, spanY); |
|
530 | QFETCH(qreal, spanY); | |
530 |
|
531 | |||
531 | Domain domain; |
|
532 | Domain domain; | |
532 |
|
533 | |||
533 | domain.setRangeY(minY, maxY); |
|
534 | domain.setRangeY(minY, maxY); | |
534 |
|
535 | |||
535 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
536 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
536 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
537 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
537 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
538 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
538 |
|
539 | |||
539 | QCOMPARE(domain.spanY(), spanY); |
|
540 | QCOMPARE(domain.spanY(), spanY); | |
540 |
|
541 | |||
541 |
|
|
542 | TRY_COMPARE(spy0.count(), 0); | |
542 |
|
|
543 | TRY_COMPARE(spy1.count(), 0); | |
543 |
|
|
544 | TRY_COMPARE(spy2.count(), 0); | |
544 | } |
|
545 | } | |
545 |
|
546 | |||
546 | void tst_Domain::zoom_data() |
|
547 | void tst_Domain::zoom_data() | |
547 | { |
|
548 | { | |
548 | QTest::addColumn<QRectF>("rect0"); |
|
549 | QTest::addColumn<QRectF>("rect0"); | |
549 | QTest::addColumn<QSizeF>("size0"); |
|
550 | QTest::addColumn<QSizeF>("size0"); | |
550 | QTest::addColumn<QRectF>("rect1"); |
|
551 | QTest::addColumn<QRectF>("rect1"); | |
551 | QTest::addColumn<QSizeF>("size1"); |
|
552 | QTest::addColumn<QSizeF>("size1"); | |
552 | QTest::addColumn<QRectF>("rect2"); |
|
553 | QTest::addColumn<QRectF>("rect2"); | |
553 | QTest::addColumn<QSizeF>("size2"); |
|
554 | QTest::addColumn<QSizeF>("size2"); | |
554 | QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000) |
|
555 | QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000) | |
555 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) |
|
556 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) | |
556 | << QSizeF(1000, 1000); |
|
557 | << QSizeF(1000, 1000); | |
557 | QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000) |
|
558 | QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000) | |
558 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) |
|
559 | << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) | |
559 | << QSizeF(1000, 1000); |
|
560 | << QSizeF(1000, 1000); | |
560 | QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20) |
|
561 | QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20) | |
561 | << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100); |
|
562 | << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100); | |
562 | } |
|
563 | } | |
563 |
|
564 | |||
564 | void tst_Domain::zoom() |
|
565 | void tst_Domain::zoom() | |
565 | { |
|
566 | { | |
566 | QFETCH(QRectF, rect0); |
|
567 | QFETCH(QRectF, rect0); | |
567 | QFETCH(QSizeF, size0); |
|
568 | QFETCH(QSizeF, size0); | |
568 | QFETCH(QRectF, rect1); |
|
569 | QFETCH(QRectF, rect1); | |
569 | QFETCH(QSizeF, size1); |
|
570 | QFETCH(QSizeF, size1); | |
570 | QFETCH(QRectF, rect2); |
|
571 | QFETCH(QRectF, rect2); | |
571 | QFETCH(QSizeF, size2); |
|
572 | QFETCH(QSizeF, size2); | |
572 |
|
573 | |||
573 | Domain domain; |
|
574 | Domain domain; | |
574 |
|
575 | |||
575 | domain.setRange(0, 1000, 0, 1000); |
|
576 | domain.setRange(0, 1000, 0, 1000); | |
576 |
|
577 | |||
577 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
578 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
578 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
579 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
579 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
580 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
580 |
|
581 | |||
581 | Domain domain0; |
|
582 | Domain domain0; | |
582 | domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); |
|
583 | domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
583 | domain.zoomIn(rect0, size0); |
|
584 | domain.zoomIn(rect0, size0); | |
584 | Domain domain1; |
|
585 | Domain domain1; | |
585 | domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); |
|
586 | domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
586 | domain.zoomIn(rect1, size1); |
|
587 | domain.zoomIn(rect1, size1); | |
587 | Domain domain2; |
|
588 | Domain domain2; | |
588 | domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); |
|
589 | domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); | |
589 | domain.zoomIn(rect2, size2); |
|
590 | domain.zoomIn(rect2, size2); | |
590 | domain.zoomOut(rect2, size2); |
|
591 | domain.zoomOut(rect2, size2); | |
591 | QCOMPARE(domain == domain2, true); |
|
592 | QCOMPARE(domain == domain2, true); | |
592 | domain.zoomOut(rect1, size1); |
|
593 | domain.zoomOut(rect1, size1); | |
593 | QCOMPARE(domain == domain1, true); |
|
594 | QCOMPARE(domain == domain1, true); | |
594 | domain.zoomOut(rect0, size0); |
|
595 | domain.zoomOut(rect0, size0); | |
595 | QCOMPARE(domain == domain0, true); |
|
596 | QCOMPARE(domain == domain0, true); | |
596 |
|
|
597 | TRY_COMPARE(spy0.count(), 6); | |
597 |
|
|
598 | TRY_COMPARE(spy1.count(), 6); | |
598 |
|
|
599 | TRY_COMPARE(spy2.count(), 6); | |
599 |
|
600 | |||
600 | } |
|
601 | } | |
601 |
|
602 | |||
602 | void tst_Domain::move_data() |
|
603 | void tst_Domain::move_data() | |
603 | { |
|
604 | { | |
604 | QTest::addColumn<int>("dx"); |
|
605 | QTest::addColumn<int>("dx"); | |
605 | QTest::addColumn<int>("dy"); |
|
606 | QTest::addColumn<int>("dy"); | |
606 | QTest::addColumn<QSizeF>("size"); |
|
607 | QTest::addColumn<QSizeF>("size"); | |
607 | QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000); |
|
608 | QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000); | |
608 | QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000); |
|
609 | QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000); | |
609 | QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000); |
|
610 | QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000); | |
610 | QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000); |
|
611 | QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000); | |
611 | QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000); |
|
612 | QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000); | |
612 | QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000); |
|
613 | QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000); | |
613 | } |
|
614 | } | |
614 |
|
615 | |||
615 | void tst_Domain::move() |
|
616 | void tst_Domain::move() | |
616 | { |
|
617 | { | |
617 | QFETCH(int, dx); |
|
618 | QFETCH(int, dx); | |
618 | QFETCH(int, dy); |
|
619 | QFETCH(int, dy); | |
619 | QFETCH(QSizeF, size); |
|
620 | QFETCH(QSizeF, size); | |
620 | Domain domain; |
|
621 | Domain domain; | |
621 |
|
622 | |||
622 | domain.setRange(0, size.width(), 0, size.height()); |
|
623 | domain.setRange(0, size.width(), 0, size.height()); | |
623 |
|
624 | |||
624 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
625 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
625 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
626 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
626 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
627 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
627 |
|
628 | |||
628 | domain.move(dx, dy, size); |
|
629 | domain.move(dx, dy, size); | |
629 |
|
630 | |||
630 | Domain result; |
|
631 | Domain result; | |
631 | result.setRange(dx, size.width() + dx, dy, size.height() + dy); |
|
632 | result.setRange(dx, size.width() + dx, dy, size.height() + dy); | |
632 |
|
633 | |||
633 | QCOMPARE(domain == result, true); |
|
634 | QCOMPARE(domain == result, true); | |
634 |
|
|
635 | TRY_COMPARE(spy0.count(), 1); | |
635 |
|
|
636 | TRY_COMPARE(spy1.count(), dx!=0?1:0); | |
636 |
|
|
637 | TRY_COMPARE(spy2.count(), dy!=0?1:0); | |
637 | } |
|
638 | } | |
638 |
|
639 | |||
639 | void tst_Domain::handleAxisXChanged_data() |
|
640 | void tst_Domain::handleAxisXChanged_data() | |
640 | { |
|
641 | { | |
641 | QTest::addColumn<qreal>("min"); |
|
642 | QTest::addColumn<qreal>("min"); | |
642 | QTest::addColumn<qreal>("max"); |
|
643 | QTest::addColumn<qreal>("max"); | |
643 | QTest::addColumn<int>("tickCount"); |
|
644 | QTest::addColumn<int>("tickCount"); | |
644 | QTest::addColumn<bool>("niceNumbers"); |
|
645 | QTest::addColumn<bool>("niceNumbers"); | |
645 | QTest::addColumn<qreal>("resultMin"); |
|
646 | QTest::addColumn<qreal>("resultMin"); | |
646 | QTest::addColumn<qreal>("resultMax"); |
|
647 | QTest::addColumn<qreal>("resultMax"); | |
647 | QTest::addColumn<int>("resultTickCount"); |
|
648 | QTest::addColumn<int>("resultTickCount"); | |
648 | QTest::newRow("0,100,5,false") << 0.0 << 100.0 << 5 << false << 0.0 << 100.0 << 5; |
|
649 | QTest::newRow("0,100,5,false") << 0.0 << 100.0 << 5 << false << 0.0 << 100.0 << 5; | |
649 | QTest::newRow("0,100,5,true") << 0.0 << 100.0 << 5 << true << 0.0 << 100.0 << 6; |
|
650 | QTest::newRow("0,100,5,true") << 0.0 << 100.0 << 5 << true << 0.0 << 100.0 << 6; | |
650 | QTest::newRow("0.1,99,5,true") << 0.1 << 99.0 << 5 << true << 0.0 << 100.0 << 6; |
|
651 | QTest::newRow("0.1,99,5,true") << 0.1 << 99.0 << 5 << true << 0.0 << 100.0 << 6; | |
651 | QTest::newRow("5,93.5,true") << 5.0 << 93.5 << 5 << true << 0.0 << 100.0 << 6; |
|
652 | QTest::newRow("5,93.5,true") << 5.0 << 93.5 << 5 << true << 0.0 << 100.0 << 6; | |
652 | } |
|
653 | } | |
653 |
|
654 | |||
654 | void tst_Domain::handleAxisXChanged() |
|
655 | void tst_Domain::handleAxisXChanged() | |
655 | { |
|
656 | { | |
656 | QFETCH(qreal, min); |
|
657 | QFETCH(qreal, min); | |
657 | QFETCH(qreal, max); |
|
658 | QFETCH(qreal, max); | |
658 | QFETCH(int, tickCount); |
|
659 | QFETCH(int, tickCount); | |
659 | QFETCH(bool, niceNumbers); |
|
660 | QFETCH(bool, niceNumbers); | |
660 | QFETCH(qreal, resultMin); |
|
661 | QFETCH(qreal, resultMin); | |
661 | QFETCH(qreal, resultMax); |
|
662 | QFETCH(qreal, resultMax); | |
662 | QFETCH(int, resultTickCount); |
|
663 | QFETCH(int, resultTickCount); | |
663 |
|
664 | |||
664 | Domain domain; |
|
665 | Domain domain; | |
665 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
666 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
666 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
667 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
667 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
668 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
668 |
|
669 | |||
669 | domain.handleAxisXChanged(min, max, tickCount, niceNumbers); |
|
670 | domain.handleAxisXChanged(min, max, tickCount, niceNumbers); | |
670 |
|
671 | |||
671 | QCOMPARE(resultMin, domain.minX()); |
|
672 | QCOMPARE(resultMin, domain.minX()); | |
672 | QCOMPARE(resultMax, domain.maxX()); |
|
673 | QCOMPARE(resultMax, domain.maxX()); | |
673 | QCOMPARE(resultTickCount, domain.tickXCount()); |
|
674 | QCOMPARE(resultTickCount, domain.tickXCount()); | |
674 |
|
|
675 | TRY_COMPARE(spy0.count(), 1); | |
675 |
|
|
676 | TRY_COMPARE(spy1.count(), 1); | |
676 |
|
|
677 | TRY_COMPARE(spy2.count(), 0); | |
677 |
|
678 | |||
678 | } |
|
679 | } | |
679 |
|
680 | |||
680 | void tst_Domain::handleAxisYChanged_data() |
|
681 | void tst_Domain::handleAxisYChanged_data() | |
681 | { |
|
682 | { | |
682 | handleAxisXChanged_data(); |
|
683 | handleAxisXChanged_data(); | |
683 | } |
|
684 | } | |
684 |
|
685 | |||
685 | void tst_Domain::handleAxisYChanged() |
|
686 | void tst_Domain::handleAxisYChanged() | |
686 | { |
|
687 | { | |
687 | QFETCH(qreal, min); |
|
688 | QFETCH(qreal, min); | |
688 | QFETCH(qreal, max); |
|
689 | QFETCH(qreal, max); | |
689 | QFETCH(int, tickCount); |
|
690 | QFETCH(int, tickCount); | |
690 | QFETCH(bool, niceNumbers); |
|
691 | QFETCH(bool, niceNumbers); | |
691 | QFETCH(qreal, resultMin); |
|
692 | QFETCH(qreal, resultMin); | |
692 | QFETCH(qreal, resultMax); |
|
693 | QFETCH(qreal, resultMax); | |
693 | QFETCH(int, resultTickCount); |
|
694 | QFETCH(int, resultTickCount); | |
694 |
|
695 | |||
695 | Domain domain; |
|
696 | Domain domain; | |
696 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); |
|
697 | QSignalSpy spy0(&domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal))); | |
697 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); |
|
698 | QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal,int))); | |
698 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); |
|
699 | QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal,int))); | |
699 |
|
700 | |||
700 | domain.handleAxisYChanged(min, max, tickCount, niceNumbers); |
|
701 | domain.handleAxisYChanged(min, max, tickCount, niceNumbers); | |
701 |
|
702 | |||
702 | QCOMPARE(resultMin, domain.minY()); |
|
703 | QCOMPARE(resultMin, domain.minY()); | |
703 | QCOMPARE(resultMax, domain.maxY()); |
|
704 | QCOMPARE(resultMax, domain.maxY()); | |
704 | QCOMPARE(resultTickCount, domain.tickYCount()); |
|
705 | QCOMPARE(resultTickCount, domain.tickYCount()); | |
705 |
|
|
706 | TRY_COMPARE(spy0.count(), 1); | |
706 |
|
|
707 | TRY_COMPARE(spy1.count(), 0); | |
707 |
|
|
708 | TRY_COMPARE(spy2.count(), 1); | |
708 | } |
|
709 | } | |
709 |
|
710 | |||
710 | QTEST_MAIN(tst_Domain) |
|
711 | QTEST_MAIN(tst_Domain) | |
711 | #include "tst_domain.moc" |
|
712 | #include "tst_domain.moc" | |
712 |
|
713 |
@@ -1,170 +1,171 | |||||
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 <qchartview.h> |
|
22 | #include <qchartview.h> | |
23 | #include <qlineseries.h> |
|
23 | #include <qlineseries.h> | |
24 | #include <cmath> |
|
24 | #include <cmath> | |
|
25 | #include <tst_definitions.h> | |||
25 |
|
26 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
27 | QTCOMMERCIALCHART_USE_NAMESPACE | |
27 |
|
28 | |||
28 |
|
29 | |||
29 | Q_DECLARE_METATYPE(QChart*) |
|
30 | Q_DECLARE_METATYPE(QChart*) | |
30 | Q_DECLARE_METATYPE(QChartView::RubberBands) |
|
31 | Q_DECLARE_METATYPE(QChartView::RubberBands) | |
31 | Q_DECLARE_METATYPE(Qt::Key) |
|
32 | Q_DECLARE_METATYPE(Qt::Key) | |
32 |
|
33 | |||
33 | class tst_QChartView : public QObject |
|
34 | class tst_QChartView : public QObject | |
34 | { |
|
35 | { | |
35 | Q_OBJECT |
|
36 | Q_OBJECT | |
36 |
|
37 | |||
37 | public Q_SLOTS: |
|
38 | public Q_SLOTS: | |
38 | void initTestCase(); |
|
39 | void initTestCase(); | |
39 | void cleanupTestCase(); |
|
40 | void cleanupTestCase(); | |
40 | void init(); |
|
41 | void init(); | |
41 | void cleanup(); |
|
42 | void cleanup(); | |
42 |
|
43 | |||
43 | private Q_SLOTS: |
|
44 | private Q_SLOTS: | |
44 | void qchartview_data(); |
|
45 | void qchartview_data(); | |
45 | void qchartview(); |
|
46 | void qchartview(); | |
46 | void chart_data(); |
|
47 | void chart_data(); | |
47 | void chart(); |
|
48 | void chart(); | |
48 | void rubberBand_data(); |
|
49 | void rubberBand_data(); | |
49 | void rubberBand(); |
|
50 | void rubberBand(); | |
50 |
|
51 | |||
51 | private: |
|
52 | private: | |
52 | QChartView* m_view; |
|
53 | QChartView* m_view; | |
53 | }; |
|
54 | }; | |
54 |
|
55 | |||
55 | void tst_QChartView::initTestCase() |
|
56 | void tst_QChartView::initTestCase() | |
56 | { |
|
57 | { | |
57 | //test tracks mouse, give a while to user to relese it |
|
58 | //test tracks mouse, give a while to user to relese it | |
58 | QTest::qWait(1000); |
|
59 | QTest::qWait(1000); | |
59 | } |
|
60 | } | |
60 |
|
61 | |||
61 | void tst_QChartView::cleanupTestCase() |
|
62 | void tst_QChartView::cleanupTestCase() | |
62 | { |
|
63 | { | |
63 | } |
|
64 | } | |
64 |
|
65 | |||
65 | void tst_QChartView::init() |
|
66 | void tst_QChartView::init() | |
66 | { |
|
67 | { | |
67 | m_view = new QChartView(new QChart()); |
|
68 | m_view = new QChartView(new QChart()); | |
68 | m_view->chart()->legend()->setVisible(false); |
|
69 | m_view->chart()->legend()->setVisible(false); | |
69 | } |
|
70 | } | |
70 |
|
71 | |||
71 | void tst_QChartView::cleanup() |
|
72 | void tst_QChartView::cleanup() | |
72 | { |
|
73 | { | |
73 | delete m_view; |
|
74 | delete m_view; | |
74 | m_view =0; |
|
75 | m_view =0; | |
75 | } |
|
76 | } | |
76 |
|
77 | |||
77 | void tst_QChartView::qchartview_data() |
|
78 | void tst_QChartView::qchartview_data() | |
78 | { |
|
79 | { | |
79 |
|
80 | |||
80 | } |
|
81 | } | |
81 |
|
82 | |||
82 | void tst_QChartView::qchartview() |
|
83 | void tst_QChartView::qchartview() | |
83 | { |
|
84 | { | |
84 | QVERIFY(m_view->chart()); |
|
85 | QVERIFY(m_view->chart()); | |
85 | QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand); |
|
86 | QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand); | |
86 | m_view->show(); |
|
87 | m_view->show(); | |
87 | QTest::qWaitForWindowShown(m_view); |
|
88 | QTest::qWaitForWindowShown(m_view); | |
88 | } |
|
89 | } | |
89 |
|
90 | |||
90 | void tst_QChartView::chart_data() |
|
91 | void tst_QChartView::chart_data() | |
91 | { |
|
92 | { | |
92 |
|
93 | |||
93 | QTest::addColumn<QChart*>("chart"); |
|
94 | QTest::addColumn<QChart*>("chart"); | |
94 | QTest::newRow("qchart") << new QChart(); |
|
95 | QTest::newRow("qchart") << new QChart(); | |
95 | } |
|
96 | } | |
96 |
|
97 | |||
97 | void tst_QChartView::chart() |
|
98 | void tst_QChartView::chart() | |
98 | { |
|
99 | { | |
99 | QFETCH(QChart*, chart); |
|
100 | QFETCH(QChart*, chart); | |
100 | QChartView* view = new QChartView(chart); |
|
101 | QChartView* view = new QChartView(chart); | |
101 | QCOMPARE(view->chart(), chart); |
|
102 | QCOMPARE(view->chart(), chart); | |
102 | delete view; |
|
103 | delete view; | |
103 | } |
|
104 | } | |
104 |
|
105 | |||
105 | void tst_QChartView::rubberBand_data() |
|
106 | void tst_QChartView::rubberBand_data() | |
106 | { |
|
107 | { | |
107 | QTest::addColumn<QChartView::RubberBands>("rubberBand"); |
|
108 | QTest::addColumn<QChartView::RubberBands>("rubberBand"); | |
108 | QTest::addColumn<int>("Xcount"); |
|
109 | QTest::addColumn<int>("Xcount"); | |
109 | QTest::addColumn<int>("Ycount"); |
|
110 | QTest::addColumn<int>("Ycount"); | |
110 |
|
111 | |||
111 | QTest::addColumn<int>("minX"); |
|
112 | QTest::addColumn<int>("minX"); | |
112 | QTest::addColumn<int>("maxX"); |
|
113 | QTest::addColumn<int>("maxX"); | |
113 | QTest::addColumn<int>("minY"); |
|
114 | QTest::addColumn<int>("minY"); | |
114 | QTest::addColumn<int>("maxY"); |
|
115 | QTest::addColumn<int>("maxY"); | |
115 |
|
116 | |||
116 | QTest::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand) << 0 << 1 << 20 << 180 << 0<< 200; |
|
117 | QTest::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand) << 0 << 1 << 20 << 180 << 0<< 200; | |
117 | QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand) << 1 << 0 << 0 << 200 << 20<< 180; |
|
118 | QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand) << 1 << 0 << 0 << 200 << 20<< 180; | |
118 | QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand) << 1 << 1 <<20 << 180 << 20<< 180; |
|
119 | QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand) << 1 << 1 <<20 << 180 << 20<< 180; | |
119 | } |
|
120 | } | |
120 |
|
121 | |||
121 | void tst_QChartView::rubberBand() |
|
122 | void tst_QChartView::rubberBand() | |
122 | { |
|
123 | { | |
123 | QFETCH(QChartView::RubberBands, rubberBand); |
|
124 | QFETCH(QChartView::RubberBands, rubberBand); | |
124 | QFETCH(int, Xcount); |
|
125 | QFETCH(int, Xcount); | |
125 | QFETCH(int, Ycount); |
|
126 | QFETCH(int, Ycount); | |
126 | QFETCH(int, minX); |
|
127 | QFETCH(int, minX); | |
127 | QFETCH(int, maxX); |
|
128 | QFETCH(int, maxX); | |
128 | QFETCH(int, minY); |
|
129 | QFETCH(int, minY); | |
129 | QFETCH(int, maxY); |
|
130 | QFETCH(int, maxY); | |
130 |
|
131 | |||
131 | m_view->setRubberBand(rubberBand); |
|
132 | m_view->setRubberBand(rubberBand); | |
132 | QRectF padding = m_view->chart()->margins(); |
|
133 | QRectF padding = m_view->chart()->margins(); | |
133 | QCOMPARE(m_view->rubberBand(), rubberBand); |
|
134 | QCOMPARE(m_view->rubberBand(), rubberBand); | |
134 |
|
135 | |||
135 | QLineSeries* line = new QLineSeries(); |
|
136 | QLineSeries* line = new QLineSeries(); | |
136 | *line << QPointF(0, 0) << QPointF(200, 200); |
|
137 | *line << QPointF(0, 0) << QPointF(200, 200); | |
137 |
|
138 | |||
138 | m_view->chart()->addSeries(line); |
|
139 | m_view->chart()->addSeries(line); | |
139 | m_view->resize(200 + padding.left() + padding.right(), 200 + padding.top()+ padding.bottom()); |
|
140 | m_view->resize(200 + padding.left() + padding.right(), 200 + padding.top()+ padding.bottom()); | |
140 | m_view->show(); |
|
141 | m_view->show(); | |
141 |
|
142 | |||
142 | //this is hack since view does not get events otherwise |
|
143 | //this is hack since view does not get events otherwise | |
143 | m_view->setMouseTracking(true); |
|
144 | m_view->setMouseTracking(true); | |
144 |
|
145 | |||
145 | QAxis* axisY = m_view->chart()->axisY(); |
|
146 | QAxis* axisY = m_view->chart()->axisY(); | |
146 | QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal,qreal))); |
|
147 | QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal,qreal))); | |
147 | QAxis* axisX = m_view->chart()->axisX(); |
|
148 | QAxis* axisX = m_view->chart()->axisX(); | |
148 | QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal,qreal))); |
|
149 | QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal,qreal))); | |
149 |
|
150 | |||
150 | QTest::qWaitForWindowShown(m_view); |
|
151 | QTest::qWaitForWindowShown(m_view); | |
151 | QTest::mouseMove(m_view->viewport(), QPoint(minX, minY) + padding.topLeft().toPoint()); |
|
152 | QTest::mouseMove(m_view->viewport(), QPoint(minX, minY) + padding.topLeft().toPoint()); | |
152 | QTest::mousePress(m_view->viewport(), Qt::LeftButton, 0, QPoint(minX, minY) + padding.topLeft().toPoint()); |
|
153 | QTest::mousePress(m_view->viewport(), Qt::LeftButton, 0, QPoint(minX, minY) + padding.topLeft().toPoint()); | |
153 | QTest::mouseMove(m_view->viewport(), QPoint(maxX, maxY) + padding.topLeft().toPoint()); |
|
154 | QTest::mouseMove(m_view->viewport(), QPoint(maxX, maxY) + padding.topLeft().toPoint()); | |
154 | QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, QPoint(maxX, maxY)+ padding.topLeft().toPoint()); |
|
155 | QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, QPoint(maxX, maxY)+ padding.topLeft().toPoint()); | |
155 |
|
156 | |||
156 |
|
|
157 | TRY_COMPARE(spy0.count(), Xcount); | |
157 |
|
|
158 | TRY_COMPARE(spy1.count(), Ycount); | |
158 |
|
159 | |||
159 | //this is hack since view does not get events otherwise |
|
160 | //this is hack since view does not get events otherwise | |
160 | m_view->setMouseTracking(false); |
|
161 | m_view->setMouseTracking(false); | |
161 |
|
162 | |||
162 | QVERIFY(axisX->min() - minX < 1); |
|
163 | QVERIFY(axisX->min() - minX < 1); | |
163 | QVERIFY(axisX->max() - maxX < 1); |
|
164 | QVERIFY(axisX->max() - maxX < 1); | |
164 | QVERIFY(axisY->min() - minY < 1); |
|
165 | QVERIFY(axisY->min() - minY < 1); | |
165 | QVERIFY(axisY->max() - maxY < 1); |
|
166 | QVERIFY(axisY->max() - maxY < 1); | |
166 | } |
|
167 | } | |
167 |
|
168 | |||
168 | QTEST_MAIN(tst_QChartView) |
|
169 | QTEST_MAIN(tst_QChartView) | |
169 | #include "tst_qchartview.moc" |
|
170 | #include "tst_qchartview.moc" | |
170 |
|
171 |
@@ -1,632 +1,621 | |||||
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 |
|
26 | |||
26 | Q_DECLARE_METATYPE(QList<QPointF>) |
|
27 | Q_DECLARE_METATYPE(QList<QPointF>) | |
27 |
|
28 | |||
28 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
29 | QTCOMMERCIALCHART_USE_NAMESPACE | |
29 |
|
30 | |||
30 | class tst_QLineSeries : public QObject |
|
31 | class tst_QLineSeries : public QObject | |
31 | { |
|
32 | { | |
32 | Q_OBJECT |
|
33 | Q_OBJECT | |
33 |
|
34 | |||
34 | public slots: |
|
35 | public slots: | |
35 | void initTestCase(); |
|
36 | void initTestCase(); | |
36 | void cleanupTestCase(); |
|
37 | void cleanupTestCase(); | |
37 | void init(); |
|
38 | void init(); | |
38 | void cleanup(); |
|
39 | void cleanup(); | |
39 |
|
40 | |||
40 | private slots: |
|
41 | private slots: | |
41 | void qlineseries_data(); |
|
42 | void qlineseries_data(); | |
42 | void qlineseries(); |
|
43 | void qlineseries(); | |
43 | void append_raw_data(); |
|
44 | void append_raw_data(); | |
44 | void append_raw(); |
|
45 | void append_raw(); | |
45 | void append_chart_data(); |
|
46 | void append_chart_data(); | |
46 | void append_chart(); |
|
47 | void append_chart(); | |
47 | void append_chart_animation_data(); |
|
48 | void append_chart_animation_data(); | |
48 | void append_chart_animation(); |
|
49 | void append_chart_animation(); | |
49 | void chart_append_data(); |
|
50 | void chart_append_data(); | |
50 | void chart_append(); |
|
51 | void chart_append(); | |
51 | void count_raw_data(); |
|
52 | void count_raw_data(); | |
52 | void count_raw(); |
|
53 | void count_raw(); | |
53 | void oper_data(); |
|
54 | void oper_data(); | |
54 | void oper(); |
|
55 | void oper(); | |
55 | void pen_data(); |
|
56 | void pen_data(); | |
56 | void pen(); |
|
57 | void pen(); | |
57 | void pointsVisible_raw_data(); |
|
58 | void pointsVisible_raw_data(); | |
58 | void pointsVisible_raw(); |
|
59 | void pointsVisible_raw(); | |
59 | void remove_raw_data(); |
|
60 | void remove_raw_data(); | |
60 | void remove_raw(); |
|
61 | void remove_raw(); | |
61 | void remove_chart_data(); |
|
62 | void remove_chart_data(); | |
62 | void remove_chart(); |
|
63 | void remove_chart(); | |
63 | void remove_chart_animation_data(); |
|
64 | void remove_chart_animation_data(); | |
64 | void remove_chart_animation(); |
|
65 | void remove_chart_animation(); | |
65 | void removeAll_raw_data(); |
|
66 | void removeAll_raw_data(); | |
66 | void removeAll_raw(); |
|
67 | void removeAll_raw(); | |
67 | void removeAll_chart_data(); |
|
68 | void removeAll_chart_data(); | |
68 | void removeAll_chart(); |
|
69 | void removeAll_chart(); | |
69 | void removeAll_chart_animation_data(); |
|
70 | void removeAll_chart_animation_data(); | |
70 | void removeAll_chart_animation(); |
|
71 | void removeAll_chart_animation(); | |
71 | void replace_raw_data(); |
|
72 | void replace_raw_data(); | |
72 | void replace_raw(); |
|
73 | void replace_raw(); | |
73 | void replace_chart_data(); |
|
74 | void replace_chart_data(); | |
74 | void replace_chart(); |
|
75 | void replace_chart(); | |
75 | void replace_chart_animation_data(); |
|
76 | void replace_chart_animation_data(); | |
76 | void replace_chart_animation(); |
|
77 | void replace_chart_animation(); | |
77 | void setModel_data(); |
|
78 | void setModel_data(); | |
78 | void setModel(); |
|
79 | void setModel(); | |
79 | void setModelMapping_data(); |
|
80 | void setModelMapping_data(); | |
80 | void setModelMapping(); |
|
81 | void setModelMapping(); | |
81 | void setModelMappingRange_data(); |
|
82 | void setModelMappingRange_data(); | |
82 | void setModelMappingRange(); |
|
83 | void setModelMappingRange(); | |
83 | void modelUpdated(); |
|
84 | void modelUpdated(); | |
84 | void modelUpdatedCustomMapping(); |
|
85 | void modelUpdatedCustomMapping(); | |
85 | private: |
|
86 | private: | |
86 | void append_data(); |
|
87 | void append_data(); | |
87 | void count_data(); |
|
88 | void count_data(); | |
88 | void pointsVisible_data(); |
|
89 | void pointsVisible_data(); | |
89 |
|
90 | |||
90 | private: |
|
91 | private: | |
91 | QChartView* m_view; |
|
92 | QChartView* m_view; | |
92 | QChart* m_chart; |
|
93 | QChart* m_chart; | |
93 | QLineSeries* m_series; |
|
94 | QLineSeries* m_series; | |
94 | }; |
|
95 | }; | |
95 |
|
96 | |||
96 | void tst_QLineSeries::initTestCase() |
|
97 | void tst_QLineSeries::initTestCase() | |
97 | { |
|
98 | { | |
98 | } |
|
99 | } | |
99 |
|
100 | |||
100 | void tst_QLineSeries::cleanupTestCase() |
|
101 | void tst_QLineSeries::cleanupTestCase() | |
101 | { |
|
102 | { | |
102 | } |
|
103 | } | |
103 |
|
104 | |||
104 | void tst_QLineSeries::init() |
|
105 | void tst_QLineSeries::init() | |
105 | { |
|
106 | { | |
106 | m_view = new QChartView(new QChart()); |
|
107 | m_view = new QChartView(new QChart()); | |
107 | m_chart = m_view->chart(); |
|
108 | m_chart = m_view->chart(); | |
108 | m_series = new QLineSeries(); |
|
109 | m_series = new QLineSeries(); | |
109 | } |
|
110 | } | |
110 |
|
111 | |||
111 | void tst_QLineSeries::cleanup() |
|
112 | void tst_QLineSeries::cleanup() | |
112 | { |
|
113 | { | |
113 | delete m_series; |
|
114 | delete m_series; | |
114 | delete m_view; |
|
115 | delete m_view; | |
115 | m_view = 0; |
|
116 | m_view = 0; | |
116 | m_chart = 0; |
|
117 | m_chart = 0; | |
117 | m_series = 0; |
|
118 | m_series = 0; | |
118 | } |
|
119 | } | |
119 |
|
120 | |||
120 | void tst_QLineSeries::qlineseries_data() |
|
121 | void tst_QLineSeries::qlineseries_data() | |
121 | { |
|
122 | { | |
122 |
|
123 | |||
123 | } |
|
124 | } | |
124 |
|
125 | |||
125 | void tst_QLineSeries::qlineseries() |
|
126 | void tst_QLineSeries::qlineseries() | |
126 | { |
|
127 | { | |
127 | QLineSeries series; |
|
128 | QLineSeries series; | |
128 |
|
129 | |||
129 | QCOMPARE(series.count(),0); |
|
130 | QCOMPARE(series.count(),0); | |
130 | QCOMPARE(series.brush(), QBrush()); |
|
131 | QCOMPARE(series.brush(), QBrush()); | |
131 | QCOMPARE(series.points(), QList<QPointF>()); |
|
132 | QCOMPARE(series.points(), QList<QPointF>()); | |
132 | QCOMPARE(series.pen(), QPen()); |
|
133 | QCOMPARE(series.pen(), QPen()); | |
133 | QCOMPARE(series.pointsVisible(), false); |
|
134 | QCOMPARE(series.pointsVisible(), false); | |
134 |
|
135 | |||
135 | series.append(QList<QPointF>()); |
|
136 | series.append(QList<QPointF>()); | |
136 | series.append(0.0,0.0); |
|
137 | series.append(0.0,0.0); | |
137 | series.append(QPointF()); |
|
138 | series.append(QPointF()); | |
138 |
|
139 | |||
139 | series.remove(0.0,0.0); |
|
140 | series.remove(0.0,0.0); | |
140 | series.remove(QPointF()); |
|
141 | series.remove(QPointF()); | |
141 | series.removeAll(); |
|
142 | series.removeAll(); | |
142 |
|
143 | |||
143 | series.replace(QPointF(),QPointF()); |
|
144 | series.replace(QPointF(),QPointF()); | |
144 | series.replace(0,0,0,0); |
|
145 | series.replace(0,0,0,0); | |
145 | series.setBrush(QBrush()); |
|
146 | series.setBrush(QBrush()); | |
146 |
|
147 | |||
147 | QCOMPARE(series.setModel((QAbstractItemModel*)0), false); |
|
148 | QCOMPARE(series.setModel((QAbstractItemModel*)0), false); | |
148 |
|
149 | |||
149 | series.setModelMapping(-1, -1, Qt::Orientation(0)); |
|
150 | series.setModelMapping(-1, -1, Qt::Orientation(0)); | |
150 |
|
151 | |||
151 | series.setPen(QPen()); |
|
152 | series.setPen(QPen()); | |
152 | series.setPointsVisible(false); |
|
153 | series.setPointsVisible(false); | |
153 |
|
154 | |||
154 | m_chart->addSeries(&series); |
|
155 | m_chart->addSeries(&series); | |
155 | m_view->show(); |
|
156 | m_view->show(); | |
156 | QTest::qWaitForWindowShown(m_view); |
|
157 | QTest::qWaitForWindowShown(m_view); | |
157 | } |
|
158 | } | |
158 |
|
159 | |||
159 | void tst_QLineSeries::append_data() |
|
160 | void tst_QLineSeries::append_data() | |
160 | { |
|
161 | { | |
161 | QTest::addColumn< QList<QPointF> >("points"); |
|
162 | QTest::addColumn< QList<QPointF> >("points"); | |
162 | 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)); | |
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 | } |
|
165 | } | |
165 |
|
166 | |||
166 |
|
167 | |||
167 | void tst_QLineSeries::append_raw_data() |
|
168 | void tst_QLineSeries::append_raw_data() | |
168 | { |
|
169 | { | |
169 | append_data(); |
|
170 | append_data(); | |
170 | } |
|
171 | } | |
171 |
|
172 | |||
172 | void tst_QLineSeries::append_raw() |
|
173 | void tst_QLineSeries::append_raw() | |
173 | { |
|
174 | { | |
174 | QFETCH(QList<QPointF>, points); |
|
175 | QFETCH(QList<QPointF>, points); | |
175 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
176 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
176 | QTest::qWait(200); |
|
|||
177 | m_series->append(points); |
|
177 | m_series->append(points); | |
178 | QTest::qWait(200); |
|
178 | TRY_COMPARE(spy0.count(), 0); | |
179 | QCOMPARE(spy0.count(), 0); |
|
|||
180 | QCOMPARE(m_series->points(), points); |
|
179 | QCOMPARE(m_series->points(), points); | |
181 | } |
|
180 | } | |
182 |
|
181 | |||
183 | void tst_QLineSeries::chart_append_data() |
|
182 | void tst_QLineSeries::chart_append_data() | |
184 | { |
|
183 | { | |
185 | append_data(); |
|
184 | append_data(); | |
186 | } |
|
185 | } | |
187 |
|
186 | |||
188 | void tst_QLineSeries::chart_append() |
|
187 | void tst_QLineSeries::chart_append() | |
189 | { |
|
188 | { | |
190 | append_raw(); |
|
189 | append_raw(); | |
191 | m_chart->addSeries(m_series); |
|
190 | m_chart->addSeries(m_series); | |
192 | m_view->show(); |
|
191 | m_view->show(); | |
193 | QTest::qWaitForWindowShown(m_view); |
|
192 | QTest::qWaitForWindowShown(m_view); | |
194 | } |
|
193 | } | |
195 |
|
194 | |||
196 | void tst_QLineSeries::append_chart_data() |
|
195 | void tst_QLineSeries::append_chart_data() | |
197 | { |
|
196 | { | |
198 | append_data(); |
|
197 | append_data(); | |
199 | } |
|
198 | } | |
200 |
|
199 | |||
201 | void tst_QLineSeries::append_chart() |
|
200 | void tst_QLineSeries::append_chart() | |
202 | { |
|
201 | { | |
203 | m_view->show(); |
|
202 | m_view->show(); | |
204 | m_chart->addSeries(m_series); |
|
203 | m_chart->addSeries(m_series); | |
205 | QTest::qWaitForWindowShown(m_view); |
|
204 | QTest::qWaitForWindowShown(m_view); | |
206 | append_raw(); |
|
205 | append_raw(); | |
207 |
|
206 | |||
208 | } |
|
207 | } | |
209 |
|
208 | |||
210 | void tst_QLineSeries::append_chart_animation_data() |
|
209 | void tst_QLineSeries::append_chart_animation_data() | |
211 | { |
|
210 | { | |
212 | append_data(); |
|
211 | append_data(); | |
213 | } |
|
212 | } | |
214 |
|
213 | |||
215 | void tst_QLineSeries::append_chart_animation() |
|
214 | void tst_QLineSeries::append_chart_animation() | |
216 | { |
|
215 | { | |
217 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
216 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
218 | append_chart(); |
|
217 | append_chart(); | |
219 | } |
|
218 | } | |
220 |
|
219 | |||
221 | void tst_QLineSeries::count_data() |
|
220 | void tst_QLineSeries::count_data() | |
222 | { |
|
221 | { | |
223 | QTest::addColumn<int>("count"); |
|
222 | QTest::addColumn<int>("count"); | |
224 | QTest::newRow("0") << 0; |
|
223 | QTest::newRow("0") << 0; | |
225 | QTest::newRow("5") << 5; |
|
224 | QTest::newRow("5") << 5; | |
226 | QTest::newRow("10") << 5; |
|
225 | QTest::newRow("10") << 5; | |
227 | } |
|
226 | } | |
228 |
|
227 | |||
229 | void tst_QLineSeries::count_raw_data() |
|
228 | void tst_QLineSeries::count_raw_data() | |
230 | { |
|
229 | { | |
231 | count_data(); |
|
230 | count_data(); | |
232 | } |
|
231 | } | |
233 |
|
232 | |||
234 | void tst_QLineSeries::count_raw() |
|
233 | void tst_QLineSeries::count_raw() | |
235 | { |
|
234 | { | |
236 | QFETCH(int, count); |
|
235 | QFETCH(int, count); | |
237 |
|
236 | |||
238 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
237 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
239 |
|
238 | |||
240 | for(int i=0 ; i< count; ++i) |
|
239 | for(int i=0 ; i< count; ++i) | |
241 | m_series->append(i,i); |
|
240 | m_series->append(i,i); | |
242 |
|
241 | |||
243 |
|
|
242 | TRY_COMPARE(spy0.count(), 0); | |
244 | QCOMPARE(m_series->count(), count); |
|
243 | QCOMPARE(m_series->count(), count); | |
245 | } |
|
244 | } | |
246 |
|
245 | |||
247 | void tst_QLineSeries::oper_data() |
|
246 | void tst_QLineSeries::oper_data() | |
248 | { |
|
247 | { | |
249 | append_data(); |
|
248 | append_data(); | |
250 | } |
|
249 | } | |
251 |
|
250 | |||
252 | void tst_QLineSeries::oper() |
|
251 | void tst_QLineSeries::oper() | |
253 | { |
|
252 | { | |
254 | QFETCH(QList<QPointF>, points); |
|
253 | QFETCH(QList<QPointF>, points); | |
255 | QLineSeries series; |
|
254 | QLineSeries series; | |
256 |
|
255 | |||
257 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
256 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); | |
258 |
|
257 | |||
259 | foreach(const QPointF& point,points) |
|
258 | foreach(const QPointF& point,points) | |
260 | { |
|
259 | { | |
261 | series<<point; |
|
260 | series<<point; | |
262 | } |
|
261 | } | |
263 |
|
262 | |||
264 | QCOMPARE(series.points(), points); |
|
263 | QCOMPARE(series.points(), points); | |
265 |
|
|
264 | TRY_COMPARE(spy0.count(), 0); | |
266 | } |
|
265 | } | |
267 |
|
266 | |||
268 |
|
267 | |||
269 | void tst_QLineSeries::pen_data() |
|
268 | void tst_QLineSeries::pen_data() | |
270 | { |
|
269 | { | |
271 | QTest::addColumn<QPen>("pen"); |
|
270 | QTest::addColumn<QPen>("pen"); | |
272 | QTest::newRow("null") << QPen(); |
|
271 | QTest::newRow("null") << QPen(); | |
273 | QTest::newRow("blue") << QPen(Qt::blue); |
|
272 | QTest::newRow("blue") << QPen(Qt::blue); | |
274 | QTest::newRow("black") << QPen(Qt::black); |
|
273 | QTest::newRow("black") << QPen(Qt::black); | |
275 | QTest::newRow("red") << QPen(Qt::red); |
|
274 | QTest::newRow("red") << QPen(Qt::red); | |
276 | } |
|
275 | } | |
277 |
|
276 | |||
278 | void tst_QLineSeries::pen() |
|
277 | void tst_QLineSeries::pen() | |
279 | { |
|
278 | { | |
280 | QFETCH(QPen, pen); |
|
279 | QFETCH(QPen, pen); | |
281 | QLineSeries series; |
|
280 | QLineSeries series; | |
282 |
|
281 | |||
283 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); |
|
282 | QSignalSpy spy0(&series, SIGNAL(clicked(QPointF const&))); | |
284 | series.setPen(pen); |
|
283 | series.setPen(pen); | |
285 |
|
284 | |||
286 |
|
|
285 | TRY_COMPARE(spy0.count(), 0); | |
287 | QCOMPARE(series.pen(), pen); |
|
286 | QCOMPARE(series.pen(), pen); | |
288 |
|
287 | |||
289 | m_chart->addSeries(&series); |
|
288 | m_chart->addSeries(&series); | |
290 |
|
289 | |||
291 | if(pen!=QPen()) QCOMPARE(series.pen(), pen); |
|
290 | if(pen!=QPen()) QCOMPARE(series.pen(), pen); | |
292 | } |
|
291 | } | |
293 |
|
292 | |||
294 | void tst_QLineSeries::pointsVisible_data() |
|
293 | void tst_QLineSeries::pointsVisible_data() | |
295 | { |
|
294 | { | |
296 | QTest::addColumn<bool>("pointsVisible"); |
|
295 | QTest::addColumn<bool>("pointsVisible"); | |
297 | QTest::newRow("true") << true; |
|
296 | QTest::newRow("true") << true; | |
298 | QTest::newRow("false") << false; |
|
297 | QTest::newRow("false") << false; | |
299 | } |
|
298 | } | |
300 |
|
299 | |||
301 | void tst_QLineSeries::pointsVisible_raw_data() |
|
300 | void tst_QLineSeries::pointsVisible_raw_data() | |
302 | { |
|
301 | { | |
303 | pointsVisible_data(); |
|
302 | pointsVisible_data(); | |
304 | } |
|
303 | } | |
305 |
|
304 | |||
306 | void tst_QLineSeries::pointsVisible_raw() |
|
305 | void tst_QLineSeries::pointsVisible_raw() | |
307 | { |
|
306 | { | |
308 | QFETCH(bool, pointsVisible); |
|
307 | QFETCH(bool, pointsVisible); | |
309 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
308 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
310 | m_series->setPointsVisible(pointsVisible); |
|
309 | m_series->setPointsVisible(pointsVisible); | |
311 |
|
|
310 | TRY_COMPARE(spy0.count(), 0); | |
312 | QCOMPARE(m_series->pointsVisible(), pointsVisible); |
|
311 | QCOMPARE(m_series->pointsVisible(), pointsVisible); | |
313 | } |
|
312 | } | |
314 |
|
313 | |||
315 | void tst_QLineSeries::remove_raw_data() |
|
314 | void tst_QLineSeries::remove_raw_data() | |
316 | { |
|
315 | { | |
317 | append_data(); |
|
316 | append_data(); | |
318 | } |
|
317 | } | |
319 |
|
318 | |||
320 | void tst_QLineSeries::remove_raw() |
|
319 | void tst_QLineSeries::remove_raw() | |
321 | { |
|
320 | { | |
322 | QFETCH(QList<QPointF>, points); |
|
321 | QFETCH(QList<QPointF>, points); | |
323 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
322 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
324 | m_series->append(points); |
|
323 | m_series->append(points); | |
325 | QTest::qWait(200); |
|
324 | TRY_COMPARE(spy0.count(), 0); | |
326 | QCOMPARE(spy0.count(), 0); |
|
|||
327 | QCOMPARE(m_series->points(), points); |
|
325 | QCOMPARE(m_series->points(), points); | |
328 |
|
326 | |||
329 | foreach(const QPointF& point,points) |
|
327 | foreach(const QPointF& point,points) | |
330 | { |
|
|||
331 | m_series->remove(point); |
|
328 | m_series->remove(point); | |
332 | QTest::qWait(200); |
|
|||
333 | } |
|
|||
334 |
|
329 | |||
335 |
|
|
330 | TRY_COMPARE(spy0.count(), 0); | |
336 | QCOMPARE(m_series->points().count(), 0); |
|
331 | QCOMPARE(m_series->points().count(), 0); | |
337 | } |
|
332 | } | |
338 |
|
333 | |||
339 | void tst_QLineSeries::remove_chart_data() |
|
334 | void tst_QLineSeries::remove_chart_data() | |
340 | { |
|
335 | { | |
341 | append_data(); |
|
336 | append_data(); | |
342 | } |
|
337 | } | |
343 |
|
338 | |||
344 | void tst_QLineSeries::remove_chart() |
|
339 | void tst_QLineSeries::remove_chart() | |
345 | { |
|
340 | { | |
346 | m_view->show(); |
|
341 | m_view->show(); | |
347 | m_chart->addSeries(m_series); |
|
342 | m_chart->addSeries(m_series); | |
348 | QTest::qWaitForWindowShown(m_view); |
|
343 | QTest::qWaitForWindowShown(m_view); | |
349 | remove_raw(); |
|
344 | remove_raw(); | |
350 | } |
|
345 | } | |
351 |
|
346 | |||
352 | void tst_QLineSeries::remove_chart_animation_data() |
|
347 | void tst_QLineSeries::remove_chart_animation_data() | |
353 | { |
|
348 | { | |
354 | append_data(); |
|
349 | append_data(); | |
355 | } |
|
350 | } | |
356 |
|
351 | |||
357 | void tst_QLineSeries::remove_chart_animation() |
|
352 | void tst_QLineSeries::remove_chart_animation() | |
358 | { |
|
353 | { | |
359 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
354 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
360 | remove_chart(); |
|
355 | remove_chart(); | |
361 | } |
|
356 | } | |
362 |
|
357 | |||
363 |
|
358 | |||
364 | void tst_QLineSeries::removeAll_raw_data() |
|
359 | void tst_QLineSeries::removeAll_raw_data() | |
365 | { |
|
360 | { | |
366 | append_data(); |
|
361 | append_data(); | |
367 | } |
|
362 | } | |
368 |
|
363 | |||
369 | void tst_QLineSeries::removeAll_raw() |
|
364 | void tst_QLineSeries::removeAll_raw() | |
370 | { |
|
365 | { | |
371 | QFETCH(QList<QPointF>, points); |
|
366 | QFETCH(QList<QPointF>, points); | |
372 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
367 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
373 | m_series->append(points); |
|
368 | m_series->append(points); | |
374 |
|
|
369 | TRY_COMPARE(spy0.count(), 0); | |
375 | QCOMPARE(m_series->points(), points); |
|
370 | QCOMPARE(m_series->points(), points); | |
376 | QTest::qWait(200); |
|
|||
377 | m_series->removeAll(); |
|
371 | m_series->removeAll(); | |
378 | QTest::qWait(200); |
|
372 | TRY_COMPARE(spy0.count(), 0); | |
379 | QCOMPARE(spy0.count(), 0); |
|
|||
380 | QCOMPARE(m_series->points().count(), 0); |
|
373 | QCOMPARE(m_series->points().count(), 0); | |
381 | } |
|
374 | } | |
382 |
|
375 | |||
383 | void tst_QLineSeries::removeAll_chart_data() |
|
376 | void tst_QLineSeries::removeAll_chart_data() | |
384 | { |
|
377 | { | |
385 | append_data(); |
|
378 | append_data(); | |
386 | } |
|
379 | } | |
387 |
|
380 | |||
388 | void tst_QLineSeries::removeAll_chart() |
|
381 | void tst_QLineSeries::removeAll_chart() | |
389 | { |
|
382 | { | |
390 | m_view->show(); |
|
383 | m_view->show(); | |
391 | m_chart->addSeries(m_series); |
|
384 | m_chart->addSeries(m_series); | |
392 | QTest::qWaitForWindowShown(m_view); |
|
385 | QTest::qWaitForWindowShown(m_view); | |
393 | removeAll_raw(); |
|
386 | removeAll_raw(); | |
394 | } |
|
387 | } | |
395 |
|
388 | |||
396 | void tst_QLineSeries::removeAll_chart_animation_data() |
|
389 | void tst_QLineSeries::removeAll_chart_animation_data() | |
397 | { |
|
390 | { | |
398 | append_data(); |
|
391 | append_data(); | |
399 | } |
|
392 | } | |
400 |
|
393 | |||
401 | void tst_QLineSeries::removeAll_chart_animation() |
|
394 | void tst_QLineSeries::removeAll_chart_animation() | |
402 | { |
|
395 | { | |
403 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
396 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
404 | removeAll_chart(); |
|
397 | removeAll_chart(); | |
405 | } |
|
398 | } | |
406 |
|
399 | |||
407 | void tst_QLineSeries::replace_raw_data() |
|
400 | void tst_QLineSeries::replace_raw_data() | |
408 | { |
|
401 | { | |
409 | append_data(); |
|
402 | append_data(); | |
410 | } |
|
403 | } | |
411 |
|
404 | |||
412 | void tst_QLineSeries::replace_raw() |
|
405 | void tst_QLineSeries::replace_raw() | |
413 | { |
|
406 | { | |
414 | QFETCH(QList<QPointF>, points); |
|
407 | QFETCH(QList<QPointF>, points); | |
415 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); |
|
408 | QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); | |
416 | m_series->append(points); |
|
409 | m_series->append(points); | |
417 |
|
|
410 | TRY_COMPARE(spy0.count(), 0); | |
418 | QCOMPARE(m_series->points(), points); |
|
411 | QCOMPARE(m_series->points(), points); | |
419 | QTest::qWait(200); |
|
|||
420 |
|
412 | |||
421 | foreach(const QPointF& point,points) |
|
413 | foreach(const QPointF& point,points) | |
422 | { |
|
414 | m_series->replace(point.x(),point.y(),point.x(),0); | |
423 | m_series->replace(point.x(),point.y(),point.x(),0); |
|
|||
424 | QTest::qWait(200); |
|
|||
425 | } |
|
|||
426 |
|
415 | |||
427 | QList<QPointF> newPoints = m_series->points(); |
|
416 | QList<QPointF> newPoints = m_series->points(); | |
428 |
|
417 | |||
429 | QCOMPARE(newPoints.count(), points.count()); |
|
418 | QCOMPARE(newPoints.count(), points.count()); | |
430 |
|
419 | |||
431 | for(int i =0 ; i<points.count() ; ++i) { |
|
420 | for(int i =0 ; i<points.count() ; ++i) { | |
432 | QCOMPARE(points[i].x(), newPoints[i].x()); |
|
421 | QCOMPARE(points[i].x(), newPoints[i].x()); | |
433 | QCOMPARE(newPoints[i].y(), 0.0); |
|
422 | QCOMPARE(newPoints[i].y(), 0.0); | |
434 | } |
|
423 | } | |
435 | } |
|
424 | } | |
436 |
|
425 | |||
437 |
|
426 | |||
438 | void tst_QLineSeries::replace_chart_data() |
|
427 | void tst_QLineSeries::replace_chart_data() | |
439 | { |
|
428 | { | |
440 | append_data(); |
|
429 | append_data(); | |
441 | } |
|
430 | } | |
442 |
|
431 | |||
443 | void tst_QLineSeries::replace_chart() |
|
432 | void tst_QLineSeries::replace_chart() | |
444 | { |
|
433 | { | |
445 | m_view->show(); |
|
434 | m_view->show(); | |
446 | m_chart->addSeries(m_series); |
|
435 | m_chart->addSeries(m_series); | |
447 | QTest::qWaitForWindowShown(m_view); |
|
436 | QTest::qWaitForWindowShown(m_view); | |
448 | replace_raw(); |
|
437 | replace_raw(); | |
449 | } |
|
438 | } | |
450 |
|
439 | |||
451 | void tst_QLineSeries::replace_chart_animation_data() |
|
440 | void tst_QLineSeries::replace_chart_animation_data() | |
452 | { |
|
441 | { | |
453 | append_data(); |
|
442 | append_data(); | |
454 | } |
|
443 | } | |
455 |
|
444 | |||
456 | void tst_QLineSeries::replace_chart_animation() |
|
445 | void tst_QLineSeries::replace_chart_animation() | |
457 | { |
|
446 | { | |
458 | m_chart->setAnimationOptions(QChart::AllAnimations); |
|
447 | m_chart->setAnimationOptions(QChart::AllAnimations); | |
459 | replace_chart(); |
|
448 | replace_chart(); | |
460 | } |
|
449 | } | |
461 |
|
450 | |||
462 | void tst_QLineSeries::setModel_data() |
|
451 | void tst_QLineSeries::setModel_data() | |
463 | { |
|
452 | { | |
464 |
|
453 | |||
465 | } |
|
454 | } | |
466 |
|
455 | |||
467 | void tst_QLineSeries::setModel() |
|
456 | void tst_QLineSeries::setModel() | |
468 | { |
|
457 | { | |
469 | QLineSeries series; |
|
458 | QLineSeries series; | |
470 | series.setModel(0); |
|
459 | series.setModel(0); | |
471 | QVERIFY2(series.model() == 0, "Model should be unset"); |
|
460 | QVERIFY2(series.model() == 0, "Model should be unset"); | |
472 |
|
461 | |||
473 | QStandardItemModel *stdModel = new QStandardItemModel(); |
|
462 | QStandardItemModel *stdModel = new QStandardItemModel(); | |
474 | series.setModel(stdModel); |
|
463 | series.setModel(stdModel); | |
475 | QVERIFY2((series.model()) == stdModel, "Model should be stdModel"); |
|
464 | QVERIFY2((series.model()) == stdModel, "Model should be stdModel"); | |
476 |
|
465 | |||
477 | // unset the model |
|
466 | // unset the model | |
478 | series.setModel(0); |
|
467 | series.setModel(0); | |
479 | QVERIFY2(series.model() == 0, "Model should be unset"); |
|
468 | QVERIFY2(series.model() == 0, "Model should be unset"); | |
480 |
|
469 | |||
481 | } |
|
470 | } | |
482 |
|
471 | |||
483 | Q_DECLARE_METATYPE(Qt::Orientation) |
|
472 | Q_DECLARE_METATYPE(Qt::Orientation) | |
484 | void tst_QLineSeries::setModelMapping_data() |
|
473 | void tst_QLineSeries::setModelMapping_data() | |
485 | { |
|
474 | { | |
486 | QTest::addColumn<int>("modelX"); |
|
475 | QTest::addColumn<int>("modelX"); | |
487 | QTest::addColumn<int>("modelY"); |
|
476 | QTest::addColumn<int>("modelY"); | |
488 | QTest::addColumn<Qt::Orientation>("orientation"); |
|
477 | QTest::addColumn<Qt::Orientation>("orientation"); | |
489 | QTest::newRow("different x and y, vertical") << 0 << 1 << Qt::Vertical; |
|
478 | QTest::newRow("different x and y, vertical") << 0 << 1 << Qt::Vertical; | |
490 | QTest::newRow("same x and y, vertical") << 0 << 0 << Qt::Vertical; |
|
479 | QTest::newRow("same x and y, vertical") << 0 << 0 << Qt::Vertical; | |
491 | QTest::newRow("invalid x, corrent y, vertical") << -1 << 1 << Qt::Vertical; |
|
480 | QTest::newRow("invalid x, corrent y, vertical") << -1 << 1 << Qt::Vertical; | |
492 |
|
481 | |||
493 | QTest::newRow("different x and y, horizontal") << 0 << 1 << Qt::Horizontal; |
|
482 | QTest::newRow("different x and y, horizontal") << 0 << 1 << Qt::Horizontal; | |
494 | QTest::newRow("same x and y, horizontal") << 0 << 0 << Qt::Horizontal; |
|
483 | QTest::newRow("same x and y, horizontal") << 0 << 0 << Qt::Horizontal; | |
495 | QTest::newRow("invalid x, corrent y, horizontal") << -1 << 1 << Qt::Horizontal; |
|
484 | QTest::newRow("invalid x, corrent y, horizontal") << -1 << 1 << Qt::Horizontal; | |
496 | } |
|
485 | } | |
497 |
|
486 | |||
498 | void tst_QLineSeries::setModelMapping() |
|
487 | void tst_QLineSeries::setModelMapping() | |
499 | { |
|
488 | { | |
500 | QFETCH(int, modelX); |
|
489 | QFETCH(int, modelX); | |
501 | QFETCH(int, modelY); |
|
490 | QFETCH(int, modelY); | |
502 | QFETCH(Qt::Orientation, orientation); |
|
491 | QFETCH(Qt::Orientation, orientation); | |
503 |
|
492 | |||
504 | QLineSeries series; |
|
493 | QLineSeries series; | |
505 |
|
494 | |||
506 | // model has not been set so setting mapping should do nothing |
|
495 | // model has not been set so setting mapping should do nothing | |
507 | series.setModelMapping(modelX, modelY, orientation); |
|
496 | series.setModelMapping(modelX, modelY, orientation); | |
508 | QCOMPARE(series.mapX(), -1); |
|
497 | QCOMPARE(series.mapX(), -1); | |
509 | QCOMPARE(series.mapY(), -1); |
|
498 | QCOMPARE(series.mapY(), -1); | |
510 | QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical"); |
|
499 | QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical"); | |
511 |
|
500 | |||
512 | // now let us set the model |
|
501 | // now let us set the model | |
513 | series.setModel(new QStandardItemModel()); |
|
502 | series.setModel(new QStandardItemModel()); | |
514 | series.setModelMapping(modelX, modelY, orientation); |
|
503 | series.setModelMapping(modelX, modelY, orientation); | |
515 | QCOMPARE(series.mapX(), modelX); |
|
504 | QCOMPARE(series.mapX(), modelX); | |
516 | QCOMPARE(series.mapY(), modelY); |
|
505 | QCOMPARE(series.mapY(), modelY); | |
517 | QVERIFY2(series.mapOrientation() == orientation, "not good"); |
|
506 | QVERIFY2(series.mapOrientation() == orientation, "not good"); | |
518 |
|
507 | |||
519 | // now let us remove the model, the values should go back to default ones. |
|
508 | // now let us remove the model, the values should go back to default ones. | |
520 | series.setModel(0); |
|
509 | series.setModel(0); | |
521 | QCOMPARE(series.mapX(), -1); |
|
510 | QCOMPARE(series.mapX(), -1); | |
522 | QCOMPARE(series.mapY(), -1); |
|
511 | QCOMPARE(series.mapY(), -1); | |
523 | QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical"); |
|
512 | QVERIFY2(series.mapOrientation() == Qt::Vertical, "The orientation by default should be Qt::Vertical"); | |
524 | } |
|
513 | } | |
525 |
|
514 | |||
526 | void tst_QLineSeries::setModelMappingRange_data() |
|
515 | void tst_QLineSeries::setModelMappingRange_data() | |
527 | { |
|
516 | { | |
528 | QTest::addColumn<int>("first"); |
|
517 | QTest::addColumn<int>("first"); | |
529 | QTest::addColumn<int>("count"); |
|
518 | QTest::addColumn<int>("count"); | |
530 | QTest::newRow("first: 0, count: unlimited") << 0 << -1; |
|
519 | QTest::newRow("first: 0, count: unlimited") << 0 << -1; | |
531 | QTest::newRow("first: 0, count: 5") << 0 << 5; |
|
520 | QTest::newRow("first: 0, count: 5") << 0 << 5; | |
532 | QTest::newRow("first: 3, count: unlimited") << 3 << -1; |
|
521 | QTest::newRow("first: 3, count: unlimited") << 3 << -1; | |
533 | QTest::newRow("first: 3, count: 5") << 3 << 5; |
|
522 | QTest::newRow("first: 3, count: 5") << 3 << 5; | |
534 | QTest::newRow("first: -3, count: 5") << -3 << 5; |
|
523 | QTest::newRow("first: -3, count: 5") << -3 << 5; | |
535 | QTest::newRow("first: 3, count: -5") << 3 << -5; |
|
524 | QTest::newRow("first: 3, count: -5") << 3 << -5; | |
536 | QTest::newRow("first: -3, count: -5") << 3 << -5; |
|
525 | QTest::newRow("first: -3, count: -5") << 3 << -5; | |
537 | QTest::newRow("first: -3, count: 0") << -3 << 0; |
|
526 | QTest::newRow("first: -3, count: 0") << -3 << 0; | |
538 | QTest::newRow("first: 0, count: -5") << 0 << -5; |
|
527 | QTest::newRow("first: 0, count: -5") << 0 << -5; | |
539 | QTest::newRow("first: 0, count: 0") << 0 << 0; |
|
528 | QTest::newRow("first: 0, count: 0") << 0 << 0; | |
540 | } |
|
529 | } | |
541 |
|
530 | |||
542 | void tst_QLineSeries::setModelMappingRange() |
|
531 | void tst_QLineSeries::setModelMappingRange() | |
543 | { |
|
532 | { | |
544 | QFETCH(int, first); |
|
533 | QFETCH(int, first); | |
545 | QFETCH(int, count); |
|
534 | QFETCH(int, count); | |
546 | QLineSeries series; |
|
535 | QLineSeries series; | |
547 |
|
536 | |||
548 | QStandardItemModel *model = new QStandardItemModel(0, 2); |
|
537 | QStandardItemModel *model = new QStandardItemModel(0, 2); | |
549 | series.setModel(model); |
|
538 | series.setModel(model); | |
550 | series.setModelMapping(0, 1); |
|
539 | series.setModelMapping(0, 1); | |
551 | series.setModelMappingRange(first, count); |
|
540 | series.setModelMappingRange(first, count); | |
552 |
|
541 | |||
553 | QCOMPARE(series.mapFirst(), qMax(first, 0)); // regardles of what value was used to set the range, first should not be less than 0 |
|
542 | QCOMPARE(series.mapFirst(), qMax(first, 0)); // regardles of what value was used to set the range, first should not be less than 0 | |
554 | QCOMPARE(series.mapCount(), qMax(count, -1)); // regardles of what value was used to set the range, first should not be less than 0 |
|
543 | QCOMPARE(series.mapCount(), qMax(count, -1)); // regardles of what value was used to set the range, first should not be less than 0 | |
555 | QVERIFY2(series.count() == 0, "No rows in the model, count should be 0"); |
|
544 | QVERIFY2(series.count() == 0, "No rows in the model, count should be 0"); | |
556 |
|
545 | |||
557 | for (int row = 0; row < 3; ++row) { |
|
546 | for (int row = 0; row < 3; ++row) { | |
558 | for (int column = 0; column < 2; column++) { |
|
547 | for (int column = 0; column < 2; column++) { | |
559 | QStandardItem *item = new QStandardItem(row * column); |
|
548 | QStandardItem *item = new QStandardItem(row * column); | |
560 | model->setItem(row, column, item); |
|
549 | model->setItem(row, column, item); | |
561 | } |
|
550 | } | |
562 | } |
|
551 | } | |
563 | if (qMax(count, -1) != -1) |
|
552 | if (qMax(count, -1) != -1) | |
564 | 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"); |
|
553 | 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"); | |
565 | else |
|
554 | else | |
566 | 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"); |
|
555 | 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"); | |
567 |
|
556 | |||
568 | // let's add few more rows to the model |
|
557 | // let's add few more rows to the model | |
569 | for (int row = 0; row < 10; ++row) { |
|
558 | for (int row = 0; row < 10; ++row) { | |
570 | QList<QStandardItem *> newRow; |
|
559 | QList<QStandardItem *> newRow; | |
571 | for (int column = 0; column < 2; column++) { |
|
560 | for (int column = 0; column < 2; column++) { | |
572 | newRow.append(new QStandardItem(row * column)); |
|
561 | newRow.append(new QStandardItem(row * column)); | |
573 | } |
|
562 | } | |
574 | model->appendRow(newRow); |
|
563 | model->appendRow(newRow); | |
575 | } |
|
564 | } | |
576 | if (qMax(count, -1) != -1) |
|
565 | if (qMax(count, -1) != -1) | |
577 | 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"); |
|
566 | 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"); | |
578 | else |
|
567 | else | |
579 | 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"); |
|
568 | 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"); | |
580 |
|
569 | |||
581 | // unset the model, values should be default |
|
570 | // unset the model, values should be default | |
582 | series.setModel(0); |
|
571 | series.setModel(0); | |
583 | QCOMPARE(series.mapFirst(), 0); |
|
572 | QCOMPARE(series.mapFirst(), 0); | |
584 | QCOMPARE(series.mapCount(), -1); |
|
573 | QCOMPARE(series.mapCount(), -1); | |
585 | QVERIFY2(series.count() == 0, "No rows in the model, count should be 0"); |
|
574 | QVERIFY2(series.count() == 0, "No rows in the model, count should be 0"); | |
586 | } |
|
575 | } | |
587 |
|
576 | |||
588 | void tst_QLineSeries::modelUpdated() |
|
577 | void tst_QLineSeries::modelUpdated() | |
589 | { |
|
578 | { | |
590 | QStandardItemModel *model = new QStandardItemModel; |
|
579 | QStandardItemModel *model = new QStandardItemModel; | |
591 | for (int row = 0; row < 10; ++row) { |
|
580 | for (int row = 0; row < 10; ++row) { | |
592 | QList<QStandardItem *> newRow; |
|
581 | QList<QStandardItem *> newRow; | |
593 | for (int column = 0; column < 2; column++) { |
|
582 | for (int column = 0; column < 2; column++) { | |
594 | newRow.append(new QStandardItem(row * column)); |
|
583 | newRow.append(new QStandardItem(row * column)); | |
595 | } |
|
584 | } | |
596 | model->appendRow(newRow); |
|
585 | model->appendRow(newRow); | |
597 | } |
|
586 | } | |
598 |
|
587 | |||
599 | QLineSeries series; |
|
588 | QLineSeries series; | |
600 | series.setModel(model); |
|
589 | series.setModel(model); | |
601 | series.setModelMapping(0, 1); |
|
590 | series.setModelMapping(0, 1); | |
602 |
|
591 | |||
603 | model->setData(model->index(3, 1), 34); |
|
592 | model->setData(model->index(3, 1), 34); | |
604 | // check that the update data is correctly taken from the model |
|
593 | // check that the update data is correctly taken from the model | |
605 | QVERIFY(qFuzzyCompare(series.points().at(3).y(), 34)); |
|
594 | QVERIFY(qFuzzyCompare(series.points().at(3).y(), 34)); | |
606 | } |
|
595 | } | |
607 |
|
596 | |||
608 | void tst_QLineSeries::modelUpdatedCustomMapping() |
|
597 | void tst_QLineSeries::modelUpdatedCustomMapping() | |
609 | { |
|
598 | { | |
610 |
|
599 | |||
611 | QStandardItemModel *model = new QStandardItemModel; |
|
600 | QStandardItemModel *model = new QStandardItemModel; | |
612 | for (int row = 0; row < 10; ++row) { |
|
601 | for (int row = 0; row < 10; ++row) { | |
613 | QList<QStandardItem *> newRow; |
|
602 | QList<QStandardItem *> newRow; | |
614 | for (int column = 0; column < 2; column++) { |
|
603 | for (int column = 0; column < 2; column++) { | |
615 | newRow.append(new QStandardItem(row * column)); |
|
604 | newRow.append(new QStandardItem(row * column)); | |
616 | } |
|
605 | } | |
617 | model->appendRow(newRow); |
|
606 | model->appendRow(newRow); | |
618 | } |
|
607 | } | |
619 |
|
608 | |||
620 | QLineSeries series; |
|
609 | QLineSeries series; | |
621 | series.setModel(model); |
|
610 | series.setModel(model); | |
622 | series.setModelMapping(0, 1); |
|
611 | series.setModelMapping(0, 1); | |
623 | series.setModelMappingRange(3, 4); |
|
612 | series.setModelMappingRange(3, 4); | |
624 |
|
613 | |||
625 | model->setData(model->index(3, 1), 34); |
|
614 | model->setData(model->index(3, 1), 34); | |
626 | QVERIFY(qFuzzyCompare(series.points().at(0).y(), 34)); |
|
615 | QVERIFY(qFuzzyCompare(series.points().at(0).y(), 34)); | |
627 | } |
|
616 | } | |
628 |
|
617 | |||
629 | QTEST_MAIN(tst_QLineSeries) |
|
618 | QTEST_MAIN(tst_QLineSeries) | |
630 |
|
619 | |||
631 | #include "tst_qlineseries.moc" |
|
620 | #include "tst_qlineseries.moc" | |
632 |
|
621 |
@@ -1,220 +1,221 | |||||
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 <qpieseries.h> |
|
22 | #include <qpieseries.h> | |
23 | #include <qpieslice.h> |
|
23 | #include <qpieslice.h> | |
|
24 | #include <tst_definitions.h> | |||
24 |
|
25 | |||
25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
26 |
|
27 | |||
27 | class tst_qpieseries : public QObject |
|
28 | class tst_qpieseries : public QObject | |
28 | { |
|
29 | { | |
29 | Q_OBJECT |
|
30 | Q_OBJECT | |
30 |
|
31 | |||
31 | public slots: |
|
32 | public slots: | |
32 | void initTestCase(); |
|
33 | void initTestCase(); | |
33 | void cleanupTestCase(); |
|
34 | void cleanupTestCase(); | |
34 | void init(); |
|
35 | void init(); | |
35 | void cleanup(); |
|
36 | void cleanup(); | |
36 |
|
37 | |||
37 | private slots: |
|
38 | private slots: | |
38 | void construction(); |
|
39 | void construction(); | |
39 | void append(); |
|
40 | void append(); | |
40 | void insert(); |
|
41 | void insert(); | |
41 | void remove(); |
|
42 | void remove(); | |
42 | //void calculatedValues(); |
|
43 | //void calculatedValues(); | |
43 | //void themes(); |
|
44 | //void themes(); | |
44 | //void clickedSignal(); |
|
45 | //void clickedSignal(); | |
45 | //void hoverSignal(); |
|
46 | //void hoverSignal(); | |
46 |
|
47 | |||
47 | private: |
|
48 | private: | |
48 |
|
49 | |||
49 |
|
50 | |||
50 | private: |
|
51 | private: | |
51 |
|
52 | |||
52 | }; |
|
53 | }; | |
53 |
|
54 | |||
54 | void tst_qpieseries::initTestCase() |
|
55 | void tst_qpieseries::initTestCase() | |
55 | { |
|
56 | { | |
56 | } |
|
57 | } | |
57 |
|
58 | |||
58 | void tst_qpieseries::cleanupTestCase() |
|
59 | void tst_qpieseries::cleanupTestCase() | |
59 | { |
|
60 | { | |
60 | } |
|
61 | } | |
61 |
|
62 | |||
62 | void tst_qpieseries::init() |
|
63 | void tst_qpieseries::init() | |
63 | { |
|
64 | { | |
64 |
|
65 | |||
65 | } |
|
66 | } | |
66 |
|
67 | |||
67 | void tst_qpieseries::cleanup() |
|
68 | void tst_qpieseries::cleanup() | |
68 | { |
|
69 | { | |
69 |
|
70 | |||
70 | } |
|
71 | } | |
71 |
|
72 | |||
72 | void tst_qpieseries::construction() |
|
73 | void tst_qpieseries::construction() | |
73 | { |
|
74 | { | |
74 | // verify default values |
|
75 | // verify default values | |
75 | QPieSeries s; |
|
76 | QPieSeries s; | |
76 | QVERIFY(s.type() == QAbstractSeries::SeriesTypePie); |
|
77 | QVERIFY(s.type() == QAbstractSeries::SeriesTypePie); | |
77 | QVERIFY(s.count() == 0); |
|
78 | QVERIFY(s.count() == 0); | |
78 | QVERIFY(s.isEmpty()); |
|
79 | QVERIFY(s.isEmpty()); | |
79 | QVERIFY(qFuzzyIsNull(s.sum())); |
|
80 | QVERIFY(qFuzzyIsNull(s.sum())); | |
80 | QVERIFY(qFuzzyCompare(s.horizontalPosition(), 0.5)); |
|
81 | QVERIFY(qFuzzyCompare(s.horizontalPosition(), 0.5)); | |
81 | QVERIFY(qFuzzyCompare(s.verticalPosition(), 0.5)); |
|
82 | QVERIFY(qFuzzyCompare(s.verticalPosition(), 0.5)); | |
82 | QVERIFY(qFuzzyCompare(s.pieSize(), 0.7)); |
|
83 | QVERIFY(qFuzzyCompare(s.pieSize(), 0.7)); | |
83 | QVERIFY(qFuzzyIsNull(s.pieStartAngle())); |
|
84 | QVERIFY(qFuzzyIsNull(s.pieStartAngle())); | |
84 | QVERIFY(qFuzzyCompare(s.pieEndAngle(), 360)); |
|
85 | QVERIFY(qFuzzyCompare(s.pieEndAngle(), 360)); | |
85 | } |
|
86 | } | |
86 |
|
87 | |||
87 | void tst_qpieseries::append() |
|
88 | void tst_qpieseries::append() | |
88 | { |
|
89 | { | |
89 | QPieSeries s; |
|
90 | QPieSeries s; | |
90 |
|
91 | |||
91 | // append pointer |
|
92 | // append pointer | |
92 | QPieSlice *slice1 = 0; |
|
93 | QPieSlice *slice1 = 0; | |
93 | QVERIFY(!s.append(slice1)); |
|
94 | QVERIFY(!s.append(slice1)); | |
94 | slice1 = new QPieSlice(1, "slice 1"); |
|
95 | slice1 = new QPieSlice(1, "slice 1"); | |
95 | QVERIFY(s.append(slice1)); |
|
96 | QVERIFY(s.append(slice1)); | |
96 | QVERIFY(!s.append(slice1)); |
|
97 | QVERIFY(!s.append(slice1)); | |
97 | QCOMPARE(s.count(), 1); |
|
98 | QCOMPARE(s.count(), 1); | |
98 |
|
99 | |||
99 | // append pointer list |
|
100 | // append pointer list | |
100 | QList<QPieSlice *> list; |
|
101 | QList<QPieSlice *> list; | |
101 | QVERIFY(!s.append(list)); |
|
102 | QVERIFY(!s.append(list)); | |
102 | list << (QPieSlice *) 0; |
|
103 | list << (QPieSlice *) 0; | |
103 | QVERIFY(!s.append(list)); |
|
104 | QVERIFY(!s.append(list)); | |
104 | list.clear(); |
|
105 | list.clear(); | |
105 | list << new QPieSlice(2, "slice 2"); |
|
106 | list << new QPieSlice(2, "slice 2"); | |
106 | list << new QPieSlice(3, "slice 3"); |
|
107 | list << new QPieSlice(3, "slice 3"); | |
107 | QVERIFY(s.append(list)); |
|
108 | QVERIFY(s.append(list)); | |
108 | QVERIFY(!s.append(list)); |
|
109 | QVERIFY(!s.append(list)); | |
109 | QCOMPARE(s.count(), 3); |
|
110 | QCOMPARE(s.count(), 3); | |
110 |
|
111 | |||
111 | // append operator |
|
112 | // append operator | |
112 | s << new QPieSlice(4, "slice 4"); |
|
113 | s << new QPieSlice(4, "slice 4"); | |
113 | s << slice1; // fails because already added |
|
114 | s << slice1; // fails because already added | |
114 | QCOMPARE(s.count(), 4); |
|
115 | QCOMPARE(s.count(), 4); | |
115 |
|
116 | |||
116 | // append with params |
|
117 | // append with params | |
117 | QPieSlice *slice5 = s.append(5, "slice 5"); |
|
118 | QPieSlice *slice5 = s.append(5, "slice 5"); | |
118 | QVERIFY(slice5 != 0); |
|
119 | QVERIFY(slice5 != 0); | |
119 | QVERIFY(qFuzzyCompare(slice5->value(), 5.0)); |
|
120 | QVERIFY(qFuzzyCompare(slice5->value(), 5.0)); | |
120 | QCOMPARE(slice5->label(), QString("slice 5")); |
|
121 | QCOMPARE(slice5->label(), QString("slice 5")); | |
121 | QCOMPARE(s.count(), 5); |
|
122 | QCOMPARE(s.count(), 5); | |
122 |
|
123 | |||
123 | // check slices |
|
124 | // check slices | |
124 | QVERIFY(!s.isEmpty()); |
|
125 | QVERIFY(!s.isEmpty()); | |
125 | for (int i=0; i<s.count(); i++) { |
|
126 | for (int i=0; i<s.count(); i++) { | |
126 | QVERIFY(qFuzzyCompare(s.slices().at(i)->value(), (qreal) i+1)); |
|
127 | QVERIFY(qFuzzyCompare(s.slices().at(i)->value(), (qreal) i+1)); | |
127 | QCOMPARE(s.slices().at(i)->label(), QString("slice ") + QString::number(i+1)); |
|
128 | QCOMPARE(s.slices().at(i)->label(), QString("slice ") + QString::number(i+1)); | |
128 | } |
|
129 | } | |
129 | } |
|
130 | } | |
130 |
|
131 | |||
131 | void tst_qpieseries::insert() |
|
132 | void tst_qpieseries::insert() | |
132 | { |
|
133 | { | |
133 | QPieSeries s; |
|
134 | QPieSeries s; | |
134 |
|
135 | |||
135 | // insert one slice |
|
136 | // insert one slice | |
136 | QPieSlice *slice1 = 0; |
|
137 | QPieSlice *slice1 = 0; | |
137 | QVERIFY(!s.insert(0, slice1)); |
|
138 | QVERIFY(!s.insert(0, slice1)); | |
138 | slice1 = new QPieSlice(1, "slice 1"); |
|
139 | slice1 = new QPieSlice(1, "slice 1"); | |
139 | QVERIFY(!s.insert(-1, slice1)); |
|
140 | QVERIFY(!s.insert(-1, slice1)); | |
140 | QVERIFY(!s.insert(5, slice1)); |
|
141 | QVERIFY(!s.insert(5, slice1)); | |
141 | QVERIFY(s.insert(0, slice1)); |
|
142 | QVERIFY(s.insert(0, slice1)); | |
142 | QVERIFY(!s.insert(0, slice1)); |
|
143 | QVERIFY(!s.insert(0, slice1)); | |
143 | QCOMPARE(s.count(), 1); |
|
144 | QCOMPARE(s.count(), 1); | |
144 |
|
145 | |||
145 | // add some more slices |
|
146 | // add some more slices | |
146 | s.append(2, "slice 2"); |
|
147 | s.append(2, "slice 2"); | |
147 | s.append(4, "slice 4"); |
|
148 | s.append(4, "slice 4"); | |
148 | QCOMPARE(s.count(), 3); |
|
149 | QCOMPARE(s.count(), 3); | |
149 |
|
150 | |||
150 | // insert between slices |
|
151 | // insert between slices | |
151 | s.insert(2, new QPieSlice(3, "slice 3")); |
|
152 | s.insert(2, new QPieSlice(3, "slice 3")); | |
152 | QCOMPARE(s.count(), 4); |
|
153 | QCOMPARE(s.count(), 4); | |
153 |
|
154 | |||
154 | // check slices |
|
155 | // check slices | |
155 | for (int i=0; i<s.count(); i++) { |
|
156 | for (int i=0; i<s.count(); i++) { | |
156 | QVERIFY(qFuzzyCompare(s.slices().at(i)->value(), (qreal) i+1)); |
|
157 | QVERIFY(qFuzzyCompare(s.slices().at(i)->value(), (qreal) i+1)); | |
157 | QCOMPARE(s.slices().at(i)->label(), QString("slice ") + QString::number(i+1)); |
|
158 | QCOMPARE(s.slices().at(i)->label(), QString("slice ") + QString::number(i+1)); | |
158 | } |
|
159 | } | |
159 | } |
|
160 | } | |
160 |
|
161 | |||
161 | void tst_qpieseries::remove() |
|
162 | void tst_qpieseries::remove() | |
162 | { |
|
163 | { | |
163 | QPieSeries s; |
|
164 | QPieSeries s; | |
164 |
|
165 | |||
165 | // add some slices |
|
166 | // add some slices | |
166 | QPieSlice *slice1 = s.append(1, "slice 1"); |
|
167 | QPieSlice *slice1 = s.append(1, "slice 1"); | |
167 | QPieSlice *slice2 = s.append(2, "slice 2"); |
|
168 | QPieSlice *slice2 = s.append(2, "slice 2"); | |
168 | QPieSlice *slice3 = s.append(3, "slice 3"); |
|
169 | QPieSlice *slice3 = s.append(3, "slice 3"); | |
169 | QSignalSpy spy1(slice1, SIGNAL(destroyed())); |
|
170 | QSignalSpy spy1(slice1, SIGNAL(destroyed())); | |
170 | QSignalSpy spy2(slice2, SIGNAL(destroyed())); |
|
171 | QSignalSpy spy2(slice2, SIGNAL(destroyed())); | |
171 | QSignalSpy spy3(slice3, SIGNAL(destroyed())); |
|
172 | QSignalSpy spy3(slice3, SIGNAL(destroyed())); | |
172 | QCOMPARE(s.count(), 3); |
|
173 | QCOMPARE(s.count(), 3); | |
173 |
|
174 | |||
174 | // null pointer remove |
|
175 | // null pointer remove | |
175 | QVERIFY(!s.remove(0)); |
|
176 | QVERIFY(!s.remove(0)); | |
176 |
|
177 | |||
177 | // remove first |
|
178 | // remove first | |
178 | QVERIFY(s.remove(slice1)); |
|
179 | QVERIFY(s.remove(slice1)); | |
179 | QVERIFY(!s.remove(slice1)); |
|
180 | QVERIFY(!s.remove(slice1)); | |
180 | QCOMPARE(s.count(), 2); |
|
181 | QCOMPARE(s.count(), 2); | |
181 | QCOMPARE(s.slices().at(0)->label(), slice2->label()); |
|
182 | QCOMPARE(s.slices().at(0)->label(), slice2->label()); | |
182 |
|
183 | |||
183 | // remove all |
|
184 | // remove all | |
184 | s.clear(); |
|
185 | s.clear(); | |
185 | QVERIFY(s.isEmpty()); |
|
186 | QVERIFY(s.isEmpty()); | |
186 | QVERIFY(s.slices().isEmpty()); |
|
187 | QVERIFY(s.slices().isEmpty()); | |
187 | QCOMPARE(s.count(), 0); |
|
188 | QCOMPARE(s.count(), 0); | |
188 |
|
189 | |||
189 | // check that slices were actually destroyed |
|
190 | // check that slices were actually destroyed | |
190 |
|
|
191 | TRY_COMPARE(spy1.count(), 1); | |
191 |
|
|
192 | TRY_COMPARE(spy2.count(), 1); | |
192 |
|
|
193 | TRY_COMPARE(spy3.count(), 1); | |
193 | } |
|
194 | } | |
194 |
|
195 | |||
195 | /* |
|
196 | /* | |
196 | void tst_qpieseries::calculatedValues() |
|
197 | void tst_qpieseries::calculatedValues() | |
197 | { |
|
198 | { | |
198 |
|
199 | |||
199 | } |
|
200 | } | |
200 |
|
201 | |||
201 | void tst_qpieseries::themes() |
|
202 | void tst_qpieseries::themes() | |
202 | { |
|
203 | { | |
203 |
|
204 | |||
204 | } |
|
205 | } | |
205 |
|
206 | |||
206 | void tst_qpieseries::clickedSignal() |
|
207 | void tst_qpieseries::clickedSignal() | |
207 | { |
|
208 | { | |
208 |
|
209 | |||
209 | } |
|
210 | } | |
210 |
|
211 | |||
211 | void tst_qpieseries::hoverSignal() |
|
212 | void tst_qpieseries::hoverSignal() | |
212 | { |
|
213 | { | |
213 |
|
214 | |||
214 | } |
|
215 | } | |
215 | */ |
|
216 | */ | |
216 |
|
217 | |||
217 | QTEST_MAIN(tst_qpieseries) |
|
218 | QTEST_MAIN(tst_qpieseries) | |
218 |
|
219 | |||
219 | #include "tst_qpieseries.moc" |
|
220 | #include "tst_qpieseries.moc" | |
220 |
|
221 |
@@ -1,131 +1,132 | |||||
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 <qpieslice.h> |
|
22 | #include <qpieslice.h> | |
|
23 | #include <tst_definitions.h> | |||
23 |
|
24 | |||
24 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |
25 |
|
26 | |||
26 | class tst_qpieslice : public QObject |
|
27 | class tst_qpieslice : public QObject | |
27 | { |
|
28 | { | |
28 | Q_OBJECT |
|
29 | Q_OBJECT | |
29 |
|
30 | |||
30 | public slots: |
|
31 | public slots: | |
31 | void initTestCase(); |
|
32 | void initTestCase(); | |
32 | void cleanupTestCase(); |
|
33 | void cleanupTestCase(); | |
33 | void init(); |
|
34 | void init(); | |
34 | void cleanup(); |
|
35 | void cleanup(); | |
35 |
|
36 | |||
36 | private slots: |
|
37 | private slots: | |
37 | void construction(); |
|
38 | void construction(); | |
38 | void changedSignals(); |
|
39 | void changedSignals(); | |
39 |
|
40 | |||
40 | private: |
|
41 | private: | |
41 |
|
42 | |||
42 |
|
43 | |||
43 | private: |
|
44 | private: | |
44 |
|
45 | |||
45 | }; |
|
46 | }; | |
46 |
|
47 | |||
47 | void tst_qpieslice::initTestCase() |
|
48 | void tst_qpieslice::initTestCase() | |
48 | { |
|
49 | { | |
49 | } |
|
50 | } | |
50 |
|
51 | |||
51 | void tst_qpieslice::cleanupTestCase() |
|
52 | void tst_qpieslice::cleanupTestCase() | |
52 | { |
|
53 | { | |
53 | } |
|
54 | } | |
54 |
|
55 | |||
55 | void tst_qpieslice::init() |
|
56 | void tst_qpieslice::init() | |
56 | { |
|
57 | { | |
57 |
|
58 | |||
58 | } |
|
59 | } | |
59 |
|
60 | |||
60 | void tst_qpieslice::cleanup() |
|
61 | void tst_qpieslice::cleanup() | |
61 | { |
|
62 | { | |
62 |
|
63 | |||
63 | } |
|
64 | } | |
64 |
|
65 | |||
65 | void tst_qpieslice::construction() |
|
66 | void tst_qpieslice::construction() | |
66 | { |
|
67 | { | |
67 | // no params |
|
68 | // no params | |
68 | QPieSlice slice1; |
|
69 | QPieSlice slice1; | |
69 | QVERIFY(qFuzzyIsNull(slice1.value())); |
|
70 | QVERIFY(qFuzzyIsNull(slice1.value())); | |
70 | QVERIFY(slice1.label().isEmpty()); |
|
71 | QVERIFY(slice1.label().isEmpty()); | |
71 | QVERIFY(!slice1.isLabelVisible()); |
|
72 | QVERIFY(!slice1.isLabelVisible()); | |
72 | QVERIFY(!slice1.isExploded()); |
|
73 | QVERIFY(!slice1.isExploded()); | |
73 | QCOMPARE(slice1.pen(), QPen()); |
|
74 | QCOMPARE(slice1.pen(), QPen()); | |
74 | QCOMPARE(slice1.brush(), QBrush()); |
|
75 | QCOMPARE(slice1.brush(), QBrush()); | |
75 | QCOMPARE(slice1.labelPen(), QPen()); |
|
76 | QCOMPARE(slice1.labelPen(), QPen()); | |
76 | QCOMPARE(slice1.labelFont(), QFont()); |
|
77 | QCOMPARE(slice1.labelFont(), QFont()); | |
77 | QVERIFY(qFuzzyCompare(slice1.labelArmLengthFactor(), 0.15)); // default value |
|
78 | QVERIFY(qFuzzyCompare(slice1.labelArmLengthFactor(), 0.15)); // default value | |
78 | QVERIFY(qFuzzyCompare(slice1.explodeDistanceFactor(), 0.15)); // default value |
|
79 | QVERIFY(qFuzzyCompare(slice1.explodeDistanceFactor(), 0.15)); // default value | |
79 | QVERIFY(qFuzzyIsNull(slice1.percentage())); |
|
80 | QVERIFY(qFuzzyIsNull(slice1.percentage())); | |
80 | QVERIFY(qFuzzyIsNull(slice1.startAngle())); |
|
81 | QVERIFY(qFuzzyIsNull(slice1.startAngle())); | |
81 | QVERIFY(qFuzzyIsNull(slice1.endAngle())); |
|
82 | QVERIFY(qFuzzyIsNull(slice1.endAngle())); | |
82 |
|
83 | |||
83 | // value and label params |
|
84 | // value and label params | |
84 | QPieSlice slice2(1.0, "foobar"); |
|
85 | QPieSlice slice2(1.0, "foobar"); | |
85 | QVERIFY(qFuzzyCompare(slice2.value(), 1.0)); |
|
86 | QVERIFY(qFuzzyCompare(slice2.value(), 1.0)); | |
86 | QCOMPARE(slice2.label(), QString("foobar")); |
|
87 | QCOMPARE(slice2.label(), QString("foobar")); | |
87 | QVERIFY(!slice2.isLabelVisible()); |
|
88 | QVERIFY(!slice2.isLabelVisible()); | |
88 | QVERIFY(!slice2.isExploded()); |
|
89 | QVERIFY(!slice2.isExploded()); | |
89 | QCOMPARE(slice2.pen(), QPen()); |
|
90 | QCOMPARE(slice2.pen(), QPen()); | |
90 | QCOMPARE(slice2.brush(), QBrush()); |
|
91 | QCOMPARE(slice2.brush(), QBrush()); | |
91 | QCOMPARE(slice2.labelPen(), QPen()); |
|
92 | QCOMPARE(slice2.labelPen(), QPen()); | |
92 | QCOMPARE(slice2.labelFont(), QFont()); |
|
93 | QCOMPARE(slice2.labelFont(), QFont()); | |
93 | QVERIFY(qFuzzyCompare(slice2.labelArmLengthFactor(), 0.15)); // default value |
|
94 | QVERIFY(qFuzzyCompare(slice2.labelArmLengthFactor(), 0.15)); // default value | |
94 | QVERIFY(qFuzzyCompare(slice2.explodeDistanceFactor(), 0.15)); // default value |
|
95 | QVERIFY(qFuzzyCompare(slice2.explodeDistanceFactor(), 0.15)); // default value | |
95 | QVERIFY(qFuzzyIsNull(slice2.percentage())); |
|
96 | QVERIFY(qFuzzyIsNull(slice2.percentage())); | |
96 | QVERIFY(qFuzzyIsNull(slice2.startAngle())); |
|
97 | QVERIFY(qFuzzyIsNull(slice2.startAngle())); | |
97 | QVERIFY(qFuzzyIsNull(slice2.endAngle())); |
|
98 | QVERIFY(qFuzzyIsNull(slice2.endAngle())); | |
98 | } |
|
99 | } | |
99 |
|
100 | |||
100 | void tst_qpieslice::changedSignals() |
|
101 | void tst_qpieslice::changedSignals() | |
101 | { |
|
102 | { | |
102 | // set everything twice to see we do not get unnecessary signals |
|
103 | // set everything twice to see we do not get unnecessary signals | |
103 | QPieSlice slice; |
|
104 | QPieSlice slice; | |
104 | QSignalSpy spy(&slice, SIGNAL(changed())); // TODO: this will be changed to something more refined |
|
105 | QSignalSpy spy(&slice, SIGNAL(changed())); // TODO: this will be changed to something more refined | |
105 | slice.setValue(1); |
|
106 | slice.setValue(1); | |
106 | slice.setValue(1); |
|
107 | slice.setValue(1); | |
107 | slice.setLabel("foobar"); |
|
108 | slice.setLabel("foobar"); | |
108 | slice.setLabel("foobar"); |
|
109 | slice.setLabel("foobar"); | |
109 | slice.setLabelVisible(); |
|
110 | slice.setLabelVisible(); | |
110 | slice.setLabelVisible(); |
|
111 | slice.setLabelVisible(); | |
111 | slice.setExploded(); |
|
112 | slice.setExploded(); | |
112 | slice.setExploded(); |
|
113 | slice.setExploded(); | |
113 | slice.setPen(QPen(Qt::red)); |
|
114 | slice.setPen(QPen(Qt::red)); | |
114 | slice.setPen(QPen(Qt::red)); |
|
115 | slice.setPen(QPen(Qt::red)); | |
115 | slice.setBrush(QBrush(Qt::red)); |
|
116 | slice.setBrush(QBrush(Qt::red)); | |
116 | slice.setBrush(QBrush(Qt::red)); |
|
117 | slice.setBrush(QBrush(Qt::red)); | |
117 | slice.setLabelPen(QPen(Qt::green)); |
|
118 | slice.setLabelPen(QPen(Qt::green)); | |
118 | slice.setLabelPen(QPen(Qt::green)); |
|
119 | slice.setLabelPen(QPen(Qt::green)); | |
119 | slice.setLabelFont(QFont("Tahoma")); |
|
120 | slice.setLabelFont(QFont("Tahoma")); | |
120 | slice.setLabelFont(QFont("Tahoma")); |
|
121 | slice.setLabelFont(QFont("Tahoma")); | |
121 | slice.setLabelArmLengthFactor(0.1); |
|
122 | slice.setLabelArmLengthFactor(0.1); | |
122 | slice.setLabelArmLengthFactor(0.1); |
|
123 | slice.setLabelArmLengthFactor(0.1); | |
123 | slice.setExplodeDistanceFactor(0.1); |
|
124 | slice.setExplodeDistanceFactor(0.1); | |
124 | slice.setExplodeDistanceFactor(0.1); |
|
125 | slice.setExplodeDistanceFactor(0.1); | |
125 |
|
|
126 | TRY_COMPARE(spy.count(), 10); | |
126 | } |
|
127 | } | |
127 |
|
128 | |||
128 | QTEST_MAIN(tst_qpieslice) |
|
129 | QTEST_MAIN(tst_qpieslice) | |
129 |
|
130 | |||
130 | #include "tst_qpieslice.moc" |
|
131 | #include "tst_qpieslice.moc" | |
131 |
|
132 |
General Comments 0
You need to be logged in to leave comments.
Login now