##// END OF EJS Templates
updated barseries unit test. fixed found errors.
sauimone -
r1101:5d7dfff0c2e8
parent child
Show More
@@ -115,7 +115,7 void QBarSeries::removeBarSet(QBarSet *set)
115 115 Q_D(QBarSeries);
116 116 if (d->m_barSets.contains(set)) {
117 117 d->m_barSets.removeOne(set);
118 QObject::disconnect(set, SIGNAL(updatedBars()), this, SLOT(barsetChanged()));
118 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), d, SLOT(barsetChanged()));
119 119 emit d->restructuredBars();
120 120 }
121 121 }
@@ -128,7 +128,7 void QBarSeries::appendBarSets(QList<QBarSet* > sets)
128 128 Q_D(QBarSeries);
129 129 foreach (QBarSet* set, sets) {
130 130 d->m_barSets.append(set);
131 QObject::connect(set, SIGNAL(updatedBars()), this, SLOT(barsetChanged()));
131 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBars()), d, SLOT(barsetChanged()));
132 132 }
133 133 emit d->restructuredBars();
134 134 }
@@ -143,7 +143,7 void QBarSeries::removeBarSets(QList<QBarSet* > sets)
143 143 foreach (QBarSet* set, sets) {
144 144 if (d->m_barSets.contains(set)) {
145 145 d->m_barSets.removeOne(set);
146 QObject::disconnect(set, SIGNAL(updatedBars()), this, SLOT(barsetChanged()));
146 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBars()), d, SLOT(barsetChanged()));
147 147 }
148 148 }
149 149 emit d->restructuredBars();
@@ -41,9 +41,30 private slots:
41 41 void type();
42 42 void appendBarSet_data();
43 43 void appendBarSet();
44 void removeBarSet_data();
45 void removeBarSet();
46 void appendBarSets_data();
47 void appendBarSets();
48 void removeBarSets_data();
49 void removeBarSets();
50 void barsetCount_data();
51 void barsetCount();
52 void categoryCount_data();
53 void categoryCount();
54 void barSets_data();
55 void barSets();
56 void categories_data();
57 void categories();
58 void setLabelsVisible_data();
59 void setLabelsVisible();
44 60
45 61 private:
46 62 QBarSeries* m_barseries;
63 QBarSeries* m_barseries_with_sets;
64
65 QList<QBarSet*> m_testSets;
66
67 QBarCategories m_categories;
47 68 };
48 69
49 70 void tst_QBarSeries::initTestCase()
@@ -56,15 +77,29 void tst_QBarSeries::cleanupTestCase()
56 77
57 78 void tst_QBarSeries::init()
58 79 {
59 QBarCategories categories;
60 categories << "category0" << "category1" << "category2";
61 m_barseries = new QBarSeries(categories);
80 m_categories << "category0" << "category1" << "category2";
81 m_barseries = new QBarSeries(m_categories);
82 m_barseries_with_sets = new QBarSeries(m_categories);
83
84 for (int i=0; i<5; i++) {
85 m_testSets.append(new QBarSet("testset"));
86 m_barseries_with_sets->appendBarSet(m_testSets.at(i));
87 }
62 88 }
63 89
64 90 void tst_QBarSeries::cleanup()
65 91 {
92 foreach(QBarSet* s, m_testSets) {
93 m_barseries_with_sets->removeBarSet(s);
94 delete s;
95 }
96 m_testSets.clear();
97
66 98 delete m_barseries;
67 99 m_barseries = 0;
100 delete m_barseries_with_sets;
101 m_barseries_with_sets = 0;
102 m_categories.clear();
68 103 }
69 104
70 105 void tst_QBarSeries::qbarseries_data()
@@ -110,16 +145,166 void tst_QBarSeries::appendBarSet()
110 145 m_barseries->appendBarSet(barset);
111 146
112 147 QVERIFY(m_barseries->barsetCount() == 1);
148
149 QBarSet *barset2 = new QBarSet("testset2");
150 m_barseries->appendBarSet(barset2);
151
152 QVERIFY(m_barseries->barsetCount() == 2);
153 }
154
155 void tst_QBarSeries::removeBarSet_data()
156 {
157 }
158
159 void tst_QBarSeries::removeBarSet()
160 {
161 int count = m_testSets.count();
162 QVERIFY(m_barseries_with_sets->barsetCount() == count);
163
164 // remove some sets
165 m_barseries_with_sets->removeBarSet(m_testSets.at(2));
166 m_barseries_with_sets->removeBarSet(m_testSets.at(3));
167 m_barseries_with_sets->removeBarSet(m_testSets.at(4));
168
169 QVERIFY(m_barseries_with_sets->barsetCount() == 2);
170
171 QList<QBarSet*> verifysets = m_barseries_with_sets->barSets();
172
173 QVERIFY(verifysets.at(0) == m_testSets.at(0));
174 QVERIFY(verifysets.at(1) == m_testSets.at(1));
175
176 // Try removing all sets again
177 for (int i=0; i<count; i++) {
178 m_barseries_with_sets->removeBarSet(m_testSets.at(i));
179 }
180
181 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
182 }
183
184 void tst_QBarSeries::appendBarSets_data()
185 {
186
187 }
188
189 void tst_QBarSeries::appendBarSets()
190 {
191 int count = 5;
192 QVERIFY(m_barseries->barsetCount() == 0);
193
194 QList<QBarSet*> sets;
195 for (int i=0; i<count; i++) {
196 sets.append(new QBarSet("testset"));
197 }
198
199 m_barseries->appendBarSets(sets);
200 QVERIFY(m_barseries->barsetCount() == count);
201 }
202
203 void tst_QBarSeries::removeBarSets_data()
204 {
205
206 }
207
208 void tst_QBarSeries::removeBarSets()
209 {
210 int count = m_testSets.count();
211 QVERIFY(m_barseries_with_sets->barsetCount() == count);
212
213 // Try removing empty list of sets
214 QList<QBarSet*> empty;
215 m_barseries_with_sets->removeBarSets(empty);
216 QVERIFY(m_barseries_with_sets->barsetCount() == count);
217
218 // remove all sets
219 m_barseries_with_sets->removeBarSets(m_testSets);
220 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
221
222 // Try removing empty list again
223 m_barseries_with_sets->removeBarSets(empty);
224 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
225
226 // remove all sets again
227 m_barseries_with_sets->removeBarSets(m_testSets);
228 QVERIFY(m_barseries_with_sets->barsetCount() == 0);
229 }
230
231 void tst_QBarSeries::barsetCount_data()
232 {
233
234 }
235
236 void tst_QBarSeries::barsetCount()
237 {
238 QVERIFY(m_barseries->barsetCount() == 0);
239 QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count());
240 }
241
242 void tst_QBarSeries::categoryCount_data()
243 {
244
245 }
246
247 void tst_QBarSeries::categoryCount()
248 {
249 QVERIFY(m_barseries->categoryCount() == m_categories.count());
250 QVERIFY(m_barseries_with_sets->categoryCount() == m_categories.count());
251 }
252
253 void tst_QBarSeries::barSets_data()
254 {
255
256 }
257
258 void tst_QBarSeries::barSets()
259 {
260 QVERIFY(m_barseries->barSets().count() == 0);
261
262 QList<QBarSet*> sets = m_barseries_with_sets->barSets();
263 QVERIFY(sets.count() == m_testSets.count());
264
265 for (int i=0; i<m_testSets.count(); i++) {
266 QVERIFY(sets.at(i) == m_testSets.at(i));
267 }
268 }
269
270 void tst_QBarSeries::categories_data()
271 {
272
273 }
274
275 void tst_QBarSeries::categories()
276 {
277 QBarCategories categories = m_barseries->categories();
278
279 QVERIFY(categories.count() == m_categories.count());
280 for (int i=0; i<m_categories.count(); i++) {
281 QVERIFY(categories.at(i).compare(m_categories.at(i)) == 0);
282 }
283 }
284
285 void tst_QBarSeries::setLabelsVisible_data()
286 {
287
288 }
289
290 void tst_QBarSeries::setLabelsVisible()
291 {
292 foreach (QBarSet* s, m_testSets) {
293 QVERIFY(s->labelsVisible() == false);
294 }
295
296 m_barseries_with_sets->setLabelsVisible(true);
297 foreach (QBarSet* s, m_testSets) {
298 QVERIFY(s->labelsVisible() == true);
299 }
300
301 m_barseries_with_sets->setLabelsVisible(false);
302 foreach (QBarSet* s, m_testSets) {
303 QVERIFY(s->labelsVisible() == false);
304 }
113 305 }
114 306
115 307 /*
116 void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set
117 void appendBarSets(QList<QBarSet* > sets);
118 void removeBarSets(QList<QBarSet* > sets);
119 int barsetCount() const;
120 int categoryCount() const;
121 QList<QBarSet*> barSets() const;
122 QBarCategories categories() const;
123 308
124 309 void setLabelsVisible(bool visible = true);
125 310
General Comments 0
You need to be logged in to leave comments. Login now