@@ -1,649 +1,691 | |||||
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 "../qabstractaxis/tst_qabstractaxis.h" |
|
21 | #include "../qabstractaxis/tst_qabstractaxis.h" | |
22 | #include <qbarseries.h> |
|
22 | #include <qbarseries.h> | |
23 | #include <qbarset.h> |
|
23 | #include <qbarset.h> | |
24 | #include <qbarcategoryaxis.h> |
|
24 | #include <qbarcategoryaxis.h> | |
25 |
|
25 | |||
26 | class tst_QBarCategoriesAxis: public tst_QAbstractAxis |
|
26 | class tst_QBarCategoriesAxis: public tst_QAbstractAxis | |
27 | { |
|
27 | { | |
28 | Q_OBJECT |
|
28 | Q_OBJECT | |
29 |
|
29 | |||
30 | public slots: |
|
30 | public slots: | |
31 | void initTestCase(); |
|
31 | void initTestCase(); | |
32 | void cleanupTestCase(); |
|
32 | void cleanupTestCase(); | |
33 | void init(); |
|
33 | void init(); | |
34 | void cleanup(); |
|
34 | void cleanup(); | |
35 |
|
35 | |||
36 | private slots: |
|
36 | private slots: | |
37 | void qbarcategoryaxis_data(); |
|
37 | void qbarcategoryaxis_data(); | |
38 | void qbarcategoryaxis(); |
|
38 | void qbarcategoryaxis(); | |
39 |
|
39 | |||
|
40 | void append2_data(); | |||
|
41 | void append2(); | |||
40 | void append_data(); |
|
42 | void append_data(); | |
41 | void append(); |
|
43 | void append(); | |
42 | void at_data(); |
|
44 | void at_data(); | |
43 | void at(); |
|
45 | void at(); | |
44 | void categories_data(); |
|
46 | void categories_data(); | |
45 | void categories(); |
|
47 | void categories(); | |
46 | void clear_data(); |
|
48 | void clear_data(); | |
47 | void clear(); |
|
49 | void clear(); | |
48 | void count_data(); |
|
50 | void count_data(); | |
49 | void count(); |
|
51 | void count(); | |
50 | void insert_data(); |
|
52 | void insert_data(); | |
51 | void insert(); |
|
53 | void insert(); | |
52 | void remove_data(); |
|
54 | void remove_data(); | |
53 | void remove(); |
|
55 | void remove(); | |
54 | void max_raw_data(); |
|
56 | void max_raw_data(); | |
55 | void max_raw(); |
|
57 | void max_raw(); | |
56 | void max_data(); |
|
58 | void max_data(); | |
57 | void max(); |
|
59 | void max(); | |
58 | void max_animation_data(); |
|
60 | void max_animation_data(); | |
59 | void max_animation(); |
|
61 | void max_animation(); | |
60 | void min_raw_data(); |
|
62 | void min_raw_data(); | |
61 | void min_raw(); |
|
63 | void min_raw(); | |
62 | void min_data(); |
|
64 | void min_data(); | |
63 | void min(); |
|
65 | void min(); | |
64 | void min_animation_data(); |
|
66 | void min_animation_data(); | |
65 | void min_animation(); |
|
67 | void min_animation(); | |
66 | void range_raw_data(); |
|
68 | void range_raw_data(); | |
67 | void range_raw(); |
|
69 | void range_raw(); | |
68 | void range_data(); |
|
70 | void range_data(); | |
69 | void range(); |
|
71 | void range(); | |
70 | void range_animation_data(); |
|
72 | void range_animation_data(); | |
71 | void range_animation(); |
|
73 | void range_animation(); | |
72 | void noautoscale_data(); |
|
74 | void noautoscale_data(); | |
73 | void noautoscale(); |
|
75 | void noautoscale(); | |
74 | void autoscale_data(); |
|
76 | void autoscale_data(); | |
75 | void autoscale(); |
|
77 | void autoscale(); | |
76 |
|
78 | |||
77 | private: |
|
79 | private: | |
78 | QBarCategoryAxis* m_baraxis; |
|
80 | QBarCategoryAxis* m_baraxis; | |
79 | QBarSeries* m_series; |
|
81 | QBarSeries* m_series; | |
80 | }; |
|
82 | }; | |
81 |
|
83 | |||
82 | void tst_QBarCategoriesAxis::initTestCase() |
|
84 | void tst_QBarCategoriesAxis::initTestCase() | |
83 | { |
|
85 | { | |
84 | } |
|
86 | } | |
85 |
|
87 | |||
86 | void tst_QBarCategoriesAxis::cleanupTestCase() |
|
88 | void tst_QBarCategoriesAxis::cleanupTestCase() | |
87 | { |
|
89 | { | |
88 | } |
|
90 | } | |
89 |
|
91 | |||
90 | void tst_QBarCategoriesAxis::init() |
|
92 | void tst_QBarCategoriesAxis::init() | |
91 | { |
|
93 | { | |
92 | m_baraxis = new QBarCategoryAxis(); |
|
94 | m_baraxis = new QBarCategoryAxis(); | |
93 | m_series = new QBarSeries(); |
|
95 | m_series = new QBarSeries(); | |
94 |
|
96 | |||
95 | QBarSet *set0 = new QBarSet("Jane"); |
|
97 | QBarSet *set0 = new QBarSet("Jane"); | |
96 | QBarSet *set1 = new QBarSet("John"); |
|
98 | QBarSet *set1 = new QBarSet("John"); | |
97 | QBarSet *set2 = new QBarSet("Axel"); |
|
99 | QBarSet *set2 = new QBarSet("Axel"); | |
98 | QBarSet *set3 = new QBarSet("Mary"); |
|
100 | QBarSet *set3 = new QBarSet("Mary"); | |
99 | QBarSet *set4 = new QBarSet("Samantha"); |
|
101 | QBarSet *set4 = new QBarSet("Samantha"); | |
100 |
|
102 | |||
101 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; |
|
103 | *set0 << 1 << 2 << 3 << 4 << 5 << 6; | |
102 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; |
|
104 | *set1 << 5 << 0 << 0 << 4 << 0 << 7; | |
103 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; |
|
105 | *set2 << 3 << 5 << 8 << 13 << 8 << 5; | |
104 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; |
|
106 | *set3 << 5 << 6 << 7 << 3 << 4 << 5; | |
105 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; |
|
107 | *set4 << 9 << 7 << 5 << 3 << 1 << 2; | |
106 |
|
108 | |||
107 | m_series->append(set0); |
|
109 | m_series->append(set0); | |
108 | m_series->append(set1); |
|
110 | m_series->append(set1); | |
109 | m_series->append(set2); |
|
111 | m_series->append(set2); | |
110 | m_series->append(set3); |
|
112 | m_series->append(set3); | |
111 | m_series->append(set4); |
|
113 | m_series->append(set4); | |
112 |
|
114 | |||
113 | QStringList categories; |
|
115 | QStringList categories; | |
114 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
116 | categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
115 |
|
117 | |||
116 | m_baraxis->append(categories); |
|
118 | foreach(QString category, categories) | |
|
119 | m_baraxis->append(category); | |||
117 |
|
120 | |||
118 | tst_QAbstractAxis::init(m_baraxis, m_series); |
|
121 | tst_QAbstractAxis::init(m_baraxis, m_series); | |
119 | m_chart->addSeries(m_series); |
|
122 | m_chart->addSeries(m_series); | |
120 | m_chart->createDefaultAxes(); |
|
123 | m_chart->createDefaultAxes(); | |
121 | } |
|
124 | } | |
122 |
|
125 | |||
123 | void tst_QBarCategoriesAxis::cleanup() |
|
126 | void tst_QBarCategoriesAxis::cleanup() | |
124 | { |
|
127 | { | |
125 | delete m_series; |
|
128 | delete m_series; | |
126 | delete m_baraxis; |
|
129 | delete m_baraxis; | |
127 | m_series = 0; |
|
130 | m_series = 0; | |
128 | m_baraxis = 0; |
|
131 | m_baraxis = 0; | |
129 | tst_QAbstractAxis::cleanup(); |
|
132 | tst_QAbstractAxis::cleanup(); | |
130 | } |
|
133 | } | |
131 |
|
134 | |||
132 | void tst_QBarCategoriesAxis::qbarcategoryaxis_data() |
|
135 | void tst_QBarCategoriesAxis::qbarcategoryaxis_data() | |
133 | { |
|
136 | { | |
134 | } |
|
137 | } | |
135 |
|
138 | |||
136 | void tst_QBarCategoriesAxis::qbarcategoryaxis() |
|
139 | void tst_QBarCategoriesAxis::qbarcategoryaxis() | |
137 | { |
|
140 | { | |
138 | qabstractaxis(); |
|
141 | qabstractaxis(); | |
139 | QBarCategoryAxis axis; |
|
142 | QBarCategoryAxis axis; | |
140 | axis.append(QStringList()); |
|
143 | axis.append(QStringList()); | |
141 | axis.append(QString()); |
|
144 | axis.append(QString()); | |
142 | QCOMPARE(axis.at(0), QString()); |
|
145 | QCOMPARE(axis.at(0), QString()); | |
143 | QStringList test; |
|
146 | QStringList test; | |
144 | test.append(QString()); |
|
147 | test.append(QString()); | |
145 | QCOMPARE(axis.categories(),test); |
|
148 | QCOMPARE(axis.categories(),test); | |
146 | axis.clear(); |
|
149 | axis.clear(); | |
147 | QCOMPARE(axis.count(), 0); |
|
150 | QCOMPARE(axis.count(), 0); | |
148 | axis.insert(-1, QString()); |
|
151 | axis.insert(-1, QString()); | |
149 | QCOMPARE(axis.max(), QString()); |
|
152 | QCOMPARE(axis.max(), QString()); | |
150 | QCOMPARE(axis.min(), QString()); |
|
153 | QCOMPARE(axis.min(), QString()); | |
151 | axis.remove(QString()); |
|
154 | axis.remove(QString()); | |
152 | axis.setCategories(QStringList()); |
|
155 | axis.setCategories(QStringList()); | |
153 | axis.setMax(QString()); |
|
156 | axis.setMax(QString()); | |
154 | axis.setMin(QString()); |
|
157 | axis.setMin(QString()); | |
155 | axis.setRange(QString(), QString()); |
|
158 | axis.setRange(QString(), QString()); | |
156 | QCOMPARE(axis.type(), QAbstractAxis::AxisTypeBarCategory); |
|
159 | QCOMPARE(axis.type(), QAbstractAxis::AxisTypeBarCategory); | |
157 | } |
|
160 | } | |
158 |
|
161 | |||
159 | void tst_QBarCategoriesAxis::append_data() |
|
162 | void tst_QBarCategoriesAxis::append_data() | |
160 | { |
|
163 | { | |
161 | QTest::addColumn<QStringList>("categories"); |
|
164 | QTest::addColumn<QStringList>("categories"); | |
162 | QTest::newRow("Jan Feb Mar Apr") << (QStringList() << "Jan" << "Feb" << "Mar" << "Apr"); |
|
165 | QTest::newRow("Jan Feb Mar Apr") << (QStringList() << "Jan" << "Feb" << "Mar" << "Apr"); | |
163 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); |
|
166 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); | |
164 | } |
|
167 | } | |
165 |
|
168 | |||
166 | void tst_QBarCategoriesAxis::append() |
|
169 | void tst_QBarCategoriesAxis::append() | |
167 | { |
|
170 | { | |
168 | QFETCH(QStringList, categories); |
|
171 | QFETCH(QStringList, categories); | |
169 |
|
172 | |||
170 | QBarCategoryAxis axis; |
|
173 | QBarCategoryAxis axis; | |
171 |
|
174 | |||
172 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); |
|
175 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
173 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); |
|
176 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | |
174 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); |
|
177 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | |
175 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); |
|
178 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | |
176 |
|
179 | |||
177 | axis.append(categories); |
|
180 | axis.append(categories); | |
178 |
|
181 | |||
179 | QCOMPARE(spy0.count(), 1); |
|
182 | QCOMPARE(spy0.count(), 1); | |
180 | QCOMPARE(spy1.count(), 1); |
|
183 | QCOMPARE(spy1.count(), 1); | |
181 | QCOMPARE(spy2.count(), 1); |
|
184 | QCOMPARE(spy2.count(), 1); | |
182 | QCOMPARE(spy3.count(), 1); |
|
185 | QCOMPARE(spy3.count(), 1); | |
183 |
|
186 | |||
184 | m_chart->setAxisX(&axis, m_series); |
|
187 | m_chart->setAxisX(&axis, m_series); | |
185 | m_view->show(); |
|
188 | m_view->show(); | |
186 | QTest::qWaitForWindowShown(m_view); |
|
189 | QTest::qWaitForWindowShown(m_view); | |
187 | QCOMPARE(axis.categories(), categories); |
|
190 | QCOMPARE(axis.categories(), categories); | |
188 |
|
191 | |||
189 | QCOMPARE(spy0.count(), 1); |
|
192 | QCOMPARE(spy0.count(), 1); | |
190 | QCOMPARE(spy1.count(), 1); |
|
193 | QCOMPARE(spy1.count(), 1); | |
191 | QCOMPARE(spy2.count(), 1); |
|
194 | QCOMPARE(spy2.count(), 1); | |
192 | QCOMPARE(spy3.count(), 1); |
|
195 | QCOMPARE(spy3.count(), 1); | |
193 | } |
|
196 | } | |
194 |
|
197 | |||
|
198 | void tst_QBarCategoriesAxis::append2_data() | |||
|
199 | { | |||
|
200 | QTest::addColumn<QStringList>("categories"); | |||
|
201 | QTest::newRow("Jan Feb Mar Apr") << (QStringList() << "Jan" << "Feb" << "Mar" << "Apr"); | |||
|
202 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); | |||
|
203 | } | |||
|
204 | ||||
|
205 | void tst_QBarCategoriesAxis::append2() | |||
|
206 | { | |||
|
207 | QFETCH(QStringList, categories); | |||
|
208 | ||||
|
209 | QBarCategoryAxis axis; | |||
|
210 | ||||
|
211 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |||
|
212 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | |||
|
213 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | |||
|
214 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | |||
|
215 | ||||
|
216 | foreach(QString category, categories) | |||
|
217 | axis.append(category); | |||
|
218 | ||||
|
219 | QCOMPARE(spy0.count(), categories.count()); | |||
|
220 | QCOMPARE(spy1.count(), categories.count()); | |||
|
221 | QCOMPARE(spy2.count(), 1); | |||
|
222 | QCOMPARE(spy3.count(), categories.count()); | |||
|
223 | ||||
|
224 | m_chart->setAxisX(&axis, m_series); | |||
|
225 | m_view->show(); | |||
|
226 | QTest::qWaitForWindowShown(m_view); | |||
|
227 | QCOMPARE(axis.categories(), categories); | |||
|
228 | ||||
|
229 | QCOMPARE(spy0.count(), categories.count()); | |||
|
230 | QCOMPARE(spy1.count(), categories.count()); | |||
|
231 | QCOMPARE(spy2.count(), 1); | |||
|
232 | QCOMPARE(spy3.count(), categories.count()); | |||
|
233 | } | |||
|
234 | ||||
195 | void tst_QBarCategoriesAxis::at_data() |
|
235 | void tst_QBarCategoriesAxis::at_data() | |
196 | { |
|
236 | { | |
197 | QTest::addColumn<QStringList>("categories"); |
|
237 | QTest::addColumn<QStringList>("categories"); | |
198 | QTest::addColumn<int>("index"); |
|
238 | QTest::addColumn<int>("index"); | |
199 | QTest::addColumn<QString>("string"); |
|
239 | QTest::addColumn<QString>("string"); | |
200 | QTest::newRow("Jul Aug Sep 0 Jul") << (QStringList() << "Jul" << "Aug" << "Sep") << 0 << "Jul"; |
|
240 | QTest::newRow("Jul Aug Sep 0 Jul") << (QStringList() << "Jul" << "Aug" << "Sep") << 0 << "Jul"; | |
201 | QTest::newRow("Jul Aug Sep 2 Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 2 << "Sep"; |
|
241 | QTest::newRow("Jul Aug Sep 2 Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 2 << "Sep"; | |
202 | QTest::newRow("Jul Aug Sep 1 Aug") << (QStringList() << "Jul" << "Aug" << "Sep") << 1 << "Aug"; |
|
242 | QTest::newRow("Jul Aug Sep 1 Aug") << (QStringList() << "Jul" << "Aug" << "Sep") << 1 << "Aug"; | |
203 | } |
|
243 | } | |
204 |
|
244 | |||
205 | void tst_QBarCategoriesAxis::at() |
|
245 | void tst_QBarCategoriesAxis::at() | |
206 | { |
|
246 | { | |
207 | QFETCH(int, index); |
|
247 | QFETCH(int, index); | |
208 | QFETCH(QString, string); |
|
248 | QFETCH(QString, string); | |
209 | QFETCH(QStringList, categories); |
|
249 | QFETCH(QStringList, categories); | |
210 |
|
250 | |||
211 | QBarCategoryAxis axis; |
|
251 | QBarCategoryAxis axis; | |
212 | axis.append(categories); |
|
252 | axis.append(categories); | |
213 |
|
253 | |||
214 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); |
|
254 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
215 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); |
|
255 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | |
216 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); |
|
256 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | |
217 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); |
|
257 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | |
218 |
|
258 | |||
219 | QCOMPARE(axis.at(index), string); |
|
259 | QCOMPARE(axis.at(index), string); | |
220 |
|
260 | |||
221 | QCOMPARE(spy0.count(), 0); |
|
261 | QCOMPARE(spy0.count(), 0); | |
222 | QCOMPARE(spy1.count(), 0); |
|
262 | QCOMPARE(spy1.count(), 0); | |
223 | QCOMPARE(spy2.count(), 0); |
|
263 | QCOMPARE(spy2.count(), 0); | |
224 | QCOMPARE(spy3.count(), 0); |
|
264 | QCOMPARE(spy3.count(), 0); | |
225 |
|
265 | |||
226 | m_chart->setAxisX(&axis, m_series); |
|
266 | m_chart->setAxisX(&axis, m_series); | |
227 | m_view->show(); |
|
267 | m_view->show(); | |
228 | QTest::qWaitForWindowShown(m_view); |
|
268 | QTest::qWaitForWindowShown(m_view); | |
229 | QCOMPARE(axis.at(index), string); |
|
269 | QCOMPARE(axis.at(index), string); | |
230 |
|
270 | |||
231 | QCOMPARE(spy0.count(), 0); |
|
271 | QCOMPARE(spy0.count(), 0); | |
232 | QCOMPARE(spy1.count(), 0); |
|
272 | QCOMPARE(spy1.count(), 0); | |
233 | QCOMPARE(spy2.count(), 0); |
|
273 | QCOMPARE(spy2.count(), 0); | |
234 | QCOMPARE(spy3.count(), 0); |
|
274 | QCOMPARE(spy3.count(), 0); | |
235 | } |
|
275 | } | |
236 |
|
276 | |||
237 | void tst_QBarCategoriesAxis::categories_data() |
|
277 | void tst_QBarCategoriesAxis::categories_data() | |
238 | { |
|
278 | { | |
239 | QTest::addColumn<QStringList>("categories"); |
|
279 | QTest::addColumn<QStringList>("categories"); | |
240 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); |
|
280 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); | |
241 | } |
|
281 | } | |
242 |
|
282 | |||
243 | void tst_QBarCategoriesAxis::categories() |
|
283 | void tst_QBarCategoriesAxis::categories() | |
244 | { |
|
284 | { | |
245 | QFETCH(QStringList, categories); |
|
285 | QFETCH(QStringList, categories); | |
246 |
|
286 | |||
247 | QBarCategoryAxis axis; |
|
287 | QBarCategoryAxis axis; | |
248 |
|
288 | |||
249 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); |
|
289 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
250 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); |
|
290 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | |
251 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); |
|
291 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | |
252 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); |
|
292 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | |
253 |
|
293 | |||
254 | axis.setCategories(categories); |
|
294 | axis.setCategories(categories); | |
255 | QCOMPARE(axis.categories(), categories); |
|
295 | QCOMPARE(axis.categories(), categories); | |
256 |
|
296 | |||
257 | QCOMPARE(spy0.count(), 1); |
|
297 | QCOMPARE(spy0.count(), 1); | |
258 | QCOMPARE(spy1.count(), 1); |
|
298 | QCOMPARE(spy1.count(), 1); | |
259 | QCOMPARE(spy2.count(), 1); |
|
299 | QCOMPARE(spy2.count(), 1); | |
260 | QCOMPARE(spy3.count(), 1); |
|
300 | QCOMPARE(spy3.count(), 1); | |
261 |
|
301 | |||
262 | m_chart->setAxisX(&axis, m_series); |
|
302 | m_chart->setAxisX(&axis, m_series); | |
263 | m_view->show(); |
|
303 | m_view->show(); | |
264 | QTest::qWaitForWindowShown(m_view); |
|
304 | QTest::qWaitForWindowShown(m_view); | |
265 | QCOMPARE(axis.categories(), categories); |
|
305 | QCOMPARE(axis.categories(), categories); | |
266 |
|
306 | |||
267 | QCOMPARE(spy0.count(), 1); |
|
307 | QCOMPARE(spy0.count(), 1); | |
268 | QCOMPARE(spy1.count(), 1); |
|
308 | QCOMPARE(spy1.count(), 1); | |
269 | QCOMPARE(spy2.count(), 1); |
|
309 | QCOMPARE(spy2.count(), 1); | |
270 | QCOMPARE(spy3.count(), 1); |
|
310 | QCOMPARE(spy3.count(), 1); | |
271 |
|
311 | |||
272 | } |
|
312 | } | |
273 |
|
313 | |||
274 | void tst_QBarCategoriesAxis::clear_data() |
|
314 | void tst_QBarCategoriesAxis::clear_data() | |
275 | { |
|
315 | { | |
276 | QTest::addColumn<QStringList>("categories"); |
|
316 | QTest::addColumn<QStringList>("categories"); | |
277 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); |
|
317 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); | |
278 | } |
|
318 | } | |
279 |
|
319 | |||
280 | void tst_QBarCategoriesAxis::clear() |
|
320 | void tst_QBarCategoriesAxis::clear() | |
281 | { |
|
321 | { | |
282 | QFETCH(QStringList, categories); |
|
322 | QFETCH(QStringList, categories); | |
283 |
|
323 | |||
284 | QBarCategoryAxis axis; |
|
324 | QBarCategoryAxis axis; | |
285 |
|
325 | |||
286 | axis.setCategories(categories); |
|
326 | axis.setCategories(categories); | |
287 | QCOMPARE(axis.categories(), categories); |
|
327 | QCOMPARE(axis.categories(), categories); | |
288 |
|
328 | |||
289 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); |
|
329 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
290 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); |
|
330 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | |
291 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); |
|
331 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | |
292 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); |
|
332 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | |
293 |
|
333 | |||
294 | axis.clear(); |
|
334 | axis.clear(); | |
295 | QCOMPARE(axis.categories(), QStringList()); |
|
335 | QCOMPARE(axis.categories(), QStringList()); | |
296 |
|
336 | |||
297 | QCOMPARE(spy0.count(), 1); |
|
337 | QCOMPARE(spy0.count(), 1); | |
298 | QCOMPARE(spy1.count(), 1); |
|
338 | QCOMPARE(spy1.count(), 1); | |
299 | QCOMPARE(spy2.count(), 1); |
|
339 | QCOMPARE(spy2.count(), 1); | |
300 | QCOMPARE(spy3.count(), 1); |
|
340 | QCOMPARE(spy3.count(), 1); | |
301 |
|
341 | |||
302 | m_chart->setAxisX(&axis, m_series); |
|
342 | m_chart->setAxisX(&axis, m_series); | |
303 | m_view->show(); |
|
343 | m_view->show(); | |
304 | QTest::qWaitForWindowShown(m_view); |
|
344 | QTest::qWaitForWindowShown(m_view); | |
305 |
|
345 | |||
306 | QCOMPARE(spy0.count(), 2); |
|
346 | QCOMPARE(spy0.count(), 2); | |
307 | QCOMPARE(spy1.count(), 2); |
|
347 | QCOMPARE(spy1.count(), 2); | |
308 | QCOMPARE(spy2.count(), 2); |
|
348 | QCOMPARE(spy2.count(), 2); | |
309 | QCOMPARE(spy3.count(), 2); |
|
349 | QCOMPARE(spy3.count(), 2); | |
310 |
|
350 | |||
311 | axis.clear(); |
|
351 | axis.clear(); | |
312 | QCOMPARE(axis.categories().count(),0); |
|
352 | QCOMPARE(axis.categories().count(),0); | |
313 | QCOMPARE(spy0.count(), 3); |
|
353 | QCOMPARE(spy0.count(), 3); | |
314 | QCOMPARE(spy1.count(), 3); |
|
354 | QCOMPARE(spy1.count(), 3); | |
315 | QCOMPARE(spy2.count(), 3); |
|
355 | QCOMPARE(spy2.count(), 3); | |
316 | QCOMPARE(spy3.count(), 3); |
|
356 | QCOMPARE(spy3.count(), 3); | |
317 | } |
|
357 | } | |
318 |
|
358 | |||
319 | void tst_QBarCategoriesAxis::count_data() |
|
359 | void tst_QBarCategoriesAxis::count_data() | |
320 | { |
|
360 | { | |
321 | QTest::addColumn<QStringList>("categories"); |
|
361 | QTest::addColumn<QStringList>("categories"); | |
322 | QTest::addColumn<int>("count"); |
|
362 | QTest::addColumn<int>("count"); | |
323 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 3; |
|
363 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 3; | |
324 | QTest::newRow("Jul Aug ") << (QStringList() << "Jul" << "Aug") << 2; |
|
364 | QTest::newRow("Jul Aug ") << (QStringList() << "Jul" << "Aug") << 2; | |
325 | } |
|
365 | } | |
326 |
|
366 | |||
327 | void tst_QBarCategoriesAxis::count() |
|
367 | void tst_QBarCategoriesAxis::count() | |
328 | { |
|
368 | { | |
329 | QFETCH(QStringList, categories); |
|
369 | QFETCH(QStringList, categories); | |
330 | QFETCH(int, count); |
|
370 | QFETCH(int, count); | |
331 |
|
371 | |||
332 | QBarCategoryAxis axis; |
|
372 | QBarCategoryAxis axis; | |
333 | axis.setCategories(categories); |
|
373 | axis.setCategories(categories); | |
334 |
|
374 | |||
335 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); |
|
375 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
336 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); |
|
376 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | |
337 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); |
|
377 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | |
338 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); |
|
378 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | |
339 |
|
379 | |||
340 | QCOMPARE(axis.count(), count); |
|
380 | QCOMPARE(axis.count(), count); | |
341 |
|
381 | |||
342 | QCOMPARE(spy0.count(), 0); |
|
382 | QCOMPARE(spy0.count(), 0); | |
343 | QCOMPARE(spy1.count(), 0); |
|
383 | QCOMPARE(spy1.count(), 0); | |
344 | QCOMPARE(spy2.count(), 0); |
|
384 | QCOMPARE(spy2.count(), 0); | |
345 | QCOMPARE(spy3.count(), 0); |
|
385 | QCOMPARE(spy3.count(), 0); | |
346 |
|
386 | |||
347 | m_chart->setAxisX(&axis, m_series); |
|
387 | m_chart->setAxisX(&axis, m_series); | |
348 | m_view->show(); |
|
388 | m_view->show(); | |
349 | QTest::qWaitForWindowShown(m_view); |
|
389 | QTest::qWaitForWindowShown(m_view); | |
350 | QCOMPARE(axis.count(), count); |
|
390 | QCOMPARE(axis.count(), count); | |
351 | } |
|
391 | } | |
352 |
|
392 | |||
353 | void tst_QBarCategoriesAxis::insert_data() |
|
393 | void tst_QBarCategoriesAxis::insert_data() | |
354 | { |
|
394 | { | |
355 | QTest::addColumn<QStringList>("categories"); |
|
395 | QTest::addColumn<QStringList>("categories"); | |
356 | QTest::addColumn<int>("index"); |
|
396 | QTest::addColumn<int>("index"); | |
357 | QTest::addColumn<QString>("category"); |
|
397 | QTest::addColumn<QString>("category"); | |
358 | QTest::newRow("Jul Aug Sep 0 Jun") << (QStringList() << "Jul" << "Aug" << "Sep") << 0 << "Jun"; |
|
398 | QTest::newRow("Jul Aug Sep 0 Jun") << (QStringList() << "Jul" << "Aug" << "Sep") << 0 << "Jun"; | |
359 | QTest::newRow("Jul Aug Sep 3 Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 3 << "Sep"; |
|
399 | QTest::newRow("Jul Aug Sep 3 Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 3 << "Sep"; | |
360 | QTest::newRow("Jul Aug Sep 2 Summer") << (QStringList() << "Jul" << "Aug" << "Sep") << 2 << "Summer"; |
|
400 | QTest::newRow("Jul Aug Sep 2 Summer") << (QStringList() << "Jul" << "Aug" << "Sep") << 2 << "Summer"; | |
361 | } |
|
401 | } | |
362 |
|
402 | |||
363 | void tst_QBarCategoriesAxis::insert() |
|
403 | void tst_QBarCategoriesAxis::insert() | |
364 | { |
|
404 | { | |
365 | QFETCH(QStringList, categories); |
|
405 | QFETCH(QStringList, categories); | |
366 | QFETCH(int, index); |
|
406 | QFETCH(int, index); | |
367 | QFETCH(QString, category); |
|
407 | QFETCH(QString, category); | |
368 |
|
408 | |||
369 | QBarCategoryAxis axis; |
|
409 | QBarCategoryAxis axis; | |
370 | axis.append(categories); |
|
410 | axis.append(categories); | |
371 |
|
411 | |||
372 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); |
|
412 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
373 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); |
|
413 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | |
374 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); |
|
414 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | |
375 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); |
|
415 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | |
376 |
|
416 | |||
377 | axis.insert(index, category); |
|
417 | axis.insert(index, category); | |
378 | QCOMPARE(axis.at(index),category); |
|
418 | QCOMPARE(axis.at(index),category); | |
379 |
|
419 | |||
380 | QCOMPARE(spy0.count(), 1); |
|
420 | QCOMPARE(spy0.count(), 1); | |
381 | QCOMPARE(spy1.count(), 0); |
|
421 | QCOMPARE(spy1.count(), 0); | |
382 | QCOMPARE(spy2.count(), 0); |
|
422 | QCOMPARE(spy2.count(), 0); | |
383 | QCOMPARE(spy3.count(), 0); |
|
423 | QCOMPARE(spy3.count(), 0); | |
384 |
|
424 | |||
385 | m_chart->setAxisX(&axis, m_series); |
|
425 | m_chart->setAxisX(&axis, m_series); | |
386 | m_view->show(); |
|
426 | m_view->show(); | |
387 | QTest::qWaitForWindowShown(m_view); |
|
427 | QTest::qWaitForWindowShown(m_view); | |
388 | } |
|
428 | } | |
389 |
|
429 | |||
390 | void tst_QBarCategoriesAxis::remove_data() |
|
430 | void tst_QBarCategoriesAxis::remove_data() | |
391 | { |
|
431 | { | |
392 | QTest::addColumn<QStringList>("categories"); |
|
432 | QTest::addColumn<QStringList>("categories"); | |
393 | QTest::addColumn<QString>("category"); |
|
433 | QTest::addColumn<QString>("category"); | |
394 | QTest::addColumn<QStringList>("result"); |
|
434 | QTest::addColumn<QStringList>("result"); | |
395 | QTest::newRow("Jul Aug Sep 0") << (QStringList() << "Jul" << "Aug" << "Sep") << "Jul" << (QStringList() << "Aug" << "Sep"); |
|
435 | QTest::newRow("Jul Aug Sep 0") << (QStringList() << "Jul" << "Aug" << "Sep") << "Jul" << (QStringList() << "Aug" << "Sep"); | |
396 | QTest::newRow("Jul Aug Sep 1") << (QStringList() << "Jul" << "Aug" << "Sep") << "Aug"<< (QStringList() << "Jul" << "Sep"); |
|
436 | QTest::newRow("Jul Aug Sep 1") << (QStringList() << "Jul" << "Aug" << "Sep") << "Aug"<< (QStringList() << "Jul" << "Sep"); | |
397 | } |
|
437 | } | |
398 |
|
438 | |||
399 | void tst_QBarCategoriesAxis::remove() |
|
439 | void tst_QBarCategoriesAxis::remove() | |
400 | { |
|
440 | { | |
401 | QFETCH(QStringList, categories); |
|
441 | QFETCH(QStringList, categories); | |
402 | QFETCH(QString, category); |
|
442 | QFETCH(QString, category); | |
403 | QFETCH(QStringList, result); |
|
443 | QFETCH(QStringList, result); | |
404 |
|
444 | |||
405 | QBarCategoryAxis axis; |
|
445 | QBarCategoryAxis axis; | |
406 | axis.append(categories); |
|
446 | axis.append(categories); | |
407 |
|
447 | |||
408 | int maxCount = axis.max() == category; |
|
448 | int maxCount = axis.max() == category; | |
409 | int minCount = axis.min() == category; |
|
449 | int minCount = axis.min() == category; | |
410 | int rangeCount = maxCount + minCount; |
|
450 | int rangeCount = maxCount + minCount; | |
411 |
|
451 | |||
412 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); |
|
452 | QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | |
413 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); |
|
453 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | |
414 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); |
|
454 | QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | |
415 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); |
|
455 | QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | |
416 |
|
456 | |||
417 | axis.remove(category); |
|
457 | axis.remove(category); | |
418 | QCOMPARE(axis.categories(),result); |
|
458 | QCOMPARE(axis.categories(),result); | |
419 |
|
459 | |||
420 | QCOMPARE(spy0.count(), 1); |
|
460 | QCOMPARE(spy0.count(), 1); | |
421 | QCOMPARE(spy1.count(), maxCount); |
|
461 | QCOMPARE(spy1.count(), maxCount); | |
422 | QCOMPARE(spy2.count(), minCount); |
|
462 | QCOMPARE(spy2.count(), minCount); | |
423 | QCOMPARE(spy3.count(), rangeCount); |
|
463 | QCOMPARE(spy3.count(), rangeCount); | |
424 | } |
|
464 | } | |
425 |
|
465 | |||
426 | void tst_QBarCategoriesAxis::max_raw_data() |
|
466 | void tst_QBarCategoriesAxis::max_raw_data() | |
427 | { |
|
467 | { | |
428 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
468 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
429 | QTest::addColumn<QString>("max"); |
|
469 | QTest::addColumn<QString>("max"); | |
430 | QTest::newRow("Feb") << "Feb"; |
|
470 | QTest::newRow("Feb") << "Feb"; | |
431 | QTest::newRow("Apr") << "Apr"; |
|
471 | QTest::newRow("Apr") << "Apr"; | |
432 | QTest::newRow("May") << "May"; |
|
472 | QTest::newRow("May") << "May"; | |
433 | } |
|
473 | } | |
434 |
|
474 | |||
435 | void tst_QBarCategoriesAxis::max_raw() |
|
475 | void tst_QBarCategoriesAxis::max_raw() | |
436 | { |
|
476 | { | |
437 | QFETCH(QString, max); |
|
477 | QFETCH(QString, max); | |
438 |
|
478 | |||
439 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); |
|
479 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); | |
440 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); |
|
480 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); | |
441 | QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); |
|
481 | QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); | |
442 | QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); |
|
482 | QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | |
443 |
|
483 | |||
444 | m_baraxis->setMax(max); |
|
484 | m_baraxis->setMax(max); | |
445 | QCOMPARE(m_baraxis->max(), max); |
|
485 | QCOMPARE(m_baraxis->max(), max); | |
446 |
|
486 | |||
447 | QCOMPARE(spy0.count(), 0); |
|
487 | QCOMPARE(spy0.count(), 0); | |
448 | QCOMPARE(spy1.count(), 1); |
|
488 | QCOMPARE(spy1.count(), 1); | |
449 | QCOMPARE(spy2.count(), 0); |
|
489 | QCOMPARE(spy2.count(), 0); | |
450 | QCOMPARE(spy3.count(), 1); |
|
490 | QCOMPARE(spy3.count(), 1); | |
451 | } |
|
491 | } | |
452 |
|
492 | |||
453 | void tst_QBarCategoriesAxis::max_data() |
|
493 | void tst_QBarCategoriesAxis::max_data() | |
454 | { |
|
494 | { | |
455 | max_raw_data(); |
|
495 | max_raw_data(); | |
456 | } |
|
496 | } | |
457 |
|
497 | |||
458 | void tst_QBarCategoriesAxis::max() |
|
498 | void tst_QBarCategoriesAxis::max() | |
459 | { |
|
499 | { | |
460 | m_chart->setAxisX(m_baraxis, m_series); |
|
500 | m_chart->setAxisX(m_baraxis, m_series); | |
461 | m_view->show(); |
|
501 | m_view->show(); | |
462 | QTest::qWaitForWindowShown(m_view); |
|
502 | QTest::qWaitForWindowShown(m_view); | |
463 | max_raw(); |
|
503 | max_raw(); | |
464 | } |
|
504 | } | |
465 |
|
505 | |||
466 | void tst_QBarCategoriesAxis::max_animation_data() |
|
506 | void tst_QBarCategoriesAxis::max_animation_data() | |
467 | { |
|
507 | { | |
468 | max_data(); |
|
508 | max_data(); | |
469 | } |
|
509 | } | |
470 |
|
510 | |||
471 | void tst_QBarCategoriesAxis::max_animation() |
|
511 | void tst_QBarCategoriesAxis::max_animation() | |
472 | { |
|
512 | { | |
473 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
513 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | |
474 | max(); |
|
514 | max(); | |
475 | } |
|
515 | } | |
476 |
|
516 | |||
477 | void tst_QBarCategoriesAxis::min_raw_data() |
|
517 | void tst_QBarCategoriesAxis::min_raw_data() | |
478 | { |
|
518 | { | |
479 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
519 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
480 | QTest::addColumn<QString>("min"); |
|
520 | QTest::addColumn<QString>("min"); | |
481 | QTest::newRow("Feb") << "Feb"; |
|
521 | QTest::newRow("Feb") << "Feb"; | |
482 | QTest::newRow("Apr") << "Apr"; |
|
522 | QTest::newRow("Apr") << "Apr"; | |
483 | QTest::newRow("May") << "May"; |
|
523 | QTest::newRow("May") << "May"; | |
484 | } |
|
524 | } | |
485 |
|
525 | |||
486 | void tst_QBarCategoriesAxis::min_raw() |
|
526 | void tst_QBarCategoriesAxis::min_raw() | |
487 | { |
|
527 | { | |
488 | QFETCH(QString, min); |
|
528 | QFETCH(QString, min); | |
489 |
|
529 | |||
490 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); |
|
530 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); | |
491 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); |
|
531 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); | |
492 | QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); |
|
532 | QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); | |
493 | QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); |
|
533 | QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | |
494 |
|
534 | |||
495 | m_baraxis->setMin(min); |
|
535 | m_baraxis->setMin(min); | |
496 | QCOMPARE(m_baraxis->min(), min); |
|
536 | QCOMPARE(m_baraxis->min(), min); | |
497 |
|
537 | |||
498 | QCOMPARE(spy0.count(), 0); |
|
538 | QCOMPARE(spy0.count(), 0); | |
499 | QCOMPARE(spy1.count(), 0); |
|
539 | QCOMPARE(spy1.count(), 0); | |
500 | QCOMPARE(spy2.count(), 1); |
|
540 | QCOMPARE(spy2.count(), 1); | |
501 | QCOMPARE(spy3.count(), 1); |
|
541 | QCOMPARE(spy3.count(), 1); | |
502 |
|
542 | |||
503 | } |
|
543 | } | |
504 |
|
544 | |||
505 | void tst_QBarCategoriesAxis::min_data() |
|
545 | void tst_QBarCategoriesAxis::min_data() | |
506 | { |
|
546 | { | |
507 | min_raw_data(); |
|
547 | min_raw_data(); | |
508 | } |
|
548 | } | |
509 |
|
549 | |||
510 | void tst_QBarCategoriesAxis::min() |
|
550 | void tst_QBarCategoriesAxis::min() | |
511 | { |
|
551 | { | |
|
552 | min_raw(); | |||
512 | m_chart->setAxisX(m_baraxis, m_series); |
|
553 | m_chart->setAxisX(m_baraxis, m_series); | |
513 | m_view->show(); |
|
554 | m_view->show(); | |
514 | QTest::qWaitForWindowShown(m_view); |
|
555 | QTest::qWaitForWindowShown(m_view); | |
515 | min_raw(); |
|
556 | ||
516 | } |
|
557 | } | |
517 |
|
558 | |||
518 | void tst_QBarCategoriesAxis::min_animation_data() |
|
559 | void tst_QBarCategoriesAxis::min_animation_data() | |
519 | { |
|
560 | { | |
520 | min_data(); |
|
561 | min_data(); | |
521 | } |
|
562 | } | |
522 |
|
563 | |||
523 | void tst_QBarCategoriesAxis::min_animation() |
|
564 | void tst_QBarCategoriesAxis::min_animation() | |
524 | { |
|
565 | { | |
525 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
566 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | |
526 | min(); |
|
567 | min(); | |
527 | } |
|
568 | } | |
528 |
|
569 | |||
529 |
|
570 | |||
530 | void tst_QBarCategoriesAxis::range_raw_data() |
|
571 | void tst_QBarCategoriesAxis::range_raw_data() | |
531 | { |
|
572 | { | |
532 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; |
|
573 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | |
533 | QTest::addColumn<QString>("min"); |
|
574 | QTest::addColumn<QString>("min"); | |
534 | QTest::addColumn<QString>("max"); |
|
575 | QTest::addColumn<QString>("max"); | |
535 | QTest::newRow("Feb - Apr") << "Feb" << "Apr"; |
|
576 | QTest::newRow("Feb - Apr") << "Feb" << "Apr"; | |
536 | QTest::newRow("Feb - May") << "Feb" << "May"; |
|
577 | QTest::newRow("Feb - May") << "Feb" << "May"; | |
537 | QTest::newRow("Mar - Apr") << "Mar" << "Apr"; |
|
578 | QTest::newRow("Mar - Apr") << "Mar" << "Apr"; | |
538 | } |
|
579 | } | |
539 |
|
580 | |||
540 | void tst_QBarCategoriesAxis::range_raw() |
|
581 | void tst_QBarCategoriesAxis::range_raw() | |
541 | { |
|
582 | { | |
542 | QFETCH(QString, min); |
|
583 | QFETCH(QString, min); | |
543 | QFETCH(QString, max); |
|
584 | QFETCH(QString, max); | |
544 |
|
585 | |||
545 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); |
|
586 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); | |
546 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); |
|
587 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); | |
547 | QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); |
|
588 | QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); | |
548 | QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); |
|
589 | QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | |
549 |
|
590 | |||
550 | m_baraxis->setRange(min, max); |
|
591 | m_baraxis->setRange(min, max); | |
551 | QCOMPARE(m_baraxis->min(), min); |
|
592 | QCOMPARE(m_baraxis->min(), min); | |
552 | QCOMPARE(m_baraxis->max(), max); |
|
593 | QCOMPARE(m_baraxis->max(), max); | |
553 |
|
594 | |||
554 | QCOMPARE(spy0.count(), 0); |
|
595 | QCOMPARE(spy0.count(), 0); | |
555 | QCOMPARE(spy1.count(), 1); |
|
596 | QCOMPARE(spy1.count(), 1); | |
556 | QCOMPARE(spy2.count(), 1); |
|
597 | QCOMPARE(spy2.count(), 1); | |
557 | QCOMPARE(spy3.count(), 1); |
|
598 | QCOMPARE(spy3.count(), 1); | |
558 | } |
|
599 | } | |
559 |
|
600 | |||
560 | void tst_QBarCategoriesAxis::range_data() |
|
601 | void tst_QBarCategoriesAxis::range_data() | |
561 | { |
|
602 | { | |
562 | range_raw_data(); |
|
603 | range_raw_data(); | |
563 | } |
|
604 | } | |
564 |
|
605 | |||
565 | void tst_QBarCategoriesAxis::range() |
|
606 | void tst_QBarCategoriesAxis::range() | |
566 | { |
|
607 | { | |
|
608 | range_raw(); | |||
567 | m_chart->setAxisX(m_baraxis, m_series); |
|
609 | m_chart->setAxisX(m_baraxis, m_series); | |
568 | m_view->show(); |
|
610 | m_view->show(); | |
569 | QTest::qWaitForWindowShown(m_view); |
|
611 | QTest::qWaitForWindowShown(m_view); | |
570 | range_raw(); |
|
612 | ||
571 | } |
|
613 | } | |
572 |
|
614 | |||
573 | void tst_QBarCategoriesAxis::range_animation_data() |
|
615 | void tst_QBarCategoriesAxis::range_animation_data() | |
574 | { |
|
616 | { | |
575 | range_data(); |
|
617 | range_data(); | |
576 | } |
|
618 | } | |
577 |
|
619 | |||
578 | void tst_QBarCategoriesAxis::range_animation() |
|
620 | void tst_QBarCategoriesAxis::range_animation() | |
579 | { |
|
621 | { | |
580 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); |
|
622 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | |
581 | range(); |
|
623 | range(); | |
582 | } |
|
624 | } | |
583 |
|
625 | |||
584 |
|
626 | |||
585 | void tst_QBarCategoriesAxis::noautoscale_data() |
|
627 | void tst_QBarCategoriesAxis::noautoscale_data() | |
586 | { |
|
628 | { | |
587 | QTest::addColumn<QString>("min"); |
|
629 | QTest::addColumn<QString>("min"); | |
588 | QTest::addColumn<QString>("max"); |
|
630 | QTest::addColumn<QString>("max"); | |
589 | QTest::newRow("Feb - Mar") << "Feb" << "Mar"; |
|
631 | QTest::newRow("Feb - Mar") << "Feb" << "Mar"; | |
590 | QTest::newRow("Feb - May") << "Feb" << "May"; |
|
632 | QTest::newRow("Feb - May") << "Feb" << "May"; | |
591 | QTest::newRow("Apr - May") << "Apr" << "May"; |
|
633 | QTest::newRow("Apr - May") << "Apr" << "May"; | |
592 | } |
|
634 | } | |
593 |
|
635 | |||
594 | void tst_QBarCategoriesAxis::noautoscale() |
|
636 | void tst_QBarCategoriesAxis::noautoscale() | |
595 | { |
|
637 | { | |
596 | QFETCH(QString, min); |
|
638 | QFETCH(QString, min); | |
597 | QFETCH(QString, max); |
|
639 | QFETCH(QString, max); | |
598 |
|
640 | |||
599 | QSignalSpy spy0(m_baraxis, SIGNAL(maxChanged(QString))); |
|
641 | QSignalSpy spy0(m_baraxis, SIGNAL(maxChanged(QString))); | |
600 | QSignalSpy spy1(m_baraxis, SIGNAL(minChanged(QString))); |
|
642 | QSignalSpy spy1(m_baraxis, SIGNAL(minChanged(QString))); | |
601 | QSignalSpy spy2(m_baraxis, SIGNAL(rangeChanged(QString,QString))); |
|
643 | QSignalSpy spy2(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | |
602 |
|
644 | |||
603 | m_baraxis->setRange(min, max); |
|
645 | m_baraxis->setRange(min, max); | |
604 | QCOMPARE(m_baraxis->min(),min); |
|
646 | QCOMPARE(m_baraxis->min(),min); | |
605 | QCOMPARE(m_baraxis->max(),max); |
|
647 | QCOMPARE(m_baraxis->max(),max); | |
606 |
|
648 | |||
607 | QCOMPARE(spy0.count(), 1); |
|
649 | QCOMPARE(spy0.count(), 1); | |
608 | QCOMPARE(spy1.count(), 1); |
|
650 | QCOMPARE(spy1.count(), 1); | |
609 | QCOMPARE(spy2.count(), 1); |
|
651 | QCOMPARE(spy2.count(), 1); | |
610 |
|
652 | |||
611 | m_chart->setAxisX(m_baraxis, m_series); |
|
653 | m_chart->setAxisX(m_baraxis, m_series); | |
612 | m_view->show(); |
|
654 | m_view->show(); | |
613 | QTest::qWaitForWindowShown(m_view); |
|
655 | QTest::qWaitForWindowShown(m_view); | |
614 | QCOMPARE(m_baraxis->min(),min); |
|
656 | QCOMPARE(m_baraxis->min(),min); | |
615 | QCOMPARE(m_baraxis->max(),max); |
|
657 | QCOMPARE(m_baraxis->max(),max); | |
616 | } |
|
658 | } | |
617 |
|
659 | |||
618 | void tst_QBarCategoriesAxis::autoscale_data() |
|
660 | void tst_QBarCategoriesAxis::autoscale_data() | |
619 | { |
|
661 | { | |
620 |
|
662 | |||
621 | } |
|
663 | } | |
622 |
|
664 | |||
623 | void tst_QBarCategoriesAxis::autoscale() |
|
665 | void tst_QBarCategoriesAxis::autoscale() | |
624 | { |
|
666 | { | |
625 | delete m_baraxis; |
|
667 | delete m_baraxis; | |
626 | m_baraxis = new QBarCategoryAxis(); |
|
668 | m_baraxis = new QBarCategoryAxis(); | |
627 |
|
669 | |||
628 | QSignalSpy spy0(m_baraxis, SIGNAL(maxChanged(QString))); |
|
670 | QSignalSpy spy0(m_baraxis, SIGNAL(maxChanged(QString))); | |
629 | QSignalSpy spy1(m_baraxis, SIGNAL(minChanged(QString))); |
|
671 | QSignalSpy spy1(m_baraxis, SIGNAL(minChanged(QString))); | |
630 | QSignalSpy spy2(m_baraxis, SIGNAL(rangeChanged(QString,QString))); |
|
672 | QSignalSpy spy2(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | |
631 |
|
673 | |||
632 | QCOMPARE(m_baraxis->min(),QString()); |
|
674 | QCOMPARE(m_baraxis->min(),QString()); | |
633 | QCOMPARE(m_baraxis->max(),QString()); |
|
675 | QCOMPARE(m_baraxis->max(),QString()); | |
634 | m_chart->setAxisX(m_baraxis, m_series); |
|
676 | m_chart->setAxisX(m_baraxis, m_series); | |
635 |
|
677 | |||
636 | QCOMPARE(spy0.count(), 1); |
|
678 | QCOMPARE(spy0.count(), 1); | |
637 | QCOMPARE(spy1.count(), 1); |
|
679 | QCOMPARE(spy1.count(), 1); | |
638 | QCOMPARE(spy2.count(), 1); |
|
680 | QCOMPARE(spy2.count(), 1); | |
639 |
|
681 | |||
640 | m_view->show(); |
|
682 | m_view->show(); | |
641 | QTest::qWaitForWindowShown(m_view); |
|
683 | QTest::qWaitForWindowShown(m_view); | |
642 | QCOMPARE(m_baraxis->min(),QString("1")); |
|
684 | QCOMPARE(m_baraxis->min(),QString("1")); | |
643 | QCOMPARE(m_baraxis->max(),QString("6")); |
|
685 | QCOMPARE(m_baraxis->max(),QString("6")); | |
644 | } |
|
686 | } | |
645 |
|
687 | |||
646 |
|
688 | |||
647 | QTEST_MAIN(tst_QBarCategoriesAxis) |
|
689 | QTEST_MAIN(tst_QBarCategoriesAxis) | |
648 | #include "tst_qbarcategoryaxis.moc" |
|
690 | #include "tst_qbarcategoryaxis.moc" | |
649 |
|
691 |
General Comments 0
You need to be logged in to leave comments.
Login now