diff --git a/test/auto/auto.pro b/test/auto/auto.pro index 8121e34..63a6c58 100644 --- a/test/auto/auto.pro +++ b/test/auto/auto.pro @@ -3,7 +3,7 @@ } TEMPLATE = subdirs -SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qpieslice qpieseries +SUBDIRS += qchartview qchart qlineseries qbarset qbarseries qstackedbarseries qpercentbarseries qpieslice qpieseries test_private:{ SUBDIRS += chartdataset domain diff --git a/test/auto/qbarseries/tst_qbarseries.cpp b/test/auto/qbarseries/tst_qbarseries.cpp index be8d26c..52c6be6 100644 --- a/test/auto/qbarseries/tst_qbarseries.cpp +++ b/test/auto/qbarseries/tst_qbarseries.cpp @@ -39,6 +39,8 @@ private slots: void qbarseries(); void type_data(); void type(); + void setCategories_data(); + void setCategories(); void appendBarSet_data(); void appendBarSet(); void removeBarSet_data(); @@ -136,6 +138,27 @@ void tst_QBarSeries::type() QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar); } +void tst_QBarSeries::setCategories_data() +{ + QTest::addColumn ("categories"); + QBarCategories categories; + categories << "c1" << "c2" << "c3" << "c4" << "c5" << "c6"; + QTest::newRow("cat") << categories; +} + +void tst_QBarSeries::setCategories() +{ + QVERIFY(m_barseries->categories().count() == m_categories.count()); + + QFETCH(QBarCategories, categories); + m_barseries->setCategories(categories); + + QVERIFY(m_barseries->categories().count() == categories.count()); + for (int i=0; icategories().at(i).compare(categories.at(i)) == 0); + } +} + void tst_QBarSeries::appendBarSet_data() { } @@ -308,9 +331,6 @@ void tst_QBarSeries::setLabelsVisible() } /* - -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); diff --git a/test/auto/qpercentbarseries/qpercentbarseries.pro b/test/auto/qpercentbarseries/qpercentbarseries.pro new file mode 100644 index 0000000..64f9b4b --- /dev/null +++ b/test/auto/qpercentbarseries/qpercentbarseries.pro @@ -0,0 +1,6 @@ +!include( ../auto.pri ) { + error( "Couldn't find the auto.pri file!" ) +} +SOURCES += tst_qpercentbarseries.cpp + +!system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" diff --git a/test/auto/qpercentbarseries/tst_qpercentbarseries.cpp b/test/auto/qpercentbarseries/tst_qpercentbarseries.cpp new file mode 100644 index 0000000..a87835e --- /dev/null +++ b/test/auto/qpercentbarseries/tst_qpercentbarseries.cpp @@ -0,0 +1,341 @@ +/**************************************************************************** +** +** 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_QPercentBarSeries : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void qpercentbarseries_data(); + void qpercentbarseries(); + void type_data(); + void type(); + void setCategories_data(); + void setCategories(); + void appendBarSet_data(); + void appendBarSet(); + void removeBarSet_data(); + void removeBarSet(); + void appendBarSets_data(); + void appendBarSets(); + void removeBarSets_data(); + void removeBarSets(); + void barsetCount_data(); + void barsetCount(); + void categoryCount_data(); + void categoryCount(); + void barSets_data(); + void barSets(); + void categories_data(); + void categories(); + void setLabelsVisible_data(); + void setLabelsVisible(); + +private: + QPercentBarSeries* m_barseries; + QPercentBarSeries* m_barseries_with_sets; + + QList m_testSets; + + QBarCategories m_categories; +}; + +void tst_QPercentBarSeries::initTestCase() +{ +} + +void tst_QPercentBarSeries::cleanupTestCase() +{ +} + +void tst_QPercentBarSeries::init() +{ + m_categories << "category0" << "category1" << "category2"; + m_barseries = new QPercentBarSeries(); + m_barseries->setCategories(m_categories); + m_barseries_with_sets = new QPercentBarSeries(); + m_barseries_with_sets->setCategories(m_categories); + + for (int i=0; i<5; i++) { + m_testSets.append(new QBarSet("testset")); + m_barseries_with_sets->appendBarSet(m_testSets.at(i)); + } +} + +void tst_QPercentBarSeries::cleanup() +{ + foreach(QBarSet* s, m_testSets) { + m_barseries_with_sets->removeBarSet(s); + delete s; + } + m_testSets.clear(); + + delete m_barseries; + m_barseries = 0; + delete m_barseries_with_sets; + m_barseries_with_sets = 0; + m_categories.clear(); +} + +void tst_QPercentBarSeries::qpercentbarseries_data() +{ + QTest::addColumn ("categories"); + QBarCategories c; + c << "category0" << "category1" << "category2"; + QTest::newRow("categories") << c; +} + +void tst_QPercentBarSeries::qpercentbarseries() +{ + QFETCH(QBarCategories, categories); + QPercentBarSeries *barseries = new QPercentBarSeries(); + QVERIFY(barseries != 0); + barseries->setCategories(categories); + QBarCategories verifyCategories = barseries->categories(); + + QVERIFY(verifyCategories.count() == categories.count()); + for (int i=0; itype() == QAbstractSeries::SeriesTypePercentBar); +} + +void tst_QPercentBarSeries::setCategories_data() +{ + QTest::addColumn ("categories"); + QBarCategories categories; + categories << "c1" << "c2" << "c3" << "c4" << "c5" << "c6"; + QTest::newRow("cat") << categories; +} + +void tst_QPercentBarSeries::setCategories() +{ + QVERIFY(m_barseries->categories().count() == m_categories.count()); + + QFETCH(QBarCategories, categories); + m_barseries->setCategories(categories); + + QVERIFY(m_barseries->categories().count() == categories.count()); + for (int i=0; icategories().at(i).compare(categories.at(i)) == 0); + } +} + +void tst_QPercentBarSeries::appendBarSet_data() +{ +} + +void tst_QPercentBarSeries::appendBarSet() +{ + QVERIFY(m_barseries->barsetCount() == 0); + + QBarSet *barset = new QBarSet("testset"); + m_barseries->appendBarSet(barset); + + QVERIFY(m_barseries->barsetCount() == 1); + + QBarSet *barset2 = new QBarSet("testset2"); + m_barseries->appendBarSet(barset2); + + QVERIFY(m_barseries->barsetCount() == 2); +} + +void tst_QPercentBarSeries::removeBarSet_data() +{ +} + +void tst_QPercentBarSeries::removeBarSet() +{ + int count = m_testSets.count(); + QVERIFY(m_barseries_with_sets->barsetCount() == count); + + // remove some sets + m_barseries_with_sets->removeBarSet(m_testSets.at(2)); + m_barseries_with_sets->removeBarSet(m_testSets.at(3)); + m_barseries_with_sets->removeBarSet(m_testSets.at(4)); + + QVERIFY(m_barseries_with_sets->barsetCount() == 2); + + QList verifysets = m_barseries_with_sets->barSets(); + + QVERIFY(verifysets.at(0) == m_testSets.at(0)); + QVERIFY(verifysets.at(1) == m_testSets.at(1)); + + // Try removing all sets again + for (int i=0; iremoveBarSet(m_testSets.at(i)); + } + + QVERIFY(m_barseries_with_sets->barsetCount() == 0); +} + +void tst_QPercentBarSeries::appendBarSets_data() +{ + +} + +void tst_QPercentBarSeries::appendBarSets() +{ + int count = 5; + QVERIFY(m_barseries->barsetCount() == 0); + + QList sets; + for (int i=0; iappendBarSets(sets); + QVERIFY(m_barseries->barsetCount() == count); +} + +void tst_QPercentBarSeries::removeBarSets_data() +{ + +} + +void tst_QPercentBarSeries::removeBarSets() +{ + int count = m_testSets.count(); + QVERIFY(m_barseries_with_sets->barsetCount() == count); + + // Try removing empty list of sets + QList empty; + m_barseries_with_sets->removeBarSets(empty); + QVERIFY(m_barseries_with_sets->barsetCount() == count); + + // remove all sets + m_barseries_with_sets->removeBarSets(m_testSets); + QVERIFY(m_barseries_with_sets->barsetCount() == 0); + + // Try removing empty list again + m_barseries_with_sets->removeBarSets(empty); + QVERIFY(m_barseries_with_sets->barsetCount() == 0); + + // remove all sets again + m_barseries_with_sets->removeBarSets(m_testSets); + QVERIFY(m_barseries_with_sets->barsetCount() == 0); +} + +void tst_QPercentBarSeries::barsetCount_data() +{ + +} + +void tst_QPercentBarSeries::barsetCount() +{ + QVERIFY(m_barseries->barsetCount() == 0); + QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count()); +} + +void tst_QPercentBarSeries::categoryCount_data() +{ + +} + +void tst_QPercentBarSeries::categoryCount() +{ + QVERIFY(m_barseries->categoryCount() == m_categories.count()); + QVERIFY(m_barseries_with_sets->categoryCount() == m_categories.count()); +} + +void tst_QPercentBarSeries::barSets_data() +{ + +} + +void tst_QPercentBarSeries::barSets() +{ + QVERIFY(m_barseries->barSets().count() == 0); + + QList sets = m_barseries_with_sets->barSets(); + QVERIFY(sets.count() == m_testSets.count()); + + for (int i=0; icategories(); + + QVERIFY(categories.count() == m_categories.count()); + for (int i=0; ilabelsVisible() == false); + } + + m_barseries_with_sets->setLabelsVisible(true); + foreach (QBarSet* s, m_testSets) { + QVERIFY(s->labelsVisible() == true); + } + + m_barseries_with_sets->setLabelsVisible(false); + foreach (QBarSet* s, m_testSets) { + QVERIFY(s->labelsVisible() == false); + } +} + +/* +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_QPercentBarSeries) + +#include "tst_qpercentbarseries.moc" + diff --git a/test/auto/qstackedbarseries/qstackedbarseries.pro b/test/auto/qstackedbarseries/qstackedbarseries.pro new file mode 100644 index 0000000..a3d9c51 --- /dev/null +++ b/test/auto/qstackedbarseries/qstackedbarseries.pro @@ -0,0 +1,6 @@ +!include( ../auto.pri ) { + error( "Couldn't find the auto.pri file!" ) +} +SOURCES += tst_qstackedbarseries.cpp + +!system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" diff --git a/test/auto/qstackedbarseries/tst_qstackedbarseries.cpp b/test/auto/qstackedbarseries/tst_qstackedbarseries.cpp new file mode 100644 index 0000000..a535a21 --- /dev/null +++ b/test/auto/qstackedbarseries/tst_qstackedbarseries.cpp @@ -0,0 +1,341 @@ +/**************************************************************************** +** +** 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_QStackedBarSeries : public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void qstackedbarseries_data(); + void qstackedbarseries(); + void type_data(); + void type(); + void setCategories_data(); + void setCategories(); + void appendBarSet_data(); + void appendBarSet(); + void removeBarSet_data(); + void removeBarSet(); + void appendBarSets_data(); + void appendBarSets(); + void removeBarSets_data(); + void removeBarSets(); + void barsetCount_data(); + void barsetCount(); + void categoryCount_data(); + void categoryCount(); + void barSets_data(); + void barSets(); + void categories_data(); + void categories(); + void setLabelsVisible_data(); + void setLabelsVisible(); + +private: + QStackedBarSeries* m_barseries; + QStackedBarSeries* m_barseries_with_sets; + + QList m_testSets; + + QBarCategories m_categories; +}; + +void tst_QStackedBarSeries::initTestCase() +{ +} + +void tst_QStackedBarSeries::cleanupTestCase() +{ +} + +void tst_QStackedBarSeries::init() +{ + m_categories << "category0" << "category1" << "category2"; + m_barseries = new QStackedBarSeries(); + m_barseries->setCategories(m_categories); + m_barseries_with_sets = new QStackedBarSeries(); + m_barseries_with_sets->setCategories(m_categories); + + for (int i=0; i<5; i++) { + m_testSets.append(new QBarSet("testset")); + m_barseries_with_sets->appendBarSet(m_testSets.at(i)); + } +} + +void tst_QStackedBarSeries::cleanup() +{ + foreach(QBarSet* s, m_testSets) { + m_barseries_with_sets->removeBarSet(s); + delete s; + } + m_testSets.clear(); + + delete m_barseries; + m_barseries = 0; + delete m_barseries_with_sets; + m_barseries_with_sets = 0; + m_categories.clear(); +} + +void tst_QStackedBarSeries::qstackedbarseries_data() +{ + QTest::addColumn ("categories"); + QBarCategories c; + c << "category0" << "category1" << "category2"; + QTest::newRow("categories") << c; +} + +void tst_QStackedBarSeries::qstackedbarseries() +{ + QFETCH(QBarCategories, categories); + QStackedBarSeries *barseries = new QStackedBarSeries(); + QVERIFY(barseries != 0); + barseries->setCategories(categories); + QBarCategories verifyCategories = barseries->categories(); + + QVERIFY(verifyCategories.count() == categories.count()); + for (int i=0; itype() == QAbstractSeries::SeriesTypeStackedBar); +} + +void tst_QStackedBarSeries::setCategories_data() +{ + QTest::addColumn ("categories"); + QBarCategories categories; + categories << "c1" << "c2" << "c3" << "c4" << "c5" << "c6"; + QTest::newRow("cat") << categories; +} + +void tst_QStackedBarSeries::setCategories() +{ + QVERIFY(m_barseries->categories().count() == m_categories.count()); + + QFETCH(QBarCategories, categories); + m_barseries->setCategories(categories); + + QVERIFY(m_barseries->categories().count() == categories.count()); + for (int i=0; icategories().at(i).compare(categories.at(i)) == 0); + } +} + +void tst_QStackedBarSeries::appendBarSet_data() +{ +} + +void tst_QStackedBarSeries::appendBarSet() +{ + QVERIFY(m_barseries->barsetCount() == 0); + + QBarSet *barset = new QBarSet("testset"); + m_barseries->appendBarSet(barset); + + QVERIFY(m_barseries->barsetCount() == 1); + + QBarSet *barset2 = new QBarSet("testset2"); + m_barseries->appendBarSet(barset2); + + QVERIFY(m_barseries->barsetCount() == 2); +} + +void tst_QStackedBarSeries::removeBarSet_data() +{ +} + +void tst_QStackedBarSeries::removeBarSet() +{ + int count = m_testSets.count(); + QVERIFY(m_barseries_with_sets->barsetCount() == count); + + // remove some sets + m_barseries_with_sets->removeBarSet(m_testSets.at(2)); + m_barseries_with_sets->removeBarSet(m_testSets.at(3)); + m_barseries_with_sets->removeBarSet(m_testSets.at(4)); + + QVERIFY(m_barseries_with_sets->barsetCount() == 2); + + QList verifysets = m_barseries_with_sets->barSets(); + + QVERIFY(verifysets.at(0) == m_testSets.at(0)); + QVERIFY(verifysets.at(1) == m_testSets.at(1)); + + // Try removing all sets again + for (int i=0; iremoveBarSet(m_testSets.at(i)); + } + + QVERIFY(m_barseries_with_sets->barsetCount() == 0); +} + +void tst_QStackedBarSeries::appendBarSets_data() +{ + +} + +void tst_QStackedBarSeries::appendBarSets() +{ + int count = 5; + QVERIFY(m_barseries->barsetCount() == 0); + + QList sets; + for (int i=0; iappendBarSets(sets); + QVERIFY(m_barseries->barsetCount() == count); +} + +void tst_QStackedBarSeries::removeBarSets_data() +{ + +} + +void tst_QStackedBarSeries::removeBarSets() +{ + int count = m_testSets.count(); + QVERIFY(m_barseries_with_sets->barsetCount() == count); + + // Try removing empty list of sets + QList empty; + m_barseries_with_sets->removeBarSets(empty); + QVERIFY(m_barseries_with_sets->barsetCount() == count); + + // remove all sets + m_barseries_with_sets->removeBarSets(m_testSets); + QVERIFY(m_barseries_with_sets->barsetCount() == 0); + + // Try removing empty list again + m_barseries_with_sets->removeBarSets(empty); + QVERIFY(m_barseries_with_sets->barsetCount() == 0); + + // remove all sets again + m_barseries_with_sets->removeBarSets(m_testSets); + QVERIFY(m_barseries_with_sets->barsetCount() == 0); +} + +void tst_QStackedBarSeries::barsetCount_data() +{ + +} + +void tst_QStackedBarSeries::barsetCount() +{ + QVERIFY(m_barseries->barsetCount() == 0); + QVERIFY(m_barseries_with_sets->barsetCount() == m_testSets.count()); +} + +void tst_QStackedBarSeries::categoryCount_data() +{ + +} + +void tst_QStackedBarSeries::categoryCount() +{ + QVERIFY(m_barseries->categoryCount() == m_categories.count()); + QVERIFY(m_barseries_with_sets->categoryCount() == m_categories.count()); +} + +void tst_QStackedBarSeries::barSets_data() +{ + +} + +void tst_QStackedBarSeries::barSets() +{ + QVERIFY(m_barseries->barSets().count() == 0); + + QList sets = m_barseries_with_sets->barSets(); + QVERIFY(sets.count() == m_testSets.count()); + + for (int i=0; icategories(); + + QVERIFY(categories.count() == m_categories.count()); + for (int i=0; ilabelsVisible() == false); + } + + m_barseries_with_sets->setLabelsVisible(true); + foreach (QBarSet* s, m_testSets) { + QVERIFY(s->labelsVisible() == true); + } + + m_barseries_with_sets->setLabelsVisible(false); + foreach (QBarSet* s, m_testSets) { + QVERIFY(s->labelsVisible() == false); + } +} + +/* +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_QStackedBarSeries) + +#include "tst_qstackedbarseries.moc" +