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