@@ -0,0 +1,6 | |||
|
1 | !include( ../auto.pri ) { | |
|
2 | error( "Couldn't find the auto.pri file!" ) | |
|
3 | } | |
|
4 | SOURCES += tst_qpercentbarseries.cpp | |
|
5 | ||
|
6 | !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" |
@@ -0,0 +1,341 | |||
|
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 | #include <QtTest/QtTest> | |
|
22 | #include <qpercentbarseries.h> | |
|
23 | #include <qbarset.h> | |
|
24 | ||
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |
|
26 | ||
|
27 | class tst_QPercentBarSeries : public QObject | |
|
28 | { | |
|
29 | Q_OBJECT | |
|
30 | ||
|
31 | public slots: | |
|
32 | void initTestCase(); | |
|
33 | void cleanupTestCase(); | |
|
34 | void init(); | |
|
35 | void cleanup(); | |
|
36 | ||
|
37 | private slots: | |
|
38 | void qpercentbarseries_data(); | |
|
39 | void qpercentbarseries(); | |
|
40 | void type_data(); | |
|
41 | void type(); | |
|
42 | void setCategories_data(); | |
|
43 | void setCategories(); | |
|
44 | void appendBarSet_data(); | |
|
45 | void appendBarSet(); | |
|
46 | void removeBarSet_data(); | |
|
47 | void removeBarSet(); | |
|
48 | void appendBarSets_data(); | |
|
49 | void appendBarSets(); | |
|
50 | void removeBarSets_data(); | |
|
51 | void removeBarSets(); | |
|
52 | void barsetCount_data(); | |
|
53 | void barsetCount(); | |
|
54 | void categoryCount_data(); | |
|
55 | void categoryCount(); | |
|
56 | void barSets_data(); | |
|
57 | void barSets(); | |
|
58 | void categories_data(); | |
|
59 | void categories(); | |
|
60 | void setLabelsVisible_data(); | |
|
61 | void setLabelsVisible(); | |
|
62 | ||
|
63 | private: | |
|
64 | QPercentBarSeries* m_barseries; | |
|
65 | QPercentBarSeries* m_barseries_with_sets; | |
|
66 | ||
|
67 | QList<QBarSet*> m_testSets; | |
|
68 | ||
|
69 | QBarCategories m_categories; | |
|
70 | }; | |
|
71 | ||
|
72 | void tst_QPercentBarSeries::initTestCase() | |
|
73 | { | |
|
74 | } | |
|
75 | ||
|
76 | void tst_QPercentBarSeries::cleanupTestCase() | |
|
77 | { | |
|
78 | } | |
|
79 | ||
|
80 | void tst_QPercentBarSeries::init() | |
|
81 | { | |
|
82 | m_categories << "category0" << "category1" << "category2"; | |
|
83 | m_barseries = new QPercentBarSeries(); | |
|
84 | m_barseries->setCategories(m_categories); | |
|
85 | m_barseries_with_sets = new QPercentBarSeries(); | |
|
86 | m_barseries_with_sets->setCategories(m_categories); | |
|
87 | ||
|
88 | for (int i=0; i<5; i++) { | |
|
89 | m_testSets.append(new QBarSet("testset")); | |
|
90 | m_barseries_with_sets->appendBarSet(m_testSets.at(i)); | |
|
91 | } | |
|
92 | } | |
|
93 | ||
|
94 | void tst_QPercentBarSeries::cleanup() | |
|
95 | { | |
|
96 | foreach(QBarSet* s, m_testSets) { | |
|
97 | m_barseries_with_sets->removeBarSet(s); | |
|
98 | delete s; | |
|
99 | } | |
|
100 | m_testSets.clear(); | |
|
101 | ||
|
102 | delete m_barseries; | |
|
103 | m_barseries = 0; | |
|
104 | delete m_barseries_with_sets; | |
|
105 | m_barseries_with_sets = 0; | |
|
106 | m_categories.clear(); | |
|
107 | } | |
|
108 | ||
|
109 | void tst_QPercentBarSeries::qpercentbarseries_data() | |
|
110 | { | |
|
111 | QTest::addColumn<QBarCategories> ("categories"); | |
|
112 | QBarCategories c; | |
|
113 | c << "category0" << "category1" << "category2"; | |
|
114 | QTest::newRow("categories") << c; | |
|
115 | } | |
|
116 | ||
|
117 | void tst_QPercentBarSeries::qpercentbarseries() | |
|
118 | { | |
|
119 | QFETCH(QBarCategories, categories); | |
|
120 | QPercentBarSeries *barseries = new QPercentBarSeries(); | |
|
121 | QVERIFY(barseries != 0); | |
|
122 | barseries->setCategories(categories); | |
|
123 | QBarCategories verifyCategories = barseries->categories(); | |
|
124 | ||
|
125 | QVERIFY(verifyCategories.count() == categories.count()); | |
|
126 | for (int i=0; i<categories.count(); i++) { | |
|
127 | QVERIFY(verifyCategories.at(i).compare(categories.at(i)) == 0); | |
|
128 | } | |
|
129 | } | |
|
130 | ||
|
131 | void tst_QPercentBarSeries::type_data() | |
|
132 | { | |
|
133 | ||
|
134 | } | |
|
135 | ||
|
136 | void tst_QPercentBarSeries::type() | |
|
137 | { | |
|
138 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar); | |
|
139 | } | |
|
140 | ||
|
141 | void tst_QPercentBarSeries::setCategories_data() | |
|
142 | { | |
|
143 | QTest::addColumn<QBarCategories> ("categories"); | |
|
144 | QBarCategories categories; | |
|
145 | categories << "c1" << "c2" << "c3" << "c4" << "c5" << "c6"; | |
|
146 | QTest::newRow("cat") << categories; | |
|
147 | } | |
|
148 | ||
|
149 | void tst_QPercentBarSeries::setCategories() | |
|
150 | { | |
|
151 | QVERIFY(m_barseries->categories().count() == m_categories.count()); | |
|
152 | ||
|
153 | QFETCH(QBarCategories, categories); | |
|
154 | m_barseries->setCategories(categories); | |
|
155 | ||
|
156 | QVERIFY(m_barseries->categories().count() == categories.count()); | |
|
157 | for (int i=0; i<categories.count(); i++) { | |
|
158 | QVERIFY(m_barseries->categories().at(i).compare(categories.at(i)) == 0); | |
|
159 | } | |
|
160 | } | |
|
161 | ||
|
162 | void tst_QPercentBarSeries::appendBarSet_data() | |
|
163 | { | |
|
164 | } | |
|
165 | ||
|
166 | void tst_QPercentBarSeries::appendBarSet() | |
|
167 | { | |
|
168 | QVERIFY(m_barseries->barsetCount() == 0); | |
|
169 | ||
|
170 | QBarSet *barset = new QBarSet("testset"); | |
|
171 | m_barseries->appendBarSet(barset); | |
|
172 | ||
|
173 | QVERIFY(m_barseries->barsetCount() == 1); | |
|
174 | ||
|
175 | QBarSet *barset2 = new QBarSet("testset2"); | |
|
176 | m_barseries->appendBarSet(barset2); | |
|
177 | ||
|
178 | QVERIFY(m_barseries->barsetCount() == 2); | |
|
179 | } | |
|
180 | ||
|
181 | void tst_QPercentBarSeries::removeBarSet_data() | |
|
182 | { | |
|
183 | } | |
|
184 | ||
|
185 | void tst_QPercentBarSeries::removeBarSet() | |
|
186 | { | |
|
187 | int count = m_testSets.count(); | |
|
188 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
|
189 | ||
|
190 | // remove some sets | |
|
191 | m_barseries_with_sets->removeBarSet(m_testSets.at(2)); | |
|
192 | m_barseries_with_sets->removeBarSet(m_testSets.at(3)); | |
|
193 | m_barseries_with_sets->removeBarSet(m_testSets.at(4)); | |
|
194 | ||
|
195 | QVERIFY(m_barseries_with_sets->barsetCount() == 2); | |
|
196 | ||
|
197 | QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); | |
|
198 | ||
|
199 | QVERIFY(verifysets.at(0) == m_testSets.at(0)); | |
|
200 | QVERIFY(verifysets.at(1) == m_testSets.at(1)); | |
|
201 | ||
|
202 | // Try removing all sets again | |
|
203 | for (int i=0; i<count; i++) { | |
|
204 | m_barseries_with_sets->removeBarSet(m_testSets.at(i)); | |
|
205 | } | |
|
206 | ||
|
207 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
|
208 | } | |
|
209 | ||
|
210 | void tst_QPercentBarSeries::appendBarSets_data() | |
|
211 | { | |
|
212 | ||
|
213 | } | |
|
214 | ||
|
215 | void tst_QPercentBarSeries::appendBarSets() | |
|
216 | { | |
|
217 | int count = 5; | |
|
218 | QVERIFY(m_barseries->barsetCount() == 0); | |
|
219 | ||
|
220 | QList<QBarSet*> sets; | |
|
221 | for (int i=0; i<count; i++) { | |
|
222 | sets.append(new QBarSet("testset")); | |
|
223 | } | |
|
224 | ||
|
225 | m_barseries->appendBarSets(sets); | |
|
226 | QVERIFY(m_barseries->barsetCount() == count); | |
|
227 | } | |
|
228 | ||
|
229 | void tst_QPercentBarSeries::removeBarSets_data() | |
|
230 | { | |
|
231 | ||
|
232 | } | |
|
233 | ||
|
234 | void tst_QPercentBarSeries::removeBarSets() | |
|
235 | { | |
|
236 | int count = m_testSets.count(); | |
|
237 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
|
238 | ||
|
239 | // Try removing empty list of sets | |
|
240 | QList<QBarSet*> empty; | |
|
241 | m_barseries_with_sets->removeBarSets(empty); | |
|
242 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
|
243 | ||
|
244 | // remove all sets | |
|
245 | m_barseries_with_sets->removeBarSets(m_testSets); | |
|
246 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
|
247 | ||
|
248 | // Try removing empty list again | |
|
249 | m_barseries_with_sets->removeBarSets(empty); | |
|
250 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
|
251 | ||
|
252 | // remove all sets again | |
|
253 | m_barseries_with_sets->removeBarSets(m_testSets); | |
|
254 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
|
255 | } | |
|
256 | ||
|
257 | void tst_QPercentBarSeries::barsetCount_data() | |
|
258 | { | |
|
259 | ||
|
260 | } | |
|
261 | ||
|
262 | void tst_QPercentBarSeries::barsetCount() | |
|
263 | { | |
|
264 | QVERIFY(m_barseries->barsetCount() == 0); | |
|
265 | QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count()); | |
|
266 | } | |
|
267 | ||
|
268 | void tst_QPercentBarSeries::categoryCount_data() | |
|
269 | { | |
|
270 | ||
|
271 | } | |
|
272 | ||
|
273 | void tst_QPercentBarSeries::categoryCount() | |
|
274 | { | |
|
275 | QVERIFY(m_barseries->categoryCount() == m_categories.count()); | |
|
276 | QVERIFY(m_barseries_with_sets->categoryCount() == m_categories.count()); | |
|
277 | } | |
|
278 | ||
|
279 | void tst_QPercentBarSeries::barSets_data() | |
|
280 | { | |
|
281 | ||
|
282 | } | |
|
283 | ||
|
284 | void tst_QPercentBarSeries::barSets() | |
|
285 | { | |
|
286 | QVERIFY(m_barseries->barSets().count() == 0); | |
|
287 | ||
|
288 | QList<QBarSet*> sets = m_barseries_with_sets->barSets(); | |
|
289 | QVERIFY(sets.count() == m_testSets.count()); | |
|
290 | ||
|
291 | for (int i=0; i<m_testSets.count(); i++) { | |
|
292 | QVERIFY(sets.at(i) == m_testSets.at(i)); | |
|
293 | } | |
|
294 | } | |
|
295 | ||
|
296 | void tst_QPercentBarSeries::categories_data() | |
|
297 | { | |
|
298 | ||
|
299 | } | |
|
300 | ||
|
301 | void tst_QPercentBarSeries::categories() | |
|
302 | { | |
|
303 | QBarCategories categories = m_barseries->categories(); | |
|
304 | ||
|
305 | QVERIFY(categories.count() == m_categories.count()); | |
|
306 | for (int i=0; i<m_categories.count(); i++) { | |
|
307 | QVERIFY(categories.at(i).compare(m_categories.at(i)) == 0); | |
|
308 | } | |
|
309 | } | |
|
310 | ||
|
311 | void tst_QPercentBarSeries::setLabelsVisible_data() | |
|
312 | { | |
|
313 | ||
|
314 | } | |
|
315 | ||
|
316 | void tst_QPercentBarSeries::setLabelsVisible() | |
|
317 | { | |
|
318 | foreach (QBarSet* s, m_testSets) { | |
|
319 | QVERIFY(s->labelsVisible() == false); | |
|
320 | } | |
|
321 | ||
|
322 | m_barseries_with_sets->setLabelsVisible(true); | |
|
323 | foreach (QBarSet* s, m_testSets) { | |
|
324 | QVERIFY(s->labelsVisible() == true); | |
|
325 | } | |
|
326 | ||
|
327 | m_barseries_with_sets->setLabelsVisible(false); | |
|
328 | foreach (QBarSet* s, m_testSets) { | |
|
329 | QVERIFY(s->labelsVisible() == false); | |
|
330 | } | |
|
331 | } | |
|
332 | ||
|
333 | /* | |
|
334 | bool setModel(QAbstractItemModel *model); | |
|
335 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); | |
|
336 | void setModelMappingRange(int first, int count = -1); | |
|
337 | */ | |
|
338 | QTEST_MAIN(tst_QPercentBarSeries) | |
|
339 | ||
|
340 | #include "tst_qpercentbarseries.moc" | |
|
341 |
@@ -0,0 +1,6 | |||
|
1 | !include( ../auto.pri ) { | |
|
2 | error( "Couldn't find the auto.pri file!" ) | |
|
3 | } | |
|
4 | SOURCES += tst_qstackedbarseries.cpp | |
|
5 | ||
|
6 | !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" |
@@ -0,0 +1,341 | |||
|
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 | #include <QtTest/QtTest> | |
|
22 | #include <qstackedbarseries.h> | |
|
23 | #include <qbarset.h> | |
|
24 | ||
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |
|
26 | ||
|
27 | class tst_QStackedBarSeries : public QObject | |
|
28 | { | |
|
29 | Q_OBJECT | |
|
30 | ||
|
31 | public slots: | |
|
32 | void initTestCase(); | |
|
33 | void cleanupTestCase(); | |
|
34 | void init(); | |
|
35 | void cleanup(); | |
|
36 | ||
|
37 | private slots: | |
|
38 | void qstackedbarseries_data(); | |
|
39 | void qstackedbarseries(); | |
|
40 | void type_data(); | |
|
41 | void type(); | |
|
42 | void setCategories_data(); | |
|
43 | void setCategories(); | |
|
44 | void appendBarSet_data(); | |
|
45 | void appendBarSet(); | |
|
46 | void removeBarSet_data(); | |
|
47 | void removeBarSet(); | |
|
48 | void appendBarSets_data(); | |
|
49 | void appendBarSets(); | |
|
50 | void removeBarSets_data(); | |
|
51 | void removeBarSets(); | |
|
52 | void barsetCount_data(); | |
|
53 | void barsetCount(); | |
|
54 | void categoryCount_data(); | |
|
55 | void categoryCount(); | |
|
56 | void barSets_data(); | |
|
57 | void barSets(); | |
|
58 | void categories_data(); | |
|
59 | void categories(); | |
|
60 | void setLabelsVisible_data(); | |
|
61 | void setLabelsVisible(); | |
|
62 | ||
|
63 | private: | |
|
64 | QStackedBarSeries* m_barseries; | |
|
65 | QStackedBarSeries* m_barseries_with_sets; | |
|
66 | ||
|
67 | QList<QBarSet*> m_testSets; | |
|
68 | ||
|
69 | QBarCategories m_categories; | |
|
70 | }; | |
|
71 | ||
|
72 | void tst_QStackedBarSeries::initTestCase() | |
|
73 | { | |
|
74 | } | |
|
75 | ||
|
76 | void tst_QStackedBarSeries::cleanupTestCase() | |
|
77 | { | |
|
78 | } | |
|
79 | ||
|
80 | void tst_QStackedBarSeries::init() | |
|
81 | { | |
|
82 | m_categories << "category0" << "category1" << "category2"; | |
|
83 | m_barseries = new QStackedBarSeries(); | |
|
84 | m_barseries->setCategories(m_categories); | |
|
85 | m_barseries_with_sets = new QStackedBarSeries(); | |
|
86 | m_barseries_with_sets->setCategories(m_categories); | |
|
87 | ||
|
88 | for (int i=0; i<5; i++) { | |
|
89 | m_testSets.append(new QBarSet("testset")); | |
|
90 | m_barseries_with_sets->appendBarSet(m_testSets.at(i)); | |
|
91 | } | |
|
92 | } | |
|
93 | ||
|
94 | void tst_QStackedBarSeries::cleanup() | |
|
95 | { | |
|
96 | foreach(QBarSet* s, m_testSets) { | |
|
97 | m_barseries_with_sets->removeBarSet(s); | |
|
98 | delete s; | |
|
99 | } | |
|
100 | m_testSets.clear(); | |
|
101 | ||
|
102 | delete m_barseries; | |
|
103 | m_barseries = 0; | |
|
104 | delete m_barseries_with_sets; | |
|
105 | m_barseries_with_sets = 0; | |
|
106 | m_categories.clear(); | |
|
107 | } | |
|
108 | ||
|
109 | void tst_QStackedBarSeries::qstackedbarseries_data() | |
|
110 | { | |
|
111 | QTest::addColumn<QBarCategories> ("categories"); | |
|
112 | QBarCategories c; | |
|
113 | c << "category0" << "category1" << "category2"; | |
|
114 | QTest::newRow("categories") << c; | |
|
115 | } | |
|
116 | ||
|
117 | void tst_QStackedBarSeries::qstackedbarseries() | |
|
118 | { | |
|
119 | QFETCH(QBarCategories, categories); | |
|
120 | QStackedBarSeries *barseries = new QStackedBarSeries(); | |
|
121 | QVERIFY(barseries != 0); | |
|
122 | barseries->setCategories(categories); | |
|
123 | QBarCategories verifyCategories = barseries->categories(); | |
|
124 | ||
|
125 | QVERIFY(verifyCategories.count() == categories.count()); | |
|
126 | for (int i=0; i<categories.count(); i++) { | |
|
127 | QVERIFY(verifyCategories.at(i).compare(categories.at(i)) == 0); | |
|
128 | } | |
|
129 | } | |
|
130 | ||
|
131 | void tst_QStackedBarSeries::type_data() | |
|
132 | { | |
|
133 | ||
|
134 | } | |
|
135 | ||
|
136 | void tst_QStackedBarSeries::type() | |
|
137 | { | |
|
138 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar); | |
|
139 | } | |
|
140 | ||
|
141 | void tst_QStackedBarSeries::setCategories_data() | |
|
142 | { | |
|
143 | QTest::addColumn<QBarCategories> ("categories"); | |
|
144 | QBarCategories categories; | |
|
145 | categories << "c1" << "c2" << "c3" << "c4" << "c5" << "c6"; | |
|
146 | QTest::newRow("cat") << categories; | |
|
147 | } | |
|
148 | ||
|
149 | void tst_QStackedBarSeries::setCategories() | |
|
150 | { | |
|
151 | QVERIFY(m_barseries->categories().count() == m_categories.count()); | |
|
152 | ||
|
153 | QFETCH(QBarCategories, categories); | |
|
154 | m_barseries->setCategories(categories); | |
|
155 | ||
|
156 | QVERIFY(m_barseries->categories().count() == categories.count()); | |
|
157 | for (int i=0; i<categories.count(); i++) { | |
|
158 | QVERIFY(m_barseries->categories().at(i).compare(categories.at(i)) == 0); | |
|
159 | } | |
|
160 | } | |
|
161 | ||
|
162 | void tst_QStackedBarSeries::appendBarSet_data() | |
|
163 | { | |
|
164 | } | |
|
165 | ||
|
166 | void tst_QStackedBarSeries::appendBarSet() | |
|
167 | { | |
|
168 | QVERIFY(m_barseries->barsetCount() == 0); | |
|
169 | ||
|
170 | QBarSet *barset = new QBarSet("testset"); | |
|
171 | m_barseries->appendBarSet(barset); | |
|
172 | ||
|
173 | QVERIFY(m_barseries->barsetCount() == 1); | |
|
174 | ||
|
175 | QBarSet *barset2 = new QBarSet("testset2"); | |
|
176 | m_barseries->appendBarSet(barset2); | |
|
177 | ||
|
178 | QVERIFY(m_barseries->barsetCount() == 2); | |
|
179 | } | |
|
180 | ||
|
181 | void tst_QStackedBarSeries::removeBarSet_data() | |
|
182 | { | |
|
183 | } | |
|
184 | ||
|
185 | void tst_QStackedBarSeries::removeBarSet() | |
|
186 | { | |
|
187 | int count = m_testSets.count(); | |
|
188 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
|
189 | ||
|
190 | // remove some sets | |
|
191 | m_barseries_with_sets->removeBarSet(m_testSets.at(2)); | |
|
192 | m_barseries_with_sets->removeBarSet(m_testSets.at(3)); | |
|
193 | m_barseries_with_sets->removeBarSet(m_testSets.at(4)); | |
|
194 | ||
|
195 | QVERIFY(m_barseries_with_sets->barsetCount() == 2); | |
|
196 | ||
|
197 | QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); | |
|
198 | ||
|
199 | QVERIFY(verifysets.at(0) == m_testSets.at(0)); | |
|
200 | QVERIFY(verifysets.at(1) == m_testSets.at(1)); | |
|
201 | ||
|
202 | // Try removing all sets again | |
|
203 | for (int i=0; i<count; i++) { | |
|
204 | m_barseries_with_sets->removeBarSet(m_testSets.at(i)); | |
|
205 | } | |
|
206 | ||
|
207 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
|
208 | } | |
|
209 | ||
|
210 | void tst_QStackedBarSeries::appendBarSets_data() | |
|
211 | { | |
|
212 | ||
|
213 | } | |
|
214 | ||
|
215 | void tst_QStackedBarSeries::appendBarSets() | |
|
216 | { | |
|
217 | int count = 5; | |
|
218 | QVERIFY(m_barseries->barsetCount() == 0); | |
|
219 | ||
|
220 | QList<QBarSet*> sets; | |
|
221 | for (int i=0; i<count; i++) { | |
|
222 | sets.append(new QBarSet("testset")); | |
|
223 | } | |
|
224 | ||
|
225 | m_barseries->appendBarSets(sets); | |
|
226 | QVERIFY(m_barseries->barsetCount() == count); | |
|
227 | } | |
|
228 | ||
|
229 | void tst_QStackedBarSeries::removeBarSets_data() | |
|
230 | { | |
|
231 | ||
|
232 | } | |
|
233 | ||
|
234 | void tst_QStackedBarSeries::removeBarSets() | |
|
235 | { | |
|
236 | int count = m_testSets.count(); | |
|
237 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
|
238 | ||
|
239 | // Try removing empty list of sets | |
|
240 | QList<QBarSet*> empty; | |
|
241 | m_barseries_with_sets->removeBarSets(empty); | |
|
242 | QVERIFY(m_barseries_with_sets->barsetCount() == count); | |
|
243 | ||
|
244 | // remove all sets | |
|
245 | m_barseries_with_sets->removeBarSets(m_testSets); | |
|
246 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
|
247 | ||
|
248 | // Try removing empty list again | |
|
249 | m_barseries_with_sets->removeBarSets(empty); | |
|
250 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
|
251 | ||
|
252 | // remove all sets again | |
|
253 | m_barseries_with_sets->removeBarSets(m_testSets); | |
|
254 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); | |
|
255 | } | |
|
256 | ||
|
257 | void tst_QStackedBarSeries::barsetCount_data() | |
|
258 | { | |
|
259 | ||
|
260 | } | |
|
261 | ||
|
262 | void tst_QStackedBarSeries::barsetCount() | |
|
263 | { | |
|
264 | QVERIFY(m_barseries->barsetCount() == 0); | |
|
265 | QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count()); | |
|
266 | } | |
|
267 | ||
|
268 | void tst_QStackedBarSeries::categoryCount_data() | |
|
269 | { | |
|
270 | ||
|
271 | } | |
|
272 | ||
|
273 | void tst_QStackedBarSeries::categoryCount() | |
|
274 | { | |
|
275 | QVERIFY(m_barseries->categoryCount() == m_categories.count()); | |
|
276 | QVERIFY(m_barseries_with_sets->categoryCount() == m_categories.count()); | |
|
277 | } | |
|
278 | ||
|
279 | void tst_QStackedBarSeries::barSets_data() | |
|
280 | { | |
|
281 | ||
|
282 | } | |
|
283 | ||
|
284 | void tst_QStackedBarSeries::barSets() | |
|
285 | { | |
|
286 | QVERIFY(m_barseries->barSets().count() == 0); | |
|
287 | ||
|
288 | QList<QBarSet*> sets = m_barseries_with_sets->barSets(); | |
|
289 | QVERIFY(sets.count() == m_testSets.count()); | |
|
290 | ||
|
291 | for (int i=0; i<m_testSets.count(); i++) { | |
|
292 | QVERIFY(sets.at(i) == m_testSets.at(i)); | |
|
293 | } | |
|
294 | } | |
|
295 | ||
|
296 | void tst_QStackedBarSeries::categories_data() | |
|
297 | { | |
|
298 | ||
|
299 | } | |
|
300 | ||
|
301 | void tst_QStackedBarSeries::categories() | |
|
302 | { | |
|
303 | QBarCategories categories = m_barseries->categories(); | |
|
304 | ||
|
305 | QVERIFY(categories.count() == m_categories.count()); | |
|
306 | for (int i=0; i<m_categories.count(); i++) { | |
|
307 | QVERIFY(categories.at(i).compare(m_categories.at(i)) == 0); | |
|
308 | } | |
|
309 | } | |
|
310 | ||
|
311 | void tst_QStackedBarSeries::setLabelsVisible_data() | |
|
312 | { | |
|
313 | ||
|
314 | } | |
|
315 | ||
|
316 | void tst_QStackedBarSeries::setLabelsVisible() | |
|
317 | { | |
|
318 | foreach (QBarSet* s, m_testSets) { | |
|
319 | QVERIFY(s->labelsVisible() == false); | |
|
320 | } | |
|
321 | ||
|
322 | m_barseries_with_sets->setLabelsVisible(true); | |
|
323 | foreach (QBarSet* s, m_testSets) { | |
|
324 | QVERIFY(s->labelsVisible() == true); | |
|
325 | } | |
|
326 | ||
|
327 | m_barseries_with_sets->setLabelsVisible(false); | |
|
328 | foreach (QBarSet* s, m_testSets) { | |
|
329 | QVERIFY(s->labelsVisible() == false); | |
|
330 | } | |
|
331 | } | |
|
332 | ||
|
333 | /* | |
|
334 | bool setModel(QAbstractItemModel *model); | |
|
335 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); | |
|
336 | void setModelMappingRange(int first, int count = -1); | |
|
337 | */ | |
|
338 | QTEST_MAIN(tst_QStackedBarSeries) | |
|
339 | ||
|
340 | #include "tst_qstackedbarseries.moc" | |
|
341 |
@@ -1,10 +1,10 | |||
|
1 | 1 | !include( ../test.pri ) { |
|
2 | 2 | error( "Couldn't find the test.pri file!" ) |
|
3 | 3 | } |
|
4 | 4 | |
|
5 | 5 | TEMPLATE = subdirs |
|
6 | SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qpieslice qpieseries | |
|
6 | SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qpieslice qpieseries | |
|
7 | 7 | |
|
8 | 8 | test_private:{ |
|
9 | 9 | SUBDIRS += chartdataset domain |
|
10 | 10 | } |
@@ -1,321 +1,341 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include <QtTest/QtTest> |
|
22 | 22 | #include <qbarseries.h> |
|
23 | 23 | #include <qbarset.h> |
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | class tst_QBarSeries : public QObject |
|
28 | 28 | { |
|
29 | 29 | Q_OBJECT |
|
30 | 30 | |
|
31 | 31 | public slots: |
|
32 | 32 | void initTestCase(); |
|
33 | 33 | void cleanupTestCase(); |
|
34 | 34 | void init(); |
|
35 | 35 | void cleanup(); |
|
36 | 36 | |
|
37 | 37 | private slots: |
|
38 | 38 | void qbarseries_data(); |
|
39 | 39 | void qbarseries(); |
|
40 | 40 | void type_data(); |
|
41 | 41 | void type(); |
|
42 | void setCategories_data(); | |
|
43 | void setCategories(); | |
|
42 | 44 | void appendBarSet_data(); |
|
43 | 45 | void appendBarSet(); |
|
44 | 46 | void removeBarSet_data(); |
|
45 | 47 | void removeBarSet(); |
|
46 | 48 | void appendBarSets_data(); |
|
47 | 49 | void appendBarSets(); |
|
48 | 50 | void removeBarSets_data(); |
|
49 | 51 | void removeBarSets(); |
|
50 | 52 | void barsetCount_data(); |
|
51 | 53 | void barsetCount(); |
|
52 | 54 | void categoryCount_data(); |
|
53 | 55 | void categoryCount(); |
|
54 | 56 | void barSets_data(); |
|
55 | 57 | void barSets(); |
|
56 | 58 | void categories_data(); |
|
57 | 59 | void categories(); |
|
58 | 60 | void setLabelsVisible_data(); |
|
59 | 61 | void setLabelsVisible(); |
|
60 | 62 | |
|
61 | 63 | private: |
|
62 | 64 | QBarSeries* m_barseries; |
|
63 | 65 | QBarSeries* m_barseries_with_sets; |
|
64 | 66 | |
|
65 | 67 | QList<QBarSet*> m_testSets; |
|
66 | 68 | |
|
67 | 69 | QBarCategories m_categories; |
|
68 | 70 | }; |
|
69 | 71 | |
|
70 | 72 | void tst_QBarSeries::initTestCase() |
|
71 | 73 | { |
|
72 | 74 | } |
|
73 | 75 | |
|
74 | 76 | void tst_QBarSeries::cleanupTestCase() |
|
75 | 77 | { |
|
76 | 78 | } |
|
77 | 79 | |
|
78 | 80 | void tst_QBarSeries::init() |
|
79 | 81 | { |
|
80 | 82 | m_categories << "category0" << "category1" << "category2"; |
|
81 | 83 | m_barseries = new QBarSeries(); |
|
82 | 84 | m_barseries->setCategories(m_categories); |
|
83 | 85 | m_barseries_with_sets = new QBarSeries(); |
|
84 | 86 | m_barseries_with_sets->setCategories(m_categories); |
|
85 | 87 | |
|
86 | 88 | for (int i=0; i<5; i++) { |
|
87 | 89 | m_testSets.append(new QBarSet("testset")); |
|
88 | 90 | m_barseries_with_sets->appendBarSet(m_testSets.at(i)); |
|
89 | 91 | } |
|
90 | 92 | } |
|
91 | 93 | |
|
92 | 94 | void tst_QBarSeries::cleanup() |
|
93 | 95 | { |
|
94 | 96 | foreach(QBarSet* s, m_testSets) { |
|
95 | 97 | m_barseries_with_sets->removeBarSet(s); |
|
96 | 98 | delete s; |
|
97 | 99 | } |
|
98 | 100 | m_testSets.clear(); |
|
99 | 101 | |
|
100 | 102 | delete m_barseries; |
|
101 | 103 | m_barseries = 0; |
|
102 | 104 | delete m_barseries_with_sets; |
|
103 | 105 | m_barseries_with_sets = 0; |
|
104 | 106 | m_categories.clear(); |
|
105 | 107 | } |
|
106 | 108 | |
|
107 | 109 | void tst_QBarSeries::qbarseries_data() |
|
108 | 110 | { |
|
109 | 111 | QTest::addColumn<QBarCategories> ("categories"); |
|
110 | 112 | QBarCategories c; |
|
111 | 113 | c << "category0" << "category1" << "category2"; |
|
112 | 114 | QTest::newRow("categories") << c; |
|
113 | 115 | } |
|
114 | 116 | |
|
115 | 117 | void tst_QBarSeries::qbarseries() |
|
116 | 118 | { |
|
117 | 119 | QFETCH(QBarCategories, categories); |
|
118 | 120 | QBarSeries *barseries = new QBarSeries(); |
|
119 | 121 | QVERIFY(barseries != 0); |
|
120 | 122 | barseries->setCategories(categories); |
|
121 | 123 | QBarCategories verifyCategories = barseries->categories(); |
|
122 | 124 | |
|
123 | 125 | QVERIFY(verifyCategories.count() == categories.count()); |
|
124 | 126 | for (int i=0; i<categories.count(); i++) { |
|
125 | 127 | QVERIFY(verifyCategories.at(i).compare(categories.at(i)) == 0); |
|
126 | 128 | } |
|
127 | 129 | } |
|
128 | 130 | |
|
129 | 131 | void tst_QBarSeries::type_data() |
|
130 | 132 | { |
|
131 | 133 | |
|
132 | 134 | } |
|
133 | 135 | |
|
134 | 136 | void tst_QBarSeries::type() |
|
135 | 137 | { |
|
136 | 138 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar); |
|
137 | 139 | } |
|
138 | 140 | |
|
141 | void tst_QBarSeries::setCategories_data() | |
|
142 | { | |
|
143 | QTest::addColumn<QBarCategories> ("categories"); | |
|
144 | QBarCategories categories; | |
|
145 | categories << "c1" << "c2" << "c3" << "c4" << "c5" << "c6"; | |
|
146 | QTest::newRow("cat") << categories; | |
|
147 | } | |
|
148 | ||
|
149 | void tst_QBarSeries::setCategories() | |
|
150 | { | |
|
151 | QVERIFY(m_barseries->categories().count() == m_categories.count()); | |
|
152 | ||
|
153 | QFETCH(QBarCategories, categories); | |
|
154 | m_barseries->setCategories(categories); | |
|
155 | ||
|
156 | QVERIFY(m_barseries->categories().count() == categories.count()); | |
|
157 | for (int i=0; i<categories.count(); i++) { | |
|
158 | QVERIFY(m_barseries->categories().at(i).compare(categories.at(i)) == 0); | |
|
159 | } | |
|
160 | } | |
|
161 | ||
|
139 | 162 | void tst_QBarSeries::appendBarSet_data() |
|
140 | 163 | { |
|
141 | 164 | } |
|
142 | 165 | |
|
143 | 166 | void tst_QBarSeries::appendBarSet() |
|
144 | 167 | { |
|
145 | 168 | QVERIFY(m_barseries->barsetCount() == 0); |
|
146 | 169 | |
|
147 | 170 | QBarSet *barset = new QBarSet("testset"); |
|
148 | 171 | m_barseries->appendBarSet(barset); |
|
149 | 172 | |
|
150 | 173 | QVERIFY(m_barseries->barsetCount() == 1); |
|
151 | 174 | |
|
152 | 175 | QBarSet *barset2 = new QBarSet("testset2"); |
|
153 | 176 | m_barseries->appendBarSet(barset2); |
|
154 | 177 | |
|
155 | 178 | QVERIFY(m_barseries->barsetCount() == 2); |
|
156 | 179 | } |
|
157 | 180 | |
|
158 | 181 | void tst_QBarSeries::removeBarSet_data() |
|
159 | 182 | { |
|
160 | 183 | } |
|
161 | 184 | |
|
162 | 185 | void tst_QBarSeries::removeBarSet() |
|
163 | 186 | { |
|
164 | 187 | int count = m_testSets.count(); |
|
165 | 188 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
166 | 189 | |
|
167 | 190 | // remove some sets |
|
168 | 191 | m_barseries_with_sets->removeBarSet(m_testSets.at(2)); |
|
169 | 192 | m_barseries_with_sets->removeBarSet(m_testSets.at(3)); |
|
170 | 193 | m_barseries_with_sets->removeBarSet(m_testSets.at(4)); |
|
171 | 194 | |
|
172 | 195 | QVERIFY(m_barseries_with_sets->barsetCount() == 2); |
|
173 | 196 | |
|
174 | 197 | QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); |
|
175 | 198 | |
|
176 | 199 | QVERIFY(verifysets.at(0) == m_testSets.at(0)); |
|
177 | 200 | QVERIFY(verifysets.at(1) == m_testSets.at(1)); |
|
178 | 201 | |
|
179 | 202 | // Try removing all sets again |
|
180 | 203 | for (int i=0; i<count; i++) { |
|
181 | 204 | m_barseries_with_sets->removeBarSet(m_testSets.at(i)); |
|
182 | 205 | } |
|
183 | 206 | |
|
184 | 207 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); |
|
185 | 208 | } |
|
186 | 209 | |
|
187 | 210 | void tst_QBarSeries::appendBarSets_data() |
|
188 | 211 | { |
|
189 | 212 | |
|
190 | 213 | } |
|
191 | 214 | |
|
192 | 215 | void tst_QBarSeries::appendBarSets() |
|
193 | 216 | { |
|
194 | 217 | int count = 5; |
|
195 | 218 | QVERIFY(m_barseries->barsetCount() == 0); |
|
196 | 219 | |
|
197 | 220 | QList<QBarSet*> sets; |
|
198 | 221 | for (int i=0; i<count; i++) { |
|
199 | 222 | sets.append(new QBarSet("testset")); |
|
200 | 223 | } |
|
201 | 224 | |
|
202 | 225 | m_barseries->appendBarSets(sets); |
|
203 | 226 | QVERIFY(m_barseries->barsetCount() == count); |
|
204 | 227 | } |
|
205 | 228 | |
|
206 | 229 | void tst_QBarSeries::removeBarSets_data() |
|
207 | 230 | { |
|
208 | 231 | |
|
209 | 232 | } |
|
210 | 233 | |
|
211 | 234 | void tst_QBarSeries::removeBarSets() |
|
212 | 235 | { |
|
213 | 236 | int count = m_testSets.count(); |
|
214 | 237 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
215 | 238 | |
|
216 | 239 | // Try removing empty list of sets |
|
217 | 240 | QList<QBarSet*> empty; |
|
218 | 241 | m_barseries_with_sets->removeBarSets(empty); |
|
219 | 242 | QVERIFY(m_barseries_with_sets->barsetCount() == count); |
|
220 | 243 | |
|
221 | 244 | // remove all sets |
|
222 | 245 | m_barseries_with_sets->removeBarSets(m_testSets); |
|
223 | 246 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); |
|
224 | 247 | |
|
225 | 248 | // Try removing empty list again |
|
226 | 249 | m_barseries_with_sets->removeBarSets(empty); |
|
227 | 250 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); |
|
228 | 251 | |
|
229 | 252 | // remove all sets again |
|
230 | 253 | m_barseries_with_sets->removeBarSets(m_testSets); |
|
231 | 254 | QVERIFY(m_barseries_with_sets->barsetCount() == 0); |
|
232 | 255 | } |
|
233 | 256 | |
|
234 | 257 | void tst_QBarSeries::barsetCount_data() |
|
235 | 258 | { |
|
236 | 259 | |
|
237 | 260 | } |
|
238 | 261 | |
|
239 | 262 | void tst_QBarSeries::barsetCount() |
|
240 | 263 | { |
|
241 | 264 | QVERIFY(m_barseries->barsetCount() == 0); |
|
242 | 265 | QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count()); |
|
243 | 266 | } |
|
244 | 267 | |
|
245 | 268 | void tst_QBarSeries::categoryCount_data() |
|
246 | 269 | { |
|
247 | 270 | |
|
248 | 271 | } |
|
249 | 272 | |
|
250 | 273 | void tst_QBarSeries::categoryCount() |
|
251 | 274 | { |
|
252 | 275 | QVERIFY(m_barseries->categoryCount() == m_categories.count()); |
|
253 | 276 | QVERIFY(m_barseries_with_sets->categoryCount() == m_categories.count()); |
|
254 | 277 | } |
|
255 | 278 | |
|
256 | 279 | void tst_QBarSeries::barSets_data() |
|
257 | 280 | { |
|
258 | 281 | |
|
259 | 282 | } |
|
260 | 283 | |
|
261 | 284 | void tst_QBarSeries::barSets() |
|
262 | 285 | { |
|
263 | 286 | QVERIFY(m_barseries->barSets().count() == 0); |
|
264 | 287 | |
|
265 | 288 | QList<QBarSet*> sets = m_barseries_with_sets->barSets(); |
|
266 | 289 | QVERIFY(sets.count() == m_testSets.count()); |
|
267 | 290 | |
|
268 | 291 | for (int i=0; i<m_testSets.count(); i++) { |
|
269 | 292 | QVERIFY(sets.at(i) == m_testSets.at(i)); |
|
270 | 293 | } |
|
271 | 294 | } |
|
272 | 295 | |
|
273 | 296 | void tst_QBarSeries::categories_data() |
|
274 | 297 | { |
|
275 | 298 | |
|
276 | 299 | } |
|
277 | 300 | |
|
278 | 301 | void tst_QBarSeries::categories() |
|
279 | 302 | { |
|
280 | 303 | QBarCategories categories = m_barseries->categories(); |
|
281 | 304 | |
|
282 | 305 | QVERIFY(categories.count() == m_categories.count()); |
|
283 | 306 | for (int i=0; i<m_categories.count(); i++) { |
|
284 | 307 | QVERIFY(categories.at(i).compare(m_categories.at(i)) == 0); |
|
285 | 308 | } |
|
286 | 309 | } |
|
287 | 310 | |
|
288 | 311 | void tst_QBarSeries::setLabelsVisible_data() |
|
289 | 312 | { |
|
290 | 313 | |
|
291 | 314 | } |
|
292 | 315 | |
|
293 | 316 | void tst_QBarSeries::setLabelsVisible() |
|
294 | 317 | { |
|
295 | 318 | foreach (QBarSet* s, m_testSets) { |
|
296 | 319 | QVERIFY(s->labelsVisible() == false); |
|
297 | 320 | } |
|
298 | 321 | |
|
299 | 322 | m_barseries_with_sets->setLabelsVisible(true); |
|
300 | 323 | foreach (QBarSet* s, m_testSets) { |
|
301 | 324 | QVERIFY(s->labelsVisible() == true); |
|
302 | 325 | } |
|
303 | 326 | |
|
304 | 327 | m_barseries_with_sets->setLabelsVisible(false); |
|
305 | 328 | foreach (QBarSet* s, m_testSets) { |
|
306 | 329 | QVERIFY(s->labelsVisible() == false); |
|
307 | 330 | } |
|
308 | 331 | } |
|
309 | 332 | |
|
310 | 333 | /* |
|
311 | ||
|
312 | void setLabelsVisible(bool visible = true); | |
|
313 | ||
|
314 | 334 | bool setModel(QAbstractItemModel *model); |
|
315 | 335 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
316 | 336 | void setModelMappingRange(int first, int count = -1); |
|
317 | 337 | */ |
|
318 | 338 | QTEST_MAIN(tst_QBarSeries) |
|
319 | 339 | |
|
320 | 340 | #include "tst_qbarseries.moc" |
|
321 | 341 |
General Comments 0
You need to be logged in to leave comments.
Login now