@@ -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 |
@@ -3,7 +3,7 | |||||
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 |
@@ -39,6 +39,8 private slots: | |||||
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(); | |
@@ -136,6 +138,27 void tst_QBarSeries::type() | |||||
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 | } | |
@@ -308,9 +331,6 void tst_QBarSeries::setLabelsVisible() | |||||
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); |
General Comments 0
You need to be logged in to leave comments.
Login now