##// END OF EJS Templates
QBarSet auto test to show the sets in QChartView
Tero Ahola -
r1335:2ed58f4cde3a
parent child
Show More
@@ -1,418 +1,409
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 <qbarset.h>
22 #include <qbarset.h>
23 #include <qgroupedbarseries.h>
24 #include <qchartview.h>
23
25
24 QTCOMMERCIALCHART_USE_NAMESPACE
26 QTCOMMERCIALCHART_USE_NAMESPACE
25
27
26 class tst_QBarSet : public QObject
28 class tst_QBarSet : public QObject
27 {
29 {
28 Q_OBJECT
30 Q_OBJECT
29
31
30 public slots:
32 public slots:
31 void initTestCase();
33 void initTestCase();
32 void cleanupTestCase();
34 void cleanupTestCase();
33 void init();
35 void init();
34 void cleanup();
36 void cleanup();
35
37
36 private slots:
38 private slots:
37 void qbarset_data();
39 void qbarset_data();
38 void qbarset();
40 void qbarset();
39 void name_data();
41 void name_data();
40 void name();
42 void name();
41 void append_data();
43 void append_data();
42 void append();
44 void append();
43 void appendOperator_data();
45 void appendOperator_data();
44 void appendOperator();
46 void appendOperator();
45 void insert_data();
47 void insert_data();
46 void insert();
48 void insert();
47 void remove_data();
49 void remove_data();
48 void remove();
50 void remove();
49 void replace_data();
51 void replace_data();
50 void replace();
52 void replace();
51 void at_data();
53 void at_data();
52 void at();
54 void at();
53 void atOperator_data();
55 void atOperator_data();
54 void atOperator();
56 void atOperator();
55 void count_data();
57 void count_data();
56 void count();
58 void count();
57 void sum_data();
59 void sum_data();
58 void sum();
60 void sum();
59 void setPen_data();
61 void customize();
60 void setPen();
61 void setBrush_data();
62 void setBrush();
63 void setLabelBrush_data();
64 void setLabelBrush();
65 void setLabelFont_data();
66 void setLabelFont();
67
62
68 private:
63 private:
69 QBarSet* m_barset;
64 QBarSet* m_barset;
70 };
65 };
71
66
72 void tst_QBarSet::initTestCase()
67 void tst_QBarSet::initTestCase()
73 {
68 {
74 }
69 }
75
70
76 void tst_QBarSet::cleanupTestCase()
71 void tst_QBarSet::cleanupTestCase()
77 {
72 {
78 }
73 }
79
74
80 void tst_QBarSet::init()
75 void tst_QBarSet::init()
81 {
76 {
82 m_barset = new QBarSet(QString("Name"));
77 m_barset = new QBarSet(QString("Name"));
83 }
78 }
84
79
85 void tst_QBarSet::cleanup()
80 void tst_QBarSet::cleanup()
86 {
81 {
87 delete m_barset;
82 delete m_barset;
88 m_barset = 0;
83 m_barset = 0;
89 }
84 }
90
85
91 void tst_QBarSet::qbarset_data()
86 void tst_QBarSet::qbarset_data()
92 {
87 {
93 }
88 }
94
89
95 void tst_QBarSet::qbarset()
90 void tst_QBarSet::qbarset()
96 {
91 {
97 QBarSet barset(QString("Name"));
92 QBarSet barset(QString("Name"));
98 QCOMPARE(barset.name(), QString("Name"));
93 QCOMPARE(barset.name(), QString("Name"));
99 QCOMPARE(barset.count(), 0);
94 QCOMPARE(barset.count(), 0);
100 QVERIFY(qFuzzyIsNull(barset.sum()));
95 QVERIFY(qFuzzyIsNull(barset.sum()));
101 }
96 }
102
97
103 void tst_QBarSet::name_data()
98 void tst_QBarSet::name_data()
104 {
99 {
105 QTest::addColumn<QString> ("name");
100 QTest::addColumn<QString> ("name");
106 QTest::addColumn<QString> ("result");
101 QTest::addColumn<QString> ("result");
107 QTest::newRow("name0") << QString("name0") << QString("name0");
102 QTest::newRow("name0") << QString("name0") << QString("name0");
108 QTest::newRow("name1") << QString("name1") << QString("name1");
103 QTest::newRow("name1") << QString("name1") << QString("name1");
109 }
104 }
110
105
111 void tst_QBarSet::name()
106 void tst_QBarSet::name()
112 {
107 {
113 QFETCH(QString, name);
108 QFETCH(QString, name);
114 QFETCH(QString, result);
109 QFETCH(QString, result);
115
110
116 m_barset->setName(name);
111 m_barset->setName(name);
117 QCOMPARE(m_barset->name(), result);
112 QCOMPARE(m_barset->name(), result);
118 }
113 }
119
114
120 void tst_QBarSet::append_data()
115 void tst_QBarSet::append_data()
121 {
116 {
122 QTest::addColumn<int> ("count");
117 QTest::addColumn<int> ("count");
123 QTest::newRow("0") << 0;
118 QTest::newRow("0") << 0;
124 QTest::newRow("5") << 5;
119 QTest::newRow("5") << 5;
125 QTest::newRow("100") << 100;
120 QTest::newRow("100") << 100;
126 QTest::newRow("1000") << 1000;
121 QTest::newRow("1000") << 1000;
127 }
122 }
128
123
129 void tst_QBarSet::append()
124 void tst_QBarSet::append()
130 {
125 {
131 QFETCH(int, count);
126 QFETCH(int, count);
132
127
133 QCOMPARE(m_barset->count(), 0);
128 QCOMPARE(m_barset->count(), 0);
134 QVERIFY(qFuzzyIsNull(m_barset->sum()));
129 QVERIFY(qFuzzyIsNull(m_barset->sum()));
135
130
136 qreal sum(0.0);
131 qreal sum(0.0);
137 qreal value(0.0);
132 qreal value(0.0);
138
133
139 for (int i=0; i<count; i++) {
134 for (int i=0; i<count; i++) {
140 m_barset->append(value);
135 m_barset->append(value);
141 QCOMPARE(m_barset->at(i).y(), value);
136 QCOMPARE(m_barset->at(i).y(), value);
142 sum += value;
137 sum += value;
143 value += 1.0;
138 value += 1.0;
144 }
139 }
145
140
146 QCOMPARE(m_barset->count(), count);
141 QCOMPARE(m_barset->count(), count);
147 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
142 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
148 }
143 }
149
144
150 void tst_QBarSet::appendOperator_data()
145 void tst_QBarSet::appendOperator_data()
151 {
146 {
152 append_data();
147 append_data();
153 }
148 }
154
149
155 void tst_QBarSet::appendOperator()
150 void tst_QBarSet::appendOperator()
156 {
151 {
157 QFETCH(int, count);
152 QFETCH(int, count);
158
153
159 QCOMPARE(m_barset->count(), 0);
154 QCOMPARE(m_barset->count(), 0);
160 QVERIFY(qFuzzyIsNull(m_barset->sum()));
155 QVERIFY(qFuzzyIsNull(m_barset->sum()));
161
156
162 qreal sum(0.0);
157 qreal sum(0.0);
163 qreal value(0.0);
158 qreal value(0.0);
164
159
165 for (int i=0; i<count; i++) {
160 for (int i=0; i<count; i++) {
166 *m_barset << value;
161 *m_barset << value;
167 QCOMPARE(m_barset->at(i).y(), value);
162 QCOMPARE(m_barset->at(i).y(), value);
168 sum += value;
163 sum += value;
169 value += 1.0;
164 value += 1.0;
170 }
165 }
171
166
172 QCOMPARE(m_barset->count(), count);
167 QCOMPARE(m_barset->count(), count);
173 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
168 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
174 }
169 }
175
170
176 void tst_QBarSet::insert_data()
171 void tst_QBarSet::insert_data()
177 {
172 {
178 }
173 }
179
174
180 void tst_QBarSet::insert()
175 void tst_QBarSet::insert()
181 {
176 {
182 QCOMPARE(m_barset->count(), 0);
177 QCOMPARE(m_barset->count(), 0);
183 QVERIFY(qFuzzyIsNull(m_barset->sum()));
178 QVERIFY(qFuzzyIsNull(m_barset->sum()));
184
179
185 m_barset->insert(0, 1.0); // 1.0
180 m_barset->insert(0, 1.0); // 1.0
186 QCOMPARE(m_barset->at(0).y(), 1.0);
181 QCOMPARE(m_barset->at(0).y(), 1.0);
187 QCOMPARE(m_barset->count(), 1);
182 QCOMPARE(m_barset->count(), 1);
188 QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0));
183 QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0));
189
184
190 m_barset->insert(0, 2.0); // 2.0 1.0
185 m_barset->insert(0, 2.0); // 2.0 1.0
191 QCOMPARE(m_barset->at(0).y(), 2.0);
186 QCOMPARE(m_barset->at(0).y(), 2.0);
192 QCOMPARE(m_barset->at(1).y(), 1.0);
187 QCOMPARE(m_barset->at(1).y(), 1.0);
193 QCOMPARE(m_barset->count(), 2);
188 QCOMPARE(m_barset->count(), 2);
194 QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0));
189 QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0));
195
190
196 m_barset->insert(1, 3.0); // 2.0 3.0 1.0
191 m_barset->insert(1, 3.0); // 2.0 3.0 1.0
197 QCOMPARE(m_barset->at(1).y(), 3.0);
192 QCOMPARE(m_barset->at(1).y(), 3.0);
198 QCOMPARE(m_barset->at(0).y(), 2.0);
193 QCOMPARE(m_barset->at(0).y(), 2.0);
199 QCOMPARE(m_barset->at(2).y(), 1.0);
194 QCOMPARE(m_barset->at(2).y(), 1.0);
200 QCOMPARE(m_barset->count(), 3);
195 QCOMPARE(m_barset->count(), 3);
201 QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0));
196 QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0));
202 }
197 }
203
198
204 void tst_QBarSet::remove_data()
199 void tst_QBarSet::remove_data()
205 {
200 {
206 }
201 }
207
202
208 void tst_QBarSet::remove()
203 void tst_QBarSet::remove()
209 {
204 {
210 QCOMPARE(m_barset->count(), 0);
205 QCOMPARE(m_barset->count(), 0);
211 QVERIFY(qFuzzyIsNull(m_barset->sum()));
206 QVERIFY(qFuzzyIsNull(m_barset->sum()));
212
207
213 m_barset->append(1.0);
208 m_barset->append(1.0);
214 m_barset->append(2.0);
209 m_barset->append(2.0);
215 m_barset->append(3.0);
210 m_barset->append(3.0);
216 m_barset->append(4.0);
211 m_barset->append(4.0);
217
212
218 QCOMPARE(m_barset->count(), 4);
213 QCOMPARE(m_barset->count(), 4);
219 QCOMPARE(m_barset->sum(), 10.0);
214 QCOMPARE(m_barset->sum(), 10.0);
220
215
221 m_barset->remove(2); // 1.0 2.0 4.0
216 m_barset->remove(2); // 1.0 2.0 4.0
222 QCOMPARE(m_barset->at(0).y(), 1.0);
217 QCOMPARE(m_barset->at(0).y(), 1.0);
223 QCOMPARE(m_barset->at(1).y(), 2.0);
218 QCOMPARE(m_barset->at(1).y(), 2.0);
224 QCOMPARE(m_barset->at(2).y(), 4.0);
219 QCOMPARE(m_barset->at(2).y(), 4.0);
225 QCOMPARE(m_barset->count(), 3);
220 QCOMPARE(m_barset->count(), 3);
226 QCOMPARE(m_barset->sum(), 7.0);
221 QCOMPARE(m_barset->sum(), 7.0);
227
222
228 m_barset->remove(0); // 2.0 4.0
223 m_barset->remove(0); // 2.0 4.0
229 QCOMPARE(m_barset->at(0).y(), 2.0);
224 QCOMPARE(m_barset->at(0).y(), 2.0);
230 QCOMPARE(m_barset->at(1).y(), 4.0);
225 QCOMPARE(m_barset->at(1).y(), 4.0);
231 QCOMPARE(m_barset->count(), 2);
226 QCOMPARE(m_barset->count(), 2);
232 QCOMPARE(m_barset->sum(), 6.0);
227 QCOMPARE(m_barset->sum(), 6.0);
233 }
228 }
234
229
235 void tst_QBarSet::replace_data()
230 void tst_QBarSet::replace_data()
236 {
231 {
237
232
238 }
233 }
239
234
240 void tst_QBarSet::replace()
235 void tst_QBarSet::replace()
241 {
236 {
242 QCOMPARE(m_barset->count(), 0);
237 QCOMPARE(m_barset->count(), 0);
243 QVERIFY(qFuzzyIsNull(m_barset->sum()));
238 QVERIFY(qFuzzyIsNull(m_barset->sum()));
244
239
245 m_barset->append(1.0);
240 m_barset->append(1.0);
246 m_barset->append(2.0);
241 m_barset->append(2.0);
247 m_barset->append(3.0);
242 m_barset->append(3.0);
248 m_barset->append(4.0);
243 m_barset->append(4.0);
249
244
250 QCOMPARE(m_barset->count(), 4);
245 QCOMPARE(m_barset->count(), 4);
251 QCOMPARE(m_barset->sum(), 10.0);
246 QCOMPARE(m_barset->sum(), 10.0);
252
247
253 m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0
248 m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0
254 QCOMPARE(m_barset->count(), 4);
249 QCOMPARE(m_barset->count(), 4);
255 QCOMPARE(m_barset->sum(), 14.0);
250 QCOMPARE(m_barset->sum(), 14.0);
256 QCOMPARE(m_barset->at(0).y(), 5.0);
251 QCOMPARE(m_barset->at(0).y(), 5.0);
257
252
258 m_barset->replace(3, 6.0);
253 m_barset->replace(3, 6.0);
259 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
254 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
260 QCOMPARE(m_barset->sum(), 16.0);
255 QCOMPARE(m_barset->sum(), 16.0);
261 QCOMPARE(m_barset->at(0).y(), 5.0);
256 QCOMPARE(m_barset->at(0).y(), 5.0);
262 QCOMPARE(m_barset->at(1).y(), 2.0);
257 QCOMPARE(m_barset->at(1).y(), 2.0);
263 QCOMPARE(m_barset->at(2).y(), 3.0);
258 QCOMPARE(m_barset->at(2).y(), 3.0);
264 QCOMPARE(m_barset->at(3).y(), 6.0);
259 QCOMPARE(m_barset->at(3).y(), 6.0);
265 }
260 }
266
261
267 void tst_QBarSet::at_data()
262 void tst_QBarSet::at_data()
268 {
263 {
269
264
270 }
265 }
271
266
272 void tst_QBarSet::at()
267 void tst_QBarSet::at()
273 {
268 {
274 QCOMPARE(m_barset->count(), 0);
269 QCOMPARE(m_barset->count(), 0);
275 QVERIFY(qFuzzyIsNull(m_barset->sum()));
270 QVERIFY(qFuzzyIsNull(m_barset->sum()));
276
271
277 m_barset->append(1.0);
272 m_barset->append(1.0);
278 m_barset->append(2.0);
273 m_barset->append(2.0);
279 m_barset->append(3.0);
274 m_barset->append(3.0);
280 m_barset->append(4.0);
275 m_barset->append(4.0);
281
276
282 QCOMPARE(m_barset->at(0).y(), 1.0);
277 QCOMPARE(m_barset->at(0).y(), 1.0);
283 QCOMPARE(m_barset->at(1).y(), 2.0);
278 QCOMPARE(m_barset->at(1).y(), 2.0);
284 QCOMPARE(m_barset->at(2).y(), 3.0);
279 QCOMPARE(m_barset->at(2).y(), 3.0);
285 QCOMPARE(m_barset->at(3).y(), 4.0);
280 QCOMPARE(m_barset->at(3).y(), 4.0);
286 }
281 }
287
282
288 void tst_QBarSet::atOperator_data()
283 void tst_QBarSet::atOperator_data()
289 {
284 {
290
285
291 }
286 }
292
287
293 void tst_QBarSet::atOperator()
288 void tst_QBarSet::atOperator()
294 {
289 {
295 QCOMPARE(m_barset->count(), 0);
290 QCOMPARE(m_barset->count(), 0);
296 QVERIFY(qFuzzyIsNull(m_barset->sum()));
291 QVERIFY(qFuzzyIsNull(m_barset->sum()));
297
292
298 m_barset->append(1.0);
293 m_barset->append(1.0);
299 m_barset->append(2.0);
294 m_barset->append(2.0);
300 m_barset->append(3.0);
295 m_barset->append(3.0);
301 m_barset->append(4.0);
296 m_barset->append(4.0);
302
297
303 QCOMPARE(m_barset->operator [](0).y(), 1.0);
298 QCOMPARE(m_barset->operator [](0).y(), 1.0);
304 QCOMPARE(m_barset->operator [](1).y(), 2.0);
299 QCOMPARE(m_barset->operator [](1).y(), 2.0);
305 QCOMPARE(m_barset->operator [](2).y(), 3.0);
300 QCOMPARE(m_barset->operator [](2).y(), 3.0);
306 QCOMPARE(m_barset->operator [](3).y(), 4.0);
301 QCOMPARE(m_barset->operator [](3).y(), 4.0);
307 }
302 }
308
303
309 void tst_QBarSet::count_data()
304 void tst_QBarSet::count_data()
310 {
305 {
311
306
312 }
307 }
313
308
314 void tst_QBarSet::count()
309 void tst_QBarSet::count()
315 {
310 {
316 QCOMPARE(m_barset->count(), 0);
311 QCOMPARE(m_barset->count(), 0);
317 QVERIFY(qFuzzyIsNull(m_barset->sum()));
312 QVERIFY(qFuzzyIsNull(m_barset->sum()));
318
313
319 m_barset->append(1.0);
314 m_barset->append(1.0);
320 QCOMPARE(m_barset->count(),1);
315 QCOMPARE(m_barset->count(),1);
321 m_barset->append(2.0);
316 m_barset->append(2.0);
322 QCOMPARE(m_barset->count(),2);
317 QCOMPARE(m_barset->count(),2);
323 m_barset->append(3.0);
318 m_barset->append(3.0);
324 QCOMPARE(m_barset->count(),3);
319 QCOMPARE(m_barset->count(),3);
325 m_barset->append(4.0);
320 m_barset->append(4.0);
326 QCOMPARE(m_barset->count(),4);
321 QCOMPARE(m_barset->count(),4);
327 }
322 }
328
323
329 void tst_QBarSet::sum_data()
324 void tst_QBarSet::sum_data()
330 {
325 {
331
326
332 }
327 }
333
328
334 void tst_QBarSet::sum()
329 void tst_QBarSet::sum()
335 {
330 {
336 QCOMPARE(m_barset->count(), 0);
331 QCOMPARE(m_barset->count(), 0);
337 QVERIFY(qFuzzyIsNull(m_barset->sum()));
332 QVERIFY(qFuzzyIsNull(m_barset->sum()));
338
333
339 m_barset->append(1.0);
334 m_barset->append(1.0);
340 QVERIFY(qFuzzyCompare(m_barset->sum(),1.0));
335 QVERIFY(qFuzzyCompare(m_barset->sum(),1.0));
341 m_barset->append(2.0);
336 m_barset->append(2.0);
342 QVERIFY(qFuzzyCompare(m_barset->sum(),3.0));
337 QVERIFY(qFuzzyCompare(m_barset->sum(),3.0));
343 m_barset->append(3.0);
338 m_barset->append(3.0);
344 QVERIFY(qFuzzyCompare(m_barset->sum(),6.0));
339 QVERIFY(qFuzzyCompare(m_barset->sum(),6.0));
345 m_barset->append(4.0);
340 m_barset->append(4.0);
346 QVERIFY(qFuzzyCompare(m_barset->sum(),10.0));
341 QVERIFY(qFuzzyCompare(m_barset->sum(),10.0));
347 }
342 }
348
343
349 void tst_QBarSet::setPen_data()
344 void tst_QBarSet::customize()
350 {
345 {
351
346 // Create sets
352 }
347 QBarSet *set1 = new QBarSet("set1");
353
348 QBarSet *set2 = new QBarSet("set2");
354 void tst_QBarSet::setPen()
349
355 {
350 // Append set1 to series
356 QVERIFY(m_barset->pen() == QPen());
351 QGroupedBarSeries *series = new QGroupedBarSeries();
357
352 series->append(set1);
358 QPen pen;
353
359 pen.setColor(QColor(128,128,128,128));
354 // Add series to the chart
360 m_barset->setPen(pen);
355 QChartView view(new QChart());
361
356 view.resize(200, 200);
362 QVERIFY(m_barset->pen() == pen);
357 view.chart()->addSeries(series);
363 }
358 view.show();
364
359 QTest::qWaitForWindowShown(&view);
365 void tst_QBarSet::setBrush_data()
360
366 {
361 // Test adding data to the sets
367
362 *set1 << 1 << 2 << 1 << 3;
368 }
363 *set2 << 2 << 1 << 3 << 1;
369
364
370 void tst_QBarSet::setBrush()
365 // Test pen
371 {
366 QVERIFY(set1->pen() != QPen());
372 QVERIFY(m_barset->brush() == QBrush());
367 QVERIFY(set2->pen() == QPen());
373
368 QPen pen(QColor(128,128,128,128));
374 QBrush brush;
369 set1->setPen(pen);
375 brush.setColor(QColor(128,128,128,128));
370 QVERIFY(set1->pen() == pen);
376 m_barset->setBrush(brush);
371 QVERIFY(set2->pen() == QPen());
377
372
378 QVERIFY(m_barset->brush() == brush);
373 // Test brush
379 }
374 QVERIFY(set1->brush() != QBrush());
380
375 QVERIFY(set2->brush() == QBrush());
381 void tst_QBarSet::setLabelBrush_data()
376 QBrush brush(QColor(128,128,128,128));
382 {
377 set1->setBrush(brush);
383
378 QVERIFY(set1->brush() == brush);
384 }
379 QVERIFY(set2->brush() == QBrush());
385
380
386 void tst_QBarSet::setLabelBrush()
381 // Test label brush
387 {
382 QVERIFY(set1->labelBrush() != QBrush());
388 QVERIFY(m_barset->labelBrush() == QBrush());
383 QVERIFY(set2->labelBrush() == QBrush());
389
384 set1->setLabelBrush(brush);
390 QBrush brush;
385 QVERIFY(set1->labelBrush() == brush);
391 brush.setColor(QColor(128,128,128,128));
386 QVERIFY(set2->labelBrush() == QBrush());
392 m_barset->setLabelBrush(brush);
387
393
388 // Test label font
394 QVERIFY(m_barset->labelBrush() == brush);
389 // Note: QFont empty constructor creates font with application's default font, so the font may or may not be the
395 }
390 // same for the set added to the series (depending on the QChart's theme configuration)
396
391 QVERIFY(set1->labelFont() != QFont() || set1->labelFont() == QFont());
397 void tst_QBarSet::setLabelFont_data()
392 QVERIFY(set2->labelFont() == QFont());
398 {
399
400 }
401
402 void tst_QBarSet::setLabelFont()
403 {
404 QVERIFY(m_barset->labelFont() == QFont());
405
406 QFont font;
393 QFont font;
407 font.setBold(true);
394 font.setBold(true);
408 font.setItalic(true);
395 font.setItalic(true);
409 m_barset->setLabelFont(font);
396 set1->setLabelFont(font);
397 QVERIFY(set1->labelFont() == font);
398 QVERIFY(set2->labelFont() == QFont());
410
399
411 QVERIFY(m_barset->labelFont() == font);
400 // Test adding data to the sets
401 *set1 << 1 << 2 << 1 << 3;
402 *set2 << 2 << 1 << 3 << 1;
403 QTest::qWait(3000);
412 }
404 }
413
405
414
415 QTEST_MAIN(tst_QBarSet)
406 QTEST_MAIN(tst_QBarSet)
416
407
417 #include "tst_qbarset.moc"
408 #include "tst_qbarset.moc"
418
409
General Comments 0
You need to be logged in to leave comments. Login now