tst_qbarseries.cpp
571 lines
| 16.5 KiB
| text/x-c
|
CppLexer
|
r1100 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
#include <QtTest/QtTest> | ||||
#include <qbarseries.h> | ||||
|
r1106 | #include <qbarset.h> | ||
|
r1145 | #include <qchartview.h> | ||
#include <qchart.h> | ||||
|
r1466 | #include "tst_definitions.h" | ||
|
r1100 | |||
QTCOMMERCIALCHART_USE_NAMESPACE | ||||
|
r1145 | Q_DECLARE_METATYPE(QBarSet*) | ||
|
r1100 | class tst_QBarSeries : public QObject | ||
{ | ||||
Q_OBJECT | ||||
public slots: | ||||
void initTestCase(); | ||||
void cleanupTestCase(); | ||||
void init(); | ||||
void cleanup(); | ||||
private slots: | ||||
void qbarseries_data(); | ||||
void qbarseries(); | ||||
void type_data(); | ||||
void type(); | ||||
|
r1194 | void append_data(); | ||
void append(); | ||||
void remove_data(); | ||||
void remove(); | ||||
void appendList_data(); | ||||
void appendList(); | ||||
|
r1463 | void count_data(); | ||
void count(); | ||||
|
r1101 | void barSets_data(); | ||
void barSets(); | ||||
void setLabelsVisible_data(); | ||||
void setLabelsVisible(); | ||||
|
r1146 | void mouseclicked_data(); | ||
void mouseclicked(); | ||||
void mousehovered_data(); | ||||
void mousehovered(); | ||||
|
r1375 | void clearWithAnimations(); | ||
|
r1100 | |||
private: | ||||
QBarSeries* m_barseries; | ||||
|
r1101 | QBarSeries* m_barseries_with_sets; | ||
QList<QBarSet*> m_testSets; | ||||
|
r1100 | }; | ||
void tst_QBarSeries::initTestCase() | ||||
{ | ||||
|
r1145 | qRegisterMetaType<QBarSet*>("QBarSet*"); | ||
|
r1100 | } | ||
void tst_QBarSeries::cleanupTestCase() | ||||
{ | ||||
} | ||||
void tst_QBarSeries::init() | ||||
{ | ||||
|
r1112 | m_barseries = new QBarSeries(); | ||
m_barseries_with_sets = new QBarSeries(); | ||||
|
r1101 | |||
for (int i=0; i<5; i++) { | ||||
m_testSets.append(new QBarSet("testset")); | ||||
|
r1194 | m_barseries_with_sets->append(m_testSets.at(i)); | ||
|
r1101 | } | ||
|
r1100 | } | ||
void tst_QBarSeries::cleanup() | ||||
{ | ||||
|
r1101 | foreach(QBarSet* s, m_testSets) { | ||
|
r1194 | m_barseries_with_sets->remove(s); | ||
|
r1101 | delete s; | ||
} | ||||
m_testSets.clear(); | ||||
|
r1100 | delete m_barseries; | ||
m_barseries = 0; | ||||
|
r1101 | delete m_barseries_with_sets; | ||
m_barseries_with_sets = 0; | ||||
|
r1100 | } | ||
void tst_QBarSeries::qbarseries_data() | ||||
{ | ||||
} | ||||
void tst_QBarSeries::qbarseries() | ||||
{ | ||||
|
r1112 | QBarSeries *barseries = new QBarSeries(); | ||
|
r1100 | QVERIFY(barseries != 0); | ||
} | ||||
void tst_QBarSeries::type_data() | ||||
{ | ||||
} | ||||
void tst_QBarSeries::type() | ||||
{ | ||||
QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar); | ||||
} | ||||
|
r1194 | void tst_QBarSeries::append_data() | ||
|
r1100 | { | ||
} | ||||
|
r1194 | void tst_QBarSeries::append() | ||
|
r1100 | { | ||
|
r1463 | QVERIFY(m_barseries->count() == 0); | ||
|
r1100 | |||
|
r1122 | bool ret = false; | ||
// Try adding barset | ||||
|
r1100 | QBarSet *barset = new QBarSet("testset"); | ||
|
r1194 | ret = m_barseries->append(barset); | ||
|
r1100 | |||
|
r1122 | QVERIFY(ret == true); | ||
|
r1463 | QVERIFY(m_barseries->count() == 1); | ||
|
r1101 | |||
|
r1122 | // Try adding another set | ||
|
r1101 | QBarSet *barset2 = new QBarSet("testset2"); | ||
|
r1194 | ret = m_barseries->append(barset2); | ||
|
r1122 | |||
QVERIFY(ret == true); | ||||
|
r1463 | QVERIFY(m_barseries->count() == 2); | ||
|
r1101 | |||
|
r1122 | // Try adding same set again | ||
|
r1194 | ret = m_barseries->append(barset2); | ||
|
r1122 | QVERIFY(ret == false); | ||
|
r1463 | QVERIFY(m_barseries->count() == 2); | ||
|
r1122 | |||
// Try adding null set | ||||
|
r1194 | ret = m_barseries->append(0); | ||
|
r1122 | QVERIFY(ret == false); | ||
|
r1463 | QVERIFY(m_barseries->count() == 2); | ||
|
r1122 | |||
|
r1101 | } | ||
|
r1194 | void tst_QBarSeries::remove_data() | ||
|
r1101 | { | ||
} | ||||
|
r1194 | void tst_QBarSeries::remove() | ||
|
r1101 | { | ||
int count = m_testSets.count(); | ||||
|
r1463 | QVERIFY(m_barseries_with_sets->count() == count); | ||
|
r1101 | |||
|
r1122 | // Try to remove null pointer (should not remove, should not crash) | ||
bool ret = false; | ||||
|
r1194 | ret = m_barseries_with_sets->remove(0); | ||
|
r1122 | QVERIFY(ret == false); | ||
|
r1463 | QVERIFY(m_barseries_with_sets->count() == count); | ||
|
r1122 | |||
// Try to remove invalid pointer (should not remove, should not crash) | ||||
|
r1194 | ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) ); | ||
|
r1122 | QVERIFY(ret == false); | ||
|
r1463 | QVERIFY(m_barseries_with_sets->count() == count); | ||
|
r1122 | |||
|
r1101 | // remove some sets | ||
|
r1194 | ret = m_barseries_with_sets->remove(m_testSets.at(2)); | ||
|
r1122 | QVERIFY(ret == true); | ||
|
r1194 | ret = m_barseries_with_sets->remove(m_testSets.at(3)); | ||
|
r1122 | QVERIFY(ret == true); | ||
|
r1194 | ret = m_barseries_with_sets->remove(m_testSets.at(4)); | ||
|
r1122 | QVERIFY(ret == true); | ||
|
r1101 | |||
|
r1463 | QVERIFY(m_barseries_with_sets->count() == 2); | ||
|
r1101 | |||
QList<QBarSet*> verifysets = m_barseries_with_sets->barSets(); | ||||
QVERIFY(verifysets.at(0) == m_testSets.at(0)); | ||||
QVERIFY(verifysets.at(1) == m_testSets.at(1)); | ||||
|
r1122 | // Try removing all sets again (should be ok, even if some sets have already been removed) | ||
ret = false; | ||||
|
r1101 | for (int i=0; i<count; i++) { | ||
|
r1194 | ret |= m_barseries_with_sets->remove(m_testSets.at(i)); | ||
|
r1101 | } | ||
|
r1122 | QVERIFY(ret == true); | ||
|
r1463 | QVERIFY(m_barseries_with_sets->count() == 0); | ||
|
r1101 | } | ||
|
r1194 | void tst_QBarSeries::appendList_data() | ||
|
r1101 | { | ||
} | ||||
|
r1194 | void tst_QBarSeries::appendList() | ||
|
r1101 | { | ||
int count = 5; | ||||
|
r1463 | QVERIFY(m_barseries->count() == 0); | ||
|
r1101 | |||
QList<QBarSet*> sets; | ||||
for (int i=0; i<count; i++) { | ||||
sets.append(new QBarSet("testset")); | ||||
} | ||||
|
r1122 | // Append new sets (should succeed, count should match the count of sets) | ||
bool ret = false; | ||||
|
r1194 | ret = m_barseries->append(sets); | ||
|
r1122 | QVERIFY(ret == true); | ||
|
r1463 | QVERIFY(m_barseries->count() == count); | ||
|
r1122 | |||
// Append same sets again (should fail, count should remain same) | ||||
|
r1194 | ret = m_barseries->append(sets); | ||
|
r1122 | QVERIFY(ret == false); | ||
|
r1463 | QVERIFY(m_barseries->count() == count); | ||
|
r1122 | |||
// Try append empty list (should succeed, but count should remain same) | ||||
QList<QBarSet*> invalidList; | ||||
|
r1194 | ret = m_barseries->append(invalidList); | ||
|
r1122 | QVERIFY(ret == true); | ||
|
r1463 | QVERIFY(m_barseries->count() == count); | ||
|
r1122 | |||
// Try append list with one new and one existing set (should fail, count remains same) | ||||
invalidList.append(new QBarSet("ok set")); | ||||
invalidList.append(sets.at(0)); | ||||
|
r1194 | ret = m_barseries->append(invalidList); | ||
|
r1122 | QVERIFY(ret == false); | ||
|
r1463 | QVERIFY(m_barseries->count() == count); | ||
|
r1122 | |||
// Try append list with null pointers (should fail, count remains same) | ||||
QList<QBarSet*> invalidList2; | ||||
invalidList2.append(0); | ||||
invalidList2.append(0); | ||||
invalidList2.append(0); | ||||
|
r1194 | ret = m_barseries->append(invalidList2); | ||
|
r1122 | QVERIFY(ret == false); | ||
|
r1463 | QVERIFY(m_barseries->count() == count); | ||
|
r1101 | } | ||
|
r1463 | void tst_QBarSeries::count_data() | ||
|
r1101 | { | ||
} | ||||
|
r1463 | void tst_QBarSeries::count() | ||
|
r1101 | { | ||
|
r1463 | QVERIFY(m_barseries->count() == 0); | ||
QVERIFY(m_barseries_with_sets->count() == m_testSets.count()); | ||||
|
r1101 | } | ||
void tst_QBarSeries::barSets_data() | ||||
{ | ||||
} | ||||
void tst_QBarSeries::barSets() | ||||
{ | ||||
QVERIFY(m_barseries->barSets().count() == 0); | ||||
QList<QBarSet*> sets = m_barseries_with_sets->barSets(); | ||||
QVERIFY(sets.count() == m_testSets.count()); | ||||
for (int i=0; i<m_testSets.count(); i++) { | ||||
QVERIFY(sets.at(i) == m_testSets.at(i)); | ||||
} | ||||
} | ||||
void tst_QBarSeries::setLabelsVisible_data() | ||||
{ | ||||
} | ||||
void tst_QBarSeries::setLabelsVisible() | ||||
{ | ||||
|
r1123 | // labels should be invisible by default | ||
|
r1246 | QVERIFY(m_barseries->isLabelsVisible() == false); | ||
QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); | ||||
|
r1101 | |||
|
r1123 | // turn labels to visible | ||
|
r1101 | m_barseries_with_sets->setLabelsVisible(true); | ||
|
r1246 | // TODO: test the signal | ||
QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); | ||||
|
r1101 | |||
|
r1123 | // turn labels to invisible | ||
|
r1101 | m_barseries_with_sets->setLabelsVisible(false); | ||
|
r1246 | // TODO: test the signal | ||
QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); | ||||
|
r1123 | |||
// without parameter, should turn labels to visible | ||||
m_barseries_with_sets->setLabelsVisible(); | ||||
|
r1246 | // TODO: test the signal | ||
QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); | ||||
|
r1100 | } | ||
|
r1146 | void tst_QBarSeries::mouseclicked_data() | ||
|
r1145 | { | ||
} | ||||
|
r1146 | void tst_QBarSeries::mouseclicked() | ||
|
r1145 | { | ||
QBarSeries* series = new QBarSeries(); | ||||
QBarSet* set1 = new QBarSet(QString("set 1")); | ||||
|
r1177 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); | ||
|
r1194 | series->append(set1); | ||
|
r1145 | |||
QBarSet* set2 = new QBarSet(QString("set 2")); | ||||
|
r1235 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); | ||
|
r1194 | series->append(set2); | ||
|
r1145 | |||
|
r1321 | QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,int))); | ||
|
r1490 | QSignalSpy setSpy1(set1, SIGNAL(clicked(int))); | ||
QSignalSpy setSpy2(set2, SIGNAL(clicked(int))); | ||||
|
r1145 | |||
QChartView view(new QChart()); | ||||
view.resize(400,300); | ||||
view.chart()->addSeries(series); | ||||
view.show(); | ||||
QTest::qWaitForWindowShown(&view); | ||||
//==================================================================================== | ||||
|
r1386 | // barset 1, bar 0 | ||
|
r1425 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(102,142)); | ||
|
r1145 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | ||
QCOMPARE(seriesSpy.count(), 1); | ||||
|
r1490 | QCOMPARE(setSpy1.count(), 1); | ||
QCOMPARE(setSpy2.count(), 0); | ||||
|
r1145 | |||
QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | ||||
|
r1321 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int); | ||
QVERIFY(seriesSpyArg.at(1).toInt() == 0); | ||||
|
r1145 | |||
|
r1490 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); | ||
QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | ||||
QVERIFY(setSpyArg.at(0).toInt() == 0); | ||||
|
r1145 | //==================================================================================== | ||
|
r1386 | // barset 1, bar 1 | ||
|
r1425 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(186,142)); | ||
|
r1145 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | ||
QCOMPARE(seriesSpy.count(), 1); | ||||
|
r1490 | QCOMPARE(setSpy1.count(), 1); | ||
QCOMPARE(setSpy2.count(), 0); | ||||
|
r1145 | |||
seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | ||||
|
r1321 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int); | ||
QVERIFY(seriesSpyArg.at(1).toInt() == 1); | ||||
|
r1145 | |||
|
r1490 | setSpyArg = setSpy1.takeFirst(); | ||
QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | ||||
QVERIFY(setSpyArg.at(0).toInt() == 1); | ||||
|
r1145 | //==================================================================================== | ||
|
r1386 | // barset 1, bar 2 | ||
|
r1425 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(271,142)); | ||
|
r1145 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | ||
QCOMPARE(seriesSpy.count(), 1); | ||||
|
r1490 | QCOMPARE(setSpy1.count(), 1); | ||
QCOMPARE(setSpy2.count(), 0); | ||||
|
r1145 | |||
seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | ||||
|
r1321 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int); | ||
QVERIFY(seriesSpyArg.at(1).toInt() == 2); | ||||
|
r1145 | |||
|
r1490 | setSpyArg = setSpy1.takeFirst(); | ||
QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | ||||
QVERIFY(setSpyArg.at(0).toInt() == 2); | ||||
|
r1145 | //==================================================================================== | ||
|
r1386 | // barset 2, bar 0 | ||
|
r1425 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(127,142)); | ||
|
r1145 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | ||
QCOMPARE(seriesSpy.count(), 1); | ||||
|
r1490 | QCOMPARE(setSpy1.count(), 0); | ||
QCOMPARE(setSpy2.count(), 1); | ||||
|
r1145 | |||
seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | ||||
|
r1321 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int); | ||
QVERIFY(seriesSpyArg.at(1).toInt() == 0); | ||||
|
r1145 | |||
|
r1490 | setSpyArg = setSpy2.takeFirst(); | ||
QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | ||||
QVERIFY(setSpyArg.at(0).toInt() == 0); | ||||
|
r1145 | //==================================================================================== | ||
|
r1386 | // barset 2, bar 1 | ||
|
r1425 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(212,142)); | ||
|
r1145 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | ||
QCOMPARE(seriesSpy.count(), 1); | ||||
|
r1490 | QCOMPARE(setSpy1.count(), 0); | ||
QCOMPARE(setSpy2.count(), 1); | ||||
|
r1145 | |||
seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | ||||
|
r1321 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int); | ||
QVERIFY(seriesSpyArg.at(1).toInt() == 1); | ||||
|
r1145 | |||
|
r1490 | setSpyArg = setSpy2.takeFirst(); | ||
QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | ||||
QVERIFY(setSpyArg.at(0).toInt() == 1); | ||||
|
r1145 | //==================================================================================== | ||
|
r1386 | // barset 2, bar 2 | ||
|
r1425 | QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(296,142)); | ||
|
r1145 | QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); | ||
QCOMPARE(seriesSpy.count(), 1); | ||||
|
r1490 | QCOMPARE(setSpy1.count(), 0); | ||
QCOMPARE(setSpy2.count(), 1); | ||||
|
r1145 | |||
seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | ||||
|
r1321 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Int); | ||
QVERIFY(seriesSpyArg.at(1).toInt() == 2); | ||||
|
r1490 | |||
setSpyArg = setSpy2.takeFirst(); | ||||
QVERIFY(setSpyArg.at(0).type() == QVariant::Int); | ||||
QVERIFY(setSpyArg.at(0).toInt() == 2); | ||||
|
r1145 | } | ||
|
r1146 | void tst_QBarSeries::mousehovered_data() | ||
{ | ||||
} | ||||
void tst_QBarSeries::mousehovered() | ||||
{ | ||||
QBarSeries* series = new QBarSeries(); | ||||
QBarSet* set1 = new QBarSet(QString("set 1")); | ||||
|
r1425 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); | ||
|
r1194 | series->append(set1); | ||
|
r1146 | |||
QBarSet* set2 = new QBarSet(QString("set 2")); | ||||
|
r1235 | *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); | ||
|
r1194 | series->append(set2); | ||
|
r1146 | |||
QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); | ||||
|
r1490 | QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); | ||
QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); | ||||
|
r1146 | |||
QChartView view(new QChart()); | ||||
view.resize(400,300); | ||||
view.chart()->addSeries(series); | ||||
view.show(); | ||||
QTest::qWaitForWindowShown(&view); | ||||
|
r1287 | //this is hack since view does not get events otherwise | ||
view.setMouseTracking(true); | ||||
|
r1146 | //======================================================================= | ||
// move mouse to left border | ||||
|
r1287 | QTest::mouseMove(view.viewport(), QPoint(0, 142)); | ||
|
r1466 | QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); | ||
TRY_COMPARE(seriesSpy.count(), 0); | ||||
|
r1490 | TRY_COMPARE(setSpy1.count(), 0); | ||
TRY_COMPARE(setSpy2.count(), 0); | ||||
|
r1146 | |||
//======================================================================= | ||||
// move mouse on top of set1 | ||||
|
r1425 | QTest::mouseMove(view.viewport(), QPoint(102,142)); | ||
|
r1466 | TRY_COMPARE(seriesSpy.count(), 1); | ||
|
r1490 | TRY_COMPARE(setSpy1.count(), 1); | ||
TRY_COMPARE(setSpy2.count(), 0); | ||||
|
r1146 | |||
QList<QVariant> seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | ||||
|
r1287 | QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | ||
QVERIFY(seriesSpyArg.at(1).toBool() == true); | ||||
|
r1146 | |||
|
r1490 | QList<QVariant> setSpyArg = setSpy1.takeFirst(); | ||
QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); | ||||
QVERIFY(setSpyArg.at(0).toBool() == true); | ||||
|
r1146 | //======================================================================= | ||
// move mouse from top of set1 to top of set2 | ||||
|
r1425 | QTest::mouseMove(view.viewport(), QPoint(127,142)); | ||
|
r1466 | TRY_COMPARE(seriesSpy.count(), 2); | ||
|
r1490 | TRY_COMPARE(setSpy1.count(), 1); | ||
TRY_COMPARE(setSpy2.count(), 1); | ||||
|
r1146 | |||
// should leave set1 | ||||
seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set1); | ||||
QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | ||||
QVERIFY(seriesSpyArg.at(1).toBool() == false); | ||||
|
r1490 | setSpyArg = setSpy1.takeFirst(); | ||
QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); | ||||
QVERIFY(setSpyArg.at(0).toBool() == false); | ||||
|
r1146 | // should enter set2 | ||
seriesSpyArg = seriesSpy.takeFirst(); | ||||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | ||||
QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | ||||
QVERIFY(seriesSpyArg.at(1).toBool() == true); | ||||
|
r1490 | setSpyArg = setSpy2.takeFirst(); | ||
QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); | ||||
QVERIFY(setSpyArg.at(0).toBool() == true); | ||||
|
r1146 | //======================================================================= | ||
// move mouse from top of set2 to background | ||||
|
r1425 | QTest::mouseMove(view.viewport(), QPoint(127,0)); | ||
|
r1466 | TRY_COMPARE(seriesSpy.count(), 1); | ||
|
r1490 | TRY_COMPARE(setSpy1.count(), 0); | ||
TRY_COMPARE(setSpy2.count(), 1); | ||||
|
r1146 | |||
|
r1287 | // should leave set2 | ||
|
r1146 | seriesSpyArg = seriesSpy.takeFirst(); | ||
QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(0)), set2); | ||||
QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); | ||||
QVERIFY(seriesSpyArg.at(1).toBool() == false); | ||||
|
r1490 | |||
setSpyArg = setSpy2.takeFirst(); | ||||
QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); | ||||
QVERIFY(setSpyArg.at(0).toBool() == false); | ||||
|
r1146 | } | ||
|
r1375 | void tst_QBarSeries::clearWithAnimations() | ||
{ | ||||
QBarSeries* series = new QBarSeries(); | ||||
QBarSet* set1 = new QBarSet(QString("set 1")); | ||||
|
r1425 | *set1 << QPointF(0,10) << QPointF(1,10) << QPointF(2,10); | ||
|
r1375 | series->append(set1); | ||
QBarSet* set2 = new QBarSet(QString("set 2")); | ||||
*set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); | ||||
series->append(set2); | ||||
QChartView view(new QChart()); | ||||
view.resize(400,300); | ||||
view.chart()->setAnimationOptions(QChart::SeriesAnimations); | ||||
view.chart()->addSeries(series); | ||||
view.show(); | ||||
series->clear(); | ||||
} | ||||
|
r1100 | QTEST_MAIN(tst_QBarSeries) | ||
#include "tst_qbarseries.moc" | ||||