diff --git a/test/auto/auto.pro b/test/auto/auto.pro index 7b74366..1a3cd60 100644 --- a/test/auto/auto.pro +++ b/test/auto/auto.pro @@ -3,7 +3,7 @@ } TEMPLATE = subdirs -SUBDIRS += qchartview qchart qlineseries #qbarset +SUBDIRS += qchartview qchart qlineseries qbarset qbarseries test_private:{ SUBDIRS += chartdataset domain diff --git a/test/auto/qbarseries/qbarseries.pro b/test/auto/qbarseries/qbarseries.pro new file mode 100644 index 0000000..508e8a9 --- /dev/null +++ b/test/auto/qbarseries/qbarseries.pro @@ -0,0 +1,6 @@ +!include( ../auto.pri ) { + error( "Couldn't find the auto.pri file!" ) +} +SOURCES += tst_qbarseries.cpp + +!system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" diff --git a/test/auto/qbarseries/tst_qbarseries.cpp b/test/auto/qbarseries/tst_qbarseries.cpp new file mode 100644 index 0000000..da939ea --- /dev/null +++ b/test/auto/qbarseries/tst_qbarseries.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** 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 +#include +#include + +QTCOMMERCIALCHART_USE_NAMESPACE + +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(); + void appendBarSet_data(); + void appendBarSet(); + +private: + QBarSeries* m_barseries; +}; + +void tst_QBarSeries::initTestCase() +{ +} + +void tst_QBarSeries::cleanupTestCase() +{ +} + +void tst_QBarSeries::init() +{ + QBarCategories categories; + categories << "category0" << "category1" << "category2"; + m_barseries = new QBarSeries(categories); +} + +void tst_QBarSeries::cleanup() +{ + delete m_barseries; + m_barseries = 0; +} + +void tst_QBarSeries::qbarseries_data() +{ + QTest::addColumn ("categories"); + QBarCategories c; + c << "category0" << "category1" << "category2"; + QTest::newRow("categories") << c; +} + +void tst_QBarSeries::qbarseries() +{ + QFETCH(QBarCategories, categories); + QBarSeries *barseries = new QBarSeries(categories); + QVERIFY(barseries != 0); + QBarCategories verifyCategories = barseries->categories(); + + QVERIFY(verifyCategories.count() == categories.count()); + for (int i=0; itype() == QAbstractSeries::SeriesTypeBar); +} + +void tst_QBarSeries::appendBarSet_data() +{ +} + +void tst_QBarSeries::appendBarSet() +{ + QVERIFY(m_barseries->barsetCount() == 0); + + QBarSet *barset = new QBarSet("testset"); + m_barseries->appendBarSet(barset); + + QVERIFY(m_barseries->barsetCount() == 1); +} + +/* +void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set +void appendBarSets(QList sets); +void removeBarSets(QList sets); +int barsetCount() const; +int categoryCount() const; +QList barSets() const; +QBarCategories categories() const; + +void setLabelsVisible(bool visible = true); + +bool setModel(QAbstractItemModel *model); +void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); +void setModelMappingRange(int first, int count = -1); +*/ +QTEST_MAIN(tst_QBarSeries) + +#include "tst_qbarseries.moc" + diff --git a/test/auto/qbarset/tst_qbarset.cpp b/test/auto/qbarset/tst_qbarset.cpp index e0d991a..fadb433 100644 --- a/test/auto/qbarset/tst_qbarset.cpp +++ b/test/auto/qbarset/tst_qbarset.cpp @@ -56,9 +56,6 @@ private slots: void count(); void sum_data(); void sum(); - -private: - private: QBarSet* m_barset; }; @@ -96,24 +93,28 @@ void tst_QBarSet::qbarset() void tst_QBarSet::name_data() { - QTest::addColumn ("names"); - QTest::newRow("name0, name1") << QString("name0") << QString("name1"); + QTest::addColumn ("name"); + QTest::addColumn ("result"); + QTest::newRow("name0") << QString("name0") << QString("name0"); + QTest::newRow("name1") << QString("name1") << QString("name1"); } void tst_QBarSet::name() { - QFETCH(QString, names); + QFETCH(QString, name); + QFETCH(QString, result); - m_barset->setName(names); - QCOMPARE(m_barset->name(), names); + m_barset->setName(name); + QCOMPARE(m_barset->name(), result); } void tst_QBarSet::append_data() { -// QTest::addColumn >("values"); -// QTest::newRow("0.0 1.0 2.0 3.0 4.0") << (QList(0.0) << qreal(1.0) << qreal(2.0) << qreal(3.0) << qreal(4.0)); QTest::addColumn ("count"); - QTest::newRow("0 1 2 3 4") << 0 << 1 << 2 << 3 << 4; + QTest::newRow("0") << 0; + QTest::newRow("5") << 5; + QTest::newRow("100") << 100; + QTest::newRow("1000") << 1000; } void tst_QBarSet::append() @@ -165,7 +166,6 @@ void tst_QBarSet::appendOperator() void tst_QBarSet::insert_data() { - // TODO? } void tst_QBarSet::insert() @@ -176,25 +176,24 @@ void tst_QBarSet::insert() m_barset->insert(0, 1.0); // 1.0 QCOMPARE(m_barset->at(0), 1.0); QCOMPARE(m_barset->count(), 1); - QCOMPARE(m_barset->sum(), 1.0); + QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0)); m_barset->insert(0, 2.0); // 2.0 1.0 QCOMPARE(m_barset->at(0), 2.0); QCOMPARE(m_barset->at(1), 1.0); QCOMPARE(m_barset->count(), 2); - QCOMPARE(m_barset->sum(), 3.0); + QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0)); m_barset->insert(1, 3.0); // 2.0 3.0 1.0 QCOMPARE(m_barset->at(1), 3.0); QCOMPARE(m_barset->at(0), 2.0); QCOMPARE(m_barset->at(2), 1.0); QCOMPARE(m_barset->count(), 3); - QCOMPARE(m_barset->sum(), 6.0); + QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0)); } void tst_QBarSet::remove_data() { - // TODO? } void tst_QBarSet::remove() @@ -329,16 +328,15 @@ void tst_QBarSet::sum() QVERIFY(qFuzzyIsNull(m_barset->sum())); m_barset->append(1.0); - QCOMPARE(m_barset->sum(),1.0); + QVERIFY(qFuzzyCompare(m_barset->sum(),1.0)); m_barset->append(2.0); - QCOMPARE(m_barset->sum(),3.0); + QVERIFY(qFuzzyCompare(m_barset->sum(),3.0)); m_barset->append(3.0); - QCOMPARE(m_barset->sum(),6.0); + QVERIFY(qFuzzyCompare(m_barset->sum(),6.0)); m_barset->append(4.0); - QCOMPARE(m_barset->sum(),10.0); + QVERIFY(qFuzzyCompare(m_barset->sum(),10.0)); } - QTEST_MAIN(tst_QBarSet) #include "tst_qbarset.moc"