##// END OF EJS Templates
Wavechart example and designer plugin disabled on arm due to include problem
Marek Rosa -
r1680:73e46ffc00f9
parent child
Show More
@@ -1,8 +1,12
1 1 !include( ../config.pri ) {
2 2 error( "Couldn't find the config.pri file!" )
3 3 }
4 4
5 5 TEMPLATE = subdirs
6 6 SUBDIRS += \
7 declarative \
8 designer No newline at end of file
7 declarative
8
9 !linux-arm*: {
10 SUBDIRS += \
11 designer
12 }
@@ -1,488 +1,488
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 <qbarset.h>
23 23 #include <qbarseries.h>
24 24 #include <qchartview.h>
25 25
26 26 QTCOMMERCIALCHART_USE_NAMESPACE
27 27
28 28 class tst_QBarSet : public QObject
29 29 {
30 30 Q_OBJECT
31 31
32 32 public slots:
33 33 void initTestCase();
34 34 void cleanupTestCase();
35 35 void init();
36 36 void cleanup();
37 37
38 38 private slots:
39 39 void qbarset_data();
40 40 void qbarset();
41 41 void label_data();
42 42 void label();
43 43 void append_data();
44 44 void append();
45 45 void appendOperator_data();
46 46 void appendOperator();
47 47 void insert_data();
48 48 void insert();
49 49 void remove_data();
50 50 void remove();
51 51 void replace_data();
52 52 void replace();
53 53 void at_data();
54 54 void at();
55 55 void atOperator_data();
56 56 void atOperator();
57 57 void count_data();
58 58 void count();
59 59 void sum_data();
60 60 void sum();
61 61 void customize();
62 62
63 63 private:
64 64 QBarSet* m_barset;
65 65 };
66 66
67 67 void tst_QBarSet::initTestCase()
68 68 {
69 69 }
70 70
71 71 void tst_QBarSet::cleanupTestCase()
72 72 {
73 73 }
74 74
75 75 void tst_QBarSet::init()
76 76 {
77 77 m_barset = new QBarSet(QString("label"));
78 78 }
79 79
80 80 void tst_QBarSet::cleanup()
81 81 {
82 82 delete m_barset;
83 83 m_barset = 0;
84 84 }
85 85
86 86 void tst_QBarSet::qbarset_data()
87 87 {
88 88 }
89 89
90 90 void tst_QBarSet::qbarset()
91 91 {
92 92 QBarSet barset(QString("label"));
93 93 QCOMPARE(barset.label(), QString("label"));
94 94 QCOMPARE(barset.count(), 0);
95 95 QVERIFY(qFuzzyIsNull(barset.sum()));
96 96 }
97 97
98 98 void tst_QBarSet::label_data()
99 99 {
100 100 QTest::addColumn<QString> ("label");
101 101 QTest::addColumn<QString> ("result");
102 102 QTest::newRow("label0") << QString("label0") << QString("label0");
103 103 QTest::newRow("label1") << QString("label1") << QString("label1");
104 104 }
105 105
106 106 void tst_QBarSet::label()
107 107 {
108 108 QFETCH(QString, label);
109 109 QFETCH(QString, result);
110 110
111 111 QSignalSpy labelSpy(m_barset,SIGNAL(labelChanged()));
112 112 m_barset->setLabel(label);
113 113 QCOMPARE(m_barset->label(), result);
114 114 QVERIFY(labelSpy.count() == 1);
115 115 }
116 116
117 117 void tst_QBarSet::append_data()
118 118 {
119 119 QTest::addColumn<int> ("count");
120 120 QTest::newRow("0") << 0;
121 121 QTest::newRow("5") << 5;
122 122 QTest::newRow("100") << 100;
123 123 QTest::newRow("1000") << 1000;
124 124 }
125 125
126 126 void tst_QBarSet::append()
127 127 {
128 128 QFETCH(int, count);
129 129
130 130 QCOMPARE(m_barset->count(), 0);
131 131 QVERIFY(qFuzzyIsNull(m_barset->sum()));
132 132
133 133 QSignalSpy valueSpy(m_barset, SIGNAL(valuesAdded(int,int)));
134 134
135 135 qreal sum(0.0);
136 136 qreal value(0.0);
137 137
138 138 for (int i=0; i<count; i++) {
139 139 m_barset->append(value);
140 140 QCOMPARE(m_barset->at(i), value);
141 141 sum += value;
142 142 value += 1.0;
143 143 }
144 144
145 145 QCOMPARE(m_barset->count(), count);
146 146 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
147 147
148 148 QCOMPARE(valueSpy.count(), count);
149 149 }
150 150
151 151 void tst_QBarSet::appendOperator_data()
152 152 {
153 153 append_data();
154 154 }
155 155
156 156 void tst_QBarSet::appendOperator()
157 157 {
158 158 QFETCH(int, count);
159 159
160 160 QCOMPARE(m_barset->count(), 0);
161 161 QVERIFY(qFuzzyIsNull(m_barset->sum()));
162 162
163 163 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
164 164
165 165 qreal sum(0.0);
166 166 qreal value(0.0);
167 167
168 168 for (int i=0; i<count; i++) {
169 169 *m_barset << value;
170 170 QCOMPARE(m_barset->at(i), value);
171 171 sum += value;
172 172 value += 1.0;
173 173 }
174 174
175 175 QCOMPARE(m_barset->count(), count);
176 176 QVERIFY(qFuzzyCompare(m_barset->sum(), sum));
177 177 QCOMPARE(valueSpy.count(), count);
178 178 }
179 179
180 180 void tst_QBarSet::insert_data()
181 181 {
182 182 }
183 183
184 184 void tst_QBarSet::insert()
185 185 {
186 186 QCOMPARE(m_barset->count(), 0);
187 187 QVERIFY(qFuzzyIsNull(m_barset->sum()));
188 188 QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int)));
189 189
190 190 m_barset->insert(0, 1.0); // 1.0
191 191 QCOMPARE(m_barset->at(0), 1.0);
192 192 QCOMPARE(m_barset->count(), 1);
193 QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0));
193 QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)1.0));
194 194
195 195 m_barset->insert(0, 2.0); // 2.0 1.0
196 196 QCOMPARE(m_barset->at(0), 2.0);
197 197 QCOMPARE(m_barset->at(1), 1.0);
198 198 QCOMPARE(m_barset->count(), 2);
199 QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0));
199 QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)3.0));
200 200
201 201 m_barset->insert(1, 3.0); // 2.0 3.0 1.0
202 202 QCOMPARE(m_barset->at(1), 3.0);
203 203 QCOMPARE(m_barset->at(0), 2.0);
204 204 QCOMPARE(m_barset->at(2), 1.0);
205 205 QCOMPARE(m_barset->count(), 3);
206 QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0));
206 QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)6.0));
207 207 QCOMPARE(valueSpy.count(), 3);
208 208 }
209 209
210 210 void tst_QBarSet::remove_data()
211 211 {
212 212 }
213 213
214 214 void tst_QBarSet::remove()
215 215 {
216 216 QCOMPARE(m_barset->count(), 0);
217 217 QVERIFY(qFuzzyIsNull(m_barset->sum()));
218 218
219 219 QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int)));
220 220
221 221 m_barset->append(1.0);
222 222 m_barset->append(2.0);
223 223 m_barset->append(3.0);
224 224 m_barset->append(4.0);
225 225
226 226 QCOMPARE(m_barset->count(), 4);
227 227 QCOMPARE(m_barset->sum(), 10.0);
228 228
229 229 // Remove middle
230 230 m_barset->remove(2); // 1.0 2.0 4.0
231 231 QCOMPARE(m_barset->at(0), 1.0);
232 232 QCOMPARE(m_barset->at(1), 2.0);
233 233 QCOMPARE(m_barset->at(2), 4.0);
234 234 QCOMPARE(m_barset->count(), 3);
235 235 QCOMPARE(m_barset->sum(), 7.0);
236 236 QCOMPARE(valueSpy.count(), 1);
237 237
238 238 QList<QVariant> valueSpyArg = valueSpy.takeFirst();
239 239 // Verify index of removed signal
240 240 QVERIFY(valueSpyArg.at(0).type() == QVariant::Int);
241 241 QVERIFY(valueSpyArg.at(0).toInt() == 2);
242 242 // Verify count of removed signal
243 243 QVERIFY(valueSpyArg.at(1).type() == QVariant::Int);
244 244 QVERIFY(valueSpyArg.at(1).toInt() == 1);
245 245
246 246 // Remove first
247 247 m_barset->remove(0); // 2.0 4.0
248 248 QCOMPARE(m_barset->at(0), 2.0);
249 249 QCOMPARE(m_barset->at(1), 4.0);
250 250 QCOMPARE(m_barset->count(), 2);
251 251 QCOMPARE(m_barset->sum(), 6.0);
252 252
253 253 QCOMPARE(valueSpy.count(), 1);
254 254 valueSpyArg = valueSpy.takeFirst();
255 255 // Verify index of removed signal
256 256 QVERIFY(valueSpyArg.at(0).type() == QVariant::Int);
257 257 QVERIFY(valueSpyArg.at(0).toInt() == 0);
258 258 // Verify count of removed signal
259 259 QVERIFY(valueSpyArg.at(1).type() == QVariant::Int);
260 260 QVERIFY(valueSpyArg.at(1).toInt() == 1);
261 261
262 262
263 263 // Illegal indexes
264 264 m_barset->remove(4);
265 265 QCOMPARE(m_barset->count(), 2);
266 266 QCOMPARE(m_barset->sum(), 6.0);
267 267 m_barset->remove(-1);
268 268 QCOMPARE(m_barset->count(), 2);
269 269 QCOMPARE(m_barset->sum(), 6.0);
270 270
271 271 // nothing removed, no signals should be emitted
272 272 QCOMPARE(valueSpy.count(), 0);
273 273
274 274 // Remove more items than list has
275 275 m_barset->remove(0,312);
276 276 QCOMPARE(m_barset->count(), 0);
277 277 QVERIFY(qFuzzyIsNull(m_barset->sum()));
278 278
279 279 QCOMPARE(valueSpy.count(), 1);
280 280 valueSpyArg = valueSpy.takeFirst();
281 281
282 282 // Verify index of removed signal
283 283 QVERIFY(valueSpyArg.at(0).type() == QVariant::Int);
284 284 QVERIFY(valueSpyArg.at(0).toInt() == 0);
285 285 // Verify count of removed signal (expect 2 values removed, because list had only 2 items)
286 286 QVERIFY(valueSpyArg.at(1).type() == QVariant::Int);
287 287 QVERIFY(valueSpyArg.at(1).toInt() == 2);
288 288 }
289 289
290 290 void tst_QBarSet::replace_data()
291 291 {
292 292
293 293 }
294 294
295 295 void tst_QBarSet::replace()
296 296 {
297 297 QCOMPARE(m_barset->count(), 0);
298 298 QVERIFY(qFuzzyIsNull(m_barset->sum()));
299 299 QSignalSpy valueSpy(m_barset,SIGNAL(valueChanged(int)));
300 300
301 301 m_barset->append(1.0);
302 302 m_barset->append(2.0);
303 303 m_barset->append(3.0);
304 304 m_barset->append(4.0);
305 305
306 306 QCOMPARE(m_barset->count(), 4);
307 307 QCOMPARE(m_barset->sum(), 10.0);
308 308
309 309 // Replace first
310 310 m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0
311 311 QCOMPARE(m_barset->count(), 4);
312 312 QCOMPARE(m_barset->sum(), 14.0);
313 313 QCOMPARE(m_barset->at(0), 5.0);
314 314
315 315 // Replace last
316 316 m_barset->replace(3, 6.0);
317 317 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
318 318 QCOMPARE(m_barset->sum(), 16.0);
319 319 QCOMPARE(m_barset->at(0), 5.0);
320 320 QCOMPARE(m_barset->at(1), 2.0);
321 321 QCOMPARE(m_barset->at(2), 3.0);
322 322 QCOMPARE(m_barset->at(3), 6.0);
323 323
324 324 // Illegal indexes
325 325 m_barset->replace(4, 6.0);
326 326 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
327 327 QCOMPARE(m_barset->sum(), 16.0);
328 328 m_barset->replace(-1, 6.0);
329 329 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
330 330 QCOMPARE(m_barset->sum(), 16.0);
331 331 m_barset->replace(4, 1.0);
332 332 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
333 333 QCOMPARE(m_barset->sum(), 16.0);
334 334 m_barset->replace(-1, 1.0);
335 335 QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0
336 336 QCOMPARE(m_barset->sum(), 16.0);
337 337
338 338 QVERIFY(valueSpy.count() == 2);
339 339 }
340 340
341 341 void tst_QBarSet::at_data()
342 342 {
343 343
344 344 }
345 345
346 346 void tst_QBarSet::at()
347 347 {
348 348 QCOMPARE(m_barset->count(), 0);
349 349 QVERIFY(qFuzzyIsNull(m_barset->sum()));
350 350
351 351 m_barset->append(1.0);
352 352 m_barset->append(2.0);
353 353 m_barset->append(3.0);
354 354 m_barset->append(4.0);
355 355
356 356 QCOMPARE(m_barset->at(0), 1.0);
357 357 QCOMPARE(m_barset->at(1), 2.0);
358 358 QCOMPARE(m_barset->at(2), 3.0);
359 359 QCOMPARE(m_barset->at(3), 4.0);
360 360 }
361 361
362 362 void tst_QBarSet::atOperator_data()
363 363 {
364 364
365 365 }
366 366
367 367 void tst_QBarSet::atOperator()
368 368 {
369 369 QCOMPARE(m_barset->count(), 0);
370 370 QVERIFY(qFuzzyIsNull(m_barset->sum()));
371 371
372 372 m_barset->append(1.0);
373 373 m_barset->append(2.0);
374 374 m_barset->append(3.0);
375 375 m_barset->append(4.0);
376 376
377 377 QCOMPARE(m_barset->operator [](0), 1.0);
378 378 QCOMPARE(m_barset->operator [](1), 2.0);
379 379 QCOMPARE(m_barset->operator [](2), 3.0);
380 380 QCOMPARE(m_barset->operator [](3), 4.0);
381 381 }
382 382
383 383 void tst_QBarSet::count_data()
384 384 {
385 385
386 386 }
387 387
388 388 void tst_QBarSet::count()
389 389 {
390 390 QCOMPARE(m_barset->count(), 0);
391 391 QVERIFY(qFuzzyIsNull(m_barset->sum()));
392 392
393 393 m_barset->append(1.0);
394 394 QCOMPARE(m_barset->count(),1);
395 395 m_barset->append(2.0);
396 396 QCOMPARE(m_barset->count(),2);
397 397 m_barset->append(3.0);
398 398 QCOMPARE(m_barset->count(),3);
399 399 m_barset->append(4.0);
400 400 QCOMPARE(m_barset->count(),4);
401 401 }
402 402
403 403 void tst_QBarSet::sum_data()
404 404 {
405 405
406 406 }
407 407
408 408 void tst_QBarSet::sum()
409 409 {
410 410 QCOMPARE(m_barset->count(), 0);
411 411 QVERIFY(qFuzzyIsNull(m_barset->sum()));
412 412
413 413 m_barset->append(1.0);
414 QVERIFY(qFuzzyCompare(m_barset->sum(),1.0));
414 QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)1.0));
415 415 m_barset->append(2.0);
416 QVERIFY(qFuzzyCompare(m_barset->sum(),3.0));
416 QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)3.0));
417 417 m_barset->append(3.0);
418 QVERIFY(qFuzzyCompare(m_barset->sum(),6.0));
418 QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)6.0));
419 419 m_barset->append(4.0);
420 QVERIFY(qFuzzyCompare(m_barset->sum(),10.0));
420 QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)10.0));
421 421 }
422 422
423 423 void tst_QBarSet::customize()
424 424 {
425 425 // Create sets
426 426 QBarSet *set1 = new QBarSet("set1");
427 427 QBarSet *set2 = new QBarSet("set2");
428 428
429 429 // Append set1 to series
430 430 QBarSeries *series = new QBarSeries();
431 431 bool success = series->append(set1);
432 432 QVERIFY(success);
433 433
434 434 // Add series to the chart
435 435 QChartView view(new QChart());
436 436 view.resize(200, 200);
437 437 view.chart()->addSeries(series);
438 438 view.show();
439 439 QTest::qWaitForWindowShown(&view);
440 440
441 441 // Test adding data to the sets
442 442 *set1 << 1 << 2 << 1 << 3;
443 443 *set2 << 2 << 1 << 3 << 1;
444 444
445 445 // Test pen
446 446 QVERIFY(set1->pen() != QPen());
447 447 QVERIFY(set2->pen() == QPen());
448 448 QPen pen(QColor(128,128,128,128));
449 449 set1->setPen(pen);
450 450 QVERIFY(set1->pen() == pen);
451 451 QVERIFY(set2->pen() == QPen());
452 452
453 453 // Test brush
454 454 QVERIFY(set1->brush() != QBrush());
455 455 QVERIFY(set2->brush() == QBrush());
456 456 QBrush brush(QColor(128,128,128,128));
457 457 set1->setBrush(brush);
458 458 QVERIFY(set1->brush() == brush);
459 459 QVERIFY(set2->brush() == QBrush());
460 460
461 461 // Test label brush
462 462 QVERIFY(set1->labelBrush() != QBrush());
463 463 QVERIFY(set2->labelBrush() == QBrush());
464 464 set1->setLabelBrush(brush);
465 465 QVERIFY(set1->labelBrush() == brush);
466 466 QVERIFY(set2->labelBrush() == QBrush());
467 467
468 468 // Test label font
469 469 // Note: QFont empty constructor creates font with application's default font, so the font may or may not be the
470 470 // same for the set added to the series (depending on the QChart's theme configuration)
471 471 QVERIFY(set1->labelFont() != QFont() || set1->labelFont() == QFont());
472 472 QVERIFY(set2->labelFont() == QFont());
473 473 QFont font;
474 474 font.setBold(true);
475 475 font.setItalic(true);
476 476 set1->setLabelFont(font);
477 477 QVERIFY(set1->labelFont() == font);
478 478 QVERIFY(set2->labelFont() == QFont());
479 479
480 480 // Test adding data to the sets
481 481 *set1 << 1 << 2 << 1 << 3;
482 482 *set2 << 2 << 1 << 3 << 1;
483 483 }
484 484
485 485 QTEST_MAIN(tst_QBarSet)
486 486
487 487 #include "tst_qbarset.moc"
488 488
@@ -1,10 +1,14
1 1 !include( ../config.pri ) {
2 2 error( "Couldn't find the config.pri file!" )
3 3 }
4 4
5 5 TEMPLATE = subdirs
6 6 SUBDIRS += \
7 7 auto \
8 8 chartwidgettest \
9 wavechart \
10 9 qmlchartproperties
10
11 !linux-arm*: {
12 SUBDIRS += \
13 wavechart
14 }
General Comments 0
You need to be logged in to leave comments. Login now