@@ -1,341 +1,95 | |||
|
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 <qpercentbarseries.h> |
|
23 | 23 | #include <qbarset.h> |
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | class tst_QPercentBarSeries : 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 qpercentbarseries_data(); |
|
39 | 39 | void qpercentbarseries(); |
|
40 | 40 | void type_data(); |
|
41 | 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 | 42 | |
|
63 | 43 | private: |
|
64 | 44 | QPercentBarSeries* m_barseries; |
|
65 | QPercentBarSeries* m_barseries_with_sets; | |
|
66 | ||
|
67 | QList<QBarSet*> m_testSets; | |
|
68 | ||
|
69 | QBarCategories m_categories; | |
|
70 | 45 | }; |
|
71 | 46 | |
|
72 | 47 | void tst_QPercentBarSeries::initTestCase() |
|
73 | 48 | { |
|
74 | 49 | } |
|
75 | 50 | |
|
76 | 51 | void tst_QPercentBarSeries::cleanupTestCase() |
|
77 | 52 | { |
|
78 | 53 | } |
|
79 | 54 | |
|
80 | 55 | void tst_QPercentBarSeries::init() |
|
81 | 56 | { |
|
82 | m_categories << "category0" << "category1" << "category2"; | |
|
83 | 57 | 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 | 58 | } |
|
93 | 59 | |
|
94 | 60 | void tst_QPercentBarSeries::cleanup() |
|
95 | 61 | { |
|
96 | foreach(QBarSet* s, m_testSets) { | |
|
97 | m_barseries_with_sets->removeBarSet(s); | |
|
98 | delete s; | |
|
99 | } | |
|
100 | m_testSets.clear(); | |
|
101 | ||
|
102 | 62 | delete m_barseries; |
|
103 | 63 | m_barseries = 0; |
|
104 | delete m_barseries_with_sets; | |
|
105 | m_barseries_with_sets = 0; | |
|
106 | m_categories.clear(); | |
|
107 | 64 | } |
|
108 | 65 | |
|
109 | 66 | void tst_QPercentBarSeries::qpercentbarseries_data() |
|
110 | 67 | { |
|
111 | QTest::addColumn<QBarCategories> ("categories"); | |
|
112 | QBarCategories c; | |
|
113 | c << "category0" << "category1" << "category2"; | |
|
114 | QTest::newRow("categories") << c; | |
|
115 | 68 | } |
|
116 | 69 | |
|
117 | 70 | void tst_QPercentBarSeries::qpercentbarseries() |
|
118 | 71 | { |
|
119 | QFETCH(QBarCategories, categories); | |
|
120 | 72 | QPercentBarSeries *barseries = new QPercentBarSeries(); |
|
121 | 73 | 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 | 74 | } |
|
130 | 75 | |
|
131 | 76 | void tst_QPercentBarSeries::type_data() |
|
132 | 77 | { |
|
133 | 78 | |
|
134 | 79 | } |
|
135 | 80 | |
|
136 | 81 | void tst_QPercentBarSeries::type() |
|
137 | 82 | { |
|
138 | 83 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar); |
|
139 | 84 | } |
|
140 | 85 | |
|
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 | 86 | |
|
333 | 87 | /* |
|
334 | 88 | bool setModel(QAbstractItemModel *model); |
|
335 | 89 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
336 | 90 | void setModelMappingRange(int first, int count = -1); |
|
337 | 91 | */ |
|
338 | 92 | QTEST_MAIN(tst_QPercentBarSeries) |
|
339 | 93 | |
|
340 | 94 | #include "tst_qpercentbarseries.moc" |
|
341 | 95 |
@@ -1,341 +1,94 | |||
|
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 <qstackedbarseries.h> |
|
23 | 23 | #include <qbarset.h> |
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | 26 | |
|
27 | 27 | class tst_QStackedBarSeries : 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 qstackedbarseries_data(); |
|
39 | 39 | void qstackedbarseries(); |
|
40 | 40 | void type_data(); |
|
41 | 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 | 42 | |
|
63 | 43 | private: |
|
64 | 44 | QStackedBarSeries* m_barseries; |
|
65 | QStackedBarSeries* m_barseries_with_sets; | |
|
66 | ||
|
67 | QList<QBarSet*> m_testSets; | |
|
68 | ||
|
69 | QBarCategories m_categories; | |
|
70 | 45 | }; |
|
71 | 46 | |
|
72 | 47 | void tst_QStackedBarSeries::initTestCase() |
|
73 | 48 | { |
|
74 | 49 | } |
|
75 | 50 | |
|
76 | 51 | void tst_QStackedBarSeries::cleanupTestCase() |
|
77 | 52 | { |
|
78 | 53 | } |
|
79 | 54 | |
|
80 | 55 | void tst_QStackedBarSeries::init() |
|
81 | 56 | { |
|
82 | m_categories << "category0" << "category1" << "category2"; | |
|
83 | 57 | 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 | 58 | } |
|
93 | 59 | |
|
94 | 60 | void tst_QStackedBarSeries::cleanup() |
|
95 | 61 | { |
|
96 | foreach(QBarSet* s, m_testSets) { | |
|
97 | m_barseries_with_sets->removeBarSet(s); | |
|
98 | delete s; | |
|
99 | } | |
|
100 | m_testSets.clear(); | |
|
101 | ||
|
102 | 62 | delete m_barseries; |
|
103 | 63 | m_barseries = 0; |
|
104 | delete m_barseries_with_sets; | |
|
105 | m_barseries_with_sets = 0; | |
|
106 | m_categories.clear(); | |
|
107 | 64 | } |
|
108 | 65 | |
|
109 | 66 | void tst_QStackedBarSeries::qstackedbarseries_data() |
|
110 | 67 | { |
|
111 | QTest::addColumn<QBarCategories> ("categories"); | |
|
112 | QBarCategories c; | |
|
113 | c << "category0" << "category1" << "category2"; | |
|
114 | QTest::newRow("categories") << c; | |
|
115 | 68 | } |
|
116 | 69 | |
|
117 | 70 | void tst_QStackedBarSeries::qstackedbarseries() |
|
118 | 71 | { |
|
119 | QFETCH(QBarCategories, categories); | |
|
120 | 72 | QStackedBarSeries *barseries = new QStackedBarSeries(); |
|
121 | 73 | 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 | 74 | } |
|
130 | 75 | |
|
131 | 76 | void tst_QStackedBarSeries::type_data() |
|
132 | 77 | { |
|
133 | 78 | |
|
134 | 79 | } |
|
135 | 80 | |
|
136 | 81 | void tst_QStackedBarSeries::type() |
|
137 | 82 | { |
|
138 | 83 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar); |
|
139 | 84 | } |
|
140 | 85 | |
|
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 | 86 | /* |
|
334 | 87 | bool setModel(QAbstractItemModel *model); |
|
335 | 88 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); |
|
336 | 89 | void setModelMappingRange(int first, int count = -1); |
|
337 | 90 | */ |
|
338 | 91 | QTEST_MAIN(tst_QStackedBarSeries) |
|
339 | 92 | |
|
340 | 93 | #include "tst_qstackedbarseries.moc" |
|
341 | 94 |
General Comments 0
You need to be logged in to leave comments.
Login now