diff --git a/charts.pro b/charts.pro index 8e3e3eb..e2c9141 100644 --- a/charts.pro +++ b/charts.pro @@ -3,7 +3,7 @@ } TEMPLATE = subdirs -SUBDIRS = src plugins examples demos tests +SUBDIRS = src plugins examples demos development_build: message('Development build') diff --git a/tests/auto/auto.pri b/tests/auto/auto.pri deleted file mode 100644 index 71d26a6..0000000 --- a/tests/auto/auto.pri +++ /dev/null @@ -1,14 +0,0 @@ -!include( ../tests.pri ) { - error( "Couldn't find the tests.pri file!" ) -} - -CONFIG += qtestlib -!contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_") - -INCLUDEPATH += ../inc -HEADERS += ../inc/tst_definitions.h - -OBJECTS_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET -MOC_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET -UI_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET -RCC_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro deleted file mode 100644 index 4411b14..0000000 --- a/tests/auto/auto.pro +++ /dev/null @@ -1,42 +0,0 @@ -!include( ../tests.pri ) { - error( "Couldn't find the tests.pri file!" ) -} - -TEMPLATE = subdirs -SUBDIRS += \ - qchartview \ - qchart \ - qlineseries \ - qbarset \ - qbarseries \ - qstackedbarseries \ - qpercentbarseries \ - qpieslice qpieseries \ - qpiemodelmapper \ - qsplineseries \ - qscatterseries \ - qxymodelmapper \ - qbarmodelmapper \ - qhorizontalbarseries \ - qhorizontalstackedbarseries \ - qhorizontalpercentbarseries \ - qvalueaxis \ - qcategoryaxis \ - qbarcategoryaxis \ - domain \ - chartdataset - -contains(QT_VERSION, ^4\\.[0-7]\\.[0-3]\\s*$) | contains(QT_VERSION, ^4\\.[0-6]\\..*) { - warning("QtCommercial.Charts QML API requires at least Qt 4.7.4. You are using $${QT_VERSION} so the QML API is disabled.") -} else { - - SUBDIRS += qml -} - -!linux-arm*: { -SUBDIRS += \ - qdatetimeaxis -} - - - diff --git a/tests/auto/chartdataset/chartdataset.pro b/tests/auto/chartdataset/chartdataset.pro deleted file mode 100644 index 9a7880d..0000000 --- a/tests/auto/chartdataset/chartdataset.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} - -SOURCES += tst_chartdataset.cpp diff --git a/tests/auto/chartdataset/tst_chartdataset.cpp b/tests/auto/chartdataset/tst_chartdataset.cpp deleted file mode 100644 index c7229f6..0000000 --- a/tests/auto/chartdataset/tst_chartdataset.cpp +++ /dev/null @@ -1,644 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -#ifndef BUILD_PRIVATE_UNIT_TESTS -#include - -class tst_ChartDataSet: public QObject { - - Q_OBJECT - -private Q_SLOTS: - void skip(); - -}; - -void tst_ChartDataSet::skip() -{ - QSKIP("This test requires the debug version of library", SkipAll); -} - -QTEST_MAIN(tst_ChartDataSet) -#include "tst_chartdataset.moc" - -#else - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(Domain *) -Q_DECLARE_METATYPE(QAbstractAxis *) -Q_DECLARE_METATYPE(QAbstractSeries *) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QLineSeries *) - -class tst_ChartDataSet: public QObject { - - Q_OBJECT - -public Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private Q_SLOTS: - void chartdataset_data(); - void chartdataset(); - void addSeries_data(); - void addSeries(); - void setAxisX_data(); - void setAxisX(); - void setAxisY_data(); - void setAxisY(); - void removeSeries_data(); - void removeSeries(); - void removeAllSeries_data(); - void removeAllSeries(); - void seriesCount_data(); - void seriesCount(); - void seriesIndex_data(); - void seriesIndex(); - void domain_data(); - void domain(); - void zoomInDomain_data(); - void zoomInDomain(); - void zoomOutDomain_data(); - void zoomOutDomain(); - void scrollDomain_data(); - void scrollDomain(); - -private: - ChartDataSet* m_dataset; -}; - -void tst_ChartDataSet::initTestCase() -{ - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); -} - -void tst_ChartDataSet::cleanupTestCase() -{ -} - -void tst_ChartDataSet::init() -{ - m_dataset = new ChartDataSet(); -} - - -void tst_ChartDataSet::cleanup() -{ - QList series = m_dataset->series(); - foreach(QAbstractSeries* serie, series) - { - m_dataset->removeSeries(serie); - } -} - -void tst_ChartDataSet::chartdataset_data() -{ -} - -void tst_ChartDataSet::chartdataset() -{ - QVERIFY(m_dataset->axisX(0) == 0); - QVERIFY(m_dataset->axisY(0) == 0); - QLineSeries* series = new QLineSeries(this); - QCOMPARE(m_dataset->seriesIndex(series),-1); - QVERIFY(m_dataset->domain(series) == 0); - QVERIFY(m_dataset->axisX(series) == 0); - QVERIFY(m_dataset->axisY(series) == 0); - m_dataset->createDefaultAxes(); -} - - -void tst_ChartDataSet::addSeries_data() -{ - QTest::addColumn("series"); - - QAbstractSeries* line = new QLineSeries(this); - QAbstractSeries* area = new QAreaSeries(static_cast(line)); - QAbstractSeries* scatter = new QScatterSeries(this); - QAbstractSeries* spline = new QSplineSeries(this); - QAbstractSeries* pie = new QPieSeries(this); - QAbstractSeries* bar = new QBarSeries(this); - QAbstractSeries* percent = new QPercentBarSeries(this); - QAbstractSeries* stacked = new QStackedBarSeries(this); - - QTest::newRow("line") << line; - QTest::newRow("area") << area; - QTest::newRow("scatter") << scatter; - QTest::newRow("spline") << spline; - QTest::newRow("pie") << pie; - QTest::newRow("bar") << bar; - QTest::newRow("percent") << percent; - QTest::newRow("stacked") << stacked; -} - -void tst_ChartDataSet::addSeries() -{ - - QFETCH(QAbstractSeries*, series); - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*, Domain *))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - m_dataset->addSeries(series); - m_dataset->createDefaultAxes(); - if(series->type()==QAbstractSeries::SeriesTypePie){ - TRY_COMPARE(spy0.count(), 0); - }else{ - TRY_COMPARE(spy0.count(), 2); - } - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 1); - TRY_COMPARE(spy3.count(), 0); -} - - -void tst_ChartDataSet::setAxisX_data() -{ - QTest::addColumn >("seriesList"); - QTest::addColumn >("axisList"); - QTest::addColumn("axisCount"); - - QAbstractSeries* line = new QLineSeries(this); - QAbstractSeries* area = new QAreaSeries(static_cast(line)); - QAbstractSeries* scatter = new QScatterSeries(this); - QAbstractSeries* spline = new QSplineSeries(this); - /*QAbstractSeries* pie = */new QPieSeries(this); - /*QAbstractSeries* bar = */new QBarSeries(this); - /*QAbstractSeries* percent = */new QPercentBarSeries(this); - /*QAbstractSeries* stacked = */new QStackedBarSeries(this); - - QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2") - << (QList() << line << spline << scatter) - << (QList() << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this)) << 3; - - QTest::newRow("area: axis 0") << (QList() << area) - << (QList() << new QValueAxis(this)) << 1; - - QList axes0; - axes0 << new QValueAxis(this) << new QValueAxis(this); - axes0 << axes0.last(); - QTest::newRow("line,spline,scatter: axis 0 axis1 axis 1") - << (QList() << line << spline << scatter) - << axes0 << 2; - //TODO: add more test cases -} - -void tst_ChartDataSet::setAxisX() -{ - QFETCH(QList, seriesList); - QFETCH(QList, axisList); - QFETCH(int, axisCount); - - Q_ASSERT(seriesList.count() == axisList.count()); - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *,Domain*))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - foreach(QAbstractSeries* series, seriesList){ - m_dataset->addSeries(series); - } - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), seriesList.count()); - TRY_COMPARE(spy3.count(), 0); - - QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); - QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); - QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); - QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - for(int i=0 ; i < seriesList.count(); i++){ - m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Horizontal); - } - - TRY_COMPARE(spy4.count(), axisCount); - TRY_COMPARE(spy5.count(), 0); - TRY_COMPARE(spy6.count(), 0); - TRY_COMPARE(spy7.count(), 0); - - for(int i=0 ; i < seriesList.count(); i++){ - QVERIFY(m_dataset->axisX(seriesList.at(i)) == axisList.at(i)); - } -} - -void tst_ChartDataSet::setAxisY_data() -{ - setAxisX_data(); -} - -void tst_ChartDataSet::setAxisY() -{ - QFETCH(QList, seriesList); - QFETCH(QList, axisList); - QFETCH(int, axisCount); - - Q_ASSERT(seriesList.count() == axisList.count()); - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - foreach(QAbstractSeries* series, seriesList){ - m_dataset->addSeries(series); - } - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), seriesList.count()); - TRY_COMPARE(spy3.count(), 0); - - QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*))); - QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); - QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*))); - QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - for(int i=0 ; i < seriesList.count(); i++){ - m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Vertical); - } - - TRY_COMPARE(spy4.count(), axisCount); - TRY_COMPARE(spy5.count(), 0); - TRY_COMPARE(spy6.count(), 0); - TRY_COMPARE(spy7.count(), 0); - - for(int i=0 ; i < seriesList.count(); i++){ - QVERIFY(m_dataset->axisY(seriesList.at(i)) == axisList.at(i)); - } -} - -void tst_ChartDataSet::removeSeries_data() -{ - addSeries_data(); -} - -void tst_ChartDataSet::removeSeries() -{ - QFETCH(QAbstractSeries*, series); - - m_dataset->addSeries(series); - m_dataset->createDefaultAxes(); - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*, Domain *))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - m_dataset->removeSeries(series); - - TRY_COMPARE(spy0.count(), 0); - if (series->type() == QAbstractSeries::SeriesTypePie) { - TRY_COMPARE(spy1.count(), 0); - } - else { - TRY_COMPARE(spy1.count(), 2); - } - TRY_COMPARE(spy2.count(), 0); - TRY_COMPARE(spy3.count(), 1); -} - -void tst_ChartDataSet::removeAllSeries_data() -{ - QTest::addColumn >("seriesList"); - QTest::addColumn >("axisList"); - QTest::addColumn("axisCount"); - - QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2") - << (QList() << new QLineSeries(this) << new QSplineSeries(this) - << new QScatterSeries(this)) - << (QList() << new QValueAxis(this) << new QValueAxis(this) - << new QValueAxis(this)) << 3; - //TODO: -} - -void tst_ChartDataSet::removeAllSeries() -{ - QFETCH(QList, seriesList); - QFETCH(QList, axisList); - QFETCH(int, axisCount); - - foreach(QAbstractSeries* series, seriesList) { - m_dataset->addSeries(series); - } - - for (int i = 0; i < seriesList.count(); i++) { - m_dataset->setAxis(seriesList.at(i), axisList.at(i),Qt::Horizontal); - } - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - m_dataset->removeAllSeries(); - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), axisCount); - TRY_COMPARE(spy2.count(), 0); - TRY_COMPARE(spy3.count(), seriesList.count()); -} - - -void tst_ChartDataSet::seriesCount_data() -{ - QTest::addColumn >("seriesList"); - QTest::addColumn("seriesCount"); - - QTest::newRow("line,line, line, spline 3") << (QList() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ) << 3; - QTest::newRow("scatter,scatter, line, line 2") << (QList() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) ) << 2; -} - -void tst_ChartDataSet::seriesCount() -{ - QFETCH(QList, seriesList); - QFETCH(int, seriesCount); - - foreach(QAbstractSeries* series, seriesList){ - m_dataset->addSeries(series); - } - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - QCOMPARE(m_dataset->seriesCount(seriesList.at(0)->type()),seriesCount); - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 0); - TRY_COMPARE(spy3.count(), 0); -} - -void tst_ChartDataSet::seriesIndex_data() -{ - QTest::addColumn >("seriesList"); - - QTest::newRow("line,line, line, spline") << (QList() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); - QTest::newRow("scatter,scatter, line, line") << (QList() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) ); -} - -void tst_ChartDataSet::seriesIndex() -{ - - QFETCH(QList, seriesList); - - foreach(QAbstractSeries* series, seriesList) { - m_dataset->addSeries(series); - } - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *,Domain*))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); - - for (int i = 0; i < seriesList.count(); i++) { - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); - } - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 0); - TRY_COMPARE(spy3.count(), 0); - - foreach(QAbstractSeries* series, seriesList) { - m_dataset->removeSeries(series); - } - - for (int i = 0; i < seriesList.count(); i++) { - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); - } - - foreach(QAbstractSeries* series, seriesList) { - m_dataset->addSeries(series); - } - - for (int i = 0; i < seriesList.count(); i++) { - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); - } - - m_dataset->removeSeries(seriesList.at(1)); - - for (int i = 0; i < seriesList.count(); i++) { - if (i != 1) - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); - else - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); - } - - m_dataset->addSeries(seriesList.at(1)); - - for (int i = 0; i < seriesList.count(); i++) { - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); - } - - m_dataset->removeSeries(seriesList.at(2)); - - for (int i = 0; i < seriesList.count(); i++) { - if (i != 2) - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); - else - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); - } - - m_dataset->removeSeries(seriesList.at(0)); - - for (int i = 0; i < seriesList.count(); i++) { - if (i != 2 && i != 0) - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); - else - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1); - } - - m_dataset->addSeries(seriesList.at(2)); - m_dataset->addSeries(seriesList.at(0)); - - for (int i = 0; i < seriesList.count(); i++) { - if (i == 2) - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 0); - else if (i == 0) - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 2); - else - QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i); - } - -} - -void tst_ChartDataSet::domain_data() -{ - addSeries_data(); -} - -void tst_ChartDataSet::domain() -{ - QFETCH(QAbstractSeries*, series); - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *))); - - m_dataset->addSeries(series); - QVERIFY(m_dataset->domain(series)); - - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 1); - - QList arguments = spy2.takeFirst(); - Domain *domain = (Domain *) arguments.at(1).value(); - QVERIFY(m_dataset->domain(series) == domain); - - TRY_COMPARE(spy3.count(), 0); - -} - -void tst_ChartDataSet::zoomInDomain_data() -{ - QTest::addColumn("sameAxis"); - QTest::addColumn >("seriesList"); - QTest::newRow("sameAxis: line,line, line, spline") << true << (QList() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); - QTest::newRow("separeateAxis: line,line, line, spline") << false << (QList() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ); -} - -void tst_ChartDataSet::zoomInDomain() -{ - QFETCH(bool, sameAxis); - QFETCH(QList, seriesList); - - foreach(QAbstractSeries* series, seriesList) { - m_dataset->addSeries(series); - } - - if(sameAxis) m_dataset->createDefaultAxes(); - - QList spyList; - - foreach(QAbstractSeries* series, seriesList) { - spyList << new QSignalSpy(m_dataset->domain(series),SIGNAL(updated())); - } - - m_dataset->zoomInDomain(QRect(0, 0, 100, 100), QSize(1000, 1000)); - - foreach(QSignalSpy* spy, spyList) { - TRY_COMPARE(spy->count(), 1); - } - - qDeleteAll(spyList); -} - - - -void tst_ChartDataSet::zoomOutDomain_data() -{ - zoomInDomain_data(); -} - -void tst_ChartDataSet::zoomOutDomain() -{ - QFETCH(bool, sameAxis); - QFETCH(QList, seriesList); - - foreach(QAbstractSeries* series, seriesList) { - m_dataset->addSeries(series); - } - - if (sameAxis) - m_dataset->createDefaultAxes(); - - QList spyList; - - foreach(QAbstractSeries* series, seriesList) { - spyList << new QSignalSpy(m_dataset->domain(series), SIGNAL(updated())); - } - - m_dataset->zoomOutDomain(QRect(0, 0, 100, 100), QSize(1000, 1000)); - - foreach(QSignalSpy* spy, spyList) { - TRY_COMPARE(spy->count(), 1); - } - - qDeleteAll (spyList); -} - -void tst_ChartDataSet::scrollDomain_data() -{ - zoomInDomain_data(); -} - -void tst_ChartDataSet::scrollDomain() -{ - QFETCH(bool, sameAxis); - QFETCH(QList, seriesList); - - foreach(QAbstractSeries* series, seriesList) { - m_dataset->addSeries(series); - } - - if (sameAxis) - m_dataset->createDefaultAxes(); - - QList spyList; - - foreach(QAbstractSeries* series, seriesList) { - spyList - << new QSignalSpy(m_dataset->domain(series), - SIGNAL(updated())); - } - - m_dataset->scrollDomain(10, 10, QSize(1000, 1000)); - - foreach(QSignalSpy* spy, spyList) { - TRY_COMPARE(spy->count(), 1); - } - - qDeleteAll(spyList); -} - -QTEST_MAIN(tst_ChartDataSet) -#include "tst_chartdataset.moc" -#endif diff --git a/tests/auto/domain/domain.pro b/tests/auto/domain/domain.pro deleted file mode 100644 index 8c9af3d..0000000 --- a/tests/auto/domain/domain.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} - -SOURCES += tst_domain.cpp diff --git a/tests/auto/domain/tst_domain.cpp b/tests/auto/domain/tst_domain.cpp deleted file mode 100644 index 544f97b..0000000 --- a/tests/auto/domain/tst_domain.cpp +++ /dev/null @@ -1,703 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -#ifndef BUILD_PRIVATE_UNIT_TESTS - -#include - -class tst_Domain: public QObject { - - Q_OBJECT - -private Q_SLOTS: - void skip(); - -}; - -void tst_Domain::skip() -{ - QSKIP("This test requires the debug version of library", SkipAll); -} - -QTEST_MAIN(tst_Domain) -#include "tst_domain.moc" - -#else - -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(Domain*) -Q_DECLARE_METATYPE(QSizeF) - - -class AxisMock: public QAbstractAxisPrivate -{ -Q_OBJECT -public: - AxisMock(Qt::Orientation orientation):QAbstractAxisPrivate(0){ setOrientation(orientation);}; - ChartAxis* createGraphics(ChartPresenter* presenter) - { - Q_UNUSED(presenter); - return 0; - }; - void intializeDomain(Domain* domain) - { - Q_UNUSED(domain); - }; - void setMin(const QVariant &min) - { - Q_UNUSED(min); - } - qreal min() { return m_min;} - void setMax(const QVariant &max) - { - Q_UNUSED(max); - } - qreal max() { return m_max; } - void setRange(const QVariant &min, const QVariant &max) - { - Q_UNUSED(min); - Q_UNUSED(max); - }; - - int count () const { return m_count; } - - void handleDomainUpdated(){}; -public: - int m_count; - qreal m_min; - qreal m_max; -}; - -class tst_Domain: public QObject -{ -Q_OBJECT - -public Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private Q_SLOTS: - void domain(); - void handleAxisUpdatedX_data(); - void handleAxisUpdatedX(); - void handleAxisUpdatedY_data(); - void handleAxisUpdatedY(); - void isEmpty_data(); - void isEmpty(); - void maxX_data(); - void maxX(); - void maxY_data(); - void maxY(); - void minX_data(); - void minX(); - void minY_data(); - void minY(); - void operatorEquals_data(); - void operatorEquals(); - void setRange_data(); - void setRange(); - void setRangeX_data(); - void setRangeX(); - void setRangeY_data(); - void setRangeY(); - void spanX_data(); - void spanX(); - void spanY_data(); - void spanY(); - void zoom_data(); - void zoom(); - void move_data(); - void move(); -}; - -void tst_Domain::initTestCase() -{ -} - -void tst_Domain::cleanupTestCase() -{ -} - -void tst_Domain::init() -{ -} - -void tst_Domain::cleanup() -{ -} - -void tst_Domain::domain() -{ - Domain domain; - - QCOMPARE(domain.isEmpty(), true); - QCOMPARE(domain.maxX(), 0.0); - QCOMPARE(domain.maxY(), 0.0); - QCOMPARE(domain.minX(), 0.0); - QCOMPARE(domain.minY(), 0.0); -} - -void tst_Domain::handleAxisUpdatedX_data() -{ - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("-1 1") << -1.0 << 1.0; - QTest::newRow("0 1") << 0.0 << 1.0; - QTest::newRow("-1 0") << -1.0 << 0.0; -} - -void tst_Domain::handleAxisUpdatedX() -{ - QFETCH(qreal, min); - QFETCH(qreal, max); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - AxisMock axis(Qt::Horizontal); - QObject::connect(&axis,SIGNAL(updated()),&domain,SLOT(handleAxisUpdated())); - axis.m_min=min; - axis.m_max=max; - axis.emitUpdated(); - - QVERIFY(qFuzzyIsNull(domain.minX() - min)); - QVERIFY(qFuzzyIsNull(domain.maxX() - max)); - - QList arg1 = spy1.first(); - QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); - QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); - - TRY_COMPARE(spy0.count(), 1); - TRY_COMPARE(spy1.count(), 1); - TRY_COMPARE(spy2.count(), 0); - -} - -void tst_Domain::handleAxisUpdatedY_data() -{ - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("-1 1") << -1.0 << 1.0; - QTest::newRow("0 1") << 0.0 << 1.0; - QTest::newRow("-1 0") << -1.0 << 0.0; -} - -void tst_Domain::handleAxisUpdatedY() -{ - QFETCH(qreal, min); - QFETCH(qreal, max); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - AxisMock axis(Qt::Vertical); - QObject::connect(&axis, SIGNAL(updated()), &domain, SLOT(handleAxisUpdated())); - axis.m_min = min; - axis.m_max = max; - axis.emitUpdated(); - - QVERIFY(qFuzzyIsNull(domain.minY() - min)); - QVERIFY(qFuzzyIsNull(domain.maxY() - max)); - - QList arg1 = spy2.first(); - QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); - QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); - - TRY_COMPARE(spy0.count(), 1); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 1); -} - -void tst_Domain::isEmpty_data() -{ - QTest::addColumn("minX"); - QTest::addColumn("maxX"); - QTest::addColumn("minY"); - QTest::addColumn("maxY"); - QTest::addColumn("isEmpty"); - QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true; - QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true; - QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true; - QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false; -} - -void tst_Domain::isEmpty() -{ - QFETCH(qreal, minX); - QFETCH(qreal, maxX); - QFETCH(qreal, minY); - QFETCH(qreal, maxY); - QFETCH(bool, isEmpty); - - Domain domain; - domain.setRange(minX, maxX, minY, maxY); - QCOMPARE(domain.isEmpty(), isEmpty); -} - -void tst_Domain::maxX_data() -{ - QTest::addColumn("maxX1"); - QTest::addColumn("maxX2"); - QTest::addColumn("count"); - QTest::newRow("1") << 0.0 << 1.0 << 1; - QTest::newRow("1.0") << 1.0 << 1.0 << 1; - QTest::newRow("2.0") << 1.0 << 0.0 << 2; -} - -void tst_Domain::maxX() -{ - QFETCH(qreal, maxX1); - QFETCH(qreal, maxX2); - QFETCH(int, count); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - domain.setMaxX(maxX1); - QCOMPARE(domain.maxX(), maxX1); - domain.setMaxX(maxX2); - QCOMPARE(domain.maxX(), maxX2); - - TRY_COMPARE(spy0.count(), count); - TRY_COMPARE(spy1.count(), count); - TRY_COMPARE(spy2.count(), 0); - -} - -void tst_Domain::maxY_data() -{ - QTest::addColumn("maxY1"); - QTest::addColumn("maxY2"); - QTest::addColumn("count"); - QTest::newRow("1") << 0.0 << 1.0 << 1; - QTest::newRow("1.0") << 1.0 << 1.0 << 1; - QTest::newRow("2.0") << 1.0 << 0.0 << 2; -} - -void tst_Domain::maxY() -{ - QFETCH(qreal, maxY1); - QFETCH(qreal, maxY2); - QFETCH(int, count); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - domain.setMaxY(maxY1); - QCOMPARE(domain.maxY(), maxY1); - domain.setMaxY(maxY2); - QCOMPARE(domain.maxY(), maxY2); - - TRY_COMPARE(spy0.count(), count); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), count); -} - -void tst_Domain::minX_data() -{ - QTest::addColumn("minX1"); - QTest::addColumn("minX2"); - QTest::addColumn("count"); - QTest::newRow("1") << 0.0 << 1.0 << 1; - QTest::newRow("1.0") << 1.0 << 1.0 << 1; - QTest::newRow("2.0") << 1.0 << 0.0 << 2; -} - -void tst_Domain::minX() -{ - QFETCH(qreal, minX1); - QFETCH(qreal, minX2); - QFETCH(int, count); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - domain.setMinX(minX1); - QCOMPARE(domain.minX(), minX1); - domain.setMinX(minX2); - QCOMPARE(domain.minX(), minX2); - - TRY_COMPARE(spy0.count(), count); - TRY_COMPARE(spy1.count(), count); - TRY_COMPARE(spy2.count(), 0); -} - -void tst_Domain::minY_data() -{ - QTest::addColumn("minY1"); - QTest::addColumn("minY2"); - QTest::addColumn("count"); - QTest::newRow("1") << 0.0 << 1.0 << 1; - QTest::newRow("1.0") << 1.0 << 1.0 << 1; - QTest::newRow("2.0") << 1.0 << 0.0 << 2; -} - -void tst_Domain::minY() -{ - QFETCH(qreal, minY1); - QFETCH(qreal, minY2); - QFETCH(int, count); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - domain.setMinY(minY1); - QCOMPARE(domain.minY(), minY1); - domain.setMinY(minY2); - QCOMPARE(domain.minY(), minY2); - - TRY_COMPARE(spy0.count(), count); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), count); -} - -void tst_Domain::operatorEquals_data() -{ - - QTest::addColumn("domain1"); - QTest::addColumn("domain2"); - QTest::addColumn("equals"); - QTest::addColumn("notEquals"); - Domain* a; - Domain* b; - a = new Domain(); - a->setRange(0, 100, 0, 100); - b = new Domain(); - b->setRange(0, 100, 0, 100); - QTest::newRow("equals") << a << b << true << false; - a = new Domain(); - a->setRange(0, 100, 0, 100); - b = new Domain(); - b->setRange(0, 100, 0, 1); - QTest::newRow("equals") << a << b << false << true; - a = new Domain(); - a->setRange(0, 100, 0, 100); - b = new Domain(); - b->setRange(0, 1, 0, 100); - QTest::newRow("equals") << a << b << false << true; - -} - -void tst_Domain::operatorEquals() -{ - QFETCH(Domain*, domain1); - QFETCH(Domain*, domain2); - QFETCH(bool, equals); - QFETCH(bool, notEquals); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - QCOMPARE(*domain1==*domain2, equals); - QCOMPARE(*domain1!=*domain2, notEquals); - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 0); -} - -void tst_Domain::setRange_data() -{ - QTest::addColumn("minX"); - QTest::addColumn("maxX"); - QTest::addColumn("minY"); - QTest::addColumn("maxY"); - QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0; - QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0; - QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0; -} - -void tst_Domain::setRange() -{ - QFETCH(qreal, minX); - QFETCH(qreal, maxX); - QFETCH(qreal, minY); - QFETCH(qreal, maxY); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - domain.setRange(minX, maxX, minY, maxY); - - QCOMPARE(domain.minX(), minX); - QCOMPARE(domain.maxX(), maxX); - QCOMPARE(domain.minY(), minY); - QCOMPARE(domain.maxY(), maxY); - - TRY_COMPARE(spy0.count(), 1); - TRY_COMPARE(spy1.count(), 1); - TRY_COMPARE(spy2.count(), 1); - -} - -void tst_Domain::setRangeX_data() -{ - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("-1 1") << -1.0 << 1.0; - QTest::newRow("0 1") << 0.0 << 1.0; - QTest::newRow("-1 0") << -1.0 << 0.0; -} - -void tst_Domain::setRangeX() -{ - QFETCH(qreal, min); - QFETCH(qreal, max); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - domain.setRangeX(min, max); - - QVERIFY(qFuzzyIsNull(domain.minX() - min)); - QVERIFY(qFuzzyIsNull(domain.maxX() - max)); - - QList arg1 = spy1.first(); - QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); - QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); - - TRY_COMPARE(spy0.count(), 1); - TRY_COMPARE(spy1.count(), 1); - TRY_COMPARE(spy2.count(), 0); -} - -void tst_Domain::setRangeY_data() -{ - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("-1 1") << -1.0 << 1.0; - QTest::newRow("0 1") << 0.0 << 1.0; - QTest::newRow("-1 0") << -1.0 << 0.0; -} - -void tst_Domain::setRangeY() -{ - QFETCH(qreal, min); - QFETCH(qreal, max); - - Domain domain; - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - domain.setRangeY(min, max); - - QVERIFY(qFuzzyIsNull(domain.minY() - min)); - QVERIFY(qFuzzyIsNull(domain.maxY() - max)); - - QList arg1 = spy2.first(); - QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); - QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); - - TRY_COMPARE(spy0.count(), 1); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 1); -} - -void tst_Domain::spanX_data() -{ - QTest::addColumn("minX"); - QTest::addColumn("maxX"); - QTest::addColumn("spanX"); - QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; - QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; -} - -void tst_Domain::spanX() -{ - QFETCH(qreal, minX); - QFETCH(qreal, maxX); - QFETCH(qreal, spanX); - - Domain domain; - - domain.setRangeX(minX, maxX); - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - QCOMPARE(domain.spanX(), spanX); - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 0); -} - -void tst_Domain::spanY_data() -{ - QTest::addColumn("minY"); - QTest::addColumn("maxY"); - QTest::addColumn("spanY"); - QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0; - QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0; -} - -void tst_Domain::spanY() -{ - QFETCH(qreal, minY); - QFETCH(qreal, maxY); - QFETCH(qreal, spanY); - - Domain domain; - - domain.setRangeY(minY, maxY); - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - QCOMPARE(domain.spanY(), spanY); - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 0); -} - -void tst_Domain::zoom_data() -{ - QTest::addColumn("rect0"); - QTest::addColumn("size0"); - QTest::addColumn("rect1"); - QTest::addColumn("size1"); - QTest::addColumn("rect2"); - QTest::addColumn("size2"); - QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000) - << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) - << QSizeF(1000, 1000); - QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000) - << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100) - << QSizeF(1000, 1000); - QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20) - << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100); -} - -void tst_Domain::zoom() -{ - QFETCH(QRectF, rect0); - QFETCH(QSizeF, size0); - QFETCH(QRectF, rect1); - QFETCH(QSizeF, size1); - QFETCH(QRectF, rect2); - QFETCH(QSizeF, size2); - - Domain domain; - - domain.setRange(0, 1000, 0, 1000); - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - Domain domain0; - domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); - domain.zoomIn(rect0, size0); - Domain domain1; - domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); - domain.zoomIn(rect1, size1); - Domain domain2; - domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY()); - domain.zoomIn(rect2, size2); - domain.zoomOut(rect2, size2); - QCOMPARE(domain == domain2, true); - domain.zoomOut(rect1, size1); - QCOMPARE(domain == domain1, true); - domain.zoomOut(rect0, size0); - QCOMPARE(domain == domain0, true); - TRY_COMPARE(spy0.count(), 6); - TRY_COMPARE(spy1.count(), 6); - TRY_COMPARE(spy2.count(), 6); -} - -void tst_Domain::move_data() -{ - QTest::addColumn("dx"); - QTest::addColumn("dy"); - QTest::addColumn("size"); - QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000); - QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000); - QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000); - QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000); - QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000); - QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000); -} - -void tst_Domain::move() -{ - QFETCH(int, dx); - QFETCH(int, dy); - QFETCH(QSizeF, size); - Domain domain; - - domain.setRange(0, size.width(), 0, size.height()); - - QSignalSpy spy0(&domain, SIGNAL(updated())); - QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal))); - QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal))); - - domain.move(dx, dy, size); - - Domain result; - result.setRange(dx, size.width() + dx, dy, size.height() + dy); - - QCOMPARE(domain == result, true); - TRY_COMPARE(spy0.count(), 1); - TRY_COMPARE(spy1.count(), (dx != 0 ? 1 : 0)); - TRY_COMPARE(spy2.count(), (dy != 0 ? 1 : 0)); -} - -QTEST_MAIN(tst_Domain) -#include "tst_domain.moc" -#endif diff --git a/tests/auto/inc/tst_definitions.h b/tests/auto/inc/tst_definitions.h deleted file mode 100644 index f30e9bb..0000000 --- a/tests/auto/inc/tst_definitions.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef TST_DEFINITIONS_H -#define TST_DEFINITIONS_H - -#include - -#define TRY_COMPARE(actual, expected) { \ - do { \ - const int timeout(1000); \ - const int waitStep(30); \ - /* always wait before comparing to catch possible extra signals */ \ - QTest::qWait(waitStep); \ - for (int time(0); (actual != expected) && (time < timeout); time += waitStep) \ - QTest::qWait(waitStep); \ - QCOMPARE(actual, expected); \ - } while (0); \ -} - -#endif // TST_DEFINITIONS_H diff --git a/tests/auto/qabstractaxis/tst_qabstractaxis.cpp b/tests/auto/qabstractaxis/tst_qabstractaxis.cpp deleted file mode 100644 index fa7744c..0000000 --- a/tests/auto/qabstractaxis/tst_qabstractaxis.cpp +++ /dev/null @@ -1,847 +0,0 @@ -/**************************************************************************** -** -** 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 "tst_qabstractaxis.h" - -Q_DECLARE_METATYPE(QPen) -Q_DECLARE_METATYPE(Qt::Orientation) - -void tst_QAbstractAxis::initTestCase() -{ -} - -void tst_QAbstractAxis::cleanupTestCase() -{ -} - -void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series) -{ - m_axis = axis; - m_series = series; - m_view = new QChartView(new QChart()); - m_chart = m_view->chart(); -} - -void tst_QAbstractAxis::cleanup() -{ - delete m_view; - m_view = 0; - m_chart = 0; - m_axis = 0; -} - -void tst_QAbstractAxis::qabstractaxis() -{ - QCOMPARE(m_axis->linePen(), QPen()); - //TODO QCOMPARE(m_axis->axisPenColor(), QColor()); - QCOMPARE(m_axis->gridLinePen(), QPen()); - QCOMPARE(m_axis->isLineVisible(), true); - QCOMPARE(m_axis->isGridLineVisible(), true); - QCOMPARE(m_axis->isVisible(), false); - QCOMPARE(m_axis->labelsAngle(), 0); - QCOMPARE(m_axis->labelsBrush(), QBrush()); - //TODO QCOMPARE(m_axis->labelsColor(), QColor()); - QCOMPARE(m_axis->labelsFont(), QFont()); - QCOMPARE(m_axis->labelsPen(), QPen()); - QCOMPARE(m_axis->labelsVisible(), true); - QCOMPARE(m_axis->orientation(), Qt::Orientation(0)); - m_axis->setLineVisible(false); - m_axis->setLinePen(QPen()); - m_axis->setLinePenColor(QColor()); - m_axis->setGridLinePen(QPen()); - m_axis->setGridLineVisible(false); - m_axis->setLabelsAngle(-1); - m_axis->setLabelsBrush(QBrush()); - m_axis->setLabelsColor(QColor()); - m_axis->setLabelsFont(QFont()); - m_axis->setLabelsPen(QPen()); - m_axis->setLabelsVisible(false); - m_axis->setMax(QVariant()); - m_axis->setMin(QVariant()); - m_axis->setRange(QVariant(), QVariant()); - m_axis->setShadesBorderColor(QColor()); - m_axis->setShadesBrush(QBrush()); - m_axis->setShadesColor(QColor()); - m_axis->setShadesPen(QPen()); - m_axis->setShadesVisible(false); - m_axis->setVisible(false); - //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor()); - //TODO QCOMPARE(m_axis->shadesBrush(), QBrush()); - //TODO QCOMPARE(m_axis->shadesColor(), QColor()); - QCOMPARE(m_axis->shadesPen(), QPen()); - QCOMPARE(m_axis->shadesVisible(), false); - m_axis->show(); - m_axis->hide(); -} - -void tst_QAbstractAxis::axisPen_data() -{ - QTest::addColumn("axisPen"); - QTest::newRow("null") << QPen(); - QTest::newRow("blue") << QPen(Qt::blue); - QTest::newRow("black") << QPen(Qt::black); - QTest::newRow("red") << QPen(Qt::red); -} - -void tst_QAbstractAxis::axisPen() -{ - QFETCH(QPen, axisPen); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setLinePen(axisPen); - QCOMPARE(m_axis->linePen(), axisPen); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - //TODO QCOMPARE(m_axis->axisPen(), axisPen); -} - -void tst_QAbstractAxis::axisPenColor_data() -{ -} - -void tst_QAbstractAxis::axisPenColor() -{ - QSKIP("Test is not implemented. This is depreciated function", SkipAll); -} - -void tst_QAbstractAxis::gridLinePen_data() -{ - - QTest::addColumn("gridLinePen"); - QTest::newRow("null") << QPen(); - QTest::newRow("blue") << QPen(Qt::blue); - QTest::newRow("black") << QPen(Qt::black); - QTest::newRow("red") << QPen(Qt::red); - -} - -void tst_QAbstractAxis::gridLinePen() -{ - QFETCH(QPen, gridLinePen); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setGridLinePen(gridLinePen); - QCOMPARE(m_axis->gridLinePen(), gridLinePen); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen); -} - -void tst_QAbstractAxis::lineVisible_data() -{ - QTest::addColumn("lineVisible"); - QTest::newRow("true") << true; - QTest::newRow("false") << false; -} - -void tst_QAbstractAxis::lineVisible() -{ - QFETCH(bool, lineVisible); - - m_axis->setLineVisible(!lineVisible); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setLineVisible(lineVisible); - QCOMPARE(m_axis->isLineVisible(), lineVisible); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->isLineVisible(), lineVisible); -} - -void tst_QAbstractAxis::gridLineVisible_data() -{ - QTest::addColumn("gridLineVisible"); - QTest::newRow("true") << true; - QTest::newRow("false") << false; -} - -void tst_QAbstractAxis::gridLineVisible() -{ - QFETCH(bool, gridLineVisible); - - m_axis->setGridLineVisible(!gridLineVisible); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setGridLineVisible(gridLineVisible); - QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible); - -} - -void tst_QAbstractAxis::visible_data() -{ - QTest::addColumn("visible"); - QTest::newRow("true") << true; - QTest::newRow("false") << false; -} - -void tst_QAbstractAxis::visible() -{ - QFETCH(bool, visible); - - m_axis->setVisible(!visible); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setVisible(visible); - QCOMPARE(m_axis->isVisible(), visible); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 1); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->isVisible(), true); -} - -void tst_QAbstractAxis::labelsAngle_data() -{ - QTest::addColumn("labelsAngle"); - QTest::newRow("0") << 0; - QTest::newRow("45") << 45; - QTest::newRow("90") << 90; -} - -void tst_QAbstractAxis::labelsAngle() -{ - QFETCH(int, labelsAngle); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setLabelsAngle(labelsAngle); - QCOMPARE(m_axis->labelsAngle(), labelsAngle); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->labelsAngle(), labelsAngle); -} - -void tst_QAbstractAxis::labelsBrush_data() -{ - QTest::addColumn("labelsBrush"); - QTest::newRow("null") << QBrush(); - QTest::newRow("blue") << QBrush(Qt::blue); - QTest::newRow("black") << QBrush(Qt::black); - -} - -void tst_QAbstractAxis::labelsBrush() -{ - - QFETCH(QBrush, labelsBrush); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setLabelsBrush(labelsBrush); - QCOMPARE(m_axis->labelsBrush(), labelsBrush); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - //TODO QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->labelsBrush(), labelsBrush); - -} - -void tst_QAbstractAxis::labelsColor_data() -{ - -} - -void tst_QAbstractAxis::labelsColor() -{ - QSKIP("Test is not implemented. This is depreciated function", SkipAll); -} - -void tst_QAbstractAxis::labelsFont_data() -{ - QTest::addColumn("labelsFont"); - QTest::newRow("null") << QFont(); - QTest::newRow("serif") << QFont("SansSerif"); -} - -void tst_QAbstractAxis::labelsFont() -{ - - QFETCH(QFont, labelsFont); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setLabelsFont(labelsFont); - QCOMPARE(m_axis->labelsFont(), labelsFont); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->labelsFont(), labelsFont); - -} - -void tst_QAbstractAxis::labelsPen_data() -{ - QTest::addColumn("labelsPen"); - QTest::newRow("null") << QPen(); - QTest::newRow("blue") << QPen(Qt::blue); - QTest::newRow("black") << QPen(Qt::black); - QTest::newRow("red") << QPen(Qt::red); -} - -void tst_QAbstractAxis::labelsPen() -{ - QFETCH(QPen, labelsPen); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setLabelsPen(labelsPen); - QCOMPARE(m_axis->labelsPen(), labelsPen); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - //TODO QCOMPARE(m_axis->labelsPen(), labelsPen); -} - -void tst_QAbstractAxis::labelsVisible_data() -{ - QTest::addColumn("labelsVisible"); - QTest::newRow("true") << true; - QTest::newRow("false") << false; -} - -void tst_QAbstractAxis::labelsVisible() -{ - QFETCH(bool, labelsVisible); - - m_axis->setLabelsVisible(!labelsVisible); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setLabelsVisible(labelsVisible); - QCOMPARE(m_axis->labelsVisible(), labelsVisible); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 1); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->labelsVisible(), labelsVisible); -} - -void tst_QAbstractAxis::orientation_data() -{ - QTest::addColumn("orientation"); - QTest::newRow("Vertical") << Qt::Vertical; - QTest::newRow("Horizontal") << Qt::Horizontal; -} - -void tst_QAbstractAxis::orientation() -{ - QFETCH(Qt::Orientation, orientation); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - if(orientation==Qt::Vertical){ - m_chart->setAxisY(m_axis,m_series); - }else{ - m_chart->setAxisX(m_axis,m_series); - } - QCOMPARE(m_axis->orientation(), orientation); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 1); - - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->orientation(), orientation); -} - -void tst_QAbstractAxis::setMax_data() -{ - //just check if it does not crash - QTest::addColumn("max"); - QTest::newRow("something") << QVariant("something"); - QTest::newRow("1.0") << QVariant(1.0); -} - -void tst_QAbstractAxis::setMax() -{ - QFETCH(QVariant, max); - m_axis->setMax(max); -} - -void tst_QAbstractAxis::setMin_data() -{ - //just check if it does not crash - QTest::addColumn("min"); - QTest::newRow("something") << QVariant("something"); - QTest::newRow("1.0") << QVariant(1.0); -} - -// public void setMin(QVariant const& min) -void tst_QAbstractAxis::setMin() -{ - QFETCH(QVariant, min); - m_axis->setMin(min); -} - -void tst_QAbstractAxis::setRange_data() -{ - //just check if it does not crash - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("something") << QVariant("something0") << QVariant("something1"); - QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0); -} - -// public void setRange(QVariant const& min, QVariant const& max) -void tst_QAbstractAxis::setRange() -{ - - QFETCH(QVariant, min); - QFETCH(QVariant, max); - m_axis->setRange(min,max); -} - -void tst_QAbstractAxis::shadesBorderColor_data() -{ - -} - -void tst_QAbstractAxis::shadesBorderColor() -{ - QSKIP("Test is not implemented. This is depreciated function", SkipAll); -} - -void tst_QAbstractAxis::shadesBrush_data() -{ - QTest::addColumn("shadesBrush"); - QTest::newRow("null") << QBrush(); - QTest::newRow("blue") << QBrush(Qt::blue); - QTest::newRow("black") << QBrush(Qt::black); -} - -void tst_QAbstractAxis::shadesBrush() -{ - QFETCH(QBrush, shadesBrush); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setShadesBrush(shadesBrush); - QCOMPARE(m_axis->shadesBrush(), shadesBrush); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - //TODO QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->shadesBrush(), shadesBrush); -} - -void tst_QAbstractAxis::shadesColor_data() -{ -} - -// public QColor shadesColor() const -void tst_QAbstractAxis::shadesColor() -{ - QSKIP("Test is not implemented. This is depreciated function", SkipAll); -} - -void tst_QAbstractAxis::shadesPen_data() -{ - QTest::addColumn("shadesPen"); - QTest::newRow("null") << QPen(); - QTest::newRow("blue") << QPen(Qt::blue); - QTest::newRow("black") << QPen(Qt::black); - QTest::newRow("red") << QPen(Qt::red); -} - -void tst_QAbstractAxis::shadesPen() -{ - QFETCH(QPen, shadesPen); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setShadesPen(shadesPen); - QCOMPARE(m_axis->shadesPen(), shadesPen); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->shadesPen(), shadesPen); -} - -void tst_QAbstractAxis::shadesVisible_data() -{ - QTest::addColumn("shadesVisible"); - QTest::newRow("true") << true; - QTest::newRow("false") << false; -} - -void tst_QAbstractAxis::shadesVisible() -{ - QFETCH(bool, shadesVisible); - - m_axis->setShadesVisible(!shadesVisible); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->setShadesVisible(shadesVisible); - QCOMPARE(m_axis->shadesVisible(), shadesVisible); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 1); - QCOMPARE(spy8.count(), 0); - - m_chart->setAxisX(m_axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_axis->shadesVisible(), shadesVisible); -} - -void tst_QAbstractAxis::show_data() -{ - -} - -void tst_QAbstractAxis::show() -{ - m_axis->hide(); - QCOMPARE(m_axis->isVisible(), false); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->show(); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 1); - QCOMPARE(m_axis->isVisible(), true); -} - -void tst_QAbstractAxis::hide_data() -{ - -} - -void tst_QAbstractAxis::hide() -{ - m_axis->show(); - QCOMPARE(m_axis->isVisible(),true); - - QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool))); - QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor))); - QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool))); - QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor))); - QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool))); - QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor))); - QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor))); - QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool))); - QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool))); - - m_axis->hide(); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - QCOMPARE(spy4.count(), 0); - QCOMPARE(spy5.count(), 0); - QCOMPARE(spy6.count(), 0); - QCOMPARE(spy7.count(), 0); - QCOMPARE(spy8.count(), 1); - QCOMPARE(m_axis->isVisible(),false); -} - - - - - - - - - - - - diff --git a/tests/auto/qabstractaxis/tst_qabstractaxis.h b/tests/auto/qabstractaxis/tst_qabstractaxis.h deleted file mode 100644 index 78c3d06..0000000 --- a/tests/auto/qabstractaxis/tst_qabstractaxis.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef TST_QABSTRACTAXIS_H -#define TST_QABSTRACTAXIS_H - -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class tst_QAbstractAxis : public QObject -{ - Q_OBJECT - -public slots: - virtual void initTestCase(); - virtual void cleanupTestCase(); - virtual void init(QAbstractAxis* axis,QAbstractSeries* series); - virtual void cleanup(); - -private slots: - void axisPen_data(); - void axisPen(); - void axisPenColor_data(); - void axisPenColor(); - void gridLinePen_data(); - void gridLinePen(); - void lineVisible_data(); - void lineVisible(); - void gridLineVisible_data(); - void gridLineVisible(); - void visible_data(); - void visible(); - void labelsAngle_data(); - void labelsAngle(); - void labelsBrush_data(); - void labelsBrush(); - void labelsColor_data(); - void labelsColor(); - void labelsFont_data(); - void labelsFont(); - void labelsPen_data(); - void labelsPen(); - void labelsVisible_data(); - void labelsVisible(); - void orientation_data(); - void orientation(); - void setMax_data(); - void setMax(); - void setMin_data(); - void setMin(); - void setRange_data(); - void setRange(); - void shadesBorderColor_data(); - void shadesBorderColor(); - void shadesBrush_data(); - void shadesBrush(); - void shadesColor_data(); - void shadesColor(); - void shadesPen_data(); - void shadesPen(); - void shadesVisible_data(); - void shadesVisible(); - void show_data(); - void show(); - void hide_data(); - void hide(); - -protected: - void qabstractaxis(); -protected: - QChartView* m_view; - QChart* m_chart; - QAbstractAxis* m_axis; - QAbstractSeries* m_series; -}; - -#endif diff --git a/tests/auto/qbarcategoryaxis/qbarcategoryaxis.pro b/tests/auto/qbarcategoryaxis/qbarcategoryaxis.pro deleted file mode 100644 index b80424a..0000000 --- a/tests/auto/qbarcategoryaxis/qbarcategoryaxis.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -HEADERS += ../qabstractaxis/tst_qabstractaxis.h -SOURCES += tst_qbarcategoryaxis.cpp ../qabstractaxis/tst_qabstractaxis.cpp diff --git a/tests/auto/qbarcategoryaxis/tst_qbarcategoryaxis.cpp b/tests/auto/qbarcategoryaxis/tst_qbarcategoryaxis.cpp deleted file mode 100644 index 2be7a7c..0000000 --- a/tests/auto/qbarcategoryaxis/tst_qbarcategoryaxis.cpp +++ /dev/null @@ -1,649 +0,0 @@ -/**************************************************************************** - ** - ** 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 "../qabstractaxis/tst_qabstractaxis.h" -#include -#include -#include - -class tst_QBarCategoriesAxis: public tst_QAbstractAxis -{ -Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qbarcategoryaxis_data(); - void qbarcategoryaxis(); - - void append_data(); - void append(); - void at_data(); - void at(); - void categories_data(); - void categories(); - void clear_data(); - void clear(); - void count_data(); - void count(); - void insert_data(); - void insert(); - void remove_data(); - void remove(); - void max_raw_data(); - void max_raw(); - void max_data(); - void max(); - void max_animation_data(); - void max_animation(); - void min_raw_data(); - void min_raw(); - void min_data(); - void min(); - void min_animation_data(); - void min_animation(); - void range_raw_data(); - void range_raw(); - void range_data(); - void range(); - void range_animation_data(); - void range_animation(); - void noautoscale_data(); - void noautoscale(); - void autoscale_data(); - void autoscale(); - -private: - QBarCategoryAxis* m_baraxis; - QBarSeries* m_series; -}; - -void tst_QBarCategoriesAxis::initTestCase() -{ -} - -void tst_QBarCategoriesAxis::cleanupTestCase() -{ -} - -void tst_QBarCategoriesAxis::init() -{ - m_baraxis = new QBarCategoryAxis(); - m_series = new QBarSeries(); - - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Samantha"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; - - m_series->append(set0); - m_series->append(set1); - m_series->append(set2); - m_series->append(set3); - m_series->append(set4); - - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - - m_baraxis->append(categories); - - tst_QAbstractAxis::init(m_baraxis, m_series); - m_chart->addSeries(m_series); - m_chart->createDefaultAxes(); -} - -void tst_QBarCategoriesAxis::cleanup() -{ - delete m_series; - delete m_baraxis; - m_series = 0; - m_baraxis = 0; - tst_QAbstractAxis::cleanup(); -} - -void tst_QBarCategoriesAxis::qbarcategoryaxis_data() -{ -} - -void tst_QBarCategoriesAxis::qbarcategoryaxis() -{ - qabstractaxis(); - QBarCategoryAxis axis; - axis.append(QStringList()); - axis.append(QString()); - QCOMPARE(axis.at(0), QString()); - QStringList test; - test.append(QString()); - QCOMPARE(axis.categories(),test); - axis.clear(); - QCOMPARE(axis.count(), 0); - axis.insert(-1, QString()); - QCOMPARE(axis.max(), QString()); - QCOMPARE(axis.min(), QString()); - axis.remove(QString()); - axis.setCategories(QStringList()); - axis.setMax(QString()); - axis.setMin(QString()); - axis.setRange(QString(), QString()); - QCOMPARE(axis.type(), QAbstractAxis::AxisTypeBarCategory); -} - -void tst_QBarCategoriesAxis::append_data() -{ - QTest::addColumn("categories"); - QTest::newRow("Jan Feb Mar Apr") << (QStringList() << "Jan" << "Feb" << "Mar" << "Apr"); - QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); -} - -void tst_QBarCategoriesAxis::append() -{ - QFETCH(QStringList, categories); - - QBarCategoryAxis axis; - - QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); - - axis.append(categories); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - - m_chart->setAxisX(&axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(axis.categories(), categories); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); -} - -void tst_QBarCategoriesAxis::at_data() -{ - QTest::addColumn("categories"); - QTest::addColumn("index"); - QTest::addColumn("string"); - QTest::newRow("Jul Aug Sep 0 Jul") << (QStringList() << "Jul" << "Aug" << "Sep") << 0 << "Jul"; - QTest::newRow("Jul Aug Sep 2 Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 2 << "Sep"; - QTest::newRow("Jul Aug Sep 1 Aug") << (QStringList() << "Jul" << "Aug" << "Sep") << 1 << "Aug"; -} - -void tst_QBarCategoriesAxis::at() -{ - QFETCH(int, index); - QFETCH(QString, string); - QFETCH(QStringList, categories); - - QBarCategoryAxis axis; - axis.append(categories); - - QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); - - QCOMPARE(axis.at(index), string); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - - m_chart->setAxisX(&axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(axis.at(index), string); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); -} - -void tst_QBarCategoriesAxis::categories_data() -{ - QTest::addColumn("categories"); - QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); -} - -void tst_QBarCategoriesAxis::categories() -{ - QFETCH(QStringList, categories); - - QBarCategoryAxis axis; - - QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); - - axis.setCategories(categories); - QCOMPARE(axis.categories(), categories); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - - m_chart->setAxisX(&axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(axis.categories(), categories); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - -} - -void tst_QBarCategoriesAxis::clear_data() -{ - QTest::addColumn("categories"); - QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); -} - -void tst_QBarCategoriesAxis::clear() -{ - QFETCH(QStringList, categories); - - QBarCategoryAxis axis; - - axis.setCategories(categories); - QCOMPARE(axis.categories(), categories); - - QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); - - axis.clear(); - QCOMPARE(axis.categories(), QStringList()); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - - m_chart->setAxisX(&axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - - QCOMPARE(spy0.count(), 2); - QCOMPARE(spy1.count(), 2); - QCOMPARE(spy2.count(), 2); - QCOMPARE(spy3.count(), 2); - - axis.clear(); - QCOMPARE(axis.categories().count(),0); - QCOMPARE(spy0.count(), 3); - QCOMPARE(spy1.count(), 3); - QCOMPARE(spy2.count(), 3); - QCOMPARE(spy3.count(), 3); -} - -void tst_QBarCategoriesAxis::count_data() -{ - QTest::addColumn("categories"); - QTest::addColumn("count"); - QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 3; - QTest::newRow("Jul Aug ") << (QStringList() << "Jul" << "Aug") << 2; -} - -void tst_QBarCategoriesAxis::count() -{ - QFETCH(QStringList, categories); - QFETCH(int, count); - - QBarCategoryAxis axis; - axis.setCategories(categories); - - QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); - - QCOMPARE(axis.count(), count); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - - m_chart->setAxisX(&axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(axis.count(), count); -} - -void tst_QBarCategoriesAxis::insert_data() -{ - QTest::addColumn("categories"); - QTest::addColumn("index"); - QTest::addColumn("category"); - QTest::newRow("Jul Aug Sep 0 Jun") << (QStringList() << "Jul" << "Aug" << "Sep") << 0 << "Jun"; - QTest::newRow("Jul Aug Sep 3 Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 3 << "Sep"; - QTest::newRow("Jul Aug Sep 2 Summer") << (QStringList() << "Jul" << "Aug" << "Sep") << 2 << "Summer"; -} - -void tst_QBarCategoriesAxis::insert() -{ - QFETCH(QStringList, categories); - QFETCH(int, index); - QFETCH(QString, category); - - QBarCategoryAxis axis; - axis.append(categories); - - QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); - - axis.insert(index, category); - QCOMPARE(axis.at(index),category); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 0); - - m_chart->setAxisX(&axis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); -} - -void tst_QBarCategoriesAxis::remove_data() -{ - QTest::addColumn("categories"); - QTest::addColumn("category"); - QTest::addColumn("result"); - QTest::newRow("Jul Aug Sep 0") << (QStringList() << "Jul" << "Aug" << "Sep") << "Jul" << (QStringList() << "Aug" << "Sep"); - QTest::newRow("Jul Aug Sep 1") << (QStringList() << "Jul" << "Aug" << "Sep") << "Aug"<< (QStringList() << "Jul" << "Sep"); -} - -void tst_QBarCategoriesAxis::remove() -{ - QFETCH(QStringList, categories); - QFETCH(QString, category); - QFETCH(QStringList, result); - - QBarCategoryAxis axis; - axis.append(categories); - - int maxCount = axis.max() == category; - int minCount = axis.min() == category; - int rangeCount = maxCount + minCount; - - QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(&axis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString const&, QString const&))); - - axis.remove(category); - QCOMPARE(axis.categories(),result); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), maxCount); - QCOMPARE(spy2.count(), minCount); - QCOMPARE(spy3.count(), rangeCount); -} - -void tst_QBarCategoriesAxis::max_raw_data() -{ - //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QTest::addColumn("max"); - QTest::newRow("Feb") << "Feb"; - QTest::newRow("Apr") << "Apr"; - QTest::newRow("May") << "May"; -} - -void tst_QBarCategoriesAxis::max_raw() -{ - QFETCH(QString, max); - - QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString const&, QString const&))); - - m_baraxis->setMax(max); - QCOMPARE(m_baraxis->max(), max); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 1); -} - -void tst_QBarCategoriesAxis::max_data() -{ - max_raw_data(); -} - -void tst_QBarCategoriesAxis::max() -{ - m_chart->setAxisX(m_baraxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - max_raw(); -} - -void tst_QBarCategoriesAxis::max_animation_data() -{ - max_data(); -} - -void tst_QBarCategoriesAxis::max_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - max(); -} - -void tst_QBarCategoriesAxis::min_raw_data() -{ - //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QTest::addColumn("min"); - QTest::newRow("Feb") << "Feb"; - QTest::newRow("Apr") << "Apr"; - QTest::newRow("May") << "May"; -} - -void tst_QBarCategoriesAxis::min_raw() -{ - QFETCH(QString, min); - - QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString const&, QString const&))); - - m_baraxis->setMin(min); - QCOMPARE(m_baraxis->min(), min); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - -} - -void tst_QBarCategoriesAxis::min_data() -{ - min_raw_data(); -} - -void tst_QBarCategoriesAxis::min() -{ - m_chart->setAxisX(m_baraxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - min_raw(); -} - -void tst_QBarCategoriesAxis::min_animation_data() -{ - min_data(); -} - -void tst_QBarCategoriesAxis::min_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - min(); -} - - -void tst_QBarCategoriesAxis::range_raw_data() -{ - //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("Feb - Apr") << "Feb" << "Apr"; - QTest::newRow("Feb - May") << "Feb" << "May"; - QTest::newRow("Mar - Apr") << "Mar" << "Apr"; -} - -void tst_QBarCategoriesAxis::range_raw() -{ - QFETCH(QString, min); - QFETCH(QString, max); - - QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); - QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString const&))); - QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString const&))); - QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString const&, QString const&))); - - m_baraxis->setRange(min, max); - QCOMPARE(m_baraxis->min(), min); - QCOMPARE(m_baraxis->max(), max); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); -} - -void tst_QBarCategoriesAxis::range_data() -{ - range_raw_data(); -} - -void tst_QBarCategoriesAxis::range() -{ - m_chart->setAxisX(m_baraxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - range_raw(); -} - -void tst_QBarCategoriesAxis::range_animation_data() -{ - range_data(); -} - -void tst_QBarCategoriesAxis::range_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - range(); -} - - -void tst_QBarCategoriesAxis::noautoscale_data() -{ - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("Feb - Mar") << "Feb" << "Mar"; - QTest::newRow("Feb - May") << "Feb" << "May"; - QTest::newRow("Apr - May") << "Apr" << "May"; -} - -void tst_QBarCategoriesAxis::noautoscale() -{ - QFETCH(QString, min); - QFETCH(QString, max); - - QSignalSpy spy0(m_baraxis, SIGNAL(maxChanged(QString))); - QSignalSpy spy1(m_baraxis, SIGNAL(minChanged(QString))); - QSignalSpy spy2(m_baraxis, SIGNAL(rangeChanged(QString, QString))); - - m_baraxis->setRange(min, max); - QCOMPARE(m_baraxis->min(),min); - QCOMPARE(m_baraxis->max(),max); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - - m_chart->setAxisX(m_baraxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_baraxis->min(),min); - QCOMPARE(m_baraxis->max(),max); -} - -void tst_QBarCategoriesAxis::autoscale_data() -{ - -} - -void tst_QBarCategoriesAxis::autoscale() -{ - delete m_baraxis; - m_baraxis = new QBarCategoryAxis(); - - QSignalSpy spy0(m_baraxis, SIGNAL(maxChanged(QString))); - QSignalSpy spy1(m_baraxis, SIGNAL(minChanged(QString))); - QSignalSpy spy2(m_baraxis, SIGNAL(rangeChanged(QString, QString))); - - QCOMPARE(m_baraxis->min(),QString()); - QCOMPARE(m_baraxis->max(),QString()); - m_chart->setAxisX(m_baraxis, m_series); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QCOMPARE(m_baraxis->min(),QString("1")); - QCOMPARE(m_baraxis->max(),QString("6")); -} - - -QTEST_MAIN(tst_QBarCategoriesAxis) -#include "tst_qbarcategoryaxis.moc" - diff --git a/tests/auto/qbarmodelmapper/qbarmodelmapper.pro b/tests/auto/qbarmodelmapper/qbarmodelmapper.pro deleted file mode 100644 index 6a15bc6..0000000 --- a/tests/auto/qbarmodelmapper/qbarmodelmapper.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} - -SOURCES += \ - tst_qbarmodelmapper.cpp diff --git a/tests/auto/qbarmodelmapper/tst_qbarmodelmapper.cpp b/tests/auto/qbarmodelmapper/tst_qbarmodelmapper.cpp deleted file mode 100644 index 0f4eebc..0000000 --- a/tests/auto/qbarmodelmapper/tst_qbarmodelmapper.cpp +++ /dev/null @@ -1,669 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class tst_qbarmodelmapper : public QObject -{ - Q_OBJECT - - public: - tst_qbarmodelmapper(); - void createVerticalMapper(); - void createHorizontalMapper(); - - private Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - void verticalMapper_data(); - void verticalMapper(); - void verticalMapperCustomMapping_data(); - void verticalMapperCustomMapping(); - void horizontalMapper_data(); - void horizontalMapper(); - void horizontalMapperCustomMapping_data(); - void horizontalMapperCustomMapping(); - void seriesUpdated(); - void verticalModelInsertRows(); - void verticalModelRemoveRows(); - void verticalModelInsertColumns(); - void verticalModelRemoveColumns(); - void horizontalModelInsertRows(); - void horizontalModelRemoveRows(); - void horizontalModelInsertColumns(); - void horizontalModelRemoveColumns(); - void modelUpdateCell(); - void verticalMapperSignals(); - void horizontalMapperSignals(); - - private: - QStandardItemModel *m_model; - int m_modelRowCount; - int m_modelColumnCount; - - QVBarModelMapper *m_vMapper; - QHBarModelMapper *m_hMapper; - - QBarSeries *m_series; - QChart *m_chart; -}; - -tst_qbarmodelmapper::tst_qbarmodelmapper(): - m_model(0), - m_modelRowCount(10), - m_modelColumnCount(8), - m_vMapper(0), - m_hMapper(0), - m_series(0), - m_chart(0) -{ -} - -void tst_qbarmodelmapper::createVerticalMapper() -{ - m_vMapper = new QVBarModelMapper; - QVERIFY(m_vMapper->model() == 0); - m_vMapper->setFirstBarSetColumn(0); - m_vMapper->setLastBarSetColumn(4); - m_vMapper->setModel(m_model); - m_vMapper->setSeries(m_series); -} - -void tst_qbarmodelmapper::createHorizontalMapper() -{ - m_hMapper = new QHBarModelMapper; - QVERIFY(m_hMapper->model() == 0); - m_hMapper->setFirstBarSetRow(0); - m_hMapper->setLastBarSetRow(4); - m_hMapper->setModel(m_model); - m_hMapper->setSeries(m_series); -} - -void tst_qbarmodelmapper::init() -{ - m_series = new QBarSeries; - m_chart->addSeries(m_series); - - m_model = new QStandardItemModel(m_modelRowCount, m_modelColumnCount, this); - for (int row = 0; row < m_modelRowCount; ++row) { - for (int column = 0; column < m_modelColumnCount; column++) { - m_model->setData(m_model->index(row, column), row * column); - } - } -} - -void tst_qbarmodelmapper::cleanup() -{ - m_chart->removeSeries(m_series); - delete m_series; - m_series = 0; - - m_model->clear(); - m_model->deleteLater(); - m_model = 0; - - if (m_vMapper) { - m_vMapper->deleteLater(); - m_vMapper = 0; - } - - if (m_hMapper) { - m_hMapper->deleteLater(); - m_hMapper = 0; - } -} - -void tst_qbarmodelmapper::initTestCase() -{ - m_chart = new QChart; - QChartView *chartView = new QChartView(m_chart); - chartView->show(); -} - -void tst_qbarmodelmapper::cleanupTestCase() -{ -} - -void tst_qbarmodelmapper::verticalMapper_data() -{ - QTest::addColumn("firstBarSetColumn"); - QTest::addColumn("lastBarSetColumn"); - QTest::addColumn("expectedBarSetCount"); - QTest::newRow("lastBarSetColumn greater than firstBarSetColumn") << 0 << 1 << 2; - QTest::newRow("lastBarSetColumn equal to firstBarSetColumn") << 1 << 1 << 1; - QTest::newRow("lastBarSetColumn lesser than firstBarSetColumn") << 1 << 0 << 0; - QTest::newRow("invalid firstBarSetColumn and correct lastBarSetColumn") << -3 << 1 << 0; - QTest::newRow("firstBarSetColumn beyond the size of model and correct lastBarSetColumn") << m_modelColumnCount << 1 << 0; - QTest::newRow("firstBarSetColumn beyond the size of model and invalid lastBarSetColumn") << m_modelColumnCount << -1 << 0; -} - -void tst_qbarmodelmapper::verticalMapper() -{ - QFETCH(int, firstBarSetColumn); - QFETCH(int, lastBarSetColumn); - QFETCH(int, expectedBarSetCount); - - m_series = new QBarSeries; - - QVBarModelMapper *mapper = new QVBarModelMapper; - mapper->setFirstBarSetColumn(firstBarSetColumn); - mapper->setLastBarSetColumn(lastBarSetColumn); - mapper->setModel(m_model); - mapper->setSeries(m_series); - - m_chart->addSeries(m_series); - - QCOMPARE(m_series->count(), expectedBarSetCount); - QCOMPARE(mapper->firstBarSetColumn(), qMax(-1, firstBarSetColumn)); - QCOMPARE(mapper->lastBarSetColumn(), qMax(-1, lastBarSetColumn)); - - delete mapper; - mapper = 0; -} - -void tst_qbarmodelmapper::verticalMapperCustomMapping_data() -{ - QTest::addColumn("first"); - QTest::addColumn("countLimit"); - QTest::addColumn("expectedBarSetCount"); - QTest::addColumn("expectedCount"); - QTest::newRow("first: 0, unlimited count") << 0 << -1 << 2 << m_modelRowCount; - QTest::newRow("first: 3, unlimited count") << 3 << -1 << 2 << m_modelRowCount - 3; - QTest::newRow("first: 0, count: 5") << 0 << 5 << 2 << qMin(5, m_modelRowCount); - QTest::newRow("first: 3, count: 5") << 3 << 5 << 2 << qMin(5, m_modelRowCount - 3); - QTest::newRow("first: +1 greater then the number of rows in the model, unlimited count") << m_modelRowCount + 1 << -1 << 0 << 0; - QTest::newRow("first: +1 greater then the number of rows in the model, count: 5") << m_modelRowCount + 1 << 5 << 0 << 0; - QTest::newRow("first: 0, count: +3 greater than the number of rows in the model (should limit to the size of model)") << 0 << m_modelRowCount + 3 << 2 << m_modelRowCount; - QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << 2 << m_modelRowCount; - QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << 2 << m_modelRowCount; - QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << 2 << m_modelRowCount; -} - -void tst_qbarmodelmapper::verticalMapperCustomMapping() -{ - QFETCH(int, first); - QFETCH(int, countLimit); - QFETCH(int, expectedBarSetCount); - QFETCH(int, expectedCount); - - m_series = new QBarSeries; - - QCOMPARE(m_series->count(), 0); - - QVBarModelMapper *mapper = new QVBarModelMapper; - mapper->setFirstBarSetColumn(0); - mapper->setLastBarSetColumn(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstRow(first); - mapper->setRowCount(countLimit); - m_chart->addSeries(m_series); - - QCOMPARE(m_series->count(), expectedBarSetCount); - - if (expectedBarSetCount > 0) - QCOMPARE(m_series->barSets().first()->count(), expectedCount); - - // change values column mapping to invalid - mapper->setFirstBarSetColumn(-1); - mapper->setLastBarSetColumn(1); - - QCOMPARE(m_series->count(), 0); - - delete mapper; - mapper = 0; -} - -void tst_qbarmodelmapper::horizontalMapper_data() -{ - QTest::addColumn("firstBarSetRow"); - QTest::addColumn("lastBarSetRow"); - QTest::addColumn("expectedBarSetCount"); - QTest::newRow("lastBarSetRow greater than firstBarSetRow") << 0 << 1 << 2; - QTest::newRow("lastBarSetRow equal to firstBarSetRow") << 1 << 1 << 1; - QTest::newRow("lastBarSetRow lesser than firstBarSetRow") << 1 << 0 << 0; - QTest::newRow("invalid firstBarSetRow and correct lastBarSetRow") << -3 << 1 << 0; - QTest::newRow("firstBarSetRow beyond the size of model and correct lastBarSetRow") << m_modelRowCount << 1 << 0; - QTest::newRow("firstBarSetRow beyond the size of model and invalid lastBarSetRow") << m_modelRowCount << -1 << 0; -} - -void tst_qbarmodelmapper::horizontalMapper() -{ - QFETCH(int, firstBarSetRow); - QFETCH(int, lastBarSetRow); - QFETCH(int, expectedBarSetCount); - - m_series = new QBarSeries; - - QHBarModelMapper *mapper = new QHBarModelMapper; - mapper->setFirstBarSetRow(firstBarSetRow); - mapper->setLastBarSetRow(lastBarSetRow); - mapper->setModel(m_model); - mapper->setSeries(m_series); - - m_chart->addSeries(m_series); - - QCOMPARE(m_series->count(), expectedBarSetCount); - QCOMPARE(mapper->firstBarSetRow(), qMax(-1, firstBarSetRow)); - QCOMPARE(mapper->lastBarSetRow(), qMax(-1, lastBarSetRow)); - - delete mapper; - mapper = 0; -} - -void tst_qbarmodelmapper::horizontalMapperCustomMapping_data() -{ - QTest::addColumn("first"); - QTest::addColumn("countLimit"); - QTest::addColumn("expectedBarSetCount"); - QTest::addColumn("expectedCount"); - QTest::newRow("first: 0, unlimited count") << 0 << -1 << 2 << m_modelColumnCount; - QTest::newRow("first: 3, unlimited count") << 3 << -1 << 2 << m_modelColumnCount - 3; - QTest::newRow("first: 0, count: 5") << 0 << 5 << 2 << qMin(5, m_modelColumnCount); - QTest::newRow("first: 3, count: 5") << 3 << 5 << 2 << qMin(5, m_modelColumnCount - 3); - QTest::newRow("first: +1 greater then the number of rows in the model, unlimited count") << m_modelColumnCount + 1 << -1 << 0 << 0; - QTest::newRow("first: +1 greater then the number of rows in the model, count: 5") << m_modelColumnCount + 1 << 5 << 0 << 0; - QTest::newRow("first: 0, count: +3 greater than the number of rows in the model (should limit to the size of model)") << 0 << m_modelColumnCount + 3 << 2 << m_modelColumnCount; - QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << 2 << m_modelColumnCount; - QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << 2 << m_modelColumnCount; - QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << 2 << m_modelColumnCount; -} - -void tst_qbarmodelmapper::horizontalMapperCustomMapping() -{ - QFETCH(int, first); - QFETCH(int, countLimit); - QFETCH(int, expectedBarSetCount); - QFETCH(int, expectedCount); - - m_series = new QBarSeries; - - QCOMPARE(m_series->count(), 0); - - QHBarModelMapper *mapper = new QHBarModelMapper; - mapper->setFirstBarSetRow(0); - mapper->setLastBarSetRow(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstColumn(first); - mapper->setColumnCount(countLimit); - m_chart->addSeries(m_series); - - QCOMPARE(m_series->count(), expectedBarSetCount); - - if (expectedBarSetCount > 0) - QCOMPARE(m_series->barSets().first()->count(), expectedCount); - - // change values column mapping to invalid - mapper->setFirstBarSetRow(-1); - mapper->setLastBarSetRow(1); - - QCOMPARE(m_series->count(), 0); - - delete mapper; - mapper = 0; -} - -void tst_qbarmodelmapper::seriesUpdated() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount); - QCOMPARE(m_vMapper->rowCount(), -1); - - m_series->barSets().first()->append(123); - QCOMPARE(m_model->rowCount(), m_modelRowCount + 1); - QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model - - m_series->barSets().last()->remove(0, m_modelRowCount); - QCOMPARE(m_model->rowCount(), 1); - QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model - - m_series->barSets().first()->replace(0, 444.0); - QCOMPARE(m_model->data(m_model->index(0, 0)).toReal(), 444.0); - - m_series->barSets().first()->setLabel("Hello"); - QCOMPARE(m_model->headerData(0, Qt::Horizontal).toString(), QString("Hello")); - - QList newValues; - newValues << 15 << 27 << 35 << 49; - m_series->barSets().first()->append(newValues); - QCOMPARE(m_model->rowCount(), 1 + newValues.count()); - - QList newBarSets; - QBarSet* newBarSet_1 = new QBarSet("New_1"); - newBarSet_1->append(101); - newBarSet_1->append(102); - newBarSet_1->append(103); - newBarSets.append(newBarSet_1); - - QBarSet* newBarSet_2 = new QBarSet("New_2"); - newBarSet_2->append(201); - newBarSet_2->append(202); - newBarSet_2->append(203); - newBarSets.append(newBarSet_2); - - m_series->append(newBarSets); - QCOMPARE(m_model->columnCount(), m_modelColumnCount + newBarSets.count()); -} - -void tst_qbarmodelmapper::verticalModelInsertRows() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int insertCount = 4; - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + insertCount); - - int first = 3; - m_vMapper->setFirstRow(3); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + insertCount - first); - - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + 2 * insertCount - first); - - int countLimit = 6; - m_vMapper->setRowCount(countLimit); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first)); - - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first)); - - m_vMapper->setFirstRow(0); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount)); - - m_vMapper->setRowCount(-1); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + 3 * insertCount); -} - -void tst_qbarmodelmapper::verticalModelRemoveRows() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int removeCount = 2; - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - removeCount); - - int first = 1; - m_vMapper->setFirstRow(first); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - removeCount - first); - - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - 2 * removeCount - first); - - int countLimit = 3; - m_vMapper->setRowCount(countLimit); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first)); - - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first)); - - m_vMapper->setFirstRow(0); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount)); - - m_vMapper->setRowCount(-1); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - 3 * removeCount); -} - -void tst_qbarmodelmapper::verticalModelInsertColumns() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int insertCount = 4; - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount); -} - -void tst_qbarmodelmapper::verticalModelRemoveColumns() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), qMin(m_model->columnCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1)); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int removeCount = m_modelColumnCount - 2; - m_model->removeColumns(0, removeCount); - QCOMPARE(m_series->count(), qMin(m_model->columnCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1)); - QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount); - - // leave all the columns - m_model->removeColumns(0, m_modelColumnCount - removeCount); - QCOMPARE(m_series->count(), 0); -} - -void tst_qbarmodelmapper::horizontalModelInsertRows() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int insertCount = 4; - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount); -} - -void tst_qbarmodelmapper::horizontalModelRemoveRows() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), qMin(m_model->rowCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1)); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int removeCount = m_modelRowCount - 2; - m_model->removeRows(0, removeCount); - QCOMPARE(m_series->count(), qMin(m_model->rowCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1)); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount); - - // leave all the columns - m_model->removeRows(0, m_modelRowCount - removeCount); - QCOMPARE(m_series->count(), 0); -} - -void tst_qbarmodelmapper::horizontalModelInsertColumns() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int insertCount = 4; - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + insertCount); - - int first = 3; - m_hMapper->setFirstColumn(3); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + insertCount - first); - - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + 2 * insertCount - first); - - int countLimit = 6; - m_hMapper->setColumnCount(countLimit); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first)); - - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first)); - - m_hMapper->setFirstColumn(0); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount)); - - m_hMapper->setColumnCount(-1); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + 3 * insertCount); -} - -void tst_qbarmodelmapper::horizontalModelRemoveColumns() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int removeCount = 2; - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - removeCount); - - int first = 1; - m_hMapper->setFirstColumn(first); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - removeCount - first); - - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - 2 * removeCount - first); - - int countLimit = 3; - m_hMapper->setColumnCount(countLimit); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first)); - - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first)); - - m_hMapper->setFirstColumn(0); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount)); - - m_hMapper->setColumnCount(-1); - QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1); - QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - 3 * removeCount); -} - -void tst_qbarmodelmapper::modelUpdateCell() -{ - // setup the mapper - createVerticalMapper(); - - QVERIFY(m_model->setData(m_model->index(1, 0), 44)); - QCOMPARE(m_series->barSets().at(0)->at(1), 44.0); - QCOMPARE(m_model->data(m_model->index(1, 0)).toReal(), 44.0); -} - -void tst_qbarmodelmapper::verticalMapperSignals() -{ - QVBarModelMapper *mapper = new QVBarModelMapper; - - QSignalSpy spy0(mapper, SIGNAL(firstRowChanged())); - QSignalSpy spy1(mapper, SIGNAL(rowCountChanged())); - QSignalSpy spy2(mapper, SIGNAL(firstBarSetColumnChanged())); - QSignalSpy spy3(mapper, SIGNAL(lastBarSetColumnChanged())); - QSignalSpy spy4(mapper, SIGNAL(modelReplaced())); - QSignalSpy spy5(mapper, SIGNAL(seriesReplaced())); - - mapper->setFirstBarSetColumn(0); - mapper->setLastBarSetColumn(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstRow(1); - mapper->setRowCount(5); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - QCOMPARE(spy4.count(), 1); - QCOMPARE(spy5.count(), 1); - -} - -void tst_qbarmodelmapper::horizontalMapperSignals() -{ - QHBarModelMapper *mapper = new QHBarModelMapper; - - QSignalSpy spy0(mapper, SIGNAL(firstColumnChanged())); - QSignalSpy spy1(mapper, SIGNAL(columnCountChanged())); - QSignalSpy spy2(mapper, SIGNAL(firstBarSetRowChanged())); - QSignalSpy spy3(mapper, SIGNAL(lastBarSetRowChanged())); - QSignalSpy spy4(mapper, SIGNAL(modelReplaced())); - QSignalSpy spy5(mapper, SIGNAL(seriesReplaced())); - - mapper->setFirstBarSetRow(0); - mapper->setLastBarSetRow(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstColumn(1); - mapper->setColumnCount(5); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - QCOMPARE(spy4.count(), 1); - QCOMPARE(spy5.count(), 1); -} - -QTEST_MAIN(tst_qbarmodelmapper) - -#include "tst_qbarmodelmapper.moc" diff --git a/tests/auto/qbarseries/qbarseries.pro b/tests/auto/qbarseries/qbarseries.pro deleted file mode 100644 index ec5d64c..0000000 --- a/tests/auto/qbarseries/qbarseries.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qbarseries.cpp diff --git a/tests/auto/qbarseries/tst_qbarseries.cpp b/tests/auto/qbarseries/tst_qbarseries.cpp deleted file mode 100644 index 3d2c18a..0000000 --- a/tests/auto/qbarseries/tst_qbarseries.cpp +++ /dev/null @@ -1,619 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include "tst_definitions.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(QBarSet*) -Q_DECLARE_METATYPE(QList) - -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 append_data(); - void append(); - void remove_data(); - void remove(); - void take_data(); - void take(); - void appendList_data(); - void appendList(); - void count_data(); - void count(); - void barSets_data(); - void barSets(); - void setLabelsVisible_data(); - void setLabelsVisible(); - void mouseclicked_data(); - void mouseclicked(); - void mousehovered_data(); - void mousehovered(); - void clearWithAnimations(); - void destruction(); - -private: - QBarSeries* m_barseries; - QBarSeries* m_barseries_with_sets; - - QList m_testSets; - -}; - -void tst_QBarSeries::initTestCase() -{ - qRegisterMetaType("QBarSet*"); - qRegisterMetaType >("QList"); -} - -void tst_QBarSeries::cleanupTestCase() -{ -} - -void tst_QBarSeries::init() -{ - m_barseries = new QBarSeries(); - m_barseries_with_sets = new QBarSeries(); - - for (int i=0; i<5; i++) { - m_testSets.append(new QBarSet("testset")); - m_barseries_with_sets->append(m_testSets.at(i)); - } -} - -void tst_QBarSeries::cleanup() -{ - foreach(QBarSet* s, m_testSets) { - m_barseries_with_sets->remove(s); - } - m_testSets.clear(); - - delete m_barseries; - m_barseries = 0; - delete m_barseries_with_sets; - m_barseries_with_sets = 0; -} - -void tst_QBarSeries::qbarseries_data() -{ -} - -void tst_QBarSeries::qbarseries() -{ - QBarSeries *barseries = new QBarSeries(); - QVERIFY(barseries != 0); -} - -void tst_QBarSeries::type_data() -{ - -} - -void tst_QBarSeries::type() -{ - QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar); -} - -void tst_QBarSeries::append_data() -{ -} - -void tst_QBarSeries::append() -{ - QVERIFY(m_barseries->count() == 0); - - bool ret = false; - - // Try adding barset - QBarSet *barset = new QBarSet("testset"); - ret = m_barseries->append(barset); - - QVERIFY(ret == true); - QVERIFY(m_barseries->count() == 1); - - // Try adding another set - QBarSet *barset2 = new QBarSet("testset2"); - ret = m_barseries->append(barset2); - - QVERIFY(ret == true); - QVERIFY(m_barseries->count() == 2); - - // Try adding same set again - ret = m_barseries->append(barset2); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == 2); - - // Try adding null set - ret = m_barseries->append(0); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == 2); - -} - -void tst_QBarSeries::remove_data() -{ -} - -void tst_QBarSeries::remove() -{ - int count = m_testSets.count(); - QVERIFY(m_barseries_with_sets->count() == count); - - // Try to remove null pointer (should not remove, should not crash) - bool ret = false; - ret = m_barseries_with_sets->remove(0); - QVERIFY(ret == false); - QVERIFY(m_barseries_with_sets->count() == count); - - // Try to remove invalid pointer (should not remove, should not crash) - ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) ); - QVERIFY(ret == false); - QVERIFY(m_barseries_with_sets->count() == count); - - // remove some sets - ret = m_barseries_with_sets->remove(m_testSets.at(2)); - QVERIFY(ret == true); - ret = m_barseries_with_sets->remove(m_testSets.at(3)); - QVERIFY(ret == true); - ret = m_barseries_with_sets->remove(m_testSets.at(4)); - QVERIFY(ret == true); - - QVERIFY(m_barseries_with_sets->count() == 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 (should be ok, even if some sets have already been removed) - ret = false; - for (int i=0; iremove(m_testSets.at(i)); - } - - QVERIFY(ret == true); - QVERIFY(m_barseries_with_sets->count() == 0); -} - -void tst_QBarSeries::take_data() -{ - -} - -void tst_QBarSeries::take() -{ - int count = m_testSets.count(); - QVERIFY(m_barseries_with_sets->count() == count); - - QSignalSpy countSpy(m_barseries_with_sets,SIGNAL(countChanged())); - QSignalSpy removedSpy(m_barseries_with_sets,SIGNAL(barsetsRemoved(QList))); - - for (int i=0; itake(set); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QVERIFY(success); - TRY_COMPARE(countSpy.count(),1); - TRY_COMPARE(removedSpy.count(),1); - - QList removedSpyArg = removedSpy.takeFirst(); - QList removedSets = qvariant_cast > (removedSpyArg.at(0)); - QCOMPARE(removedSets.at(0), m_testSets.at(i)); - countSpy.takeFirst(); - } -} - - -void tst_QBarSeries::appendList_data() -{ - -} - -void tst_QBarSeries::appendList() -{ - int count = 5; - QVERIFY(m_barseries->count() == 0); - - QList sets; - for (int i=0; iappend(sets); - QVERIFY(ret == true); - QVERIFY(m_barseries->count() == count); - - // Append same sets again (should fail, count should remain same) - ret = m_barseries->append(sets); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == count); - - // Try append empty list (should succeed, but count should remain same) - QList invalidList; - ret = m_barseries->append(invalidList); - QVERIFY(ret == true); - QVERIFY(m_barseries->count() == count); - - // 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)); - ret = m_barseries->append(invalidList); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == count); - - // Try append list with null pointers (should fail, count remains same) - QList invalidList2; - invalidList2.append(0); - invalidList2.append(0); - invalidList2.append(0); - ret = m_barseries->append(invalidList2); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == count); -} - -void tst_QBarSeries::count_data() -{ - -} - -void tst_QBarSeries::count() -{ - QVERIFY(m_barseries->count() == 0); - QVERIFY(m_barseries_with_sets->count() == m_testSets.count()); -} - -void tst_QBarSeries::barSets_data() -{ - -} - -void tst_QBarSeries::barSets() -{ - QVERIFY(m_barseries->barSets().count() == 0); - - QList sets = m_barseries_with_sets->barSets(); - QVERIFY(sets.count() == m_testSets.count()); - - for (int i=0; iisLabelsVisible() == false); - QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); - - // turn labels to visible - m_barseries_with_sets->setLabelsVisible(true); - // TODO: test the signal - QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); - - // turn labels to invisible - m_barseries_with_sets->setLabelsVisible(false); - // TODO: test the signal - QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); - - // without parameter, should turn labels to visible - m_barseries_with_sets->setLabelsVisible(); - // TODO: test the signal - QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); -} - -void tst_QBarSeries::mouseclicked_data() -{ - -} - -void tst_QBarSeries::mouseclicked() -{ - QBarSeries* series = new QBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(clicked(int,QBarSet*))); - QSignalSpy setSpy1(set1, SIGNAL(clicked(int))); - QSignalSpy setSpy2(set2, SIGNAL(clicked(int))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - -//==================================================================================== -// barset 1, bar 0 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(95,143)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 1, bar 1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(187,143)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 1, bar 2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,143)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); - - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 2); - -//==================================================================================== -// barset 2, bar 0 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(118,143)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 2, bar 1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(210,143)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 2, bar 2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(303,143)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 2); -} - -void tst_QBarSeries::mousehovered_data() -{ - -} - -void tst_QBarSeries::mousehovered() -{ - QBarSeries* series = new QBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(hovered(bool,QBarSet*))); - QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); - QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - //this is hack since view does not get events otherwise - view.setMouseTracking(true); - -//======================================================================= -// move mouse to left border - QTest::mouseMove(view.viewport(), QPoint(0, 143)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - TRY_COMPARE(seriesSpy.count(), 0); - TRY_COMPARE(setSpy1.count(), 0); - TRY_COMPARE(setSpy2.count(), 0); - -//======================================================================= -// move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(95,143)); - TRY_COMPARE(seriesSpy.count(), 1); - TRY_COMPARE(setSpy1.count(), 1); - TRY_COMPARE(setSpy2.count(), 0); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(118,143)); - TRY_COMPARE(seriesSpy.count(), 2); - TRY_COMPARE(setSpy1.count(), 1); - TRY_COMPARE(setSpy2.count(), 1); - - // should leave set1 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); - - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should enter set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(118,0)); - TRY_COMPARE(seriesSpy.count(), 1); - TRY_COMPARE(setSpy1.count(), 0); - TRY_COMPARE(setSpy2.count(), 1); - - // should leave set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); -} - -void tst_QBarSeries::clearWithAnimations() -{ - QBarSeries* series = new QBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 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(); -} - -void tst_QBarSeries::destruction() -{ - // add a barset - QBarSeries *series = new QBarSeries(); - QBarSet *set = new QBarSet("testset"); - QSignalSpy spy1(set, SIGNAL(destroyed())); - series->append(set); - - // delete the series - delete series; - - // check that series deletes the set - QCOMPARE(spy1.count(), 1); -} - -QTEST_MAIN(tst_QBarSeries) - -#include "tst_qbarseries.moc" - diff --git a/tests/auto/qbarset/qbarset.pro b/tests/auto/qbarset/qbarset.pro deleted file mode 100644 index 2436301..0000000 --- a/tests/auto/qbarset/qbarset.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qbarset.cpp diff --git a/tests/auto/qbarset/tst_qbarset.cpp b/tests/auto/qbarset/tst_qbarset.cpp deleted file mode 100644 index 9e049a2..0000000 --- a/tests/auto/qbarset/tst_qbarset.cpp +++ /dev/null @@ -1,519 +0,0 @@ -/**************************************************************************** -** -** 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 -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class tst_QBarSet : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qbarset_data(); - void qbarset(); - void label_data(); - void label(); - void append_data(); - void append(); - void appendOperator_data(); - void appendOperator(); - void insert_data(); - void insert(); - void remove_data(); - void remove(); - void replace_data(); - void replace(); - void at_data(); - void at(); - void atOperator_data(); - void atOperator(); - void count_data(); - void count(); - void sum_data(); - void sum(); - void customize(); - -private: - QBarSet* m_barset; -}; - -void tst_QBarSet::initTestCase() -{ -} - -void tst_QBarSet::cleanupTestCase() -{ -} - -void tst_QBarSet::init() -{ - m_barset = new QBarSet(QString("label")); -} - -void tst_QBarSet::cleanup() -{ - delete m_barset; - m_barset = 0; -} - -void tst_QBarSet::qbarset_data() -{ -} - -void tst_QBarSet::qbarset() -{ - QBarSet barset(QString("label")); - QCOMPARE(barset.label(), QString("label")); - QCOMPARE(barset.count(), 0); - QVERIFY(qFuzzyIsNull(barset.sum())); -} - -void tst_QBarSet::label_data() -{ - QTest::addColumn ("label"); - QTest::addColumn ("result"); - QTest::newRow("label0") << QString("label0") << QString("label0"); - QTest::newRow("label1") << QString("label1") << QString("label1"); -} - -void tst_QBarSet::label() -{ - QFETCH(QString, label); - QFETCH(QString, result); - - QSignalSpy labelSpy(m_barset,SIGNAL(labelChanged())); - m_barset->setLabel(label); - QCOMPARE(m_barset->label(), result); - QVERIFY(labelSpy.count() == 1); -} - -void tst_QBarSet::append_data() -{ - QTest::addColumn ("count"); - QTest::newRow("0") << 0; - QTest::newRow("5") << 5; - QTest::newRow("100") << 100; - QTest::newRow("1000") << 1000; -} - -void tst_QBarSet::append() -{ - QFETCH(int, count); - - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - - QSignalSpy valueSpy(m_barset, SIGNAL(valuesAdded(int,int))); - - qreal sum(0.0); - qreal value(0.0); - - for (int i=0; iappend(value); - QCOMPARE(m_barset->at(i), value); - sum += value; - value += 1.0; - } - - QCOMPARE(m_barset->count(), count); - QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); - - QCOMPARE(valueSpy.count(), count); -} - -void tst_QBarSet::appendOperator_data() -{ - append_data(); -} - -void tst_QBarSet::appendOperator() -{ - QFETCH(int, count); - - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - - QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); - - qreal sum(0.0); - qreal value(0.0); - - for (int i=0; iat(i), value); - sum += value; - value += 1.0; - } - - QCOMPARE(m_barset->count(), count); - QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); - QCOMPARE(valueSpy.count(), count); -} - -void tst_QBarSet::insert_data() -{ -} - -void tst_QBarSet::insert() -{ - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); - - m_barset->insert(0, 1.0); // 1.0 - QCOMPARE(m_barset->at(0), 1.0); - QCOMPARE(m_barset->count(), 1); - QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)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); - QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)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); - QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)6.0)); - QCOMPARE(valueSpy.count(), 3); -} - -void tst_QBarSet::remove_data() -{ -} - -void tst_QBarSet::remove() -{ - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - - QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int))); - - m_barset->append(1.0); - m_barset->append(2.0); - m_barset->append(3.0); - m_barset->append(4.0); - - QCOMPARE(m_barset->count(), 4); - QCOMPARE(m_barset->sum(), 10.0); - - // Remove middle - m_barset->remove(2); // 1.0 2.0 4.0 - QCOMPARE(m_barset->at(0), 1.0); - QCOMPARE(m_barset->at(1), 2.0); - QCOMPARE(m_barset->at(2), 4.0); - QCOMPARE(m_barset->count(), 3); - QCOMPARE(m_barset->sum(), 7.0); - QCOMPARE(valueSpy.count(), 1); - - QList valueSpyArg = valueSpy.takeFirst(); - // Verify index of removed signal - QVERIFY(valueSpyArg.at(0).type() == QVariant::Int); - QVERIFY(valueSpyArg.at(0).toInt() == 2); - // Verify count of removed signal - QVERIFY(valueSpyArg.at(1).type() == QVariant::Int); - QVERIFY(valueSpyArg.at(1).toInt() == 1); - - // Remove first - m_barset->remove(0); // 2.0 4.0 - QCOMPARE(m_barset->at(0), 2.0); - QCOMPARE(m_barset->at(1), 4.0); - QCOMPARE(m_barset->count(), 2); - QCOMPARE(m_barset->sum(), 6.0); - - QCOMPARE(valueSpy.count(), 1); - valueSpyArg = valueSpy.takeFirst(); - // Verify index of removed signal - QVERIFY(valueSpyArg.at(0).type() == QVariant::Int); - QVERIFY(valueSpyArg.at(0).toInt() == 0); - // Verify count of removed signal - QVERIFY(valueSpyArg.at(1).type() == QVariant::Int); - QVERIFY(valueSpyArg.at(1).toInt() == 1); - - - // Illegal indexes - m_barset->remove(4); - QCOMPARE(m_barset->count(), 2); - QCOMPARE(m_barset->sum(), 6.0); - m_barset->remove(-1); - QCOMPARE(m_barset->count(), 2); - QCOMPARE(m_barset->sum(), 6.0); - - // nothing removed, no signals should be emitted - QCOMPARE(valueSpy.count(), 0); - - // Remove more items than list has - m_barset->remove(0,312); - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - - QCOMPARE(valueSpy.count(), 1); - valueSpyArg = valueSpy.takeFirst(); - - // Verify index of removed signal - QVERIFY(valueSpyArg.at(0).type() == QVariant::Int); - QVERIFY(valueSpyArg.at(0).toInt() == 0); - // Verify count of removed signal (expect 2 values removed, because list had only 2 items) - QVERIFY(valueSpyArg.at(1).type() == QVariant::Int); - QVERIFY(valueSpyArg.at(1).toInt() == 2); -} - -void tst_QBarSet::replace_data() -{ - -} - -void tst_QBarSet::replace() -{ - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - QSignalSpy valueSpy(m_barset,SIGNAL(valueChanged(int))); - - m_barset->append(1.0); - m_barset->append(2.0); - m_barset->append(3.0); - m_barset->append(4.0); - - QCOMPARE(m_barset->count(), 4); - QCOMPARE(m_barset->sum(), 10.0); - - // Replace first - m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0 - QCOMPARE(m_barset->count(), 4); - QCOMPARE(m_barset->sum(), 14.0); - QCOMPARE(m_barset->at(0), 5.0); - - // Replace last - m_barset->replace(3, 6.0); - QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 - QCOMPARE(m_barset->sum(), 16.0); - QCOMPARE(m_barset->at(0), 5.0); - QCOMPARE(m_barset->at(1), 2.0); - QCOMPARE(m_barset->at(2), 3.0); - QCOMPARE(m_barset->at(3), 6.0); - - // Illegal indexes - m_barset->replace(4, 6.0); - QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 - QCOMPARE(m_barset->sum(), 16.0); - m_barset->replace(-1, 6.0); - QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 - QCOMPARE(m_barset->sum(), 16.0); - m_barset->replace(4, 1.0); - QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 - QCOMPARE(m_barset->sum(), 16.0); - m_barset->replace(-1, 1.0); - QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 - QCOMPARE(m_barset->sum(), 16.0); - - QVERIFY(valueSpy.count() == 2); -} - -void tst_QBarSet::at_data() -{ - -} - -void tst_QBarSet::at() -{ - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - - m_barset->append(1.0); - m_barset->append(2.0); - m_barset->append(3.0); - m_barset->append(4.0); - - QCOMPARE(m_barset->at(0), 1.0); - QCOMPARE(m_barset->at(1), 2.0); - QCOMPARE(m_barset->at(2), 3.0); - QCOMPARE(m_barset->at(3), 4.0); -} - -void tst_QBarSet::atOperator_data() -{ - -} - -void tst_QBarSet::atOperator() -{ - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - - m_barset->append(1.0); - m_barset->append(2.0); - m_barset->append(3.0); - m_barset->append(4.0); - - QCOMPARE(m_barset->operator [](0), 1.0); - QCOMPARE(m_barset->operator [](1), 2.0); - QCOMPARE(m_barset->operator [](2), 3.0); - QCOMPARE(m_barset->operator [](3), 4.0); -} - -void tst_QBarSet::count_data() -{ - -} - -void tst_QBarSet::count() -{ - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - - m_barset->append(1.0); - QCOMPARE(m_barset->count(),1); - m_barset->append(2.0); - QCOMPARE(m_barset->count(),2); - m_barset->append(3.0); - QCOMPARE(m_barset->count(),3); - m_barset->append(4.0); - QCOMPARE(m_barset->count(),4); -} - -void tst_QBarSet::sum_data() -{ - -} - -void tst_QBarSet::sum() -{ - QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); - - m_barset->append(1.0); - QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)1.0)); - m_barset->append(2.0); - QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)3.0)); - m_barset->append(3.0); - QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)6.0)); - m_barset->append(4.0); - QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)10.0)); -} - -void tst_QBarSet::customize() -{ - // Create sets - QBarSet *set1 = new QBarSet("set1"); - QBarSet *set2 = new QBarSet("set2"); - - // Append set1 to series - QBarSeries *series = new QBarSeries(); - bool success = series->append(set1); - QVERIFY(success); - - // Add series to the chart - QChartView view(new QChart()); - view.resize(200, 200); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - // Test adding data to the sets - *set1 << 1 << 2 << 1 << 3; - *set2 << 2 << 1 << 3 << 1; - - // Remove sets from series - series->take(set1); - series->take(set2); - - // Test pen - QVERIFY(set1->pen() != QPen()); - QVERIFY(set2->pen() == QPen()); - QPen pen(QColor(128,128,128,128)); - set1->setPen(pen); - - // Add sets back to series - series->append(set1); - series->append(set2); - - QVERIFY(set1->pen() == pen); // Should be customized - QVERIFY(set2->pen() != QPen()); // Should be decorated by theme - - // Remove sets from series - series->take(set1); - series->take(set2); - - // Test brush - set2->setBrush(QBrush()); - QVERIFY(set1->brush() != QBrush()); - QVERIFY(set2->brush() == QBrush()); - QBrush brush(QColor(128,128,128,128)); - set1->setBrush(brush); - - // Add sets back to series - series->append(set1); - series->append(set2); - - QVERIFY(set1->brush() == brush); // Should be customized - QVERIFY(set2->brush() != QBrush()); // Should be decorated by theme - - // Remove sets from series - series->take(set1); - series->take(set2); - - // Test label brush - set2->setLabelBrush(QBrush()); - QVERIFY(set1->labelBrush() != QBrush()); - QVERIFY(set2->labelBrush() == QBrush()); - set1->setLabelBrush(brush); - - series->append(set1); - series->append(set2); - QVERIFY(set1->labelBrush() == brush); // Should be customized - QVERIFY(set2->labelBrush() != QBrush()); // Should be decorated by theme - - // Test label font - // Note: QFont empty constructor creates font with application's default font, so the font may or may not be the - // same for the set added to the series (depending on the QChart's theme configuration) - QVERIFY(set1->labelFont() != QFont() || set1->labelFont() == QFont()); - QVERIFY(set2->labelFont() == QFont()); - QFont font; - font.setBold(true); - font.setItalic(true); - set1->setLabelFont(font); - QVERIFY(set1->labelFont() == font); - QVERIFY(set2->labelFont() == QFont()); - - // Test adding data to the sets - *set1 << 1 << 2 << 1 << 3; - *set2 << 2 << 1 << 3 << 1; - -} - - - - -QTEST_MAIN(tst_QBarSet) - -#include "tst_qbarset.moc" - diff --git a/tests/auto/qcategoryaxis/qcategoryaxis.pro b/tests/auto/qcategoryaxis/qcategoryaxis.pro deleted file mode 100644 index 3f662bb..0000000 --- a/tests/auto/qcategoryaxis/qcategoryaxis.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -HEADERS += ../qabstractaxis/tst_qabstractaxis.h -SOURCES += tst_qcategoryaxis.cpp ../qabstractaxis/tst_qabstractaxis.cpp diff --git a/tests/auto/qcategoryaxis/tst_qcategoryaxis.cpp b/tests/auto/qcategoryaxis/tst_qcategoryaxis.cpp deleted file mode 100644 index 4c7e7c2..0000000 --- a/tests/auto/qcategoryaxis/tst_qcategoryaxis.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/**************************************************************************** - ** - ** 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 "../qabstractaxis/tst_qabstractaxis.h" -#include "qcategoryaxis.h" -#include - -class tst_QCategoryAxis: public tst_QAbstractAxis -{ -Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qcategoryaxis_data(); - void qcategoryaxis(); - - void max_raw_data(); - void max_raw(); - void max_data(); - void max(); - void max_animation_data(); - void max_animation(); - void min_raw_data(); - void min_raw(); - void min_data(); - void min(); - void min_animation_data(); - void min_animation(); - void range_raw_data(); - void range_raw(); - void range_data(); - void range(); - void range_animation_data(); - void range_animation(); - - void interval_data(); - void interval(); - -private: - QCategoryAxis* m_categoryaxis; - QLineSeries* m_series; -}; - -void tst_QCategoryAxis::initTestCase() -{ -} - -void tst_QCategoryAxis::cleanupTestCase() -{ -} - -void tst_QCategoryAxis::init() -{ - m_categoryaxis = new QCategoryAxis(); - m_series = new QLineSeries(); - *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100); - tst_QAbstractAxis::init(m_categoryaxis, m_series); - m_chart->addSeries(m_series); - m_chart->createDefaultAxes(); -} - -void tst_QCategoryAxis::cleanup() -{ - delete m_series; - delete m_categoryaxis; - m_series = 0; - m_categoryaxis = 0; - tst_QAbstractAxis::cleanup(); -} - -void tst_QCategoryAxis::qcategoryaxis_data() -{ -} - -void tst_QCategoryAxis::qcategoryaxis() -{ - qabstractaxis(); - - QVERIFY(qFuzzyIsNull(m_categoryaxis->max())); - QVERIFY(qFuzzyIsNull(m_categoryaxis->min())); - QCOMPARE(m_categoryaxis->type(), QAbstractAxis::AxisTypeCategory); - - m_chart->setAxisX(m_categoryaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - - QVERIFY(!qFuzzyIsNull(m_categoryaxis->max())); - QVERIFY(!qFuzzyIsNull(m_categoryaxis->min())); -} - -void tst_QCategoryAxis::max_raw_data() -{ - QTest::addColumn("max"); - QTest::newRow("1.0") << (qreal)1.0; - QTest::newRow("50.0") << (qreal)50.0; - QTest::newRow("101.0") << (qreal)101.0; -} - -void tst_QCategoryAxis::max_raw() -{ - QFETCH(qreal, max); - - QSignalSpy spy0(m_categoryaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_categoryaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_categoryaxis->setMax(max); - QVERIFY2(qFuzzyIsNull(m_categoryaxis->max() - max), "Not equal"); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 1); -} - -void tst_QCategoryAxis::max_data() -{ - max_raw_data(); -} - -void tst_QCategoryAxis::max() -{ - m_chart->setAxisX(m_categoryaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - max_raw(); -} - -void tst_QCategoryAxis::max_animation_data() -{ - max_data(); -} - -void tst_QCategoryAxis::max_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - max(); -} - -void tst_QCategoryAxis::min_raw_data() -{ - QTest::addColumn("min"); - QTest::newRow("-1.0") << (qreal)-1.0; - QTest::newRow("-50.0") << (qreal)-50.0; - QTest::newRow("-101.0") << (qreal)-101.0; -} - -void tst_QCategoryAxis::min_raw() -{ - QFETCH(qreal, min); - - QSignalSpy spy0(m_categoryaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_categoryaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_categoryaxis->setMin(min); - QVERIFY2(qFuzzyIsNull(m_categoryaxis->min() - min), "Not equal"); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); -} - -void tst_QCategoryAxis::min_data() -{ - min_raw_data(); -} - -void tst_QCategoryAxis::min() -{ - m_chart->setAxisX(m_categoryaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - min_raw(); -} - -void tst_QCategoryAxis::min_animation_data() -{ - min_data(); -} - -void tst_QCategoryAxis::min_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - min(); -} - -void tst_QCategoryAxis::range_raw_data() -{ - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0; - QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0; - QTest::newRow("101.0") << (qreal)40.0 << (qreal)60.0; - QTest::newRow("-35.0 - 0.0") << (qreal)-35.0 << (qreal)10.0; - QTest::newRow("-35.0 - 0.0") << (qreal)-35.0 << (qreal)-15.0; - QTest::newRow("0.0 - 0.0") << (qreal)-0.1 << (qreal)0.1; -} - -void tst_QCategoryAxis::range_raw() -{ - QFETCH(qreal, min); - QFETCH(qreal, max); - - QSignalSpy spy0(m_categoryaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_categoryaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_categoryaxis->setRange(min, max); - QVERIFY2(qFuzzyIsNull(m_categoryaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_categoryaxis->max() - max), "Max not equal"); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); -} - -void tst_QCategoryAxis::range_data() -{ - range_raw_data(); -} - -void tst_QCategoryAxis::range() -{ - m_chart->setAxisX(m_categoryaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - range_raw(); -} - -void tst_QCategoryAxis::range_animation_data() -{ - range_data(); -} - -void tst_QCategoryAxis::range_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - range(); -} - -void tst_QCategoryAxis::interval_data() -{ - // -} - -void tst_QCategoryAxis::interval() -{ - // append one correct interval - m_categoryaxis->append("first", (qreal)45); - QCOMPARE(m_categoryaxis->startValue("first"), (qreal)0); - QCOMPARE(m_categoryaxis->endValue("first"), (qreal)45); - - // append one more correct interval - m_categoryaxis->append("second", (qreal)75); - QCOMPARE(m_categoryaxis->startValue("second"), (qreal)45); - QCOMPARE(m_categoryaxis->endValue("second"), (qreal)75); - - // append one incorrect interval - m_categoryaxis->append("third", (qreal)15); - QCOMPARE(m_categoryaxis->count(), 2); - QCOMPARE(m_categoryaxis->endValue(m_categoryaxis->categoriesLabels().last()), (qreal)75); -// QCOMPARE(intervalMax("first"), (qreal)75); - - // append one more correct interval - m_categoryaxis->append("third", (qreal)100); - QCOMPARE(m_categoryaxis->count(), 3); - QCOMPARE(m_categoryaxis->startValue("third"), (qreal)75); - QCOMPARE(m_categoryaxis->endValue("third"), (qreal)100); - - // remove one interval - m_categoryaxis->remove("first"); - QCOMPARE(m_categoryaxis->count(), 2); - QCOMPARE(m_categoryaxis->startValue("second"), (qreal)0); // second interval should extend to firstInterval minimum - QCOMPARE(m_categoryaxis->endValue("second"), (qreal)75); - - // remove one interval - m_categoryaxis->replaceLabel("second", "replaced"); - QCOMPARE(m_categoryaxis->count(), 2); - QCOMPARE(m_categoryaxis->startValue("replaced"), (qreal)0); // second interval should extend to firstInterval minimum - QCOMPARE(m_categoryaxis->endValue("replaced"), (qreal)75); -} - -QTEST_MAIN(tst_QCategoryAxis) -#include "tst_qcategoryaxis.moc" - diff --git a/tests/auto/qchart/qchart.pro b/tests/auto/qchart/qchart.pro deleted file mode 100644 index 53f6737..0000000 --- a/tests/auto/qchart/qchart.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qchart.cpp diff --git a/tests/auto/qchart/tst_qchart.cpp b/tests/auto/qchart/tst_qchart.cpp deleted file mode 100644 index 5d53fde..0000000 --- a/tests/auto/qchart/tst_qchart.cpp +++ /dev/null @@ -1,794 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(QAbstractAxis *) -Q_DECLARE_METATYPE(QValueAxis *) -Q_DECLARE_METATYPE(QBarCategoryAxis *) -Q_DECLARE_METATYPE(QAbstractSeries *) -Q_DECLARE_METATYPE(QChart::AnimationOption) -Q_DECLARE_METATYPE(QBrush) -Q_DECLARE_METATYPE(QPen) -Q_DECLARE_METATYPE(QChart::ChartTheme) - -class tst_QChart : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qchart_data(); - void qchart(); - void addSeries_data(); - void addSeries(); - void animationOptions_data(); - void animationOptions(); - void axisX_data(); - void axisX(); - void axisY_data(); - void axisY(); - void backgroundBrush_data(); - void backgroundBrush(); - void backgroundPen_data(); - void backgroundPen(); - void isBackgroundVisible_data(); - void isBackgroundVisible(); - void legend_data(); - void legend(); - void plotArea_data(); - void plotArea(); - void removeAllSeries_data(); - void removeAllSeries(); - void removeSeries_data(); - void removeSeries(); - void scroll_right_data(); - void scroll_right(); - void scroll_left_data(); - void scroll_left(); - void scroll_up_data(); - void scroll_up(); - void scroll_down_data(); - void scroll_down(); - void theme_data(); - void theme(); - void title_data(); - void title(); - void titleBrush_data(); - void titleBrush(); - void titleFont_data(); - void titleFont(); - void zoomIn_data(); - void zoomIn(); - void zoomOut_data(); - void zoomOut(); - -private: - void createTestData(); - -private: - QChartView* m_view; - QChart* m_chart; -}; - -void tst_QChart::initTestCase() -{ - -} - -void tst_QChart::cleanupTestCase() -{ - -} - -void tst_QChart::init() -{ - m_view = new QChartView(new QChart()); - m_chart = m_view->chart(); -} - -void tst_QChart::cleanup() -{ - delete m_view; - m_view = 0; - m_chart = 0; -} - - -void tst_QChart::createTestData() -{ - QLineSeries* series0 = new QLineSeries(this); - *series0 << QPointF(0, 0) << QPointF(100, 100); - m_chart->addSeries(series0); - m_view->show(); - QTest::qWaitForWindowShown(m_view); -} - -void tst_QChart::qchart_data() -{ -} - -void tst_QChart::qchart() -{ - QVERIFY(m_chart); - QVERIFY(m_chart->legend()); - QVERIFY(m_chart->legend()->isVisible()); - - QCOMPARE(m_chart->animationOptions(), QChart::NoAnimation); - QVERIFY(!m_chart->axisX()); - QVERIFY(!m_chart->axisY()); - QVERIFY(m_chart->backgroundBrush()!=QBrush()); - QVERIFY(m_chart->backgroundPen()!=QPen()); - QCOMPARE(m_chart->isBackgroundVisible(), true); - QVERIFY(m_chart->plotArea().top()==0); - QVERIFY(m_chart->plotArea().left()==0); - QVERIFY(m_chart->plotArea().right()==0); - QVERIFY(m_chart->plotArea().bottom()==0); - QCOMPARE(m_chart->theme(), QChart::ChartThemeLight); - QCOMPARE(m_chart->title(), QString()); - - //QCOMPARE(m_chart->titleBrush(),QBrush()); - //QCOMPARE(m_chart->titleFont(),QFont()); - - m_chart->removeAllSeries(); - m_chart->scroll(0,0); - - m_chart->zoomIn(); - m_chart->zoomIn(QRectF()); - m_chart->zoomOut(); - - m_view->show(); - - QVERIFY(m_chart->plotArea().top()>0); - QVERIFY(m_chart->plotArea().left()>0); - QVERIFY(m_chart->plotArea().right()>0); - QVERIFY(m_chart->plotArea().bottom()>0); -} - -void tst_QChart::addSeries_data() -{ - QTest::addColumn("series"); - - QAbstractSeries* line = new QLineSeries(this); - QAbstractSeries* area = new QAreaSeries(static_cast(line)); - QAbstractSeries* scatter = new QScatterSeries(this); - QAbstractSeries* spline = new QSplineSeries(this); - QAbstractSeries* pie = new QPieSeries(this); - QAbstractSeries* bar = new QBarSeries(this); - QAbstractSeries* percent = new QPercentBarSeries(this); - QAbstractSeries* stacked = new QStackedBarSeries(this); - - QTest::newRow("lineSeries") << line; - QTest::newRow("areaSeries") << area; - QTest::newRow("scatterSeries") << scatter; - QTest::newRow("splineSeries") << spline; - QTest::newRow("pieSeries") << pie; - QTest::newRow("barSeries") << bar; - QTest::newRow("percentBarSeries") << percent; - QTest::newRow("stackedBarSeries") << stacked; - -} - -void tst_QChart::addSeries() -{ - QFETCH(QAbstractSeries *, series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QVERIFY(!series->chart()); - QCOMPARE(m_chart->series().count(), 0); - m_chart->addSeries(series); - QCOMPARE(m_chart->series().count(), 1); - QCOMPARE(m_chart->series().first(), series); - QVERIFY(series->chart() == m_chart); - m_chart->createDefaultAxes(); - if(series->type()!=QAbstractSeries::SeriesTypePie){ - QVERIFY(m_chart->axisY(series)); - QVERIFY(m_chart->axisX(series)); - }else{ - QVERIFY(!m_chart->axisY(series)); - QVERIFY(!m_chart->axisX(series)); - } - m_chart->removeSeries(series); - QVERIFY(!series->chart()); - QCOMPARE(m_chart->series().count(), 0); -} - -void tst_QChart::animationOptions_data() -{ - QTest::addColumn("animationOptions"); - QTest::newRow("AllAnimations") << QChart::AllAnimations; - QTest::newRow("NoAnimation") << QChart::NoAnimation; - QTest::newRow("GridAxisAnimations") << QChart::GridAxisAnimations; - QTest::newRow("SeriesAnimations") << QChart::SeriesAnimations; -} - -void tst_QChart::animationOptions() -{ - createTestData(); - QFETCH(QChart::AnimationOption, animationOptions); - m_chart->setAnimationOptions(animationOptions); - QCOMPARE(m_chart->animationOptions(), animationOptions); -} - -void tst_QChart::axisX_data() -{ - - QTest::addColumn("axis"); - QTest::addColumn("series"); - - QTest::newRow("categories,lineSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QLineSeries(this); - QTest::newRow("categories,areaSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QAreaSeries(new QLineSeries(this)); - QTest::newRow("categories,scatterSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QScatterSeries(this); - QTest::newRow("categories,splineSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QSplineSeries(this); - QTest::newRow("categories,pieSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QPieSeries(this); - QTest::newRow("categories,barSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QBarSeries(this); - QTest::newRow("categories,percentBarSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QPercentBarSeries(this); - QTest::newRow("categories,stackedBarSeries") << (QAbstractAxis*) new QBarCategoryAxis() << (QAbstractSeries*) new QStackedBarSeries(this); - - QTest::newRow("value,lineSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QLineSeries(this); - QTest::newRow("value,areaSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QAreaSeries(new QLineSeries(this)); - QTest::newRow("value,scatterSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QScatterSeries(this); - QTest::newRow("value,splineSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QSplineSeries(this); - QTest::newRow("value,pieSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QPieSeries(this); - QTest::newRow("value,barSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QBarSeries(this); - QTest::newRow("value,percentBarSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QPercentBarSeries(this); - QTest::newRow("value,stackedBarSeries") << (QAbstractAxis*) new QValueAxis() << (QAbstractSeries*) new QStackedBarSeries(this); - -} - -void tst_QChart::axisX() -{ - QFETCH(QAbstractAxis*, axis); - QFETCH(QAbstractSeries*, series); - QVERIFY(!m_chart->axisX()); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - m_chart->addSeries(series); - m_chart->setAxisX(axis,series); - QVERIFY(m_chart->axisX(series)==axis); -} - -void tst_QChart::axisY_data() -{ - axisX_data(); -} - - -void tst_QChart::axisY() -{ - QFETCH(QAbstractAxis*, axis); - QFETCH(QAbstractSeries*, series); - QVERIFY(!m_chart->axisY()); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - m_chart->addSeries(series); - m_chart->setAxisY(axis,series); - QVERIFY(m_chart->axisY(series)==axis); -} - -void tst_QChart::backgroundBrush_data() -{ - QTest::addColumn("backgroundBrush"); - QTest::newRow("null") << QBrush(); - QTest::newRow("blue") << QBrush(Qt::blue); - QTest::newRow("white") << QBrush(Qt::white); - QTest::newRow("black") << QBrush(Qt::black); -} - -void tst_QChart::backgroundBrush() -{ - QFETCH(QBrush, backgroundBrush); - m_chart->setBackgroundBrush(backgroundBrush); - QCOMPARE(m_chart->backgroundBrush(), backgroundBrush); -} - -void tst_QChart::backgroundPen_data() -{ - QTest::addColumn("backgroundPen"); - QTest::newRow("null") << QPen(); - QTest::newRow("blue") << QPen(Qt::blue); - QTest::newRow("white") << QPen(Qt::white); - QTest::newRow("black") << QPen(Qt::black); -} - - -void tst_QChart::backgroundPen() -{ - QFETCH(QPen, backgroundPen); - m_chart->setBackgroundPen(backgroundPen); - QCOMPARE(m_chart->backgroundPen(), backgroundPen); -} - -void tst_QChart::isBackgroundVisible_data() -{ - QTest::addColumn("isBackgroundVisible"); - QTest::newRow("true") << true; - QTest::newRow("false") << false; -} - -void tst_QChart::isBackgroundVisible() -{ - QFETCH(bool, isBackgroundVisible); - m_chart->setBackgroundVisible(isBackgroundVisible); - QCOMPARE(m_chart->isBackgroundVisible(), isBackgroundVisible); -} - -void tst_QChart::legend_data() -{ - -} - -void tst_QChart::legend() -{ - QLegend *legend = m_chart->legend(); - QVERIFY(legend); - - // Colors related signals - QSignalSpy colorSpy(legend, SIGNAL(colorChanged(QColor))); - QSignalSpy borderColorSpy(legend, SIGNAL(borderColorChanged(QColor))); - QSignalSpy labelColorSpy(legend, SIGNAL(labelColorChanged(QColor))); - - // colorChanged - legend->setColor(QColor("aliceblue")); - QCOMPARE(colorSpy.count(), 1); - QBrush b = legend->brush(); - b.setColor(QColor("aqua")); - legend->setBrush(b); - QCOMPARE(colorSpy.count(), 2); - - // borderColorChanged - legend->setBorderColor(QColor("aliceblue")); - QCOMPARE(borderColorSpy.count(), 1); - QPen p = legend->pen(); - p.setColor(QColor("aqua")); - legend->setPen(p); - QCOMPARE(borderColorSpy.count(), 2); - - // labelColorChanged - legend->setLabelColor(QColor("lightsalmon")); - QCOMPARE(labelColorSpy.count(), 1); - b = legend->labelBrush(); - b.setColor(QColor("lightseagreen")); - legend->setLabelBrush(b); - QCOMPARE(labelColorSpy.count(), 2); - - // fontChanged - QSignalSpy fontSpy(legend, SIGNAL(fontChanged(QFont))); - QFont f = legend->font(); - f.setBold(!f.bold()); - legend->setFont(f); - QCOMPARE(fontSpy.count(), 1); -} - -void tst_QChart::plotArea_data() -{ - -} - -void tst_QChart::plotArea() -{ - createTestData(); - QRectF rect = m_chart->geometry(); - QVERIFY(m_chart->plotArea().isValid()); - QVERIFY(m_chart->plotArea().height() < rect.height()); - QVERIFY(m_chart->plotArea().width() < rect.width()); -} - -void tst_QChart::removeAllSeries_data() -{ - -} - -void tst_QChart::removeAllSeries() -{ - QLineSeries* series0 = new QLineSeries(this); - QLineSeries* series1 = new QLineSeries(this); - QLineSeries* series2 = new QLineSeries(this); - QSignalSpy deleteSpy1(series0, SIGNAL(destroyed())); - QSignalSpy deleteSpy2(series1, SIGNAL(destroyed())); - QSignalSpy deleteSpy3(series2, SIGNAL(destroyed())); - - m_chart->addSeries(series0); - m_chart->addSeries(series1); - m_chart->addSeries(series2); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - m_chart->createDefaultAxes(); - QVERIFY(m_chart->axisY(series0)!=0); - QVERIFY(m_chart->axisY(series1)!=0); - QVERIFY(m_chart->axisY(series2)!=0); - - m_chart->removeAllSeries(); - QVERIFY(m_chart->axisY(series0)==0); - QVERIFY(m_chart->axisY(series1)==0); - QVERIFY(m_chart->axisY(series2)==0); - QCOMPARE(deleteSpy1.count(), 1); - QCOMPARE(deleteSpy2.count(), 1); - QCOMPARE(deleteSpy3.count(), 1); -} - -void tst_QChart::removeSeries_data() -{ - axisX_data(); -} - -void tst_QChart::removeSeries() -{ - QFETCH(QAbstractAxis *, axis); - QFETCH(QAbstractSeries *, series); - QSignalSpy deleteSpy(series, SIGNAL(destroyed())); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - if(!axis) axis = m_chart->axisY(); - m_chart->addSeries(series); - m_chart->setAxisY(axis,series); - QCOMPARE(m_chart->axisY(series),axis); - m_chart->removeSeries(series); - QVERIFY(m_chart->axisY(series)==0); - QCOMPARE(deleteSpy.count(), 0); -} - -void tst_QChart::scroll_right_data() -{ - QTest::addColumn("series"); - - QLineSeries* series0 = new QLineSeries(this); - *series0 << QPointF(0, 0) << QPointF(100, 100); - - QTest::newRow("lineSeries") << (QAbstractSeries*) series0; - - -} - -void tst_QChart::scroll_right() -{ - QFETCH(QAbstractSeries *, series); - m_chart->addSeries(series); - m_chart->createDefaultAxes(); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QAbstractAxis * axis = m_chart->axisX(); - QVERIFY(axis!=0); - - switch(axis->type()) - { - case QAbstractAxis::AxisTypeValue:{ - QValueAxis* vaxis = qobject_cast(axis); - QVERIFY(vaxis!=0); - qreal min = vaxis->min(); - qreal max = vaxis->max(); - QVERIFY(max>min); - m_chart->scroll(50, 0); - QVERIFY(minmin()); - QVERIFY(maxmax()); - break; - } - case QAbstractAxis::AxisTypeBarCategory:{ - QBarCategoryAxis* caxis = qobject_cast(axis); - QVERIFY(caxis!=0); - qreal min = caxis->min().toDouble(); - qreal max = caxis->max().toDouble(); - m_chart->scroll(50, 0); - QVERIFY(minmin().toDouble()); - QVERIFY(maxmax().toDouble()); - break; - } - default: - qFatal("Unsupported type"); - break; - } -} - -void tst_QChart::scroll_left_data() -{ - scroll_right_data(); -} - -void tst_QChart::scroll_left() -{ - QFETCH(QAbstractSeries *, series); - m_chart->addSeries(series); - m_chart->createDefaultAxes(); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QAbstractAxis * axis = m_chart->axisX(); - QVERIFY(axis!=0); - - switch(axis->type()) - { - case QAbstractAxis::AxisTypeValue:{ - QValueAxis* vaxis = qobject_cast(axis); - QVERIFY(vaxis!=0); - qreal min = vaxis->min(); - qreal max = vaxis->max(); - m_chart->scroll(-50, 0); - QVERIFY(min>vaxis->min()); - QVERIFY(max>vaxis->max()); - break; - } - case QAbstractAxis::AxisTypeBarCategory:{ - QBarCategoryAxis* caxis = qobject_cast(axis); - QVERIFY(caxis!=0); - qreal min = caxis->min().toDouble(); - qreal max = caxis->max().toDouble(); - m_chart->scroll(-50, 0); - QVERIFY(min>caxis->min().toDouble()); - QVERIFY(max>caxis->max().toDouble()); - break; - } - default: - qFatal("Unsupported type"); - break; - } -} - -void tst_QChart::scroll_up_data() -{ - scroll_right_data(); -} - -void tst_QChart::scroll_up() -{ - QFETCH(QAbstractSeries *, series); - m_chart->addSeries(series); - m_chart->createDefaultAxes(); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QAbstractAxis * axis = m_chart->axisY(); - QVERIFY(axis!=0); - - switch(axis->type()) - { - case QAbstractAxis::AxisTypeValue:{ - QValueAxis* vaxis = qobject_cast(axis); - QVERIFY(vaxis!=0); - qreal min = vaxis->min(); - qreal max = vaxis->max(); - m_chart->scroll(0, 50); - QVERIFY(minmin()); - QVERIFY(maxmax()); - break; - } - case QAbstractAxis::AxisTypeBarCategory:{ - QBarCategoryAxis* caxis = qobject_cast(axis); - QVERIFY(caxis!=0); - qreal min = caxis->min().toDouble(); - qreal max = caxis->max().toDouble(); - m_chart->scroll(0, 50); - QVERIFY(minmin().toDouble()); - QVERIFY(maxmax().toDouble()); - break; - } - default: - qFatal("Unsupported type"); - break; - } -} - -void tst_QChart::scroll_down_data() -{ - scroll_right_data(); -} - -void tst_QChart::scroll_down() -{ - QFETCH(QAbstractSeries *, series); - m_chart->addSeries(series); - m_chart->createDefaultAxes(); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QAbstractAxis * axis = m_chart->axisY(); - QVERIFY(axis!=0); - - switch(axis->type()) - { - case QAbstractAxis::AxisTypeValue:{ - QValueAxis* vaxis = qobject_cast(axis); - QVERIFY(vaxis!=0); - qreal min = vaxis->min(); - qreal max = vaxis->max(); - m_chart->scroll(0, -50); - QVERIFY(min>vaxis->min()); - QVERIFY(max>vaxis->max()); - break; - } - case QAbstractAxis::AxisTypeBarCategory:{ - QBarCategoryAxis* caxis = qobject_cast(axis); - QVERIFY(caxis!=0); - qreal min = caxis->min().toDouble(); - qreal max = caxis->max().toDouble(); - m_chart->scroll(0, -50); - QVERIFY(min>caxis->min().toDouble()); - QVERIFY(max>caxis->max().toDouble()); - break; - } - default: - qFatal("Unsupported type"); - break; - } -} - -void tst_QChart::theme_data() -{ - QTest::addColumn("theme"); - QTest::newRow("ChartThemeBlueCerulean") << QChart::ChartThemeBlueCerulean; - QTest::newRow("ChartThemeBlueIcy") << QChart::ChartThemeBlueIcy; - QTest::newRow("ChartThemeBlueNcs") << QChart::ChartThemeBlueNcs; - QTest::newRow("ChartThemeBrownSand") << QChart::ChartThemeBrownSand; - QTest::newRow("ChartThemeDark") << QChart::ChartThemeDark; - QTest::newRow("hartThemeHighContrast") << QChart::ChartThemeHighContrast; - QTest::newRow("ChartThemeLight") << QChart::ChartThemeLight; -} - -void tst_QChart::theme() -{ - QFETCH(QChart::ChartTheme, theme); - createTestData(); - m_chart->setTheme(theme); - QVERIFY(m_chart->theme()==theme); -} - -void tst_QChart::title_data() -{ - QTest::addColumn("title"); - QTest::newRow("null") << QString(); - QTest::newRow("foo") << QString("foo"); -} - -void tst_QChart::title() -{ - QFETCH(QString, title); - m_chart->setTitle(title); - QCOMPARE(m_chart->title(), title); -} - -void tst_QChart::titleBrush_data() -{ - QTest::addColumn("titleBrush"); - QTest::newRow("null") << QBrush(); - QTest::newRow("blue") << QBrush(Qt::blue); - QTest::newRow("white") << QBrush(Qt::white); - QTest::newRow("black") << QBrush(Qt::black); -} - -void tst_QChart::titleBrush() -{ - QFETCH(QBrush, titleBrush); - m_chart->setTitleBrush(titleBrush); - QCOMPARE(m_chart->titleBrush(), titleBrush); -} - -void tst_QChart::titleFont_data() -{ - QTest::addColumn("titleFont"); - QTest::newRow("null") << QFont(); - QTest::newRow("courier") << QFont("Courier", 8, QFont::Bold, true); -} - -void tst_QChart::titleFont() -{ - QFETCH(QFont, titleFont); - m_chart->setTitleFont(titleFont); - QCOMPARE(m_chart->titleFont(), titleFont); -} - -void tst_QChart::zoomIn_data() -{ - QTest::addColumn("rect"); - QTest::newRow("null") << QRectF(); - QTest::newRow("100x100") << QRectF(10,10,100,100); - QTest::newRow("200x200") << QRectF(10,10,200,200); -} - - -void tst_QChart::zoomIn() -{ - - QFETCH(QRectF, rect); - createTestData(); - m_chart->createDefaultAxes(); - QRectF marigns = m_chart->plotArea(); - rect.adjust(marigns.left(),marigns.top(),-marigns.right(),-marigns.bottom()); - QValueAxis* axisX = qobject_cast(m_chart->axisX()); - QVERIFY(axisX!=0); - QValueAxis* axisY = qobject_cast(m_chart->axisY()); - QVERIFY(axisY!=0); - qreal minX = axisX->min(); - qreal minY = axisY->min(); - qreal maxX = axisX->max(); - qreal maxY = axisY->max(); - m_chart->zoomIn(rect); - if(rect.isValid()){ - QVERIFY(minXmin()); - QVERIFY(maxX>axisX->max()); - QVERIFY(minYmin()); - QVERIFY(maxY>axisY->max()); - } - -} - -void tst_QChart::zoomOut_data() -{ - -} - -void tst_QChart::zoomOut() -{ - createTestData(); - m_chart->createDefaultAxes(); - - QValueAxis* axisX = qobject_cast(m_chart->axisX()); - QVERIFY(axisX!=0); - QValueAxis* axisY = qobject_cast(m_chart->axisY()); - QVERIFY(axisY!=0); - - qreal minX = axisX->min(); - qreal minY = axisY->min(); - qreal maxX = axisX->max(); - qreal maxY = axisY->max(); - - m_chart->zoomIn(); - - QVERIFY(minX < axisX->min()); - QVERIFY(maxX > axisX->max()); - QVERIFY(minY < axisY->min()); - QVERIFY(maxY > axisY->max()); - - m_chart->zoomOut(); - - // min x may be a zero value - if (qFuzzyIsNull(minX)) - QVERIFY(qFuzzyIsNull(axisX->min())); - else - QCOMPARE(minX, axisX->min()); - - // min y may be a zero value - if (qFuzzyIsNull(minY)) - QVERIFY(qFuzzyIsNull(axisY->min())); - else - QCOMPARE(minY, axisY->min()); - - QVERIFY(maxX == axisX->max()); - QVERIFY(maxY == axisY->max()); - -} - -QTEST_MAIN(tst_QChart) -#include "tst_qchart.moc" - diff --git a/tests/auto/qchartview/qchartview.pro b/tests/auto/qchartview/qchartview.pro deleted file mode 100644 index 1cc04db..0000000 --- a/tests/auto/qchartview/qchartview.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qchartview.cpp diff --git a/tests/auto/qchartview/tst_qchartview.cpp b/tests/auto/qchartview/tst_qchartview.cpp deleted file mode 100644 index 7e51af1..0000000 --- a/tests/auto/qchartview/tst_qchartview.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - - -Q_DECLARE_METATYPE(QChart*) -Q_DECLARE_METATYPE(QChartView::RubberBands) -Q_DECLARE_METATYPE(Qt::Key) - -class tst_QChartView : public QObject -{ - Q_OBJECT - -public Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private Q_SLOTS: - void qchartview_data(); - void qchartview(); - void chart_data(); - void chart(); - void rubberBand_data(); - void rubberBand(); - -private: - QChartView* m_view; -}; - -void tst_QChartView::initTestCase() -{ - //test tracks mouse, give a while to user to relese it - QTest::qWait(1000); -} - -void tst_QChartView::cleanupTestCase() -{ -} - -void tst_QChartView::init() -{ - m_view = new QChartView(new QChart()); - m_view->chart()->legend()->setVisible(false); -} - -void tst_QChartView::cleanup() -{ - delete m_view; - m_view =0; -} - -void tst_QChartView::qchartview_data() -{ - -} - -void tst_QChartView::qchartview() -{ - QVERIFY(m_view->chart()); - QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - - delete(new QChartView()); - - QChartView view; - QVERIFY(view.chart()); - -} - -void tst_QChartView::chart_data() -{ - - QTest::addColumn("chart"); - QTest::newRow("qchart") << new QChart(); -} - -void tst_QChartView::chart() -{ - QFETCH(QChart*, chart); - QChartView* view = new QChartView(chart); - QCOMPARE(view->chart(), chart); - delete view; -} - -void tst_QChartView::rubberBand_data() -{ - QTest::addColumn("rubberBand"); - QTest::addColumn("Xcount"); - QTest::addColumn("Ycount"); - - QTest::addColumn("min"); - QTest::addColumn("max"); - - QTest::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand) << 0 << 1 << QPoint(5,5) << QPoint(5,5); - QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand) << 1 << 0 << QPoint(5,5) << QPoint(5,5); - QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand) << 1 << 1 << QPoint(5,5) << QPoint(5,5); -} - -void tst_QChartView::rubberBand() -{ - QFETCH(QChartView::RubberBands, rubberBand); - QFETCH(int, Xcount); - QFETCH(int, Ycount); - QFETCH(QPoint, min); - QFETCH(QPoint, max); - - m_view->setRubberBand(rubberBand); - - QCOMPARE(m_view->rubberBand(), rubberBand); - - QLineSeries* line = new QLineSeries(); - *line << QPointF(0, 0) << QPointF(200, 200); - - m_view->chart()->addSeries(line); - m_view->chart()->createDefaultAxes(); - m_view->show(); - - QRectF plotArea = m_view->chart()->plotArea(); - //this is hack since view does not get events otherwise - m_view->setMouseTracking(true); - - QAbstractAxis* axisY = m_view->chart()->axisY(); - QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal,qreal))); - QAbstractAxis* axisX = m_view->chart()->axisX(); - QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal,qreal))); - - - QValueAxis* vaxisX = qobject_cast(axisX); - QValueAxis* vaxisY = qobject_cast(axisY); - - int minX = vaxisX->min(); - int minY = vaxisY->min(); - int maxX = vaxisX->max(); - int maxY = vaxisY->max(); - - QTest::qWaitForWindowShown(m_view); - QTest::mouseMove(m_view->viewport(), min + plotArea.topLeft().toPoint()); - QTest::qWait(2000); - QTest::mousePress(m_view->viewport(), Qt::LeftButton, 0, min + plotArea.topLeft().toPoint()); - QTest::qWait(2000); - QTest::mouseMove(m_view->viewport(), plotArea.bottomRight().toPoint() - max); - QTest::qWait(2000); - QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, plotArea.bottomRight().toPoint() - max); - - TRY_COMPARE(spy0.count(), Xcount); - TRY_COMPARE(spy1.count(), Ycount); - - //this is hack since view does not get events otherwise - m_view->setMouseTracking(false); - - QVERIFY(vaxisX->min() >= minX ); - QVERIFY(vaxisX->max() <= maxX ); - QVERIFY(vaxisY->min() >= minY ); - QVERIFY(vaxisY->max() <= maxY ); - -} - -QTEST_MAIN(tst_QChartView) -#include "tst_qchartview.moc" - diff --git a/tests/auto/qdatetimeaxis/qdatetimeaxis.pro b/tests/auto/qdatetimeaxis/qdatetimeaxis.pro deleted file mode 100644 index ea34c14..0000000 --- a/tests/auto/qdatetimeaxis/qdatetimeaxis.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -HEADERS += ../qabstractaxis/tst_qabstractaxis.h -SOURCES += tst_qdatetimeaxis.cpp ../qabstractaxis/tst_qabstractaxis.cpp diff --git a/tests/auto/qdatetimeaxis/tst_qdatetimeaxis.cpp b/tests/auto/qdatetimeaxis/tst_qdatetimeaxis.cpp deleted file mode 100644 index 347dfe4..0000000 --- a/tests/auto/qdatetimeaxis/tst_qdatetimeaxis.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** - ** - ** 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 "../qabstractaxis/tst_qabstractaxis.h" -#include -#include - -class tst_QDateTimeAxis : public QObject//: public tst_QAbstractAxis -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qdatetimeaxis_data(); - void qdatetimeaxis(); - - void max_raw_data(); - void max_raw(); - void max_data(); - void max(); - void max_animation_data(); - void max_animation(); - void min_raw_data(); - void min_raw(); - void min_data(); - void min(); - void min_animation_data(); - void min_animation(); - void range_raw_data(); - void range_raw(); - void range_data(); - void range(); - void range_animation_data(); - void range_animation(); - -private: - QDateTimeAxis *m_dateTimeAxisX; - QDateTimeAxis *m_dateTimeAxisY; - QLineSeries* m_series; - QChartView* m_view; - QChart* m_chart; -}; - -void tst_QDateTimeAxis::initTestCase() -{ -} - -void tst_QDateTimeAxis::cleanupTestCase() -{ -} - -void tst_QDateTimeAxis::init() -{ - m_dateTimeAxisX = new QDateTimeAxis(); - m_dateTimeAxisY = new QDateTimeAxis(); - m_series = new QLineSeries(); - *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100); - // tst_QAbstractAxis::init(m_datetimeaxis, m_series); - - m_view = new QChartView; - m_chart = m_view->chart(); - m_chart->addSeries(m_series); - m_chart->setAxisY(m_dateTimeAxisY, m_series); - m_chart->setAxisX(m_dateTimeAxisX, m_series); -} - -void tst_QDateTimeAxis::cleanup() -{ - delete m_series; - delete m_dateTimeAxisX; - delete m_dateTimeAxisY; - m_series = 0; - m_dateTimeAxisX = 0; - m_dateTimeAxisY = 0; - delete m_view; - m_view = 0; - m_chart = 0; - // tst_QAbstractAxis::cleanup(); -} - -void tst_QDateTimeAxis::qdatetimeaxis_data() -{ -} - -void tst_QDateTimeAxis::qdatetimeaxis() -{ - // qabstractaxis(); - QCOMPARE(m_dateTimeAxisX->type(), QAbstractAxis::AxisTypeDateTime); - - m_view->show(); - QTest::qWaitForWindowShown(m_view); - - QVERIFY(m_dateTimeAxisX->max().toMSecsSinceEpoch() != 0); - QVERIFY(m_dateTimeAxisX->min().toMSecsSinceEpoch() != 0); -} - -void tst_QDateTimeAxis::max_raw_data() -{ - QTest::addColumn("max"); - QTest::addColumn("valid"); - QDateTime dateTime; - dateTime.setDate(QDate(2012, 7, 19)); - QTest::newRow("19.7.2012 - Valid") << dateTime << true; - dateTime.setDate(QDate(2012, 17, 32)); - QTest::newRow("32.17.2012 - Invalid") << dateTime << false; -} - -void tst_QDateTimeAxis::max_raw() -{ - QFETCH(QDateTime, max); - QFETCH(bool, valid); - - QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime))); - QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime))); - QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime, QDateTime))); - - m_dateTimeAxisX->setMax(max); - - if (valid) { - QVERIFY2(m_dateTimeAxisX->max() == max, "Not equal"); - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 1); - } else { - QVERIFY2(m_dateTimeAxisX->max() != max, "Date is invalid and should not be set"); - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - } -} - -void tst_QDateTimeAxis::max_data() -{ - max_raw_data(); -} - -void tst_QDateTimeAxis::max() -{ -// m_chart->setAxisX(m_dateTimeAxisX, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - max_raw(); -} - -void tst_QDateTimeAxis::max_animation_data() -{ - max_data(); -} - -void tst_QDateTimeAxis::max_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - max(); -} - -void tst_QDateTimeAxis::min_raw_data() -{ - QTest::addColumn("min"); - QTest::addColumn("valid"); - QDateTime dateTime; - dateTime.setDate(QDate(1908, 1, 11)); - QTest::newRow("11.1.1908 - Valid") << dateTime << true; // negative MSecs from Epoch - dateTime.setDate(QDate(2012, 17, 32)); - QTest::newRow("32.17.2012 - Invalid") << dateTime << false; -} - -void tst_QDateTimeAxis::min_raw() -{ - QFETCH(QDateTime, min); - QFETCH(bool, valid); - - QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime))); - QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime))); - QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime, QDateTime))); - - m_dateTimeAxisX->setMin(min); - - if (valid) { - QVERIFY2(m_dateTimeAxisX->min() == min, "Not equal"); - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - } else { - QVERIFY2(m_dateTimeAxisX->min() != min, "Date is invalid and should not be set"); - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - } -} - -void tst_QDateTimeAxis::min_data() -{ - min_raw_data(); -} - -void tst_QDateTimeAxis::min() -{ -// m_chart->setAxisX(m_dateTimeAxisX, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - min_raw(); -} - -void tst_QDateTimeAxis::min_animation_data() -{ - min_data(); -} - -void tst_QDateTimeAxis::min_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - min(); -} - -void tst_QDateTimeAxis::range_raw_data() -{ - QTest::addColumn("min"); - QTest::addColumn("minValid"); - QTest::addColumn("max"); - QTest::addColumn("maxValid"); - - QDateTime minDateTime; - QDateTime maxDateTime; - minDateTime.setDate(QDate(1908, 1, 11)); - maxDateTime.setDate(QDate(1958, 11, 21)); - QTest::newRow("11.1.1908 - min valid, 21.12.1958 - max valid") << minDateTime << true << maxDateTime << true; // negative MSecs from Epoch, min < max - - minDateTime.setDate(QDate(2012, 17, 32)); - QTest::newRow("32.17.2012 - min invalid, 21.12.1958 - max valid") << minDateTime << false << maxDateTime << true; - - maxDateTime.setDate(QDate(2017, 0, 1)); - QTest::newRow("32.17.2012 - min invalid, 1.0.2017 - max invalid") << minDateTime << false << maxDateTime << false; - - minDateTime.setDate(QDate(2012, 1, 1)); - QTest::newRow("1.1.2012 - min valid, 1.0.2017 - max invalid") << minDateTime << true << maxDateTime << false; - - maxDateTime.setDate(QDate(2005, 2, 5)); - QTest::newRow("1.1.2012 - min valid, 5.2.2005 - max valid") << minDateTime << true << maxDateTime << true; // min > max -} - -void tst_QDateTimeAxis::range_raw() -{ - QFETCH(QDateTime, min); - QFETCH(bool, minValid); - QFETCH(QDateTime, max); - QFETCH(bool, maxValid); - - QSignalSpy spy0(m_dateTimeAxisX, SIGNAL(maxChanged(QDateTime))); - QSignalSpy spy1(m_dateTimeAxisX, SIGNAL(minChanged(QDateTime))); - QSignalSpy spy2(m_dateTimeAxisX, SIGNAL(rangeChanged(QDateTime, QDateTime))); - - m_dateTimeAxisX->setRange(min, max); - - if (minValid && maxValid && min < max) { - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - } else { - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - } -} - -void tst_QDateTimeAxis::range_data() -{ - range_raw_data(); -} - -void tst_QDateTimeAxis::range() -{ -// m_chart->setAxisX(m_dateTimeAxisX, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - range_raw(); -} - -void tst_QDateTimeAxis::range_animation_data() -{ - range_data(); -} - -void tst_QDateTimeAxis::range_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - range(); -} - -QTEST_MAIN(tst_QDateTimeAxis) -#include "tst_qdatetimeaxis.moc" - diff --git a/tests/auto/qhorizontalbarseries/qhorizontalbarseries.pro b/tests/auto/qhorizontalbarseries/qhorizontalbarseries.pro deleted file mode 100644 index b26460a..0000000 --- a/tests/auto/qhorizontalbarseries/qhorizontalbarseries.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qhorizontalbarseries.cpp diff --git a/tests/auto/qhorizontalbarseries/tst_qhorizontalbarseries.cpp b/tests/auto/qhorizontalbarseries/tst_qhorizontalbarseries.cpp deleted file mode 100644 index 5add4a4..0000000 --- a/tests/auto/qhorizontalbarseries/tst_qhorizontalbarseries.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include "tst_definitions.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(QBarSet*) - -class tst_QHorizontalBarSeries : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qhorizontalbarseries_data(); - void qhorizontalbarseries(); - void type_data(); - void type(); - void append_data(); - void append(); - void remove_data(); - void remove(); - void appendList_data(); - void appendList(); - void count_data(); - void count(); - void barSets_data(); - void barSets(); - void setLabelsVisible_data(); - void setLabelsVisible(); - void mouseclicked_data(); - void mouseclicked(); - void mousehovered_data(); - void mousehovered(); - void clearWithAnimations(); - -private: - QHorizontalBarSeries* m_barseries; - QHorizontalBarSeries* m_barseries_with_sets; - - QList m_testSets; - -}; - -void tst_QHorizontalBarSeries::initTestCase() -{ - qRegisterMetaType("QBarSet*"); -} - -void tst_QHorizontalBarSeries::cleanupTestCase() -{ -} - -void tst_QHorizontalBarSeries::init() -{ - m_barseries = new QHorizontalBarSeries(); - m_barseries_with_sets = new QHorizontalBarSeries(); - - for (int i=0; i<5; i++) { - m_testSets.append(new QBarSet("testset")); - m_barseries_with_sets->append(m_testSets.at(i)); - } -} - -void tst_QHorizontalBarSeries::cleanup() -{ - foreach(QBarSet* s, m_testSets) { - m_barseries_with_sets->remove(s); - } - m_testSets.clear(); - - delete m_barseries; - m_barseries = 0; - delete m_barseries_with_sets; - m_barseries_with_sets = 0; -} - -void tst_QHorizontalBarSeries::qhorizontalbarseries_data() -{ -} - -void tst_QHorizontalBarSeries::qhorizontalbarseries() -{ - QHorizontalBarSeries *barseries = new QHorizontalBarSeries(); - QVERIFY(barseries != 0); -} - -void tst_QHorizontalBarSeries::type_data() -{ - -} - -void tst_QHorizontalBarSeries::type() -{ - QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeHorizontalBar); -} - -void tst_QHorizontalBarSeries::append_data() -{ -} - -void tst_QHorizontalBarSeries::append() -{ - QVERIFY(m_barseries->count() == 0); - - bool ret = false; - - // Try adding barset - QBarSet *barset = new QBarSet("testset"); - ret = m_barseries->append(barset); - - QVERIFY(ret == true); - QVERIFY(m_barseries->count() == 1); - - // Try adding another set - QBarSet *barset2 = new QBarSet("testset2"); - ret = m_barseries->append(barset2); - - QVERIFY(ret == true); - QVERIFY(m_barseries->count() == 2); - - // Try adding same set again - ret = m_barseries->append(barset2); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == 2); - - // Try adding null set - ret = m_barseries->append(0); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == 2); - -} - -void tst_QHorizontalBarSeries::remove_data() -{ -} - -void tst_QHorizontalBarSeries::remove() -{ - int count = m_testSets.count(); - QVERIFY(m_barseries_with_sets->count() == count); - - // Try to remove null pointer (should not remove, should not crash) - bool ret = false; - ret = m_barseries_with_sets->remove(0); - QVERIFY(ret == false); - QVERIFY(m_barseries_with_sets->count() == count); - - // Try to remove invalid pointer (should not remove, should not crash) - ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) ); - QVERIFY(ret == false); - QVERIFY(m_barseries_with_sets->count() == count); - - // remove some sets - ret = m_barseries_with_sets->remove(m_testSets.at(2)); - QVERIFY(ret == true); - ret = m_barseries_with_sets->remove(m_testSets.at(3)); - QVERIFY(ret == true); - ret = m_barseries_with_sets->remove(m_testSets.at(4)); - QVERIFY(ret == true); - - QVERIFY(m_barseries_with_sets->count() == 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 (should be ok, even if some sets have already been removed) - ret = false; - for (int i=0; iremove(m_testSets.at(i)); - } - - QVERIFY(ret == true); - QVERIFY(m_barseries_with_sets->count() == 0); -} - -void tst_QHorizontalBarSeries::appendList_data() -{ - -} - -void tst_QHorizontalBarSeries::appendList() -{ - int count = 5; - QVERIFY(m_barseries->count() == 0); - - QList sets; - for (int i=0; iappend(sets); - QVERIFY(ret == true); - QVERIFY(m_barseries->count() == count); - - // Append same sets again (should fail, count should remain same) - ret = m_barseries->append(sets); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == count); - - // Try append empty list (should succeed, but count should remain same) - QList invalidList; - ret = m_barseries->append(invalidList); - QVERIFY(ret == true); - QVERIFY(m_barseries->count() == count); - - // 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)); - ret = m_barseries->append(invalidList); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == count); - - // Try append list with null pointers (should fail, count remains same) - QList invalidList2; - invalidList2.append(0); - invalidList2.append(0); - invalidList2.append(0); - ret = m_barseries->append(invalidList2); - QVERIFY(ret == false); - QVERIFY(m_barseries->count() == count); -} - -void tst_QHorizontalBarSeries::count_data() -{ - -} - -void tst_QHorizontalBarSeries::count() -{ - QVERIFY(m_barseries->count() == 0); - QVERIFY(m_barseries_with_sets->count() == m_testSets.count()); -} - -void tst_QHorizontalBarSeries::barSets_data() -{ - -} - -void tst_QHorizontalBarSeries::barSets() -{ - QVERIFY(m_barseries->barSets().count() == 0); - - QList sets = m_barseries_with_sets->barSets(); - QVERIFY(sets.count() == m_testSets.count()); - - for (int i=0; iisLabelsVisible() == false); - QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); - - // turn labels to visible - m_barseries_with_sets->setLabelsVisible(true); - // TODO: test the signal - QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); - - // turn labels to invisible - m_barseries_with_sets->setLabelsVisible(false); - // TODO: test the signal - QVERIFY(m_barseries_with_sets->isLabelsVisible() == false); - - // without parameter, should turn labels to visible - m_barseries_with_sets->setLabelsVisible(); - // TODO: test the signal - QVERIFY(m_barseries_with_sets->isLabelsVisible() == true); -} - -void tst_QHorizontalBarSeries::mouseclicked_data() -{ - -} - -void tst_QHorizontalBarSeries::mouseclicked() -{ - QHorizontalBarSeries* series = new QHorizontalBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(clicked(int,QBarSet*))); - QSignalSpy setSpy1(set1, SIGNAL(clicked(int))); - QSignalSpy setSpy2(set2, SIGNAL(clicked(int))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - -//==================================================================================== -// barset 1, bar 0 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,218)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 1, bar 1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,161)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 1, bar 2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,104)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); - - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 2); - -//==================================================================================== -// barset 2, bar 0 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,203)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 2, bar 1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,146)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 2, bar 2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,89)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Int); - QVERIFY(setSpyArg.at(0).toInt() == 2); -} - -void tst_QHorizontalBarSeries::mousehovered_data() -{ - -} - -void tst_QHorizontalBarSeries::mousehovered() -{ - QHorizontalBarSeries* series = new QHorizontalBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(hovered(bool,QBarSet*))); - QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); - QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - //this is hack since view does not get events otherwise - view.setMouseTracking(true); - -//======================================================================= -// move mouse to bottom border - QTest::mouseMove(view.viewport(), QPoint(200, 300)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - TRY_COMPARE(seriesSpy.count(), 0); - TRY_COMPARE(setSpy1.count(), 0); - TRY_COMPARE(setSpy2.count(), 0); - -//======================================================================= -// move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(200,218)); - TRY_COMPARE(seriesSpy.count(), 1); - TRY_COMPARE(setSpy1.count(), 1); - TRY_COMPARE(setSpy2.count(), 0); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(200,203)); - TRY_COMPARE(seriesSpy.count(), 2); - TRY_COMPARE(setSpy1.count(), 1); - TRY_COMPARE(setSpy2.count(), 1); - - // should leave set1 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); - - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should enter set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(0,203)); - TRY_COMPARE(seriesSpy.count(), 1); - TRY_COMPARE(setSpy1.count(), 0); - TRY_COMPARE(setSpy2.count(), 1); - - // should leave set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); - - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); -} - -void tst_QHorizontalBarSeries::clearWithAnimations() -{ - QHorizontalBarSeries* series = new QHorizontalBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 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(); -} - -QTEST_MAIN(tst_QHorizontalBarSeries) - -#include "tst_qhorizontalbarseries.moc" - diff --git a/tests/auto/qhorizontalpercentbarseries/qhorizontalpercentbarseries.pro b/tests/auto/qhorizontalpercentbarseries/qhorizontalpercentbarseries.pro deleted file mode 100644 index ff0a832..0000000 --- a/tests/auto/qhorizontalpercentbarseries/qhorizontalpercentbarseries.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qhorizontalpercentbarseries.cpp diff --git a/tests/auto/qhorizontalpercentbarseries/tst_qhorizontalpercentbarseries.cpp b/tests/auto/qhorizontalpercentbarseries/tst_qhorizontalpercentbarseries.cpp deleted file mode 100644 index c55e053..0000000 --- a/tests/auto/qhorizontalpercentbarseries/tst_qhorizontalpercentbarseries.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include "tst_definitions.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(QBarSet*) - -class tst_QHorizontalPercentBarSeries : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qhorizontalpercentbarseries_data(); - void qhorizontalpercentbarseries(); - void type_data(); - void type(); - void mouseclicked_data(); - void mouseclicked(); - void mousehovered_data(); - void mousehovered(); - -private: - QHorizontalPercentBarSeries* m_barseries; -}; - -void tst_QHorizontalPercentBarSeries::initTestCase() -{ - qRegisterMetaType("QBarSet*"); -} - -void tst_QHorizontalPercentBarSeries::cleanupTestCase() -{ -} - -void tst_QHorizontalPercentBarSeries::init() -{ - m_barseries = new QHorizontalPercentBarSeries(); -} - -void tst_QHorizontalPercentBarSeries::cleanup() -{ - delete m_barseries; - m_barseries = 0; -} - -void tst_QHorizontalPercentBarSeries::qhorizontalpercentbarseries_data() -{ -} - -void tst_QHorizontalPercentBarSeries::qhorizontalpercentbarseries() -{ - QHorizontalPercentBarSeries *barseries = new QHorizontalPercentBarSeries(); - QVERIFY(barseries != 0); -} - -void tst_QHorizontalPercentBarSeries::type_data() -{ - -} - -void tst_QHorizontalPercentBarSeries::type() -{ - QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeHorizontalPercentBar); -} - -void tst_QHorizontalPercentBarSeries::mouseclicked_data() -{ - -} - -void tst_QHorizontalPercentBarSeries::mouseclicked() -{ - QHorizontalPercentBarSeries* series = new QHorizontalPercentBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(clicked(int, QBarSet*))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - -//==================================================================================== -// barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(130,211)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(130,154)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(130,97)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); - -//==================================================================================== -// barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(269,210)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(269,154)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 2, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(269,97)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); -} - -void tst_QHorizontalPercentBarSeries::mousehovered_data() -{ - -} - -void tst_QHorizontalPercentBarSeries::mousehovered() -{ - QHorizontalPercentBarSeries* series = new QHorizontalPercentBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(hovered(bool, QBarSet*))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - //this is hack since view does not get events otherwise - view.setMouseTracking(true); - -//======================================================================= -// move mouse to left border - QTest::mouseMove(view.viewport(), QPoint(0, 211)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - TRY_COMPARE(seriesSpy.count(), 0); - -//======================================================================= -// move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(130,211)); - TRY_COMPARE(seriesSpy.count(), 1); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(269,211)); - TRY_COMPARE(seriesSpy.count(), 2); - - // should leave set1 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); - - // should enter set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(269,300)); - TRY_COMPARE(seriesSpy.count(), 1); - - // should leave set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); -} - -QTEST_MAIN(tst_QHorizontalPercentBarSeries) - -#include "tst_qhorizontalpercentbarseries.moc" - diff --git a/tests/auto/qhorizontalstackedbarseries/qhorizontalstackedbarseries.pro b/tests/auto/qhorizontalstackedbarseries/qhorizontalstackedbarseries.pro deleted file mode 100644 index 84179cc..0000000 --- a/tests/auto/qhorizontalstackedbarseries/qhorizontalstackedbarseries.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qhorizontalstackedbarseries.cpp diff --git a/tests/auto/qhorizontalstackedbarseries/tst_qhorizontalstackedbarseries.cpp b/tests/auto/qhorizontalstackedbarseries/tst_qhorizontalstackedbarseries.cpp deleted file mode 100644 index 4b6539e..0000000 --- a/tests/auto/qhorizontalstackedbarseries/tst_qhorizontalstackedbarseries.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include "tst_definitions.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(QBarSet*) - -class tst_QHorizontalStackedBarSeries : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qhorizontalstackedbarseries_data(); - void qhorizontalstackedbarseries(); - void type_data(); - void type(); - void mouseclicked_data(); - void mouseclicked(); - void mousehovered_data(); - void mousehovered(); - -private: - QHorizontalStackedBarSeries* m_barseries; -}; - -void tst_QHorizontalStackedBarSeries::initTestCase() -{ - qRegisterMetaType("QBarSet*"); -} - -void tst_QHorizontalStackedBarSeries::cleanupTestCase() -{ -} - -void tst_QHorizontalStackedBarSeries::init() -{ - m_barseries = new QHorizontalStackedBarSeries(); -} - -void tst_QHorizontalStackedBarSeries::cleanup() -{ - delete m_barseries; - m_barseries = 0; -} - -void tst_QHorizontalStackedBarSeries::qhorizontalstackedbarseries_data() -{ -} - -void tst_QHorizontalStackedBarSeries::qhorizontalstackedbarseries() -{ - QHorizontalStackedBarSeries *barseries = new QHorizontalStackedBarSeries(); - QVERIFY(barseries != 0); -} - -void tst_QHorizontalStackedBarSeries::type_data() -{ - -} - -void tst_QHorizontalStackedBarSeries::type() -{ - QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeHorizontalStackedBar); -} - -void tst_QHorizontalStackedBarSeries::mouseclicked_data() -{ - -} - -void tst_QHorizontalStackedBarSeries::mouseclicked() -{ - QHorizontalStackedBarSeries* series = new QHorizontalStackedBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(clicked(int, QBarSet*))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - -//==================================================================================== -// barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(130,211)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(130,154)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(130,97)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); - -//==================================================================================== -// barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(269,210)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(269,154)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 2, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(269,97)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); -} - -void tst_QHorizontalStackedBarSeries::mousehovered_data() -{ - -} - -void tst_QHorizontalStackedBarSeries::mousehovered() -{ - QHorizontalStackedBarSeries* series = new QHorizontalStackedBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(hovered(bool, QBarSet*))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - //this is hack since view does not get events otherwise - view.setMouseTracking(true); - -//======================================================================= -// move mouse to left border - QTest::mouseMove(view.viewport(), QPoint(0, 211)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - TRY_COMPARE(seriesSpy.count(), 0); - -//======================================================================= -// move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(130,211)); - TRY_COMPARE(seriesSpy.count(), 1); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(269,211)); - TRY_COMPARE(seriesSpy.count(), 2); - - // should leave set1 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); - - // should enter set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(269,300)); - TRY_COMPARE(seriesSpy.count(), 1); - - // should leave set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); -} - -QTEST_MAIN(tst_QHorizontalStackedBarSeries) - -#include "tst_qhorizontalstackedbarseries.moc" - diff --git a/tests/auto/qlineseries/qlineseries.pro b/tests/auto/qlineseries/qlineseries.pro deleted file mode 100644 index 855812e..0000000 --- a/tests/auto/qlineseries/qlineseries.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -HEADERS += ../qxyseries/tst_qxyseries.h -SOURCES += tst_qlineseries.cpp ../qxyseries/tst_qxyseries.cpp diff --git a/tests/auto/qlineseries/tst_qlineseries.cpp b/tests/auto/qlineseries/tst_qlineseries.cpp deleted file mode 100644 index 7e21106..0000000 --- a/tests/auto/qlineseries/tst_qlineseries.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** 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 "../qxyseries/tst_qxyseries.h" -#include - - -Q_DECLARE_METATYPE(QList) - -class tst_QLineSeries : public tst_QXYSeries -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); -private slots: - void qlineseries_data(); - void qlineseries(); -protected: - void pointsVisible_data(); -}; - -void tst_QLineSeries::initTestCase() -{ -} - -void tst_QLineSeries::cleanupTestCase() -{ -} - -void tst_QLineSeries::init() -{ - tst_QXYSeries::init(); - m_series = new QLineSeries(); -} - -void tst_QLineSeries::cleanup() -{ - delete m_series; - m_series=0; - tst_QXYSeries::cleanup(); -} - -void tst_QLineSeries::qlineseries_data() -{ - -} - -void tst_QLineSeries::qlineseries() -{ - QLineSeries series; - - QCOMPARE(series.count(),0); - QCOMPARE(series.brush(), QBrush()); - QCOMPARE(series.points(), QList()); - QCOMPARE(series.pen(), QPen()); - QCOMPARE(series.pointsVisible(), false); - - series.append(QList()); - series.append(0.0,0.0); - series.append(QPointF()); - - series.remove(0.0,0.0); - series.remove(QPointF()); - series.clear(); - - series.replace(QPointF(),QPointF()); - series.replace(0,0,0,0); - series.setBrush(QBrush()); - - series.setPen(QPen()); - series.setPointsVisible(false); - - m_chart->addSeries(&series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); -} - -QTEST_MAIN(tst_QLineSeries) - -#include "tst_qlineseries.moc" - diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro deleted file mode 100644 index 144e5db..0000000 --- a/tests/auto/qml/qml.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qml.cpp -QT += declarative diff --git a/tests/auto/qml/tst_qml.cpp b/tests/auto/qml/tst_qml.cpp deleted file mode 100644 index 4bce0f6..0000000 --- a/tests/auto/qml/tst_qml.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** 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 -#include "tst_definitions.h" - -class tst_QML : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); -private slots: - void checkPlugin_data(); - void checkPlugin(); -private: - QString componentErrors(const QDeclarativeComponent* component) const; - QString imports(); - -}; - -QString tst_QML::componentErrors(const QDeclarativeComponent* component) const -{ - Q_ASSERT(component); - - QStringList errors; - - foreach (QDeclarativeError const& error, component->errors()) { - errors << error.toString(); - } - - return errors.join("\n"); -} - -QString tst_QML::imports() -{ - return "import QtQuick 1.0 \n" - "import QtCommercial.Chart 1.1 \n"; -} - - -void tst_QML::initTestCase() -{ -} - -void tst_QML::cleanupTestCase() -{ -} - -void tst_QML::init() -{ - -} - -void tst_QML::cleanup() -{ - -} - -void tst_QML::checkPlugin_data() -{ - QTest::addColumn("source"); - - QTest::newRow("createChartView") << imports() + "ChartView{}"; - QTest::newRow("XYPoint") << imports() + "XYPoint{}"; - QTest::newRow("scatterSeries") << imports() + "ScatterSeries{}"; - QTest::newRow("lineSeries") << imports() + "LineSeries{}"; - QTest::newRow("splineSeries") << imports() + "SplineSeries{}"; - QTest::newRow("areaSeries") << imports() + "AreaSeries{}"; - QTest::newRow("barSeries") << imports() + "BarSeries{}"; - QTest::newRow("stackedBarSeries") << imports() + "StackedBarSeries{}"; - QTest::newRow("precentBarSeries") << imports() + "PercentBarSeries{}"; - QTest::newRow("horizonatlBarSeries") << imports() + "HorizontalBarSeries{}"; - QTest::newRow("horizonatlStackedBarSeries") << imports() + "HorizontalStackedBarSeries{}"; - QTest::newRow("horizonatlstackedBarSeries") << imports() + "HorizontalPercentBarSeries{}"; - QTest::newRow("pieSeries") << imports() + "PieSeries{}"; - QTest::newRow("PieSlice") << imports() + "PieSlice{}"; - QTest::newRow("BarSet") << imports() + "BarSet{}"; - QTest::newRow("HXYModelMapper") << imports() + "HXYModelMapper{}"; - QTest::newRow("VXYModelMapper") << imports() + "VXYModelMapper{}"; - QTest::newRow("HPieModelMapper") << imports() + "HPieModelMapper{}"; - QTest::newRow("HPieModelMapper") << imports() + "HPieModelMapper{}"; - QTest::newRow("HBarModelMapper") << imports() + "HBarModelMapper{}"; - QTest::newRow("VBarModelMapper") << imports() + "VBarModelMapper{}"; - QTest::newRow("ValueAxis") << imports() + "ValueAxis{}"; -#ifndef QT_ON_ARM - QTest::newRow("DateTimeAxis") << imports() + "DateTimeAxis{}"; -#endif - QTest::newRow("CategoryAxis") << imports() + "CategoryAxis{}"; - QTest::newRow("CategoryRange") << imports() + "CategoryRange{}"; - QTest::newRow("BarCategoryAxis") << imports() + "BarCategoryAxis{}"; -} - -void tst_QML::checkPlugin() -{ - QFETCH(QString, source); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(source.toLatin1(), QUrl()); - QVERIFY2(!component.isError(), qPrintable(componentErrors(&component))); - TRY_COMPARE(component.status(), QDeclarativeComponent::Ready); - QObject *obj = component.create(); - QVERIFY(obj != 0); - - // - //TODO: - // QCOMPARE(obj->property("something").toInt(), 0); - - delete obj; -} - -QTEST_MAIN(tst_QML) - -#include "tst_qml.moc" - diff --git a/tests/auto/qpercentbarseries/qpercentbarseries.pro b/tests/auto/qpercentbarseries/qpercentbarseries.pro deleted file mode 100644 index e32360e..0000000 --- a/tests/auto/qpercentbarseries/qpercentbarseries.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qpercentbarseries.cpp diff --git a/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp b/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp deleted file mode 100644 index 55aef04..0000000 --- a/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include "tst_definitions.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(QBarSet*) - -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 mouseclicked_data(); - void mouseclicked(); - void mousehovered_data(); - void mousehovered(); - -private: - QPercentBarSeries* m_barseries; -}; - -void tst_QPercentBarSeries::initTestCase() -{ - qRegisterMetaType("QBarSet*"); -} - -void tst_QPercentBarSeries::cleanupTestCase() -{ -} - -void tst_QPercentBarSeries::init() -{ - m_barseries = new QPercentBarSeries(); -} - -void tst_QPercentBarSeries::cleanup() -{ - delete m_barseries; - m_barseries = 0; -} - -void tst_QPercentBarSeries::qpercentbarseries_data() -{ -} - -void tst_QPercentBarSeries::qpercentbarseries() -{ - QPercentBarSeries *barseries = new QPercentBarSeries(); - QVERIFY(barseries != 0); -} - -void tst_QPercentBarSeries::type_data() -{ - -} - -void tst_QPercentBarSeries::type() -{ - QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypePercentBar); -} - -void tst_QPercentBarSeries::mouseclicked_data() -{ - -} - -void tst_QPercentBarSeries::mouseclicked() -{ - QPercentBarSeries* series = new QPercentBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(clicked(int, QBarSet*))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - -//==================================================================================== -// barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); - -//==================================================================================== -// barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 2, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); -} - -void tst_QPercentBarSeries::mousehovered_data() -{ - -} - -void tst_QPercentBarSeries::mousehovered() -{ - QPercentBarSeries* series = new QPercentBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(hovered(bool, QBarSet*))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - //this is hack since view does not get events otherwise - view.setMouseTracking(true); - -//======================================================================= -// move mouse to left border - QTest::mouseMove(view.viewport(), QPoint(0, 190)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - TRY_COMPARE(seriesSpy.count(), 0); - -//======================================================================= -// move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(106,190)); - TRY_COMPARE(seriesSpy.count(), 1); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(106,95)); - TRY_COMPARE(seriesSpy.count(), 2); - - // should leave set1 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); - - // should enter set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(106,0)); - TRY_COMPARE(seriesSpy.count(), 1); - - // should leave set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); -} - -QTEST_MAIN(tst_QPercentBarSeries) - -#include "tst_qpercentbarseries.moc" - diff --git a/tests/auto/qpiemodelmapper/qpiemodelmapper.pro b/tests/auto/qpiemodelmapper/qpiemodelmapper.pro deleted file mode 100644 index e03e230..0000000 --- a/tests/auto/qpiemodelmapper/qpiemodelmapper.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} - -SOURCES += \ - tst_qpiemodelmapper.cpp diff --git a/tests/auto/qpiemodelmapper/tst_qpiemodelmapper.cpp b/tests/auto/qpiemodelmapper/tst_qpiemodelmapper.cpp deleted file mode 100644 index dbfe97c..0000000 --- a/tests/auto/qpiemodelmapper/tst_qpiemodelmapper.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class tst_qpiemodelmapper : public QObject -{ - Q_OBJECT - - public: - tst_qpiemodelmapper(); - void createVerticalMapper(); - void createHorizontalMapper(); - - private Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - void verticalMapper_data(); - void verticalMapper(); - void verticalMapperCustomMapping_data(); - void verticalMapperCustomMapping(); - void horizontalMapper_data(); - void horizontalMapper(); - void horizontalMapperCustomMapping_data(); - void horizontalMapperCustomMapping(); - void seriesUpdated(); - void verticalModelInsertRows(); - void verticalModelRemoveRows(); - void verticalModelInsertColumns(); - void verticalModelRemoveColumns(); - void horizontalModelInsertRows(); - void horizontalModelRemoveRows(); - void horizontalModelInsertColumns(); - void horizontalModelRemoveColumns(); - void modelUpdateCell(); - void verticalMapperSignals(); - void horizontalMapperSignals(); - - private: - QStandardItemModel *m_model; - int m_modelRowCount; - int m_modelColumnCount; - QVPieModelMapper *m_vMapper; - QHPieModelMapper *m_hMapper; - - QPieSeries *m_series; - QChart *m_chart; -}; - -tst_qpiemodelmapper::tst_qpiemodelmapper(): - m_model(0), - m_modelRowCount(10), - m_modelColumnCount(8), - m_vMapper(0), - m_hMapper(0), - m_series(0), - m_chart(0) -{ -} - -void tst_qpiemodelmapper::createVerticalMapper() -{ - m_vMapper = new QVPieModelMapper; - QVERIFY(m_vMapper->model() == 0); - m_vMapper->setValuesColumn(0); - m_vMapper->setLabelsColumn(1); - m_vMapper->setModel(m_model); - m_vMapper->setSeries(m_series); -} - -void tst_qpiemodelmapper::createHorizontalMapper() -{ - m_hMapper = new QHPieModelMapper; - QVERIFY(m_hMapper->model() == 0); - m_hMapper->setValuesRow(0); - m_hMapper->setLabelsRow(1); - m_hMapper->setModel(m_model); - m_hMapper->setSeries(m_series); -} - -void tst_qpiemodelmapper::init() -{ - m_series = new QPieSeries; - m_chart->addSeries(m_series); - - m_model = new QStandardItemModel(m_modelRowCount, m_modelColumnCount, this); - for (int row = 0; row < m_modelRowCount; ++row) { - for (int column = 0; column < m_modelColumnCount; column++) { - m_model->setData(m_model->index(row, column), row * column); - } - } -} - -void tst_qpiemodelmapper::cleanup() -{ - m_chart->removeSeries(m_series); - m_series->deleteLater(); - m_series = 0; - - m_model->clear(); - m_model->deleteLater(); - m_model = 0; - - if (m_vMapper) { - m_vMapper->deleteLater(); - m_vMapper = 0; - } - - if (m_hMapper) { - m_hMapper->deleteLater(); - m_hMapper = 0; - } -} - -void tst_qpiemodelmapper::initTestCase() -{ - m_chart = new QChart; - QChartView *chartView = new QChartView(m_chart); - chartView->show(); -} - -void tst_qpiemodelmapper::cleanupTestCase() -{ - // -} - -void tst_qpiemodelmapper::verticalMapper_data() -{ - QTest::addColumn("valuesColumn"); - QTest::addColumn("labelsColumn"); - QTest::addColumn("expectedCount"); - QTest::newRow("different values and labels columns") << 0 << 1 << m_modelRowCount; - QTest::newRow("same values and labels columns") << 1 << 1 << m_modelRowCount; - QTest::newRow("invalid values column and correct labels column") << -3 << 1 << 0; - QTest::newRow("values column beyond the size of model and correct labels column") << m_modelColumnCount << 1 << 0; - QTest::newRow("values column beyond the size of model and invalid labels column") << m_modelColumnCount << -1 << 0; -} - -void tst_qpiemodelmapper::verticalMapper() -{ - QFETCH(int, valuesColumn); - QFETCH(int, labelsColumn); - QFETCH(int, expectedCount); - - QVPieModelMapper *mapper = new QVPieModelMapper; - mapper->setValuesColumn(valuesColumn); - mapper->setLabelsColumn(labelsColumn); - mapper->setModel(m_model); - mapper->setSeries(m_series); - - QCOMPARE(m_series->count(), expectedCount); - QCOMPARE(mapper->valuesColumn(), qMax(-1, valuesColumn)); - QCOMPARE(mapper->labelsColumn(), qMax(-1, labelsColumn)); - - delete mapper; - mapper = 0; -} - -void tst_qpiemodelmapper::verticalMapperCustomMapping_data() -{ - QTest::addColumn("first"); - QTest::addColumn("countLimit"); - QTest::addColumn("expectedCount"); - QTest::newRow("first: 0, unlimited count") << 0 << -1 << m_modelRowCount; - QTest::newRow("first: 3, unlimited count") << 3 << -1 << m_modelRowCount - 3; - QTest::newRow("first: 0, count: 5") << 0 << 5 << qMin(5, m_modelRowCount); - QTest::newRow("first: 3, count: 5") << 3 << 5 << qMin(5, m_modelRowCount - 3); - QTest::newRow("first: +1 greater then the number of rows in the model, unlimited count") << m_modelRowCount + 1 << -1 << 0; - QTest::newRow("first: +1 greater then the number of rows in the model, count: 5") << m_modelRowCount + 1 << 5 << 0; - QTest::newRow("first: 0, count: +3 greater than the number of rows in the model (should limit to the size of model)") << 0 << m_modelRowCount + 3 << m_modelRowCount; - QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << m_modelRowCount; - QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << m_modelRowCount; - QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << m_modelRowCount; - -} - -void tst_qpiemodelmapper::verticalMapperCustomMapping() -{ - QFETCH(int, first); - QFETCH(int, countLimit); - QFETCH(int, expectedCount); - - QCOMPARE(m_series->count(), 0); - - QVPieModelMapper *mapper = new QVPieModelMapper; - mapper->setValuesColumn(0); - mapper->setLabelsColumn(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstRow(first); - mapper->setRowCount(countLimit); - - QCOMPARE(m_series->count(), expectedCount); - - // change values column mapping to invalid - mapper->setValuesColumn(-1); - mapper->setLabelsColumn(1); - - QCOMPARE(m_series->count(), 0); - - delete mapper; - mapper = 0; -} - -void tst_qpiemodelmapper::horizontalMapper_data() -{ - QTest::addColumn("valuesRow"); - QTest::addColumn("labelsRow"); - QTest::addColumn("expectedCount"); - QTest::newRow("different values and labels rows") << 0 << 1 << m_modelColumnCount; - QTest::newRow("same values and labels rows") << 1 << 1 << m_modelColumnCount; - QTest::newRow("invalid values row and correct labels row") << -3 << 1 << 0; - QTest::newRow("values row beyond the size of model and correct labels row") << m_modelRowCount << 1 << 0; - QTest::newRow("values row beyond the size of model and invalid labels row") << m_modelRowCount << -1 << 0; -} - -void tst_qpiemodelmapper::horizontalMapper() -{ - QFETCH(int, valuesRow); - QFETCH(int, labelsRow); - QFETCH(int, expectedCount); - - QHPieModelMapper *mapper = new QHPieModelMapper; - mapper->setValuesRow(valuesRow); - mapper->setLabelsRow(labelsRow); - mapper->setModel(m_model); - mapper->setSeries(m_series); - - QCOMPARE(m_series->count(), expectedCount); - QCOMPARE(mapper->valuesRow(), qMax(-1, valuesRow)); - QCOMPARE(mapper->labelsRow(), qMax(-1, labelsRow)); - - delete mapper; - mapper = 0; -} - -void tst_qpiemodelmapper::horizontalMapperCustomMapping_data() -{ - QTest::addColumn("first"); - QTest::addColumn("countLimit"); - QTest::addColumn("expectedCount"); - QTest::newRow("first: 0, unlimited count") << 0 << -1 << m_modelColumnCount; - QTest::newRow("first: 3, unlimited count") << 3 << -1 << m_modelColumnCount - 3; - QTest::newRow("first: 0, count: 5") << 0 << 5 << qMin(5, m_modelColumnCount); - QTest::newRow("first: 3, count: 5") << 3 << 5 << qMin(5, m_modelColumnCount - 3); - QTest::newRow("first: +1 greater then the number of columns in the model, unlimited count") << m_modelColumnCount + 1 << -1 << 0; - QTest::newRow("first: +1 greater then the number of columns in the model, count: 5") << m_modelColumnCount + 1 << 5 << 0; - QTest::newRow("first: 0, count: +3 greater than the number of columns in the model (should limit to the size of model)") << 0 << m_modelColumnCount + 3 << m_modelColumnCount; - QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << m_modelColumnCount; - QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << m_modelColumnCount; - QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << m_modelColumnCount; -} - -void tst_qpiemodelmapper::horizontalMapperCustomMapping() -{ - QFETCH(int, first); - QFETCH(int, countLimit); - QFETCH(int, expectedCount); - - QCOMPARE(m_series->count(), 0); - - QHPieModelMapper *mapper = new QHPieModelMapper; - mapper->setValuesRow(0); - mapper->setLabelsRow(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstColumn(first); - mapper->setColumnCount(countLimit); - - QCOMPARE(m_series->count(), expectedCount); - - // change values row mapping to invalid - mapper->setValuesRow(-1); - mapper->setLabelsRow(1); - - QCOMPARE(m_series->count(), 0); - - delete mapper; - mapper = 0; -} - -void tst_qpiemodelmapper::seriesUpdated() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QCOMPARE(m_vMapper->rowCount(), -1); - - m_series->append("1000", 1000); - QCOMPARE(m_series->count(), m_modelRowCount + 1); - QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model - - m_series->remove(m_series->slices().last()); - QCOMPARE(m_series->count(), m_modelRowCount); - QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model - - QPieSlice *slice = m_series->slices().first(); - slice->setValue(25.0); - slice->setLabel(QString("25.0")); - QCOMPARE(m_model->data(m_model->index(0, 0)).toReal(), 25.0); - QCOMPARE(m_model->data(m_model->index(0, 1)).toString(), QString("25.0")); -} - -void tst_qpiemodelmapper::verticalModelInsertRows() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int insertCount = 4; - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_modelRowCount + insertCount); - - int first = 3; - m_vMapper->setFirstRow(3); - QCOMPARE(m_series->count(), m_modelRowCount + insertCount - first); - - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_modelRowCount + 2 * insertCount - first); - - int countLimit = 6; - m_vMapper->setRowCount(countLimit); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first)); - - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first)); - - m_vMapper->setFirstRow(0); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount)); - - m_vMapper->setRowCount(-1); - QCOMPARE(m_series->count(), m_modelRowCount + 3 * insertCount); -} - -void tst_qpiemodelmapper::verticalModelRemoveRows() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int removeCount = 2; - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), m_modelRowCount - removeCount); - - int first = 1; - m_vMapper->setFirstRow(first); - QCOMPARE(m_series->count(), m_modelRowCount - removeCount - first); - - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), m_modelRowCount - 2 * removeCount - first); - - int countLimit = 3; - m_vMapper->setRowCount(countLimit); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first)); - - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first)); - - m_vMapper->setFirstRow(0); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount)); - - m_vMapper->setRowCount(-1); - QCOMPARE(m_series->count(), m_modelRowCount - 3 * removeCount); -} - -void tst_qpiemodelmapper::verticalModelInsertColumns() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int insertCount = 4; - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_modelRowCount); -} - -void tst_qpiemodelmapper::verticalModelRemoveColumns() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int removeCount = m_modelColumnCount - 2; - m_model->removeColumns(0, removeCount); - QCOMPARE(m_series->count(), m_modelRowCount); - - // leave only one column - m_model->removeColumns(0, m_modelColumnCount - removeCount - 1); - QCOMPARE(m_series->count(), 0); -} - -void tst_qpiemodelmapper::horizontalModelInsertRows() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int insertCount = 4; - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_modelColumnCount); -} - -void tst_qpiemodelmapper::horizontalModelRemoveRows() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int removeCount = m_modelRowCount - 2; - m_model->removeRows(0, removeCount); - QCOMPARE(m_series->count(), m_modelColumnCount); - - // leave only one column - m_model->removeRows(0, m_modelRowCount - removeCount - 1); - QCOMPARE(m_series->count(), 0); -} - -void tst_qpiemodelmapper::horizontalModelInsertColumns() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int insertCount = 4; - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_modelColumnCount + insertCount); - - int first = 3; - m_hMapper->setFirstColumn(3); - QCOMPARE(m_series->count(), m_modelColumnCount + insertCount - first); - - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_modelColumnCount + 2 * insertCount - first); - - int countLimit = 6; - m_hMapper->setColumnCount(countLimit); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first)); - - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first)); - - m_hMapper->setFirstColumn(0); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount)); - - m_hMapper->setColumnCount(-1); - QCOMPARE(m_series->count(), m_modelColumnCount + 3 * insertCount); -} - -void tst_qpiemodelmapper::horizontalModelRemoveColumns() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int removeCount = 2; - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), m_modelColumnCount - removeCount); - - int first = 1; - m_hMapper->setFirstColumn(first); - QCOMPARE(m_series->count(), m_modelColumnCount - removeCount - first); - - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), m_modelColumnCount - 2 * removeCount - first); - - int countLimit = 3; - m_hMapper->setColumnCount(countLimit); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first)); - - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first)); - - m_hMapper->setFirstColumn(0); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount)); - - m_hMapper->setColumnCount(-1); - QCOMPARE(m_series->count(), m_modelColumnCount - 3 * removeCount); -} - -void tst_qpiemodelmapper::modelUpdateCell() -{ - // setup the mapper - createVerticalMapper(); - - QVERIFY(m_model->setData(m_model->index(1, 0), 44)); - QCOMPARE(m_series->slices().at(1)->value(), 44.0); - QCOMPARE(m_model->data(m_model->index(1, 0)).toReal(), 44.0); -} - -void tst_qpiemodelmapper::verticalMapperSignals() -{ - QVPieModelMapper *mapper = new QVPieModelMapper; - - QSignalSpy spy0(mapper, SIGNAL(firstRowChanged())); - QSignalSpy spy1(mapper, SIGNAL(rowCountChanged())); - QSignalSpy spy2(mapper, SIGNAL(valuesColumnChanged())); - QSignalSpy spy3(mapper, SIGNAL(labelsColumnChanged())); - QSignalSpy spy4(mapper, SIGNAL(modelReplaced())); - QSignalSpy spy5(mapper, SIGNAL(seriesReplaced())); - - mapper->setValuesColumn(0); - mapper->setLabelsColumn(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstRow(1); - mapper->setRowCount(5); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - QCOMPARE(spy4.count(), 1); - QCOMPARE(spy5.count(), 1); - -} - -void tst_qpiemodelmapper::horizontalMapperSignals() -{ - QHPieModelMapper *mapper = new QHPieModelMapper; - - QSignalSpy spy0(mapper, SIGNAL(firstColumnChanged())); - QSignalSpy spy1(mapper, SIGNAL(columnCountChanged())); - QSignalSpy spy2(mapper, SIGNAL(valuesRowChanged())); - QSignalSpy spy3(mapper, SIGNAL(labelsRowChanged())); - QSignalSpy spy4(mapper, SIGNAL(modelReplaced())); - QSignalSpy spy5(mapper, SIGNAL(seriesReplaced())); - - mapper->setValuesRow(0); - mapper->setLabelsRow(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstColumn(1); - mapper->setColumnCount(5); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - QCOMPARE(spy4.count(), 1); - QCOMPARE(spy5.count(), 1); -} - -QTEST_MAIN(tst_qpiemodelmapper) - -#include "tst_qpiemodelmapper.moc" diff --git a/tests/auto/qpieseries/qpieseries.pro b/tests/auto/qpieseries/qpieseries.pro deleted file mode 100644 index 82a19f9..0000000 --- a/tests/auto/qpieseries/qpieseries.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qpieseries.cpp diff --git a/tests/auto/qpieseries/tst_qpieseries.cpp b/tests/auto/qpieseries/tst_qpieseries.cpp deleted file mode 100644 index a742df1..0000000 --- a/tests/auto/qpieseries/tst_qpieseries.cpp +++ /dev/null @@ -1,638 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(QPieSlice*) -Q_DECLARE_METATYPE(QList) - -class tst_qpieseries : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void properties(); - void append(); - void appendAnimated(); - void insert(); - void insertAnimated(); - void remove(); - void removeAnimated(); - void take(); - void takeAnimated(); - void calculatedValues(); - void clickedSignal(); - void hoverSignal(); - void sliceSeries(); - void destruction(); - -private: - void verifyCalculatedData(const QPieSeries &series, bool *ok); - -private: - QChartView *m_view; - QPieSeries *m_series; -}; - -void tst_qpieseries::initTestCase() -{ - qRegisterMetaType("QPieSlice*"); - qRegisterMetaType >("QList"); -} - -void tst_qpieseries::cleanupTestCase() -{ -} - -void tst_qpieseries::init() -{ - m_view = new QChartView(); - m_series = new QPieSeries(m_view); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - -} - -void tst_qpieseries::cleanup() -{ - delete m_view; - m_view = 0; - m_series = 0; -} - -void tst_qpieseries::properties() -{ - QSignalSpy countSpy(m_series, SIGNAL(countChanged())); - QSignalSpy sumSpy(m_series, SIGNAL(sumChanged())); - - QVERIFY(m_series->type() == QAbstractSeries::SeriesTypePie); - QVERIFY(m_series->count() == 0); - QVERIFY(m_series->isEmpty()); - QCOMPARE(m_series->sum(), 0.0); - QCOMPARE(m_series->horizontalPosition(), 0.5); - QCOMPARE(m_series->verticalPosition(), 0.5); - QCOMPARE(m_series->pieSize(), 0.7); - QCOMPARE(m_series->pieStartAngle(), 0.0); - QCOMPARE(m_series->pieEndAngle(), 360.0); - - m_series->append("s1", 1); - m_series->append("s2", 1); - m_series->append("s3", 1); - m_series->insert(1, new QPieSlice("s4", 1)); - m_series->remove(m_series->slices().first()); - QCOMPARE(m_series->count(), 3); - QCOMPARE(m_series->sum(), 3.0); - m_series->clear(); - QCOMPARE(m_series->count(), 0); - QCOMPARE(m_series->sum(), 0.0); - QCOMPARE(countSpy.count(), 6); - QCOMPARE(sumSpy.count(), 6); - - m_series->setPieSize(-1.0); - QCOMPARE(m_series->pieSize(), 0.0); - m_series->setPieSize(0.0); - m_series->setPieSize(0.9); - m_series->setPieSize(2.0); - QCOMPARE(m_series->pieSize(), 1.0); - - m_series->setPieSize(0.7); - QCOMPARE(m_series->pieSize(), 0.7); - - m_series->setHoleSize(-1.0); - QCOMPARE(m_series->holeSize(), 0.0); - m_series->setHoleSize(0.5); - QCOMPARE(m_series->holeSize(), 0.5); - - m_series->setHoleSize(0.8); - QCOMPARE(m_series->holeSize(), 0.8); - QCOMPARE(m_series->pieSize(), 0.8); - - m_series->setPieSize(0.4); - QCOMPARE(m_series->pieSize(), 0.4); - QCOMPARE(m_series->holeSize(), 0.4); - - m_series->setPieStartAngle(0); - m_series->setPieStartAngle(-180); - m_series->setPieStartAngle(180); - QCOMPARE(m_series->pieStartAngle(), 180.0); - - m_series->setPieEndAngle(360); - m_series->setPieEndAngle(-180); - m_series->setPieEndAngle(180); - QCOMPARE(m_series->pieEndAngle(), 180.0); - - m_series->setHorizontalPosition(0.5); - m_series->setHorizontalPosition(-1.0); - QCOMPARE(m_series->horizontalPosition(), 0.0); - m_series->setHorizontalPosition(1.0); - m_series->setHorizontalPosition(2.0); - QCOMPARE(m_series->horizontalPosition(), 1.0); - - m_series->setVerticalPosition(0.5); - m_series->setVerticalPosition(-1.0); - QCOMPARE(m_series->verticalPosition(), 0.0); - m_series->setVerticalPosition(1.0); - m_series->setVerticalPosition(2.0); - QCOMPARE(m_series->verticalPosition(), 1.0); -} - -void tst_qpieseries::append() -{ - m_view->chart()->addSeries(m_series); - QSignalSpy addedSpy(m_series, SIGNAL(added(QList))); - - // append pointer - QPieSlice *slice1 = 0; - QVERIFY(!m_series->append(slice1)); - slice1 = new QPieSlice("slice 1", 1); - QVERIFY(m_series->append(slice1)); - QVERIFY(!m_series->append(slice1)); - QCOMPARE(m_series->count(), 1); - QCOMPARE(addedSpy.count(), 1); - QList added = qvariant_cast >(addedSpy.at(0).at(0)); - QCOMPARE(added.count(), 1); - QCOMPARE(added.first(), slice1); - - // try to append same slice to another series - QPieSeries series2; - QVERIFY(!series2.append(slice1)); - - // append pointer list - QList list; - QVERIFY(!m_series->append(list)); - list << (QPieSlice *) 0; - QVERIFY(!m_series->append(list)); - list.clear(); - list << new QPieSlice("slice 2", 2); - list << new QPieSlice("slice 3", 3); - QVERIFY(m_series->append(list)); - QVERIFY(!m_series->append(list)); - QCOMPARE(m_series->count(), 3); - QCOMPARE(addedSpy.count(), 2); - added = qvariant_cast >(addedSpy.at(1).at(0)); - QCOMPARE(added.count(), 2); - QCOMPARE(added, list); - - // append operator - QPieSlice *slice4 = new QPieSlice("slice 4", 4); - *m_series << slice4; - *m_series << slice1; // fails because already added - QCOMPARE(m_series->count(), 4); - QCOMPARE(addedSpy.count(), 3); - added = qvariant_cast >(addedSpy.at(2).at(0)); - QCOMPARE(added.count(), 1); - QCOMPARE(added.first(), slice4); - - // append with params - QPieSlice *slice5 = m_series->append("slice 5", 5); - QVERIFY(slice5 != 0); - QCOMPARE(slice5->value(), 5.0); - QCOMPARE(slice5->label(), QString("slice 5")); - QCOMPARE(m_series->count(), 5); - QCOMPARE(addedSpy.count(), 4); - added = qvariant_cast >(addedSpy.at(3).at(0)); - QCOMPARE(added.count(), 1); - QCOMPARE(added.first(), slice5); - - // check slices - QVERIFY(!m_series->isEmpty()); - for (int i=0; icount(); i++) { - QCOMPARE(m_series->slices().at(i)->value(), (qreal) i+1); - QCOMPARE(m_series->slices().at(i)->label(), QString("slice ") + QString::number(i+1)); - } -} - -void tst_qpieseries::appendAnimated() -{ - m_view->chart()->setAnimationOptions(QChart::AllAnimations); - append(); -} - -void tst_qpieseries::insert() -{ - m_view->chart()->addSeries(m_series); - QSignalSpy addedSpy(m_series, SIGNAL(added(QList))); - - // insert one slice - QPieSlice *slice1 = 0; - QVERIFY(!m_series->insert(0, slice1)); - slice1 = new QPieSlice("slice 1", 1); - QVERIFY(!m_series->insert(-1, slice1)); - QVERIFY(!m_series->insert(5, slice1)); - QVERIFY(m_series->insert(0, slice1)); - QVERIFY(!m_series->insert(0, slice1)); - QCOMPARE(m_series->count(), 1); - QCOMPARE(addedSpy.count(), 1); - QList added = qvariant_cast >(addedSpy.at(0).at(0)); - QCOMPARE(added.count(), 1); - QCOMPARE(added.first(), slice1); - - // try to insert same slice to another series - QPieSeries series2; - QVERIFY(!series2.insert(0, slice1)); - - // add some more slices - QPieSlice *slice2 = m_series->append("slice 2", 2); - QPieSlice *slice4 = m_series->append("slice 4", 4); - QCOMPARE(m_series->count(), 3); - QCOMPARE(addedSpy.count(), 3); - added = qvariant_cast >(addedSpy.at(1).at(0)); - QCOMPARE(added.count(), 1); - QCOMPARE(added.first(), slice2); - added = qvariant_cast >(addedSpy.at(2).at(0)); - QCOMPARE(added.count(), 1); - QCOMPARE(added.first(), slice4); - - // insert between slices - QPieSlice *slice3 = new QPieSlice("slice 3", 3); - m_series->insert(2, slice3); - QCOMPARE(m_series->count(), 4); - QCOMPARE(addedSpy.count(), 4); - added = qvariant_cast >(addedSpy.at(3).at(0)); - QCOMPARE(added.count(), 1); - QCOMPARE(added.first(), slice3); - - // check slices - for (int i=0; icount(); i++) { - QCOMPARE(m_series->slices().at(i)->value(), (qreal) i+1); - QCOMPARE(m_series->slices().at(i)->label(), QString("slice ") + QString::number(i+1)); - QVERIFY(m_series->slices().at(i)->parent() == m_series); - } -} - -void tst_qpieseries::insertAnimated() -{ - m_view->chart()->setAnimationOptions(QChart::AllAnimations); - insert(); -} - -void tst_qpieseries::remove() -{ - m_view->chart()->addSeries(m_series); - QSignalSpy removedSpy(m_series, SIGNAL(removed(QList))); - - // add some slices - QPieSlice *slice1 = m_series->append("slice 1", 1); - QPieSlice *slice2 = m_series->append("slice 2", 2); - QPieSlice *slice3 = m_series->append("slice 3", 3); - QSignalSpy spy1(slice1, SIGNAL(destroyed())); - QSignalSpy spy2(slice2, SIGNAL(destroyed())); - QSignalSpy spy3(slice3, SIGNAL(destroyed())); - QCOMPARE(m_series->count(), 3); - - // null pointer remove - QVERIFY(!m_series->remove(0)); - - // remove first - QVERIFY(m_series->remove(slice1)); - QVERIFY(!m_series->remove(slice1)); - QCOMPARE(m_series->count(), 2); - QCOMPARE(m_series->slices().at(0)->label(), slice2->label()); - QCOMPARE(removedSpy.count(), 1); - QList removed = qvariant_cast >(removedSpy.at(0).at(0)); - QCOMPARE(removed.count(), 1); - QCOMPARE(removed.first(), slice1); - - // remove all - m_series->clear(); - QVERIFY(m_series->isEmpty()); - QVERIFY(m_series->slices().isEmpty()); - QCOMPARE(m_series->count(), 0); - QCOMPARE(removedSpy.count(), 2); - removed = qvariant_cast >(removedSpy.at(1).at(0)); - QCOMPARE(removed.count(), 2); - QCOMPARE(removed.first(), slice2); - QCOMPARE(removed.last(), slice3); - - // check that slices were actually destroyed - TRY_COMPARE(spy1.count(), 1); - TRY_COMPARE(spy2.count(), 1); - TRY_COMPARE(spy3.count(), 1); -} - -void tst_qpieseries::removeAnimated() -{ - m_view->chart()->setAnimationOptions(QChart::AllAnimations); - remove(); -} - -void tst_qpieseries::take() -{ - m_view->chart()->addSeries(m_series); - QSignalSpy removedSpy(m_series, SIGNAL(removed(QList))); - - // add some slices - QPieSlice *slice1 = m_series->append("slice 1", 1); - QPieSlice *slice2 = m_series->append("slice 2", 2); - m_series->append("slice 3", 3); - QSignalSpy spy1(slice1, SIGNAL(destroyed())); - QCOMPARE(m_series->count(), 3); - - // null pointer remove - QVERIFY(!m_series->take(0)); - - // take first - QVERIFY(m_series->take(slice1)); - TRY_COMPARE(spy1.count(), 0); - QVERIFY(slice1->parent() == m_series); // series is still the parent object - QVERIFY(!m_series->take(slice1)); - QCOMPARE(m_series->count(), 2); - QCOMPARE(m_series->slices().at(0)->label(), slice2->label()); - QCOMPARE(removedSpy.count(), 1); - QList removed = qvariant_cast >(removedSpy.at(0).at(0)); - QCOMPARE(removed.count(), 1); - QCOMPARE(removed.first(), slice1); -} - -void tst_qpieseries::takeAnimated() -{ - m_view->chart()->setAnimationOptions(QChart::AllAnimations); - take(); -} - -void tst_qpieseries::calculatedValues() -{ - m_view->chart()->addSeries(m_series); - - QPieSlice *slice1 = new QPieSlice("slice 1", 1); - QSignalSpy percentageSpy(slice1, SIGNAL(percentageChanged())); - QSignalSpy startAngleSpy(slice1, SIGNAL(startAngleChanged())); - QSignalSpy angleSpanSpy(slice1, SIGNAL(angleSpanChanged())); - - // add a slice - m_series->append(slice1); - bool ok; - verifyCalculatedData(*m_series, &ok); - if (!ok) - return; - QCOMPARE(percentageSpy.count(), 1); - QCOMPARE(startAngleSpy.count(), 0); - QCOMPARE(angleSpanSpy.count(), 1); - - // add some more slices - QList list; - list << new QPieSlice("slice 2", 2); - list << new QPieSlice("slice 3", 3); - m_series->append(list); - verifyCalculatedData(*m_series, &ok); - if (!ok) - return; - QCOMPARE(percentageSpy.count(), 2); - QCOMPARE(startAngleSpy.count(), 0); - QCOMPARE(angleSpanSpy.count(), 2); - - // remove a slice - m_series->remove(list.first()); // remove slice 2 - verifyCalculatedData(*m_series, &ok); - if (!ok) - return; - QCOMPARE(percentageSpy.count(), 3); - QCOMPARE(startAngleSpy.count(), 0); - QCOMPARE(angleSpanSpy.count(), 3); - - // insert a slice - m_series->insert(0, new QPieSlice("Slice 4", 4)); - verifyCalculatedData(*m_series, &ok); - if (!ok) - return; - QCOMPARE(percentageSpy.count(), 4); - QCOMPARE(startAngleSpy.count(), 1); - QCOMPARE(angleSpanSpy.count(), 4); - - // modify pie angles - m_series->setPieStartAngle(-90); - m_series->setPieEndAngle(90); - verifyCalculatedData(*m_series, &ok); - if (!ok) - return; - QCOMPARE(percentageSpy.count(), 4); - QCOMPARE(startAngleSpy.count(), 3); - QCOMPARE(angleSpanSpy.count(), 6); - - // clear all - m_series->clear(); - verifyCalculatedData(*m_series, &ok); - if (!ok) - return; - QCOMPARE(percentageSpy.count(), 4); - QCOMPARE(startAngleSpy.count(), 3); - QCOMPARE(angleSpanSpy.count(), 6); -} - -void tst_qpieseries::verifyCalculatedData(const QPieSeries &series, bool *ok) -{ - *ok = false; - - qreal sum = 0; - foreach (const QPieSlice *slice, series.slices()) - sum += slice->value(); - QCOMPARE(series.sum(), sum); - - qreal startAngle = series.pieStartAngle(); - qreal pieAngleSpan = series.pieEndAngle() - series.pieStartAngle(); - foreach (const QPieSlice *slice, series.slices()) { - qreal ratio = slice->value() / sum; - qreal sliceSpan = pieAngleSpan * ratio; - QCOMPARE(slice->startAngle(), startAngle); - QCOMPARE(slice->angleSpan(), sliceSpan); - QCOMPARE(slice->percentage(), ratio); - startAngle += sliceSpan; - } - - if (!series.isEmpty()) - QCOMPARE(series.slices().last()->startAngle() + series.slices().last()->angleSpan(), series.pieEndAngle()); - - *ok = true; -} - - -void tst_qpieseries::clickedSignal() -{ - // add some slices - QPieSlice *s1 = m_series->append("slice 1", 1); - QPieSlice *s2 = m_series->append("slice 2", 1); - QPieSlice *s3 = m_series->append("slice 3", 1); - QPieSlice *s4 = m_series->append("slice 4", 1); - QSignalSpy clickSpy(m_series, SIGNAL(clicked(QPieSlice*))); - - // add series to the chart - m_view->chart()->legend()->setVisible(false); - m_view->resize(200, 200); - m_view->chart()->addSeries(m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - - // if you divide the chart in four equal tiles these - // are the center points of those tiles - QPoint p1(90.25, 90); - QPoint p2(150, 90); - QPoint p3(90, 150); - QPoint p4(150, 150); - - QPoint center(120, 120); - - m_series->setPieSize(1.0); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center); - TRY_COMPARE(clickSpy.count(), 5); // all hit - QCOMPARE(qvariant_cast(clickSpy.at(0).at(0)), s4); - QCOMPARE(qvariant_cast(clickSpy.at(1).at(0)), s1); - QCOMPARE(qvariant_cast(clickSpy.at(2).at(0)), s3); - QCOMPARE(qvariant_cast(clickSpy.at(3).at(0)), s2); - clickSpy.clear(); - - m_series->setPieSize(0.5); - m_series->setVerticalPosition(0.25); - m_series->setHorizontalPosition(0.25); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1); // hits - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center); - TRY_COMPARE(clickSpy.count(), 1); - clickSpy.clear(); - - m_series->setVerticalPosition(0.25); - m_series->setHorizontalPosition(0.75); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2); // hits - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center); - TRY_COMPARE(clickSpy.count(), 1); - clickSpy.clear(); - - m_series->setVerticalPosition(0.75); - m_series->setHorizontalPosition(0.25); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3); // hits - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center); - TRY_COMPARE(clickSpy.count(), 1); - clickSpy.clear(); - - m_series->setVerticalPosition(0.75); - m_series->setHorizontalPosition(0.75); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p1); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p2); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p3); - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, p4); // hits - QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, center); - TRY_COMPARE(clickSpy.count(), 1); - clickSpy.clear(); -} - -void tst_qpieseries::hoverSignal() -{ - // add some slices - m_series->setPieSize(1.0); - QPieSlice *s1 = m_series->append("slice 1", 1); - m_series->append("slice 2", 2); - m_series->append("slice 3", 3); - - // add series to the chart - m_view->chart()->legend()->setVisible(false); - m_view->resize(200, 200); - m_view->chart()->addSeries(m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - - // first move to right top corner - QTest::mouseMove(m_view->viewport(), QPoint(200, 0)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - // move inside the slice - // pie rectangle: QRectF(60,60 121x121) - QSignalSpy hoverSpy(m_series, SIGNAL(hovered(QPieSlice*,bool))); - QTest::mouseMove(m_view->viewport(), QPoint(139, 85)); - TRY_COMPARE(hoverSpy.count(), 1); - QCOMPARE(qvariant_cast(hoverSpy.at(0).at(0)), s1); - QCOMPARE(qvariant_cast(hoverSpy.at(0).at(1)), true); - - // move outside the slice - QTest::mouseMove(m_view->viewport(), QPoint(200, 0)); - TRY_COMPARE(hoverSpy.count(), 2); - QCOMPARE(qvariant_cast(hoverSpy.at(1).at(0)), s1); - QCOMPARE(qvariant_cast(hoverSpy.at(1).at(1)), false); -} - -void tst_qpieseries::sliceSeries() -{ - QPieSlice *slice = new QPieSlice(); - QVERIFY(!slice->series()); - delete slice; - - slice = new QPieSlice(m_series); - QVERIFY(!slice->series()); - - m_series->append(slice); - QCOMPARE(slice->series(), m_series); - - slice = new QPieSlice(); - m_series->insert(0, slice); - QCOMPARE(slice->series(), m_series); - - m_series->take(slice); - QCOMPARE(slice->series(), (QPieSeries*) 0); -} - -void tst_qpieseries::destruction() -{ - // add some slices - QPieSlice *slice1 = m_series->append("slice 1", 1); - QPieSlice *slice2 = m_series->append("slice 2", 2); - QPieSlice *slice3 = m_series->append("slice 3", 3); - QSignalSpy spy1(slice1, SIGNAL(destroyed())); - QSignalSpy spy2(slice2, SIGNAL(destroyed())); - QSignalSpy spy3(slice3, SIGNAL(destroyed())); - - // destroy series - delete m_series; - m_series = 0; - - // check that series has destroyed its slices - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); -} - -QTEST_MAIN(tst_qpieseries) - -#include "tst_qpieseries.moc" - diff --git a/tests/auto/qpieslice/qpieslice.pro b/tests/auto/qpieslice/qpieslice.pro deleted file mode 100644 index 3c8c5a0..0000000 --- a/tests/auto/qpieslice/qpieslice.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qpieslice.cpp diff --git a/tests/auto/qpieslice/tst_qpieslice.cpp b/tests/auto/qpieslice/tst_qpieslice.cpp deleted file mode 100644 index a0f67f2..0000000 --- a/tests/auto/qpieslice/tst_qpieslice.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class tst_qpieslice : public QObject -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void construction(); - void changedSignals(); - void customize(); - void mouseClick(); - void mouseHover(); - -private: - - -private: - -}; - -void tst_qpieslice::initTestCase() -{ -} - -void tst_qpieslice::cleanupTestCase() -{ -} - -void tst_qpieslice::init() -{ - -} - -void tst_qpieslice::cleanup() -{ - -} - -void tst_qpieslice::construction() -{ - // no params - QPieSlice slice1; - QCOMPARE(slice1.value(), 0.0); - QVERIFY(slice1.label().isEmpty()); - QVERIFY(!slice1.isLabelVisible()); - QVERIFY(!slice1.isExploded()); - QCOMPARE(slice1.pen(), QPen()); - QCOMPARE(slice1.brush(), QBrush()); - QCOMPARE(slice1.labelBrush(), QBrush()); - QCOMPARE(slice1.labelFont(), QFont()); - QCOMPARE(slice1.labelArmLengthFactor(), 0.15); // default value - QCOMPARE(slice1.explodeDistanceFactor(), 0.15); // default value - QCOMPARE(slice1.percentage(), 0.0); - QCOMPARE(slice1.startAngle(), 0.0); - QCOMPARE(slice1.angleSpan(), 0.0); - - // value and label params - QPieSlice slice2("foobar", 1.0); - QCOMPARE(slice2.value(), 1.0); - QCOMPARE(slice2.label(), QString("foobar")); - QVERIFY(!slice2.isLabelVisible()); - QVERIFY(!slice2.isExploded()); - QCOMPARE(slice2.pen(), QPen()); - QCOMPARE(slice2.brush(), QBrush()); - QCOMPARE(slice2.labelBrush(), QBrush()); - QCOMPARE(slice2.labelFont(), QFont()); - QCOMPARE(slice2.labelArmLengthFactor(), 0.15); // default value - QCOMPARE(slice2.explodeDistanceFactor(), 0.15); // default value - QCOMPARE(slice2.percentage(), 0.0); - QCOMPARE(slice2.startAngle(), 0.0); - QCOMPARE(slice2.angleSpan(), 0.0); -} - -void tst_qpieslice::changedSignals() -{ - QPieSlice slice; - - QSignalSpy valueSpy(&slice, SIGNAL(valueChanged())); - QSignalSpy labelSpy(&slice, SIGNAL(labelChanged())); - QSignalSpy penSpy(&slice, SIGNAL(penChanged())); - QSignalSpy brushSpy(&slice, SIGNAL(brushChanged())); - QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged())); - QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged())); - QSignalSpy colorSpy(&slice, SIGNAL(colorChanged())); - QSignalSpy borderColorSpy(&slice, SIGNAL(borderColorChanged())); - QSignalSpy borderWidthSpy(&slice, SIGNAL(borderWidthChanged())); - QSignalSpy labelColorSpy(&slice, SIGNAL(labelColorChanged())); - - // percentageChanged(), startAngleChanged() and angleSpanChanged() signals tested at tst_qpieseries::calculatedValues() - - // set everything twice to see we do not get unnecessary signals - slice.setValue(1.0); - slice.setValue(-1.0); - QCOMPARE(slice.value(), 1.0); - slice.setLabel("foobar"); - slice.setLabel("foobar"); - slice.setLabelVisible(); - slice.setLabelVisible(); - slice.setExploded(); - slice.setExploded(); - slice.setPen(QPen(Qt::red)); - slice.setPen(QPen(QBrush(Qt::red), 3)); - slice.setBrush(QBrush(Qt::red)); - slice.setBrush(QBrush(Qt::red)); - slice.setLabelBrush(QBrush(Qt::green)); - slice.setLabelBrush(QBrush(Qt::green)); - slice.setLabelFont(QFont("Tahoma")); - slice.setLabelFont(QFont("Tahoma")); - slice.setLabelPosition(QPieSlice::LabelInsideHorizontal); - slice.setLabelPosition(QPieSlice::LabelInsideHorizontal); - slice.setLabelArmLengthFactor(0.1); - slice.setLabelArmLengthFactor(0.1); - slice.setExplodeDistanceFactor(0.1); - slice.setExplodeDistanceFactor(0.1); - - TRY_COMPARE(valueSpy.count(), 1); - TRY_COMPARE(labelSpy.count(), 1); - TRY_COMPARE(penSpy.count(), 2); - TRY_COMPARE(brushSpy.count(), 1); - TRY_COMPARE(labelBrushSpy.count(), 1); - TRY_COMPARE(labelFontSpy.count(), 1); - TRY_COMPARE(colorSpy.count(), 1); - TRY_COMPARE(borderColorSpy.count(), 1); - TRY_COMPARE(borderWidthSpy.count(), 1); - TRY_COMPARE(labelColorSpy.count(), 1); -} - -void tst_qpieslice::customize() -{ - // create a pie series - QPieSeries *series = new QPieSeries(); - QPieSlice *s1 = series->append("slice 1", 1); - QPieSlice *s2 = series->append("slice 2", 2); - series->append("slice 3", 3); - - // customize a slice - QPen p1(Qt::red); - s1->setPen(p1); - QBrush b1(Qt::red); - s1->setBrush(b1); - s1->setLabelBrush(b1); - QFont f1("Consolas"); - s1->setLabelFont(f1); - - // add series to the chart - QChartView view(new QChart()); - view.resize(200, 200); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - //QTest::qWait(1000); - - // check that customizations persist - QCOMPARE(s1->pen(), p1); - QCOMPARE(s1->brush(), b1); - QCOMPARE(s1->labelBrush(), b1); - QCOMPARE(s1->labelFont(), f1); - - // remove a slice - series->remove(s2); - QCOMPARE(s1->pen(), p1); - QCOMPARE(s1->brush(), b1); - QCOMPARE(s1->labelBrush(), b1); - QCOMPARE(s1->labelFont(), f1); - - // add a slice - series->append("slice 4", 4); - QCOMPARE(s1->pen(), p1); - QCOMPARE(s1->brush(), b1); - QCOMPARE(s1->labelBrush(), b1); - QCOMPARE(s1->labelFont(), f1); - - // insert a slice - series->insert(0, new QPieSlice("slice 5", 5)); - QCOMPARE(s1->pen(), p1); - QCOMPARE(s1->brush(), b1); - QCOMPARE(s1->labelBrush(), b1); - QCOMPARE(s1->labelFont(), f1); - - // change theme - // theme will overwrite customizations - view.chart()->setTheme(QChart::ChartThemeHighContrast); - QVERIFY(s1->pen() != p1); - QVERIFY(s1->brush() != b1); - QVERIFY(s1->labelBrush() != b1); - QVERIFY(s1->labelFont() != f1); -} - -void tst_qpieslice::mouseClick() -{ - // create a pie series - QPieSeries *series = new QPieSeries(); - series->setPieSize(1.0); - QPieSlice *s1 = series->append("slice 1", 1); - QPieSlice *s2 = series->append("slice 2", 2); - QPieSlice *s3 = series->append("slice 3", 3); - QSignalSpy clickSpy1(s1, SIGNAL(clicked())); - QSignalSpy clickSpy2(s2, SIGNAL(clicked())); - QSignalSpy clickSpy3(s3, SIGNAL(clicked())); - - // add series to the chart - QChartView view(new QChart()); - view.chart()->legend()->setVisible(false); - view.resize(200, 200); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - // simulate clicks - // pie rectangle: QRectF(60,60 121x121) - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(139, 85)); // inside slice 1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(146, 136)); // inside slice 2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(91, 119)); // inside slice 3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(70, 70)); // inside pie rectangle but not inside a slice - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(170, 170)); // inside pie rectangle but not inside a slice - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(clickSpy1.count(), 1); - QCOMPARE(clickSpy2.count(), 1); - QCOMPARE(clickSpy3.count(), 1); -} - -void tst_qpieslice::mouseHover() -{ - // create a pie series - QPieSeries *series = new QPieSeries(); - series->setPieSize(1.0); - QPieSlice *s1 = series->append("slice 1", 1); - series->append("slice 2", 2); - series->append("slice 3", 3); - - // add series to the chart - QChartView view(new QChart()); - view.chart()->legend()->setVisible(false); - view.resize(200, 200); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - // first move to right top corner - QTest::mouseMove(view.viewport(), QPoint(200, 0)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - // move inside slice rectangle but NOT the actual slice - // pie rectangle: QRectF(60,60 121x121) - QSignalSpy hoverSpy(s1, SIGNAL(hovered(bool))); - QTest::mouseMove(view.viewport(), QPoint(170, 70)); - TRY_COMPARE(hoverSpy.count(), 0); - - // move inside the slice - QTest::mouseMove(view.viewport(), QPoint(139, 85)); - TRY_COMPARE(hoverSpy.count(), 1); - QCOMPARE(qvariant_cast(hoverSpy.at(0).at(0)), true); - - // move outside the slice - QTest::mouseMove(view.viewport(), QPoint(200, 0)); - TRY_COMPARE(hoverSpy.count(), 2); - QCOMPARE(qvariant_cast(hoverSpy.at(1).at(0)), false); -} - -QTEST_MAIN(tst_qpieslice) - -#include "tst_qpieslice.moc" - diff --git a/tests/auto/qscatterseries/qscatterseries.pro b/tests/auto/qscatterseries/qscatterseries.pro deleted file mode 100644 index 8144798..0000000 --- a/tests/auto/qscatterseries/qscatterseries.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ):error( "Couldn't find the auto.pri file!" ) - -HEADERS += ../qxyseries/tst_qxyseries.h -SOURCES += tst_qscatterseries.cpp ../qxyseries/tst_qxyseries.cpp diff --git a/tests/auto/qscatterseries/tst_qscatterseries.cpp b/tests/auto/qscatterseries/tst_qscatterseries.cpp deleted file mode 100644 index acdc9d5..0000000 --- a/tests/auto/qscatterseries/tst_qscatterseries.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** 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 "../qxyseries/tst_qxyseries.h" -#include - -Q_DECLARE_METATYPE(QList) - -class tst_QScatterSeries : public tst_QXYSeries -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); -private slots: - void qscatterseries_data(); - void qscatterseries(); - void scatterChangedSignals(); - -protected: - void pointsVisible_data(); -}; - -void tst_QScatterSeries::initTestCase() -{ -} - -void tst_QScatterSeries::cleanupTestCase() -{ -} - -void tst_QScatterSeries::init() -{ - tst_QXYSeries::init(); - m_series = new QScatterSeries(); -} - -void tst_QScatterSeries::cleanup() -{ - delete m_series; - tst_QXYSeries::cleanup(); -} - -void tst_QScatterSeries::qscatterseries_data() -{ - -} - -void tst_QScatterSeries::qscatterseries() -{ - QScatterSeries series; - - QCOMPARE(series.count(),0); - QCOMPARE(series.brush(), QBrush()); - QCOMPARE(series.points(), QList()); - QCOMPARE(series.pen(), QPen()); - QCOMPARE(series.pointsVisible(), false); - - series.append(QList()); - series.append(0.0,0.0); - series.append(QPointF()); - - series.remove(0.0,0.0); - series.remove(QPointF()); - series.clear(); - - series.replace(QPointF(),QPointF()); - series.replace(0,0,0,0); - series.setBrush(QBrush()); - - series.setPen(QPen()); - series.setPointsVisible(false); - - m_chart->addSeries(&series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); -} - -void tst_QScatterSeries::scatterChangedSignals() -{ - QScatterSeries *series = qobject_cast(m_series); - QVERIFY(series); - - QSignalSpy colorSpy(series, SIGNAL(colorChanged(QColor))); - QSignalSpy borderColorSpy(series, SIGNAL(borderColorChanged(QColor))); - - // Color - series->setColor(QColor("blueviolet")); - TRY_COMPARE(colorSpy.count(), 1); - - // Border color - series->setBorderColor(QColor("burlywood")); - TRY_COMPARE(borderColorSpy.count(), 1); - - // Pen - QPen p = series->pen(); - p.setColor("lightpink"); - series->setPen(p); - TRY_COMPARE(borderColorSpy.count(), 2); - - // Brush - QBrush b = series->brush(); - b.setColor("lime"); - series->setBrush(b); - TRY_COMPARE(colorSpy.count(), 2); -} - -QTEST_MAIN(tst_QScatterSeries) - -#include "tst_qscatterseries.moc" - diff --git a/tests/auto/qsplineseries/qsplineseries.pro b/tests/auto/qsplineseries/qsplineseries.pro deleted file mode 100644 index 7d5d179..0000000 --- a/tests/auto/qsplineseries/qsplineseries.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -HEADERS += ../qxyseries/tst_qxyseries.h -SOURCES += tst_qsplineseries.cpp ../qxyseries/tst_qxyseries.cpp diff --git a/tests/auto/qsplineseries/tst_qsplineseries.cpp b/tests/auto/qsplineseries/tst_qsplineseries.cpp deleted file mode 100644 index fe27884..0000000 --- a/tests/auto/qsplineseries/tst_qsplineseries.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** 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 "../qxyseries/tst_qxyseries.h" -#include - -Q_DECLARE_METATYPE(QList) - -class tst_QSplineSeries : public tst_QXYSeries -{ - Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); -private slots: - void qsplineseries_data(); - void qsplineseries(); -protected: - void pointsVisible_data(); -}; - -void tst_QSplineSeries::initTestCase() -{ -} - -void tst_QSplineSeries::cleanupTestCase() -{ -} - -void tst_QSplineSeries::init() -{ - tst_QXYSeries::init(); - m_series = new QSplineSeries(); -} - -void tst_QSplineSeries::cleanup() -{ - delete m_series; - tst_QXYSeries::cleanup(); -} - -void tst_QSplineSeries::qsplineseries_data() -{ - -} - -void tst_QSplineSeries::qsplineseries() -{ - QSplineSeries series; - - QCOMPARE(series.count(),0); - QCOMPARE(series.brush(), QBrush()); - QCOMPARE(series.points(), QList()); - QCOMPARE(series.pen(), QPen()); - QCOMPARE(series.pointsVisible(), false); - - series.append(QList()); - series.append(0.0,0.0); - series.append(QPointF()); - - series.remove(0.0,0.0); - series.remove(QPointF()); - series.clear(); - - series.replace(QPointF(),QPointF()); - series.replace(0,0,0,0); - series.setBrush(QBrush()); - - series.setPen(QPen()); - series.setPointsVisible(false); - - m_chart->addSeries(&series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); -} - -QTEST_MAIN(tst_QSplineSeries) - -#include "tst_qsplineseries.moc" - diff --git a/tests/auto/qstackedbarseries/qstackedbarseries.pro b/tests/auto/qstackedbarseries/qstackedbarseries.pro deleted file mode 100644 index 0852d15..0000000 --- a/tests/auto/qstackedbarseries/qstackedbarseries.pro +++ /dev/null @@ -1,4 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qstackedbarseries.cpp diff --git a/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp b/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp deleted file mode 100644 index 8f64f00..0000000 --- a/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include "tst_definitions.h" - -QTCOMMERCIALCHART_USE_NAMESPACE - -Q_DECLARE_METATYPE(QBarSet*) - -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 mouseclicked_data(); - void mouseclicked(); - void mousehovered_data(); - void mousehovered(); - -private: - QStackedBarSeries* m_barseries; -}; - -void tst_QStackedBarSeries::initTestCase() -{ - qRegisterMetaType("QBarSet*"); -} - -void tst_QStackedBarSeries::cleanupTestCase() -{ -} - -void tst_QStackedBarSeries::init() -{ - m_barseries = new QStackedBarSeries(); -} - -void tst_QStackedBarSeries::cleanup() -{ - delete m_barseries; - m_barseries = 0; -} - -void tst_QStackedBarSeries::qstackedbarseries_data() -{ -} - -void tst_QStackedBarSeries::qstackedbarseries() -{ - QStackedBarSeries *barseries = new QStackedBarSeries(); - QVERIFY(barseries != 0); -} - -void tst_QStackedBarSeries::type_data() -{ - -} - -void tst_QStackedBarSeries::type() -{ - QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeStackedBar); -} - -void tst_QStackedBarSeries::mouseclicked_data() -{ - -} - -void tst_QStackedBarSeries::mouseclicked() -{ - QStackedBarSeries* series = new QStackedBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(clicked(int, QBarSet*))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - -//==================================================================================== -// barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); - -//==================================================================================== -// barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 0); - -//==================================================================================== -// barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 1); - -//==================================================================================== -// barset 2, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - - QCOMPARE(seriesSpy.count(), 1); - - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int); - QVERIFY(seriesSpyArg.at(0).toInt() == 2); -} - -void tst_QStackedBarSeries::mousehovered_data() -{ - -} - -void tst_QStackedBarSeries::mousehovered() -{ - QStackedBarSeries* series = new QStackedBarSeries(); - - QBarSet* set1 = new QBarSet(QString("set 1")); - *set1 << 10 << 10 << 10; - series->append(set1); - - QBarSet* set2 = new QBarSet(QString("set 2")); - *set2 << 10 << 10 << 10; - series->append(set2); - - QSignalSpy seriesSpy(series,SIGNAL(hovered(bool, QBarSet*))); - - QChartView view(new QChart()); - view.resize(400,300); - view.chart()->addSeries(series); - view.show(); - QTest::qWaitForWindowShown(&view); - - //this is hack since view does not get events otherwise - view.setMouseTracking(true); - -//======================================================================= -// move mouse to left border - QTest::mouseMove(view.viewport(), QPoint(0, 190)); - QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - TRY_COMPARE(seriesSpy.count(), 0); - -//======================================================================= -// move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(106,190)); - TRY_COMPARE(seriesSpy.count(), 1); - - QList seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(106,95)); - TRY_COMPARE(seriesSpy.count(), 2); - - // should leave set1 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set1); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); - - // should enter set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == true); - -//======================================================================= -// move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(106,0)); - TRY_COMPARE(seriesSpy.count(), 1); - - // should leave set2 - seriesSpyArg = seriesSpy.takeFirst(); - QCOMPARE(qvariant_cast(seriesSpyArg.at(1)), set2); - QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(seriesSpyArg.at(0).toBool() == false); -} - -QTEST_MAIN(tst_QStackedBarSeries) - -#include "tst_qstackedbarseries.moc" - diff --git a/tests/auto/qvalueaxis/qvalueaxis.pro b/tests/auto/qvalueaxis/qvalueaxis.pro deleted file mode 100644 index 315a8a6..0000000 --- a/tests/auto/qvalueaxis/qvalueaxis.pro +++ /dev/null @@ -1,5 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -HEADERS += ../qabstractaxis/tst_qabstractaxis.h -SOURCES += tst_qvalueaxis.cpp ../qabstractaxis/tst_qabstractaxis.cpp diff --git a/tests/auto/qvalueaxis/tst_qvalueaxis.cpp b/tests/auto/qvalueaxis/tst_qvalueaxis.cpp deleted file mode 100644 index 6112cd3..0000000 --- a/tests/auto/qvalueaxis/tst_qvalueaxis.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/**************************************************************************** - ** - ** 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 "../qabstractaxis/tst_qabstractaxis.h" -#include "qvalueaxis.h" -#include - -class tst_QValueAxis: public tst_QAbstractAxis -{ -Q_OBJECT - -public slots: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - -private slots: - void qvalueaxis_data(); - void qvalueaxis(); - void max_raw_data(); - void max_raw(); - void max_data(); - void max(); - void max_animation_data(); - void max_animation(); - void min_raw_data(); - void min_raw(); - void min_data(); - void min(); - void min_animation_data(); - void min_animation(); - void niceNumbersEnabled_data(); - void niceNumbersEnabled(); - void range_raw_data(); - void range_raw(); - void range_data(); - void range(); - void range_animation_data(); - void range_animation(); - void ticksCount_data(); - void ticksCount(); - void noautoscale_data(); - void noautoscale(); - void autoscale_data(); - void autoscale(); - -private: - QValueAxis* m_valuesaxis; - QLineSeries* m_series; -}; - -void tst_QValueAxis::initTestCase() -{ -} - -void tst_QValueAxis::cleanupTestCase() -{ -} - -void tst_QValueAxis::init() -{ - m_valuesaxis = new QValueAxis(); - m_series = new QLineSeries(); - *m_series << QPointF(-100, -100) << QPointF(0, 0) << QPointF(100, 100); - tst_QAbstractAxis::init(m_valuesaxis,m_series); - m_chart->addSeries(m_series); - m_chart->createDefaultAxes(); -} - -void tst_QValueAxis::cleanup() -{ - delete m_series; - delete m_valuesaxis; - m_series = 0; - m_valuesaxis = 0; - tst_QAbstractAxis::cleanup(); -} - -void tst_QValueAxis::qvalueaxis_data() -{ -} - -void tst_QValueAxis::qvalueaxis() -{ - qabstractaxis(); - - QVERIFY(qFuzzyIsNull(m_valuesaxis->max())); - QVERIFY(qFuzzyIsNull(m_valuesaxis->min())); - QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); - QCOMPARE(m_valuesaxis->tickCount(), 5); - QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValue); - - m_chart->setAxisX(m_valuesaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - - QVERIFY(!qFuzzyIsNull(m_valuesaxis->max())); - QVERIFY(!qFuzzyIsNull(m_valuesaxis->min())); - QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); - QCOMPARE(m_valuesaxis->tickCount(), 5); -} - -void tst_QValueAxis::max_raw_data() -{ - QTest::addColumn("max"); - QTest::newRow("1.0") << (qreal)1.0; - QTest::newRow("50.0") << (qreal)50.0; - QTest::newRow("101.0") << (qreal)101.0; -} - -void tst_QValueAxis::max_raw() -{ - QFETCH(qreal, max); - - QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_valuesaxis->setMax(max); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Not equal"); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 1); - -} - -void tst_QValueAxis::max_data() -{ - max_raw_data(); -} - -void tst_QValueAxis::max() -{ - m_chart->setAxisX(m_valuesaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - max_raw(); -} - -void tst_QValueAxis::max_animation_data() -{ - max_data(); -} - -void tst_QValueAxis::max_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - max(); -} - -void tst_QValueAxis::min_raw_data() -{ - QTest::addColumn("min"); - QTest::newRow("-1.0") << (qreal)-1.0; - QTest::newRow("-50.0") << (qreal)-50.0; - QTest::newRow("-101.0") << (qreal)-101.0; -} - -void tst_QValueAxis::min_raw() -{ - QFETCH(qreal, min); - - QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_valuesaxis->setMin(min); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Not equal"); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); -} - -void tst_QValueAxis::min_data() -{ - min_raw_data(); -} - -void tst_QValueAxis::min() -{ - m_chart->setAxisX(m_valuesaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - min_raw(); -} - -void tst_QValueAxis::min_animation_data() -{ - min_data(); -} - -void tst_QValueAxis::min_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - min(); -} - -void tst_QValueAxis::niceNumbersEnabled_data() -{ - QTest::addColumn("niceNumbersEnabled"); - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::addColumn("ticks"); - QTest::addColumn("expectedMin"); - QTest::addColumn("expectedMax"); - QTest::addColumn("expectedTicks"); - QTest::newRow("true 0.1 , 99.0 , 5") << true << (qreal)0.1 << (qreal)99.0 << 5 << (qreal)0.0 << (qreal)100.0 << 6; - QTest::newRow("true 1 , 10.0 , 5") << true << (qreal)1.0 << (qreal)10.0 << 5 << (qreal)0.0 << (qreal)10.0 << 6; - QTest::newRow("true 0.1 , 6.6 , 5") << true << (qreal)0.1 << (qreal)6.6 << 5 << (qreal)0.0 << (qreal)8.0 << 5; - QTest::newRow("false 0.1 , 6.6 , 5") << false << (qreal)0.1 << (qreal)6.6 << 5 << (qreal)0.1 << (qreal)6.6 << 5; - QTest::newRow("true 0.1, 99, 5") << true << (qreal)0.1 << (qreal)99.0 << 5 << (qreal)0.0 << (qreal)100.0 << 6; - QTest::newRow("true 5, 93.5 , 5") << true << (qreal)5.0 << (qreal)93.5 << 5 << (qreal)0.0 << (qreal)100.0 << 6; -} - -void tst_QValueAxis::niceNumbersEnabled() -{ - QFETCH(bool, niceNumbersEnabled); - QFETCH(qreal, min); - QFETCH(qreal, max); - QFETCH(int, ticks); - QFETCH(qreal, expectedMin); - QFETCH(qreal, expectedMax); - QFETCH(int, expectedTicks); - - m_valuesaxis->setRange(min, max); - m_valuesaxis->setTickCount(ticks); - - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); - - QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_valuesaxis->setNiceNumbersEnabled(niceNumbersEnabled); - QCOMPARE(m_valuesaxis->niceNumbersEnabled(), niceNumbersEnabled); - - if(!qFuzzyIsNull(expectedMin - min)) - QCOMPARE(spy1.count(), 1); - if(!qFuzzyIsNull(expectedMax - max)) - QCOMPARE(spy0.count(), 1); - if((!qFuzzyIsNull(expectedMin - min)) || (!qFuzzyIsNull(expectedMax - max))) - QCOMPARE(spy2.count(), 1); - - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal"); - QCOMPARE(m_valuesaxis->tickCount(), expectedTicks); - -} - -void tst_QValueAxis::range_raw_data() -{ - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0; - QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0; - QTest::newRow("101.0") << (qreal)40.0 << (qreal)60.0; -} - -void tst_QValueAxis::range_raw() -{ - QFETCH(qreal, min); - QFETCH(qreal, max); - - QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_valuesaxis->setRange(min, max); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); -} - -void tst_QValueAxis::range_data() -{ - range_raw_data(); -} - -void tst_QValueAxis::range() -{ - m_chart->setAxisX(m_valuesaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - range_raw(); -} - -void tst_QValueAxis::range_animation_data() -{ - range_data(); -} - -void tst_QValueAxis::range_animation() -{ - m_chart->setAnimationOptions(QChart::GridAxisAnimations); - range(); -} - -void tst_QValueAxis::ticksCount_data() -{ - QTest::addColumn("ticksCount"); - QTest::addColumn("expectedCount"); - QTest::newRow("0") << 2; - QTest::newRow("1") << 2; - QTest::newRow("2") << 2; - QTest::newRow("3") << 3; - QTest::newRow("-1") << 2; -} - -void tst_QValueAxis::ticksCount() -{ - QFETCH(int, ticksCount); - - QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_valuesaxis->setTickCount(ticksCount); - QCOMPARE(m_valuesaxis->tickCount(), ticksCount); - - QCOMPARE(spy0.count(), 0); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - - m_chart->setAxisX(m_valuesaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - - QCOMPARE(m_valuesaxis->tickCount(), ticksCount); -} - -void tst_QValueAxis::noautoscale_data() -{ - QTest::addColumn("min"); - QTest::addColumn("max"); - QTest::newRow("1.0 - 101.0") << (qreal)-1.0 << (qreal)101.0; - QTest::newRow("25.0 - 75.0") << (qreal)25.0 << (qreal)75.0; - QTest::newRow("101.0") << (qreal)40.0 << (qreal)60.0; -} - -void tst_QValueAxis::noautoscale() -{ - QFETCH(qreal, min); - QFETCH(qreal, max); - - QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); - - m_valuesaxis->setRange(min, max); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - - m_chart->setAxisX(m_valuesaxis, m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); -} - -void tst_QValueAxis::autoscale_data() -{ - -} - -void tst_QValueAxis::autoscale() -{ - QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); - QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); - QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal, qreal))); - - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min()), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max()), "Max not equal"); - m_chart->setAxisX(m_valuesaxis, m_series); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - - m_view->show(); - QTest::qWaitForWindowShown(m_view); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() + 100), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - 100), "Max not equal"); -} - -QTEST_MAIN(tst_QValueAxis) -#include "tst_qvalueaxis.moc" - diff --git a/tests/auto/qxymodelmapper/qxymodelmapper.pro b/tests/auto/qxymodelmapper/qxymodelmapper.pro deleted file mode 100644 index 4b3647a..0000000 --- a/tests/auto/qxymodelmapper/qxymodelmapper.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} - -SOURCES += \ - tst_qxymodelmapper.cpp diff --git a/tests/auto/qxymodelmapper/tst_qxymodelmapper.cpp b/tests/auto/qxymodelmapper/tst_qxymodelmapper.cpp deleted file mode 100644 index e650577..0000000 --- a/tests/auto/qxymodelmapper/tst_qxymodelmapper.cpp +++ /dev/null @@ -1,584 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class tst_qxymodelmapper : public QObject -{ - Q_OBJECT - - public: - tst_qxymodelmapper(); - void createVerticalMapper(); - void createHorizontalMapper(); - - private Q_SLOTS: - void initTestCase(); - void cleanupTestCase(); - void init(); - void cleanup(); - void verticalMapper_data(); - void verticalMapper(); - void verticalMapperCustomMapping_data(); - void verticalMapperCustomMapping(); - void horizontalMapper_data(); - void horizontalMapper(); - void horizontalMapperCustomMapping_data(); - void horizontalMapperCustomMapping(); - void seriesUpdated(); - void verticalModelInsertRows(); - void verticalModelRemoveRows(); - void verticalModelInsertColumns(); - void verticalModelRemoveColumns(); - void horizontalModelInsertRows(); - void horizontalModelRemoveRows(); - void horizontalModelInsertColumns(); - void horizontalModelRemoveColumns(); - void modelUpdateCell(); - void verticalMapperSignals(); - void horizontalMapperSignals(); - - private: - QStandardItemModel *m_model; - int m_modelRowCount; - int m_modelColumnCount; - - QHXYModelMapper *m_hMapper; - QVXYModelMapper *m_vMapper; - - QXYSeries *m_series; - QChart *m_chart; -}; - -tst_qxymodelmapper::tst_qxymodelmapper(): - m_model(0), - m_modelRowCount(10), - m_modelColumnCount(8), - m_hMapper(0), - m_vMapper(0), - m_series(0), - m_chart(0) -{ -} - -void tst_qxymodelmapper::createVerticalMapper() -{ - m_vMapper = new QVXYModelMapper; - QVERIFY(m_vMapper->model() == 0); - m_vMapper->setXColumn(0); - m_vMapper->setYColumn(1); - m_vMapper->setModel(m_model); - m_vMapper->setSeries(m_series); -} - -void tst_qxymodelmapper::createHorizontalMapper() -{ - m_hMapper = new QHXYModelMapper; - QVERIFY(m_hMapper->model() == 0); - m_hMapper->setXRow(0); - m_hMapper->setYRow(1); - m_hMapper->setModel(m_model); - m_hMapper->setSeries(m_series); -} - -void tst_qxymodelmapper::init() -{ - m_series = new QLineSeries; - m_chart->addSeries(m_series); - - m_model = new QStandardItemModel(m_modelRowCount, m_modelColumnCount, this); - for (int row = 0; row < m_modelRowCount; ++row) { - for (int column = 0; column < m_modelColumnCount; column++) { - m_model->setData(m_model->index(row, column), row * column); - } - } -} - -void tst_qxymodelmapper::cleanup() -{ - m_chart->removeSeries(m_series); - m_series->deleteLater(); - m_series = 0; - - m_model->clear(); - m_model->deleteLater(); - m_model = 0; - - if (m_vMapper) { - m_vMapper->deleteLater(); - m_vMapper = 0; - } - - if (m_hMapper) { - m_hMapper->deleteLater(); - m_hMapper = 0; - } -} - -void tst_qxymodelmapper::initTestCase() -{ - m_chart = new QChart; - QChartView *chartView = new QChartView(m_chart); - chartView->show(); -} - -void tst_qxymodelmapper::cleanupTestCase() -{ - // -} - -void tst_qxymodelmapper::verticalMapper_data() -{ - QTest::addColumn("xColumn"); - QTest::addColumn("yColumn"); - QTest::addColumn("expectedCount"); - QTest::newRow("different x and y columns") << 0 << 1 << m_modelRowCount; - QTest::newRow("same x and y columns") << 1 << 1 << m_modelRowCount; - QTest::newRow("invalid x column and correct y column") << -3 << 1 << 0; - QTest::newRow("x column beyond the size of model and correct y column") << m_modelColumnCount << 1 << 0; - QTest::newRow("x column beyond the size of model and invalid y column") << m_modelColumnCount << -1 << 0; -} - -void tst_qxymodelmapper::verticalMapper() -{ - QFETCH(int, xColumn); - QFETCH(int, yColumn); - QFETCH(int, expectedCount); - - QVXYModelMapper *mapper = new QVXYModelMapper; - QVERIFY(mapper->model() == 0); - - mapper->setXColumn(xColumn); - mapper->setYColumn(yColumn); - mapper->setModel(m_model); - mapper->setSeries(m_series); - - QCOMPARE(m_series->count(), expectedCount); - QCOMPARE(mapper->xColumn(), qMax(-1, xColumn)); - QCOMPARE(mapper->yColumn(), qMax(-1, yColumn)); - - delete mapper; - mapper = 0; -} - -void tst_qxymodelmapper::verticalMapperCustomMapping_data() -{ - QTest::addColumn("first"); - QTest::addColumn("countLimit"); - QTest::addColumn("expectedCount"); - QTest::newRow("first: 0, unlimited count") << 0 << -1 << m_modelRowCount; - QTest::newRow("first: 3, unlimited count") << 3 << -1 << m_modelRowCount - 3; - QTest::newRow("first: 0, count: 5") << 0 << 5 << qMin(5, m_modelRowCount); - QTest::newRow("first: 3, count: 5") << 3 << 5 << qMin(5, m_modelRowCount - 3); - QTest::newRow("first: +1 greater then the number of rows in the model, unlimited count") << m_modelRowCount + 1 << -1 << 0; - QTest::newRow("first: +1 greater then the number of rows in the model, count: 5") << m_modelRowCount + 1 << 5 << 0; - QTest::newRow("first: 0, count: +3 greater than the number of rows in the model (should limit to the size of model)") << 0 << m_modelRowCount + 3 << m_modelRowCount; - QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << m_modelRowCount; - QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << m_modelRowCount; - QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << m_modelRowCount; - -} - -void tst_qxymodelmapper::verticalMapperCustomMapping() -{ - QFETCH(int, first); - QFETCH(int, countLimit); - QFETCH(int, expectedCount); - - QCOMPARE(m_series->count(), 0); - - QVXYModelMapper *mapper = new QVXYModelMapper; - mapper->setXColumn(0); - mapper->setYColumn(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstRow(first); - mapper->setRowCount(countLimit); - - QCOMPARE(m_series->count(), expectedCount); - - // change values column mapping to invalid - mapper->setXColumn(-1); - mapper->setYColumn(1); - - QCOMPARE(m_series->count(), 0); - - delete mapper; - mapper = 0; -} - -void tst_qxymodelmapper::horizontalMapper_data() -{ - QTest::addColumn("xRow"); - QTest::addColumn("yRow"); - QTest::addColumn("expectedCount"); - QTest::newRow("different x and y rows") << 0 << 1 << m_modelColumnCount; - QTest::newRow("same x and y rows") << 1 << 1 << m_modelColumnCount; - QTest::newRow("invalid x row and correct y row") << -3 << 1 << 0; - QTest::newRow("x row beyond the size of model and correct y row") << m_modelRowCount << 1 << 0; - QTest::newRow("x row beyond the size of model and invalid y row") << m_modelRowCount << -1 << 0; -} - -void tst_qxymodelmapper::horizontalMapper() -{ - QFETCH(int, xRow); - QFETCH(int, yRow); - QFETCH(int, expectedCount); - - QHXYModelMapper *mapper = new QHXYModelMapper; - mapper->setXRow(xRow); - mapper->setYRow(yRow); - mapper->setModel(m_model); - mapper->setSeries(m_series); - - QCOMPARE(m_series->count(), expectedCount); - QCOMPARE(mapper->xRow(), qMax(-1, xRow)); - QCOMPARE(mapper->yRow(), qMax(-1, yRow)); - - delete mapper; - mapper = 0; -} - -void tst_qxymodelmapper::horizontalMapperCustomMapping_data() -{ - QTest::addColumn("first"); - QTest::addColumn("countLimit"); - QTest::addColumn("expectedCount"); - QTest::newRow("first: 0, unlimited count") << 0 << -1 << m_modelColumnCount; - QTest::newRow("first: 3, unlimited count") << 3 << -1 << m_modelColumnCount - 3; - QTest::newRow("first: 0, count: 5") << 0 << 5 << qMin(5, m_modelColumnCount); - QTest::newRow("first: 3, count: 5") << 3 << 5 << qMin(5, m_modelColumnCount - 3); - QTest::newRow("first: +1 greater then the number of columns in the model, unlimited count") << m_modelColumnCount + 1 << -1 << 0; - QTest::newRow("first: +1 greater then the number of columns in the model, count: 5") << m_modelColumnCount + 1 << 5 << 0; - QTest::newRow("first: 0, count: +3 greater than the number of columns in the model (should limit to the size of model)") << 0 << m_modelColumnCount + 3 << m_modelColumnCount; - QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << m_modelColumnCount; - QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << m_modelColumnCount; - QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << m_modelColumnCount; -} - -void tst_qxymodelmapper::horizontalMapperCustomMapping() -{ - QFETCH(int, first); - QFETCH(int, countLimit); - QFETCH(int, expectedCount); - - QCOMPARE(m_series->count(), 0); - - QHXYModelMapper *mapper = new QHXYModelMapper; - mapper->setXRow(0); - mapper->setYRow(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstColumn(first); - mapper->setColumnCount(countLimit); - - QCOMPARE(m_series->count(), expectedCount); - - // change values row mapping to invalid - mapper->setXRow(-1); - mapper->setYRow(1); - - QCOMPARE(m_series->count(), 0); - - delete mapper; - mapper = 0; -} - -void tst_qxymodelmapper::seriesUpdated() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QCOMPARE(m_vMapper->rowCount(), -1); - - m_series->append(QPointF(100, 100)); - QCOMPARE(m_series->count(), m_modelRowCount + 1); - QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model - - m_series->remove(m_series->points().last()); - QCOMPARE(m_series->count(), m_modelRowCount); - QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model - - m_series->replace(m_series->points().first(), QPointF(25.0, 75.0)); - QCOMPARE(m_model->data(m_model->index(0, 0)).toReal(), 25.0); - QCOMPARE(m_model->data(m_model->index(0, 1)).toReal(), 75.0); -} - -void tst_qxymodelmapper::verticalModelInsertRows() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int insertCount = 4; - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_modelRowCount + insertCount); - - int first = 3; - m_vMapper->setFirstRow(3); - QCOMPARE(m_series->count(), m_modelRowCount + insertCount - first); - - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_modelRowCount + 2 * insertCount - first); - - int countLimit = 6; - m_vMapper->setRowCount(countLimit); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first)); - - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first)); - - m_vMapper->setFirstRow(0); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount)); - - m_vMapper->setRowCount(-1); - QCOMPARE(m_series->count(), m_modelRowCount + 3 * insertCount); -} - -void tst_qxymodelmapper::verticalModelRemoveRows() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int removeCount = 2; - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), m_modelRowCount - removeCount); - - int first = 1; - m_vMapper->setFirstRow(first); - QCOMPARE(m_series->count(), m_modelRowCount - removeCount - first); - - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), m_modelRowCount - 2 * removeCount - first); - - int countLimit = 3; - m_vMapper->setRowCount(countLimit); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first)); - - m_model->removeRows(1, removeCount); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first)); - - m_vMapper->setFirstRow(0); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount)); - - m_vMapper->setRowCount(-1); - QCOMPARE(m_series->count(), m_modelRowCount - 3 * removeCount); -} - -void tst_qxymodelmapper::verticalModelInsertColumns() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int insertCount = 4; - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_modelRowCount); -} - -void tst_qxymodelmapper::verticalModelRemoveColumns() -{ - // setup the mapper - createVerticalMapper(); - QCOMPARE(m_series->count(), m_modelRowCount); - QVERIFY(m_vMapper->model() != 0); - - int removeCount = m_modelColumnCount - 2; - m_model->removeColumns(0, removeCount); - QCOMPARE(m_series->count(), m_modelRowCount); - - // leave only one column - m_model->removeColumns(0, m_modelColumnCount - removeCount - 1); - QCOMPARE(m_series->count(), 0); -} - -void tst_qxymodelmapper::horizontalModelInsertRows() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int insertCount = 4; - m_model->insertRows(3, insertCount); - QCOMPARE(m_series->count(), m_modelColumnCount); -} - -void tst_qxymodelmapper::horizontalModelRemoveRows() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int removeCount = m_modelRowCount - 2; - m_model->removeRows(0, removeCount); - QCOMPARE(m_series->count(), m_modelColumnCount); - - // leave only one column - m_model->removeRows(0, m_modelRowCount - removeCount - 1); - QCOMPARE(m_series->count(), 0); -} - -void tst_qxymodelmapper::horizontalModelInsertColumns() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int insertCount = 4; - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_modelColumnCount + insertCount); - - int first = 3; - m_hMapper->setFirstColumn(3); - QCOMPARE(m_series->count(), m_modelColumnCount + insertCount - first); - - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), m_modelColumnCount + 2 * insertCount - first); - - int countLimit = 6; - m_hMapper->setColumnCount(countLimit); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first)); - - m_model->insertColumns(3, insertCount); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first)); - - m_hMapper->setFirstColumn(0); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount)); - - m_hMapper->setColumnCount(-1); - QCOMPARE(m_series->count(), m_modelColumnCount + 3 * insertCount); -} - -void tst_qxymodelmapper::horizontalModelRemoveColumns() -{ - // setup the mapper - createHorizontalMapper(); - QCOMPARE(m_series->count(), m_modelColumnCount); - QVERIFY(m_hMapper->model() != 0); - - int removeCount = 2; - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), m_modelColumnCount - removeCount); - - int first = 1; - m_hMapper->setFirstColumn(first); - QCOMPARE(m_series->count(), m_modelColumnCount - removeCount - first); - - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), m_modelColumnCount - 2 * removeCount - first); - - int countLimit = 3; - m_hMapper->setColumnCount(countLimit); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first)); - - m_model->removeColumns(1, removeCount); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first)); - - m_hMapper->setFirstColumn(0); - QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount)); - - m_hMapper->setColumnCount(-1); - QCOMPARE(m_series->count(), m_modelColumnCount - 3 * removeCount); -} - -void tst_qxymodelmapper::modelUpdateCell() -{ - // setup the mapper - createVerticalMapper(); - - QVERIFY(m_model->setData(m_model->index(1, 0), 44)); - QCOMPARE(m_series->points().at(1).x(), 44.0); - QCOMPARE(m_model->data(m_model->index(1, 0)).toReal(), 44.0); -} - -void tst_qxymodelmapper::verticalMapperSignals() -{ - QVXYModelMapper *mapper = new QVXYModelMapper; - - QSignalSpy spy0(mapper, SIGNAL(firstRowChanged())); - QSignalSpy spy1(mapper, SIGNAL(rowCountChanged())); - QSignalSpy spy2(mapper, SIGNAL(xColumnChanged())); - QSignalSpy spy3(mapper, SIGNAL(yColumnChanged())); - QSignalSpy spy4(mapper, SIGNAL(modelReplaced())); - QSignalSpy spy5(mapper, SIGNAL(seriesReplaced())); - - mapper->setXColumn(0); - mapper->setYColumn(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstRow(1); - mapper->setRowCount(5); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - QCOMPARE(spy4.count(), 1); - QCOMPARE(spy5.count(), 1); - -} - -void tst_qxymodelmapper::horizontalMapperSignals() -{ - QHXYModelMapper *mapper = new QHXYModelMapper; - - QSignalSpy spy0(mapper, SIGNAL(firstColumnChanged())); - QSignalSpy spy1(mapper, SIGNAL(columnCountChanged())); - QSignalSpy spy2(mapper, SIGNAL(xRowChanged())); - QSignalSpy spy3(mapper, SIGNAL(yRowChanged())); - QSignalSpy spy4(mapper, SIGNAL(modelReplaced())); - QSignalSpy spy5(mapper, SIGNAL(seriesReplaced())); - - mapper->setXRow(0); - mapper->setYRow(1); - mapper->setModel(m_model); - mapper->setSeries(m_series); - mapper->setFirstColumn(1); - mapper->setColumnCount(5); - - QCOMPARE(spy0.count(), 1); - QCOMPARE(spy1.count(), 1); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy3.count(), 1); - QCOMPARE(spy4.count(), 1); - QCOMPARE(spy5.count(), 1); -} - -QTEST_MAIN(tst_qxymodelmapper) - -#include "tst_qxymodelmapper.moc" diff --git a/tests/auto/qxyseries/qlineseries.pro b/tests/auto/qxyseries/qlineseries.pro deleted file mode 100644 index cb35386..0000000 --- a/tests/auto/qxyseries/qlineseries.pro +++ /dev/null @@ -1,6 +0,0 @@ -!include( ../auto.pri ) { - error( "Couldn't find the auto.pri file!" ) -} -SOURCES += tst_qlineseries.cpp - -!system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" diff --git a/tests/auto/qxyseries/tst_qxyseries.cpp b/tests/auto/qxyseries/tst_qxyseries.cpp deleted file mode 100644 index 0cfd891..0000000 --- a/tests/auto/qxyseries/tst_qxyseries.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/**************************************************************************** -** -** 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 "tst_qxyseries.h" - -Q_DECLARE_METATYPE(QList) - -void tst_QXYSeries::initTestCase() -{ -} - -void tst_QXYSeries::cleanupTestCase() -{ -} - -void tst_QXYSeries::init() -{ - m_view = new QChartView(new QChart()); - m_chart = m_view->chart(); -} - -void tst_QXYSeries::cleanup() -{ - delete m_view; - m_view = 0; - m_chart = 0; - m_series = 0; -} - -void tst_QXYSeries::seriesName() -{ - QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); - QCOMPARE(m_series->name(), QString()); - m_series->setName("seriesname"); - QCOMPARE(m_series->name(), QString("seriesname")); - TRY_COMPARE(nameSpy.count(), 1); -} - -void tst_QXYSeries::seriesVisible() -{ - QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); - QCOMPARE(m_series->isVisible(), true); - m_series->setVisible(false); - QCOMPARE(m_series->isVisible(), false); - m_series->setVisible(true); - TRY_COMPARE(visibleSpy.count(), 2); -} - -void tst_QXYSeries::append_data() -{ - QTest::addColumn< QList >("points"); - QTest::newRow("0,0 1,1 2,2 3,3") << (QList() << QPointF(0,0) << QPointF(1,1) << QPointF(2,2) << QPointF(3,3)); - QTest::newRow("0,0 -1,-1 -2,-2 -3,-3") << (QList() << QPointF(0,0) << QPointF(-1,-1) << QPointF(-2,-2) << QPointF(-3,-3)); -} - - -void tst_QXYSeries::append_raw_data() -{ - append_data(); -} - -void tst_QXYSeries::append_raw() -{ - QFETCH(QList, points); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); - m_series->append(points); - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(addedSpy.count(), points.count()); - QCOMPARE(m_series->points(), points); -} - -void tst_QXYSeries::chart_append_data() -{ - append_data(); -} - -void tst_QXYSeries::chart_append() -{ - append_raw(); - m_chart->addSeries(m_series); - m_view->show(); - QTest::qWaitForWindowShown(m_view); -} - -void tst_QXYSeries::append_chart_data() -{ - append_data(); -} - -void tst_QXYSeries::append_chart() -{ - m_view->show(); - m_chart->addSeries(m_series); - QTest::qWaitForWindowShown(m_view); - append_raw(); - -} - -void tst_QXYSeries::append_chart_animation_data() -{ - append_data(); -} - -void tst_QXYSeries::append_chart_animation() -{ - m_chart->setAnimationOptions(QChart::AllAnimations); - append_chart(); -} - -void tst_QXYSeries::count_data() -{ - QTest::addColumn("count"); - QTest::newRow("0") << 0; - QTest::newRow("5") << 5; - QTest::newRow("10") << 5; -} - -void tst_QXYSeries::count_raw_data() -{ - count_data(); -} - -void tst_QXYSeries::count_raw() -{ - QFETCH(int, count); - - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - - for(int i=0 ; i< count; ++i) - m_series->append(i,i); - - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->count(), count); -} - -void tst_QXYSeries::remove_raw_data() -{ - append_data(); -} - -void tst_QXYSeries::remove_raw() -{ - QFETCH(QList, points); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->append(points); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points(), points); - - foreach(const QPointF& point,points) - m_series->remove(point); - - QCOMPARE(m_series->points().count(), 0); - TRY_COMPARE(spy0.count(), 0); - - m_series->append(points); - QCOMPARE(m_series->points(), points); - - //reverse order - for(int i = points.count()-1 ; i>=0; i--){ - m_series->remove(points[i]); - } - QCOMPARE(m_series->points().count(), 0); -} - -void tst_QXYSeries::remove_chart_data() -{ - append_data(); -} - -void tst_QXYSeries::remove_chart() -{ - m_view->show(); - m_chart->addSeries(m_series); - QTest::qWaitForWindowShown(m_view); - remove_raw(); -} - -void tst_QXYSeries::remove_chart_animation_data() -{ - append_data(); -} - -void tst_QXYSeries::remove_chart_animation() -{ - m_chart->setAnimationOptions(QChart::AllAnimations); - remove_chart(); -} - - -void tst_QXYSeries::clear_raw_data() -{ - append_data(); -} - -void tst_QXYSeries::clear_raw() -{ - QFETCH(QList, points); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->append(points); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points(), points); - m_series->clear(); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->points().count(), 0); -} - -void tst_QXYSeries::clear_chart_data() -{ - append_data(); -} - -void tst_QXYSeries::clear_chart() -{ - m_view->show(); - m_chart->addSeries(m_series); - QTest::qWaitForWindowShown(m_view); - clear_raw(); -} - -void tst_QXYSeries::clear_chart_animation_data() -{ - append_data(); -} - -void tst_QXYSeries::clear_chart_animation() -{ - m_chart->setAnimationOptions(QChart::AllAnimations); - clear_chart(); -} - -void tst_QXYSeries::replace_raw_data() -{ - append_data(); -} - -void tst_QXYSeries::replace_raw() -{ - QFETCH(QList, points); - QSignalSpy pointReplacedSpy(m_series, SIGNAL(pointReplaced(int))); - QSignalSpy pointsReplacedSpy(m_series, SIGNAL(pointsReplaced())); - m_series->append(points); - TRY_COMPARE(pointReplacedSpy.count(), 0); - TRY_COMPARE(pointsReplacedSpy.count(), 0); - QCOMPARE(m_series->points(), points); - - foreach(const QPointF& point, points) - m_series->replace(point.x(),point.y(),point.x(),0); - TRY_COMPARE(pointReplacedSpy.count(), points.count()); - TRY_COMPARE(pointsReplacedSpy.count(), 0); - - // Replace a point that does not exist - m_series->replace(-123, 999, 0, 0); - TRY_COMPARE(pointReplacedSpy.count(), points.count()); - TRY_COMPARE(pointsReplacedSpy.count(), 0); - - QList newPoints = m_series->points(); - QCOMPARE(newPoints.count(), points.count()); - for(int i =0 ; i allPoints; - for (int i = 0; i < 10; i++) - allPoints.append(QPointF(i, (qreal) rand() / (qreal) RAND_MAX)); - m_series->replace(allPoints); - TRY_COMPARE(pointReplacedSpy.count(), points.count()); - TRY_COMPARE(pointsReplacedSpy.count(), 1); -} - - -void tst_QXYSeries::replace_chart_data() -{ - append_data(); -} - -void tst_QXYSeries::replace_chart() -{ - m_view->show(); - m_chart->addSeries(m_series); - QTest::qWaitForWindowShown(m_view); - replace_raw(); -} - -void tst_QXYSeries::replace_chart_animation_data() -{ - append_data(); -} - -void tst_QXYSeries::replace_chart_animation() -{ - m_chart->setAnimationOptions(QChart::AllAnimations); - replace_chart(); -} - -void tst_QXYSeries::insert_data() -{ - append_data(); -} - -void tst_QXYSeries::insert() -{ - QFETCH(QList, points); - m_series->append(points); - - QSignalSpy addedSpy(m_series, SIGNAL(pointAdded(int))); - - m_series->insert(0, QPointF(5, 5)); - TRY_COMPARE(addedSpy.count(), 1); - QCOMPARE(m_series->points().count(), points.count() + 1); - - m_series->insert(m_series->count(), QPointF(6, 6)); - TRY_COMPARE(addedSpy.count(), 2); - QCOMPARE(m_series->points().count(), points.count() + 2); -} - -void tst_QXYSeries::oper_data() -{ - append_data(); -} - -void tst_QXYSeries::oper() -{ - QFETCH(QList, points); - - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - - foreach(const QPointF& point,points) - { - *m_series<points(), points); - TRY_COMPARE(spy0.count(), 0); -} - - -void tst_QXYSeries::pen_data() -{ - QTest::addColumn("pen"); - QTest::newRow("null") << QPen(); - QTest::newRow("blue") << QPen(Qt::blue); - QTest::newRow("black") << QPen(Qt::black); - QTest::newRow("red") << QPen(Qt::red); -} - -void tst_QXYSeries::pen() -{ - QFETCH(QPen, pen); - - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->setPen(pen); - - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->pen(), pen); - - m_chart->addSeries(m_series); - - if (pen != QPen()) - QCOMPARE(m_series->pen(), pen); - - m_chart->setTheme(QChart::ChartThemeDark); - - // setting a theme will overwrite all customizations - if (pen != QPen()) - QVERIFY(m_series->pen() != pen); -} - -void tst_QXYSeries::pointsVisible_data() -{ - QTest::addColumn("pointsVisible"); - QTest::newRow("true") << true; - QTest::newRow("false") << false; -} - -void tst_QXYSeries::pointsVisible_raw_data() -{ - pointsVisible_data(); -} - -void tst_QXYSeries::pointsVisible_raw() -{ - QFETCH(bool, pointsVisible); - QSignalSpy spy0(m_series, SIGNAL(clicked(QPointF const&))); - m_series->setPointsVisible(pointsVisible); - TRY_COMPARE(spy0.count(), 0); - QCOMPARE(m_series->pointsVisible(), pointsVisible); -} - -void tst_QXYSeries::changedSignals() -{ - QSignalSpy visibleSpy(m_series, SIGNAL(visibleChanged())); - QSignalSpy nameSpy(m_series, SIGNAL(nameChanged())); - QSignalSpy colorSpy(m_series, SIGNAL(colorChanged(QColor))); - - // Visibility - m_series->setVisible(false); - m_series->setVisible(false); - TRY_COMPARE(visibleSpy.count(), 1); - m_series->setVisible(true); - TRY_COMPARE(visibleSpy.count(), 2); - - // Color - m_series->setColor(QColor("aliceblue")); - TRY_COMPARE(colorSpy.count(), 1); - - // Pen and Brush - QPen p = m_series->pen(); - p.setColor("aquamarine"); - m_series->setPen(p); - QBrush b = m_series->brush(); - b.setColor("beige"); - m_series->setBrush(b); - TRY_COMPARE(colorSpy.count(), 2); - - // Verify all the signals again, to make sure no extra signals were emitted - TRY_COMPARE(visibleSpy.count(), 2); - TRY_COMPARE(nameSpy.count(), 0); - TRY_COMPARE(colorSpy.count(), 2); -} diff --git a/tests/auto/qxyseries/tst_qxyseries.h b/tests/auto/qxyseries/tst_qxyseries.h deleted file mode 100644 index f05a054..0000000 --- a/tests/auto/qxyseries/tst_qxyseries.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef TST_QXYSERIES_H -#define TST_QXYSERIES_H - -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class tst_QXYSeries : public QObject -{ - Q_OBJECT - -public slots: - virtual void initTestCase(); - virtual void cleanupTestCase(); - virtual void init(); - virtual void cleanup(); - -private slots: - void seriesName(); - void seriesVisible(); - void oper_data(); - void oper(); - void pen_data(); - void pen(); - void pointsVisible_raw_data(); - void pointsVisible_raw(); - void append_raw_data(); - void append_raw(); - void append_chart_data(); - void append_chart(); - void append_chart_animation_data(); - void append_chart_animation(); - void chart_append_data(); - void chart_append(); - void count_raw_data(); - void count_raw(); - void remove_raw_data(); - void remove_raw(); - void remove_chart_data(); - void remove_chart(); - void remove_chart_animation_data(); - void remove_chart_animation(); - void clear_raw_data(); - void clear_raw(); - void clear_chart_data(); - void clear_chart(); - void clear_chart_animation_data(); - void clear_chart_animation(); - void replace_raw_data(); - void replace_raw(); - void replace_chart_data(); - void replace_chart(); - void replace_chart_animation_data(); - void replace_chart_animation(); - void insert_data(); - void insert(); - void changedSignals(); -protected: - void append_data(); - void count_data(); - void pointsVisible_data(); - -protected: - QChartView* m_view; - QChart* m_chart; - QXYSeries* m_series; -}; - -#endif diff --git a/tests/chartdesigner/brushwidget.cpp b/tests/chartdesigner/brushwidget.cpp deleted file mode 100644 index 99ae200..0000000 --- a/tests/chartdesigner/brushwidget.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** 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 "brushwidget.h" - -BrushWidget::BrushWidget(QWidget *parent):QWidget(parent) -{ - - -} - -BrushWidget::~BrushWidget() -{ - -} - diff --git a/tests/chartdesigner/brushwidget.h b/tests/chartdesigner/brushwidget.h deleted file mode 100644 index 4cb487c..0000000 --- a/tests/chartdesigner/brushwidget.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef BRUSHWIDGET_H -#define BRUSHWIDGET_H - -#include - -class BrushWidget: public QWidget -{ -public: - explicit BrushWidget(QWidget *parent = 0); - ~BrushWidget(); - - QBrush brush() const { return m_brush; } - void setBrush(const QBrush &brush); - -private: - QBrush m_brush; -}; - -#endif /* BRUSHWIDGET_H */ diff --git a/tests/chartdesigner/chartdesigner.pro b/tests/chartdesigner/chartdesigner.pro deleted file mode 100644 index 0594b37..0000000 --- a/tests/chartdesigner/chartdesigner.pro +++ /dev/null @@ -1,24 +0,0 @@ -!include( ../tests.pri ) { - error( "Couldn't find the test.pri file!" ) -} - -TEMPLATE = app -QT += core gui - -SOURCES += \ - brushwidget.cpp \ - main.cpp \ - mainwindow.cpp \ - objectinspectorwidget.cpp \ - penwidget.cpp \ - engine.cpp - - -HEADERS += \ - brushwidget.h \ - mainwindow.h \ - objectinspectorwidget.h \ - penwidget.h \ - engine.h - -!system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_TESTS_BIN_DIR" diff --git a/tests/chartdesigner/engine.cpp b/tests/chartdesigner/engine.cpp deleted file mode 100644 index bbc61c0..0000000 --- a/tests/chartdesigner/engine.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/**************************************************************************** - ** - ** 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 "engine.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -const qint32 MAGIC_NUMBER = 0x66666666; - -Engine::Engine(QObject* parent) : - QObject(parent), m_count(10), m_chart(new QChart()), m_model(0), m_selection(0) -{ - createModels(); -} - -Engine::~Engine() -{ - delete m_chart; - delete m_selection; - delete m_model; -} - -void Engine::createModels() -{ - m_model = new QStandardItemModel(m_count, m_count); - m_model->setHorizontalHeaderLabels( - QStringList() << "A" << "B" << "C" << "D" << "E" << "F" << "G" << "H" << "I" << "J"); - m_model->setVerticalHeaderLabels( - QStringList() << "1" << "2" << "3" << "4" << "5" << "6" << "7" << "8" << "9" << "10"); - m_selection = new QItemSelectionModel(m_model); - -} - -QList Engine::addSeries(QAbstractSeries::SeriesType type) -{ - const QModelIndexList& list = m_selection->selectedIndexes(); - - QMap columns; - - foreach(const QModelIndex& index, list) { - columns.insertMulti(index.column(), index); - } - - QList keys = columns.uniqueKeys(); - - QModelIndexList rows = columns.values(keys.first()); - - int minRow = m_count + 1; - int maxRow = -1; - - foreach(const QModelIndex& index, rows) { - minRow = qMin(index.row(), minRow); - maxRow = qMax(index.row(), maxRow); - } - - QList result; - QColor color; - - switch (type) { - - case QAbstractSeries::SeriesTypeLine: - { - for (int i = 1; i < keys.count(); ++i) { - QLineSeries *line = new QLineSeries(); - setupXYSeries(line, keys, i, minRow, maxRow); - result << line; - } - break; - } - case QAbstractSeries::SeriesTypeSpline: - { - for (int i = 1; i < keys.count(); ++i) { - QSplineSeries *line = new QSplineSeries(); - setupXYSeries(line, keys, i, minRow, maxRow); - result << line; - } - break; - } - case QAbstractSeries::SeriesTypeScatter: - { - for (int i = 1; i < keys.count(); ++i) { - QScatterSeries *line = new QScatterSeries(); - setupXYSeries(line, keys, i, minRow, maxRow); - result << line; - } - break; - } - case QAbstractSeries::SeriesTypeBar: - { - //TODO: fix me - QBarSeries *bar = new QBarSeries(); - setupBarSeries(bar,keys,minRow,maxRow); - result << bar; - break; - } - case QAbstractSeries::SeriesTypePercentBar: - { - QPercentBarSeries *bar = new QPercentBarSeries(); - setupBarSeries(bar,keys,minRow,maxRow); - result << bar; - break; - } - case QAbstractSeries::SeriesTypeStackedBar: - { - QStackedBarSeries *bar = new QStackedBarSeries(); - setupBarSeries(bar,keys,minRow,maxRow); - result << bar; - break; - } - case QAbstractSeries::SeriesTypePie: - { - - QPieSeries *pie = new QPieSeries(); - setupPieSeries(pie,keys,minRow,maxRow); - result << pie; - break; - } - case QAbstractSeries::SeriesTypeArea: - { - QAreaSeries *area = new QAreaSeries( new QLineSeries(), new QLineSeries()); - setupAreaSeries(area,keys,minRow,maxRow); - result << area; - break; - } - } - - m_chart->createDefaultAxes(); - return result; -} - -void Engine::removeSeries(QAbstractSeries* series) -{ - m_chart->removeSeries(series); - - foreach(const QModelIndex& index, m_seriesModelIndex.value(series)) { - m_model->setData(index, Qt::white, Qt::BackgroundRole); - } -} - -void Engine::clearModels() -{ - delete m_selection; - m_selection = 0; - delete m_model; - m_model = 0; - createModels(); -} - -bool Engine::save(const QString &filename) const -{ - if (filename.isEmpty()) - return false; - - QFile file(filename); - - if (!file.open(QIODevice::WriteOnly)) { - return false; - } - - QDataStream out(&file); - out << MAGIC_NUMBER; - out.setVersion(QDataStream::Qt_4_8); - out << m_model->rowCount(); - out << m_model->columnCount(); - - for (int row = 0; row < m_model->rowCount(); ++row) { - for (int column = 0; column < m_model->columnCount(); ++column) { - QStandardItem *item = m_model->item(row, column); - if (item) { - out << row; - out << column; - out << item->data(Qt::EditRole).toString(); - } - } - } - return true; -} - -bool Engine::load(const QString &filename) -{ - clearModels(); - - if (filename.isEmpty()) - return false; - - QFile file(filename); - - if (!file.open(QIODevice::ReadOnly)) { - return false; - } - - QDataStream in(&file); - - qint32 magicNumber; - in >> magicNumber; - - if (magicNumber != MAGIC_NUMBER) - return false; - - in.setVersion(QDataStream::Qt_4_8); - - int rowCount; - in >> rowCount; - - int columnCount; - in >> columnCount; - - while (!in.atEnd()) { - int row; - int column; - QString value; - in >> row >> column >> value; - QStandardItem *item = new QStandardItem(); - bool ok; - double result = value.toDouble(&ok); - if(ok) - item->setData(result, Qt::EditRole); - else - item->setData(value, Qt::EditRole); - m_model->setItem(row, column, item); - } - - return true; -} - -void Engine::setupXYSeries(QXYSeries *xyseries, const QList& columns, int column, int minRow, int maxRow) -{ - QVXYModelMapper* mapper = new QVXYModelMapper(xyseries); - mapper->setSeries(xyseries); - mapper->setModel(m_model); - mapper->setXColumn(columns.first()); - mapper->setYColumn(columns.at(column)); - mapper->setFirstRow(minRow); - mapper->setRowCount(maxRow - minRow + 1); - m_chart->addSeries(xyseries); - xyseries->setName(QString("Series %1").arg(m_chart->series().count())); - QObject::connect(xyseries,SIGNAL(clicked(const QPointF&)),this,SIGNAL(selected())); - const QModelIndexList& list = m_selection->selectedIndexes(); - QModelIndexList result; - foreach(const QModelIndex& index, list) { - if (index.column() ==columns.at(column)){ - m_model->setData(index, xyseries->pen().color(), Qt::BackgroundRole); - result << index; - } - } - m_seriesModelIndex.insert(xyseries,result); -} - -void Engine::setupBarSeries(QAbstractBarSeries *bar, const QList& columns, int minRow, int maxRow) -{ - QHBarModelMapper* mapper = new QHBarModelMapper(bar); - mapper->setSeries(bar); - mapper->setModel(m_model); - mapper->setFirstColumn(minRow); - mapper->setColumnCount(maxRow - minRow + 1); - mapper->setFirstBarSetRow(columns.at(1)); - mapper->setLastBarSetRow(columns.last()); - m_chart->addSeries(bar); - bar->setName(QString("Series %1").arg(m_chart->series().count())); - - const QModelIndexList& list = m_selection->selectedIndexes(); - foreach(const QModelIndex& index, list) { - if (index.column() >= columns.at(1) && index.column()<= columns.last()) { - //m_model->setData(index, bar->barSets().at(index.column())->brush().color(), Qt::BackgroundRole); - } - } -} - -void Engine::setupPieSeries(QPieSeries *pie, const QList& columns, int minRow, int maxRow) -{ - QVPieModelMapper* mapper = new QVPieModelMapper(pie); - mapper->setSeries(pie); - mapper->setModel(m_model); - mapper->setValuesColumn(columns.at(1)); - mapper->setLabelsColumn(columns.first()); - mapper->setFirstRow(minRow); - mapper->setRowCount(maxRow - minRow + 1); - m_chart->addSeries(pie); - pie->setName(QString("Series %1").arg(m_chart->series().count())); - - const QModelIndexList& list = m_selection->selectedIndexes(); - foreach(const QModelIndex& index, list) { - // m_model->setData(index, bar->barSets()pen().color(), Qt::BackgroundRole); - } -} - -void Engine::setupAreaSeries(QAreaSeries *series, const QList& columns, int minRow, int maxRow) -{ - QVXYModelMapper* umapper = new QVXYModelMapper(series); - umapper->setSeries(series->upperSeries()); - umapper->setModel(m_model); - umapper->setXColumn(columns.first()); - umapper->setYColumn(columns.at(1)); - umapper->setFirstRow(minRow); - umapper->setRowCount(maxRow - minRow + 1); - - QVXYModelMapper* lmapper = new QVXYModelMapper(series); - lmapper->setSeries(series->lowerSeries()); - lmapper->setModel(m_model); - lmapper->setXColumn(columns.first()); - lmapper->setYColumn(columns.at(2)); - lmapper->setFirstRow(minRow); - lmapper->setRowCount(maxRow - minRow + 1); - - m_chart->addSeries(series); - series->setName(QString("Series %1").arg(m_chart->series().count())); - - const QModelIndexList& list = m_selection->selectedIndexes(); - foreach(const QModelIndex& index, list) { - //if (index.column() ==columns.at(column)) - // m_model->setData(index, xyseries->pen().color(), Qt::BackgroundRole); - } -} diff --git a/tests/chartdesigner/engine.h b/tests/chartdesigner/engine.h deleted file mode 100644 index 368f70d..0000000 --- a/tests/chartdesigner/engine.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** - ** - ** 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$ - ** - ****************************************************************************/ - -#ifndef ENGINE_H -#define ENGINE_H - -#include -#include -#include - -class QStandardItemModel; -class QItemSelectionModel; - - -QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QChart; -class QXYSeries; -class QAbstractBarSeries; -class QPieSeries; -class QAreaSeries; -QTCOMMERCIALCHART_END_NAMESPACE - -QTCOMMERCIALCHART_USE_NAMESPACE - -class Engine : public QObject -{ - Q_OBJECT -public: - explicit Engine(QObject *parent = 0); - ~Engine(); - - int modelCount() { return m_count; } - QStandardItemModel *model() const { return m_model; } - QItemSelectionModel *selectionModel() const { return m_selection; } - QChart* chart() const { return m_chart; } - void clearModels(); - QList addSeries(QAbstractSeries::SeriesType type); - void removeSeries(QAbstractSeries* series); - bool save(const QString &filename) const; - bool load(const QString &filename); -signals: - void selected(); - -private: - void createModels(); - void setupXYSeries(QXYSeries *xyseries, const QList& columns, int column, int minRow, int maxRow); - void setupBarSeries(QAbstractBarSeries *series, const QList& columns, int minRow, int maxRow); - void setupPieSeries(QPieSeries *pie, const QList& columns, int minRow, int maxRow); - void setupAreaSeries(QAreaSeries *series, const QList& columns, int minRow, int maxRow); - -private: - int m_count; - QChart *m_chart; - QStandardItemModel *m_model; - QItemSelectionModel *m_selection; - QMap > m_seriesModelIndex; -}; - -#endif /* ENGINE_H */ diff --git a/tests/chartdesigner/main.cpp b/tests/chartdesigner/main.cpp deleted file mode 100644 index ab7a03d..0000000 --- a/tests/chartdesigner/main.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/**************************************************************************** -** -** 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 "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - MainWindow window; - window.resize(1000,600); - window.show(); - return a.exec(); -} diff --git a/tests/chartdesigner/mainwindow.cpp b/tests/chartdesigner/mainwindow.cpp deleted file mode 100644 index b0e93e2..0000000 --- a/tests/chartdesigner/mainwindow.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/**************************************************************************** - ** - ** 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 "mainwindow.h" -#include "objectinspectorwidget.h" -#include "penwidget.h" -#include "brushwidget.h" -#include "engine.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const QString FILENAME_SETTING("filename"); -static const QString GEOMETRY_SETTING("geometry"); - -MainWindow::MainWindow() : - m_engine(new Engine(this)), - m_view(new QChartView(m_engine->chart())), - m_scene(m_view->scene()), - m_table(new QTableView()), - m_addSeriesMenu(0), - m_seriesMenu(0), - m_chartMenu(0), - m_themeMenu(0), - m_animationMenu(0), - m_zoomMenu(0), - m_removeAllAction(0), - m_legendAction(0), - m_antialiasingAction(0) -{ - createMenus(); - createDockWidgets(); - createTable(); - createLayout(); - - QSettings settings; - restoreGeometry(settings.value(GEOMETRY_SETTING).toByteArray()); - m_filename = settings.value(FILENAME_SETTING).toString(); - if (m_filename.isEmpty()) - m_filename = "untitled"; - - setWindowTitle(m_filename); - updateUI(); -} - -MainWindow::~MainWindow() -{ - delete m_engine; -} - -void MainWindow::createMenus() -{ - QMenu *file = menuBar()->addMenu(tr("File")); - QMenu *edit = menuBar()->addMenu(tr("Edit")); - m_seriesMenu = menuBar()->addMenu(tr("Series")); - m_chartMenu = menuBar()->addMenu(tr("Chart")); - - m_addSeriesMenu = new QMenu(tr("Add series")); - m_themeMenu = new QMenu(tr("Apply theme")); - m_animationMenu = new QMenu(tr("Animations")); - m_zoomMenu = new QMenu(tr("Zoom")); - - file->addAction(tr("New"), this, SLOT(handleNewAction())); - file->addAction(tr("Load"), this, SLOT(handleLoadAction())); - file->addAction(tr("Save"), this, SLOT(handleSaveAction())); - file->addAction(tr("Save As"), this, SLOT(handleSaveAsAction())); - - //seriesMenu - m_seriesMenu->addMenu(m_addSeriesMenu); - m_removeAllAction = new QAction(tr("Remove all series"), this); - QObject::connect(m_removeAllAction, SIGNAL(triggered()), this, SLOT(handleRemoveAllSeriesAction())); - m_seriesMenu->addAction(m_removeAllAction); - m_seriesMenu->addSeparator(); - - //seriesMenu /addSeriesMenu - { - int index = QAbstractSeries::staticMetaObject.indexOfEnumerator("SeriesType"); - QMetaEnum metaEnum = QAbstractSeries::staticMetaObject.enumerator(index); - - int count = metaEnum.keyCount(); - - for (int i = 0; i < count; ++i) { - QAction* action = new QAction(metaEnum.key(i), this); - action->setData(metaEnum.value(i)); - m_addSeriesMenu->addAction(action); - QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleAddSeriesMenu())); - } - } - - //chartMenu / themeMenu - { - m_chartMenu->addMenu(m_themeMenu); - int index = QChart::staticMetaObject.indexOfEnumerator("ChartTheme"); - QMetaEnum metaEnum = QChart::staticMetaObject.enumerator(index); - - int count = metaEnum.keyCount(); - - for (int i = 0; i < count; ++i) { - QAction* action = new QAction(metaEnum.key(i), this); - action->setData(metaEnum.value(i)); - action->setCheckable(true); - m_themeMenu->addAction(action); - QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleThemeMenu())); - } - } - - //chartMenu / animationMenu - { - m_chartMenu->addMenu(m_animationMenu); - int index = QChart::staticMetaObject.indexOfEnumerator("AnimationOption"); - QMetaEnum metaEnum = QChart::staticMetaObject.enumerator(index); - - int count = metaEnum.keyCount(); - - for (int i = 0; i < count; ++i) { - QAction* action = new QAction(metaEnum.key(i), this); - action->setData(metaEnum.value(i)); - action->setCheckable(true); - m_animationMenu->addAction(action); - QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleAnimationMenu())); - } - } - - //chartMenu / zoomMenu - { - m_chartMenu->addMenu(m_zoomMenu); - int index = QChartView::staticMetaObject.indexOfEnumerator("RubberBand"); - QMetaEnum metaEnum = QChartView::staticMetaObject.enumerator(index); - - int count = metaEnum.keyCount(); - - for (int i = 0; i < count; ++i) { - QAction* action = new QAction(metaEnum.key(i), this); - action->setData(metaEnum.value(i)); - action->setCheckable(true); - m_zoomMenu->addAction(action); - QObject::connect(action, SIGNAL(triggered()), this, SLOT(handleZoomMenu())); - } - } - - //chartMenu / legend - m_legendAction = new QAction(tr("Legend"), this); - m_legendAction->setCheckable(true); - m_chartMenu->addAction(m_legendAction); - QObject::connect(m_legendAction, SIGNAL(triggered()), this, SLOT(handleLegendAction())); - - //chartMenu / Anti-aliasing - m_antialiasingAction = new QAction(tr("Anti-aliasing"), this); - m_antialiasingAction->setCheckable(true); - m_chartMenu->addAction(m_antialiasingAction); - QObject::connect(m_antialiasingAction, SIGNAL(triggered()), this, SLOT(handleAntialiasingAction())); - -} - -void MainWindow::createDockWidgets() -{ - m_brushWidget = new BrushWidget(); - QDockWidget *brushDockWidget = new QDockWidget(tr("Brush"), this); - brushDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); - brushDockWidget->setWidget(m_brushWidget); - addDockWidget(Qt::RightDockWidgetArea, brushDockWidget); - - m_penWidget = new PenWidget(); - QDockWidget *penDockWidget = new QDockWidget(tr("Pen"), this); - penDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); - penDockWidget->setWidget(m_penWidget); - addDockWidget(Qt::RightDockWidgetArea, penDockWidget); - - m_inspectorWidget = new InspectorWidget(); - QDockWidget *inspectorDockWidget = new QDockWidget(tr("Object Inspector"), this); - inspectorDockWidget->setFeatures( - QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); - inspectorDockWidget->setWidget(m_inspectorWidget); - addDockWidget(Qt::RightDockWidgetArea, inspectorDockWidget); - - setDockOptions(QMainWindow::AnimatedDocks); -} - -void MainWindow::createLayout() -{ - m_table->horizontalHeader()->setResizeMode(QHeaderView::Stretch); - - int rowHeight = m_table->rowHeight(0); - int tableHeight = (m_engine->modelCount() * rowHeight) + m_table->horizontalHeader()->height() + 2 * m_table->frameWidth(); - - m_table->setMinimumHeight(tableHeight); - m_table->setMaximumHeight(tableHeight); - - QSplitter *splitter = new QSplitter(this); - splitter->setOrientation(Qt::Vertical); - splitter->addWidget(m_table); - splitter->addWidget(m_view); - setCentralWidget(splitter); - m_view->hide(); -} - -void MainWindow::createTable() -{ - m_table->setModel(m_engine->model()); - m_table->setSelectionModel(m_engine->selectionModel()); - QObject::connect(m_table->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this,SLOT(updateUI())); -} - -void MainWindow::updateUI() -{ - - QItemSelectionModel* selection = m_table->selectionModel(); - const QModelIndexList& list = selection->selectedIndexes(); - - QMap columns; - - foreach(const QModelIndex& index, list) { - columns.insertMulti(index.column(), index); - } - - QList keys = columns.uniqueKeys(); - - bool seriesEnabled = false; - - foreach(QAction* action, m_addSeriesMenu->actions()) { - switch (action->data().toInt()) { - case QAbstractSeries::SeriesTypeLine: - case QAbstractSeries::SeriesTypeSpline: - case QAbstractSeries::SeriesTypeScatter: - action->setEnabled(list.count() > 0 && keys.count() >= 2); - seriesEnabled |= action->isEnabled(); - break; - case QAbstractSeries::SeriesTypeBar: - case QAbstractSeries::SeriesTypePercentBar: - case QAbstractSeries::SeriesTypeStackedBar: - action->setEnabled(list.count() > 0 && keys.count() >= 2); - seriesEnabled |= action->isEnabled(); - break; - case QAbstractSeries::SeriesTypePie: - action->setEnabled(list.count() > 0 && keys.count() == 2); - seriesEnabled |= action->isEnabled(); - break; - case QAbstractSeries::SeriesTypeArea: - action->setEnabled(list.count() > 0 && keys.count() == 3); - seriesEnabled |= action->isEnabled(); - break; - } - } - - m_chartMenu->setEnabled(m_engine->chart()->series().count() > 0); - m_seriesMenu->setEnabled(seriesEnabled || m_engine->chart()->series().count() > 0); - m_removeAllAction->setEnabled(m_engine->chart()->series().count() > 0); - - int theme = m_engine->chart()->theme(); - foreach(QAction* action, m_themeMenu->actions()) { - action->setChecked(action->data().toInt() == theme); - } - - int animation = m_engine->chart()->animationOptions(); - foreach(QAction* action, m_animationMenu->actions()) { - action->setChecked(action->data().toInt() == animation); - } - - int zoom = m_view->rubberBand(); - foreach(QAction* action, m_zoomMenu->actions()) { - action->setChecked(action->data().toInt() == zoom); - } - - m_legendAction->setChecked(m_engine->chart()->legend()->isVisible()); - m_antialiasingAction->setChecked(m_view->renderHints().testFlag(QPainter::Antialiasing)); - - foreach(QAction *action, m_seriesMenu->actions()) { - //TODO: visibility handling - //if (m_series.value(action->text())) - // ; - //action->setChecked(false); - } -} - -void MainWindow::closeEvent(QCloseEvent *event) -{ - QSettings settings; - settings.setValue(GEOMETRY_SETTING, saveGeometry()); - settings.setValue(FILENAME_SETTING, m_filename); - QMainWindow::closeEvent(event); -} - -//handlers - -void MainWindow::handleNewAction() -{ - m_engine->chart()->removeAllSeries(); - m_view->hide(); - m_engine->clearModels(); - createTable(); - m_filename = "untitled"; - setWindowTitle(m_filename); - updateUI(); -} - -void MainWindow::handleAddSeriesMenu() -{ - m_view->show(); - QAction* action = qobject_cast(sender()); - QList series = m_engine->addSeries(QAbstractSeries::SeriesType(action->data().toInt())); - - foreach(QAbstractSeries* s , series) - { - QAction *newAction = new QAction(s->name(),this); - //newAction->setCheckable(true); - m_series.insert(s->name(),s); - m_seriesMenu->addAction(newAction); - } - - updateUI(); -} - -void MainWindow::handleRemoveAllSeriesAction() -{ - - foreach(QAction* action, m_seriesMenu->actions()){ - if(m_series.contains(action->text())){ - m_seriesMenu->removeAction(action); - m_engine->removeSeries(m_series.value(action->text())); - delete action; - } - } - - m_series.clear(); - - m_view->hide(); - updateUI(); -} - -void MainWindow::handleThemeMenu() -{ - QAction* action = qobject_cast(sender()); - m_engine->chart()->setTheme(QChart::ChartTheme(action->data().toInt())); - updateUI(); -} - -void MainWindow::handleAnimationMenu() -{ - QAction* action = qobject_cast(sender()); - m_engine->chart()->setAnimationOptions(QChart::AnimationOption(action->data().toInt())); - updateUI(); -} - -void MainWindow::handleZoomMenu() -{ - QAction* action = qobject_cast(sender()); - m_view->setRubberBand(QChartView::RubberBand(action->data().toInt())); - updateUI(); -} - -void MainWindow::handleAntialiasingAction() -{ - QAction* action = qobject_cast(sender()); - if (action->isChecked()) { - m_view->setRenderHint(QPainter::Antialiasing, true); - } - else { - m_view->setRenderHint(QPainter::Antialiasing, false); - } -} - -void MainWindow::handleLegendAction() -{ - QAction* action = qobject_cast(sender()); - if (action->isChecked()) { - m_engine->chart()->legend()->setVisible(true); - } - else { - m_engine->chart()->legend()->setVisible(false); - } -} - -void MainWindow::handleSaveAction() -{ - if(!m_engine->save(m_filename)) { - - QScopedPointer messageBox(new QMessageBox(this)); - messageBox->setIcon(QMessageBox::Warning); - messageBox->setWindowModality(Qt::WindowModal); - messageBox->setWindowTitle(QString(tr("Error"))); - messageBox->setText(tr("Could not write to ") + m_filename); - messageBox->exec(); - } -} - -void MainWindow::handleLoadAction() -{ - if(!m_engine->load(m_filename)) { - - QScopedPointer messageBox(new QMessageBox(this)); - messageBox->setIcon(QMessageBox::Warning); - messageBox->setWindowModality(Qt::WindowModal); - messageBox->setWindowTitle(QString(tr("Error"))); - messageBox->setText(tr("Could not open ") + m_filename); - messageBox->exec(); - - }else createTable(); -} diff --git a/tests/chartdesigner/mainwindow.h b/tests/chartdesigner/mainwindow.h deleted file mode 100644 index 3b120fc..0000000 --- a/tests/chartdesigner/mainwindow.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include - - -QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QChartView; -class QAbstractSeries; -QTCOMMERCIALCHART_END_NAMESPACE - -class QGraphicsScene; -class InspectorWidget; -class BrushWidget; -class PenWidget; -class QTableView; -class Engine; - -QTCOMMERCIALCHART_USE_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - MainWindow(); - ~MainWindow(); - -private slots: - void handleNewAction(); - void handleAddSeriesMenu(); - void handleRemoveAllSeriesAction(); - void updateUI(); - void handleThemeMenu(); - void handleAnimationMenu(); - void handleZoomMenu(); - void handleAntialiasingAction(); - void handleLegendAction(); - void handleSaveAction(); - void handleLoadAction(); - -protected: - void closeEvent(QCloseEvent *event); - -private: - void createMenus(); - void createDockWidgets(); - void createModel(); - void createLayout(); - void createTable(); - -private: - Engine *m_engine; - QChartView *m_view; - QGraphicsScene *m_scene; - QTableView *m_table; - InspectorWidget *m_inspectorWidget; - PenWidget *m_penWidget; - BrushWidget *m_brushWidget; - QMenu *m_addSeriesMenu; - QMenu *m_seriesMenu; - QMenu *m_chartMenu; - QMenu *m_themeMenu; - QMenu *m_animationMenu; - QMenu *m_zoomMenu; - - QAction *m_removeAllAction; - QAction *m_legendAction; - QAction *m_antialiasingAction; - QString m_filename; - - QMap m_series; - -}; - -#endif /* MAINWINDOW_H */ diff --git a/tests/chartdesigner/objectinspectorwidget.cpp b/tests/chartdesigner/objectinspectorwidget.cpp deleted file mode 100644 index 82c9dd6..0000000 --- a/tests/chartdesigner/objectinspectorwidget.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** 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 "objectinspectorwidget.h" -#include -#include -#include - -InspectorWidget::InspectorWidget() -{ - -} - -InspectorWidget::~InspectorWidget() -{ - -} - -QIcon InspectorWidget::getColorIcon(const QColor& color,const QSize &size) const -{ - - QString key = QString("COLOR_ICON=%1:%2x%3").arg(color.name()).arg(size.width()).arg(size.height()); - - QPixmap pixmap(size); - - if (!QPixmapCache::find(key, &pixmap)) { - pixmap.fill(Qt::white); - QPainter painter(&pixmap); - painter.fillRect(2, 2, 46, 46, color); - QPixmapCache::insert(key, pixmap); - } - - return QIcon(pixmap); -} diff --git a/tests/chartdesigner/objectinspectorwidget.h b/tests/chartdesigner/objectinspectorwidget.h deleted file mode 100644 index b454f31..0000000 --- a/tests/chartdesigner/objectinspectorwidget.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef INSPECTORWIDGET_H -#define INSPECTORWIDGET_H - -#include - -class InspectorWidget : public QWidget -{ -public: - InspectorWidget(); - ~InspectorWidget(); - -private: - QIcon getColorIcon(const QColor& color,const QSize &size) const; - -}; - -#endif diff --git a/tests/chartdesigner/penwidget.cpp b/tests/chartdesigner/penwidget.cpp deleted file mode 100644 index e34a662..0000000 --- a/tests/chartdesigner/penwidget.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** 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 "penwidget.h" -#include -#include -#include - -PenWidget::PenWidget(QWidget *parent):QWidget(parent), -m_colorComboBox(0), -m_lineStyleComboBox(0), -m_widthSpinBox(0) -{ - createContent(); - createLayout(); - setFixedSize(minimumSizeHint()); -} - -PenWidget::~PenWidget() -{ - -} - -void PenWidget::createContent() -{ - m_colorComboBox = new QComboBox(this); - m_lineStyleComboBox = new QComboBox(this); - m_widthSpinBox = new QSpinBox(this); -} - -void PenWidget::createLayout() -{ - QFormLayout *layout = new QFormLayout(); - layout->addRow(tr("Color"), m_colorComboBox); - layout->addRow(tr("Style"), m_lineStyleComboBox); - layout->addRow(tr("Width"), m_widthSpinBox); - setLayout(layout); -} - diff --git a/tests/chartdesigner/penwidget.h b/tests/chartdesigner/penwidget.h deleted file mode 100644 index 1cef9b9..0000000 --- a/tests/chartdesigner/penwidget.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef PENWIDGET_H -#define PENWIDGET_H - -#include -#include - -class QComboBox; -class QSpinBox; - -class PenWidget : public QWidget -{ -public: - explicit PenWidget(QWidget* parent = 0); - ~PenWidget(); - - QPen pen() const { return m_pen; } -private: - void createContent(); - void createLayout(); - -private: - QPen m_pen; - QComboBox *m_colorComboBox; - QComboBox *m_lineStyleComboBox; - QSpinBox *m_widthSpinBox; -}; - -#endif /* PENWIDGET_H */ diff --git a/tests/chartwidgettest/chartwidgettest.pro b/tests/chartwidgettest/chartwidgettest.pro deleted file mode 100644 index 97845ff..0000000 --- a/tests/chartwidgettest/chartwidgettest.pro +++ /dev/null @@ -1,18 +0,0 @@ -!include( ../tests.pri ) { - error( "Couldn't find the test.pri file!" ) -} - -TEMPLATE = app - -QT += core gui opengl -contains(QT_MAJOR_VERSION, 5) { - QT += widgets -} - -SOURCES += main.cpp \ - mainwidget.cpp \ - dataseriedialog.cpp - -HEADERS += \ - mainwidget.h \ - dataseriedialog.h diff --git a/tests/chartwidgettest/dataseriedialog.cpp b/tests/chartwidgettest/dataseriedialog.cpp deleted file mode 100644 index 73e6fe4..0000000 --- a/tests/chartwidgettest/dataseriedialog.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -** -** 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 "dataseriedialog.h" -#include -#include -#include -#include -#include -#include -#include -#include - -DataSerieDialog::DataSerieDialog(QWidget *parent) : - QDialog(parent) -{ - QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal); - QPushButton *b = addSeriesBox->addButton(QDialogButtonBox::Ok); - connect(b, SIGNAL(clicked()), this, SLOT(accept())); - b = addSeriesBox->addButton(QDialogButtonBox::Cancel); - connect(b, SIGNAL(clicked()), this, SLOT(reject())); - - QGridLayout *grid = new QGridLayout(); - - m_seriesTypeSelector = seriesTypeSelector(); - m_columnCountSelector = columnCountSelector(); - m_rowCountSelector = rowCountSelector(); - m_dataCharacteristicsSelector = dataCharacteristicsSelector(); - - grid->addWidget(m_seriesTypeSelector, 0, 0); - grid->addWidget(m_columnCountSelector, 0, 1); - grid->addWidget(m_rowCountSelector, 1, 1); - grid->addWidget(m_dataCharacteristicsSelector, 1, 0); - m_labelsSelector = new QCheckBox("Labels defined"); - m_labelsSelector->setChecked(true); - grid->addWidget(m_labelsSelector, 2, 0); - grid->addWidget(addSeriesBox, 3, 1); - - setLayout(grid); -} - -QGroupBox *DataSerieDialog::seriesTypeSelector() -{ - QVBoxLayout *layout = new QVBoxLayout(); - - QRadioButton *line = new QRadioButton("Line"); - line->setChecked(true); - layout->addWidget(line); - layout->addWidget(new QRadioButton("Area")); - layout->addWidget(new QRadioButton("Pie")); - layout->addWidget(new QRadioButton("Bar")); - layout->addWidget(new QRadioButton("Stacked bar")); - layout->addWidget(new QRadioButton("Percent bar")); - layout->addWidget(new QRadioButton("Scatter")); - layout->addWidget(new QRadioButton("Spline")); - - QGroupBox *groupBox = new QGroupBox("Series type"); - groupBox->setLayout(layout); - selectRadio(groupBox, 0); - - return groupBox; -} - -QGroupBox *DataSerieDialog::columnCountSelector() -{ - QVBoxLayout *layout = new QVBoxLayout(); - - QRadioButton *radio = new QRadioButton("1"); - radio->setChecked(true); - layout->addWidget(radio); - layout->addWidget(new QRadioButton("2")); - layout->addWidget(new QRadioButton("3")); - layout->addWidget(new QRadioButton("4")); - layout->addWidget(new QRadioButton("5")); - layout->addWidget(new QRadioButton("8")); - layout->addWidget(new QRadioButton("10")); - layout->addWidget(new QRadioButton("100")); - - QGroupBox *groupBox = new QGroupBox("Column count"); - groupBox->setLayout(layout); - selectRadio(groupBox, 0); - - return groupBox; -} - -QGroupBox *DataSerieDialog::rowCountSelector() -{ - QVBoxLayout *layout = new QVBoxLayout(); - - layout->addWidget(new QRadioButton("1")); - QRadioButton *radio = new QRadioButton("10"); - radio->setChecked(true); - layout->addWidget(radio); - layout->addWidget(new QRadioButton("50")); - layout->addWidget(new QRadioButton("100")); - layout->addWidget(new QRadioButton("1000")); - layout->addWidget(new QRadioButton("10000")); - layout->addWidget(new QRadioButton("100000")); - layout->addWidget(new QRadioButton("1000000")); - - QGroupBox *groupBox = new QGroupBox("Row count"); - groupBox->setLayout(layout); - selectRadio(groupBox, 0); - - return groupBox; -} - -QGroupBox *DataSerieDialog::dataCharacteristicsSelector() -{ - QVBoxLayout *layout = new QVBoxLayout(); - - layout->addWidget(new QRadioButton("Linear")); - layout->addWidget(new QRadioButton("Constant")); - layout->addWidget(new QRadioButton("Random")); - layout->addWidget(new QRadioButton("Sin")); - layout->addWidget(new QRadioButton("Sin + random")); - - QGroupBox *groupBox = new QGroupBox("Data Characteristics"); - groupBox->setLayout(layout); - selectRadio(groupBox, 0); - - return groupBox; -} - -void DataSerieDialog::accept() -{ - accepted(radioSelection(m_seriesTypeSelector), - radioSelection(m_columnCountSelector).toInt(), - radioSelection(m_rowCountSelector).toInt(), - radioSelection(m_dataCharacteristicsSelector), - m_labelsSelector->isChecked()); - QDialog::accept(); -} - -void DataSerieDialog::selectRadio(QGroupBox *groupBox, int defaultSelection) -{ - QVBoxLayout *layout = qobject_cast(groupBox->layout()); - Q_ASSERT(layout); - Q_ASSERT(layout->count()); - - QLayoutItem *item = 0; - if (defaultSelection == -1) { - item = layout->itemAt(0); - } else if (layout->count() > defaultSelection) { - item = layout->itemAt(defaultSelection); - } - Q_ASSERT(item); - QRadioButton *radio = qobject_cast(item->widget()); - Q_ASSERT(radio); - radio->setChecked(true); -} - -QString DataSerieDialog::radioSelection(QGroupBox *groupBox) -{ - QString selection; - QVBoxLayout *layout = qobject_cast(groupBox->layout()); - Q_ASSERT(layout); - - for (int i(0); i < layout->count(); i++) { - QLayoutItem *item = layout->itemAt(i); - Q_ASSERT(item); - QRadioButton *radio = qobject_cast(item->widget()); - Q_ASSERT(radio); - if (radio->isChecked()) { - selection = radio->text(); - break; - } - } - - qDebug() << "radioSelection: " << selection; - return selection; -} diff --git a/tests/chartwidgettest/dataseriedialog.h b/tests/chartwidgettest/dataseriedialog.h deleted file mode 100644 index 189ad92..0000000 --- a/tests/chartwidgettest/dataseriedialog.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef DATASERIEDIALOG_H -#define DATASERIEDIALOG_H - -#include - -class QGroupBox; -class QCheckBox; - -class DataSerieDialog : public QDialog -{ - Q_OBJECT -public: - explicit DataSerieDialog(QWidget *parent = 0); - -signals: - void accepted(QString series, int columnCount, int rowCount, QString dataCharacteristics, bool labelsDefined); - -public slots: - void accept(); - -private: - QGroupBox *seriesTypeSelector(); - QGroupBox *columnCountSelector(); - QGroupBox *rowCountSelector(); - QGroupBox *dataCharacteristicsSelector(); - void selectRadio(QGroupBox *groupBox, int defaultSelection); - QString radioSelection(QGroupBox *groupBox); - QGroupBox *m_seriesTypeSelector; - QGroupBox *m_columnCountSelector; - QGroupBox *m_rowCountSelector; - QCheckBox *m_labelsSelector; - QGroupBox *m_dataCharacteristicsSelector; -}; - -#endif // DATASERIEDIALOG_H diff --git a/tests/chartwidgettest/main.cpp b/tests/chartwidgettest/main.cpp deleted file mode 100644 index 99b254b..0000000 --- a/tests/chartwidgettest/main.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** -** 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 -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) -#include -#else -#include -#endif -#include "mainwidget.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - MainWidget w; - w.resize(1000,600); - w.show(); - - return a.exec(); -} diff --git a/tests/chartwidgettest/mainwidget.cpp b/tests/chartwidgettest/mainwidget.cpp deleted file mode 100644 index bb5f1bf..0000000 --- a/tests/chartwidgettest/mainwidget.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/**************************************************************************** -** -** 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 "mainwidget.h" -#include "dataseriedialog.h" -#include "qchartview.h" -#include "qpieseries.h" -#include "qscatterseries.h" -#include "qlineseries.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -MainWidget::MainWidget(QWidget *parent) : - QWidget(parent), - m_addSerieDialog(0), - m_chart(0) -{ - m_chart = new QChart(); - - // Grid layout for the controls for configuring the chart widget - QGridLayout *grid = new QGridLayout(); - QPushButton *addSeriesButton = new QPushButton("Add series"); - connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); - grid->addWidget(addSeriesButton, 0, 1); - initBackroundCombo(grid); - initScaleControls(grid); - initThemeCombo(grid); - initCheckboxes(grid); - - // add row with empty label to make all the other rows static - grid->addWidget(new QLabel(""), grid->rowCount(), 0); - grid->setRowStretch(grid->rowCount() - 1, 1); - - // Create chart view with the chart - m_chartView = new QChartView(m_chart, this); - m_chartView->setRubberBand(QChartView::HorizonalRubberBand); - - // Another grid layout as a main layout - QGridLayout *mainLayout = new QGridLayout(); - mainLayout->addLayout(grid, 0, 0); - mainLayout->addWidget(m_chartView, 0, 1, 3, 1); - setLayout(mainLayout); -} - -// Combo box for selecting the chart's background -void MainWidget::initBackroundCombo(QGridLayout *grid) -{ - QComboBox *backgroundCombo = new QComboBox(this); - backgroundCombo->addItem("Color"); - backgroundCombo->addItem("Gradient"); - backgroundCombo->addItem("Image"); - connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(backgroundChanged(int))); - - grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); - grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); -} - -// Scale related controls (auto-scale vs. manual min-max values) -void MainWidget::initScaleControls(QGridLayout *grid) -{ - m_autoScaleCheck = new QCheckBox("Automatic scaling"); - connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); - // Allow setting also non-sense values (like -2147483648 and 2147483647) - m_xMinSpin = new QSpinBox(); - m_xMinSpin->setMinimum(INT_MIN); - m_xMinSpin->setMaximum(INT_MAX); - m_xMinSpin->setValue(0); - connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); - m_xMaxSpin = new QSpinBox(); - m_xMaxSpin->setMinimum(INT_MIN); - m_xMaxSpin->setMaximum(INT_MAX); - m_xMaxSpin->setValue(10); - connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); - m_yMinSpin = new QSpinBox(); - m_yMinSpin->setMinimum(INT_MIN); - m_yMinSpin->setMaximum(INT_MAX); - m_yMinSpin->setValue(0); - connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); - m_yMaxSpin = new QSpinBox(); - m_yMaxSpin->setMinimum(INT_MIN); - m_yMaxSpin->setMaximum(INT_MAX); - m_yMaxSpin->setValue(10); - connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); - - grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); - grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); - grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); - grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); - grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); - grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); - grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); - grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); - grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); - - m_autoScaleCheck->setChecked(true); -} - -// Combo box for selecting theme -void MainWidget::initThemeCombo(QGridLayout *grid) -{ - QComboBox *chartTheme = new QComboBox(); - chartTheme->addItem("Default"); - chartTheme->addItem("Light"); - chartTheme->addItem("Blue Cerulean"); - chartTheme->addItem("Dark"); - chartTheme->addItem("Brown Sand"); - chartTheme->addItem("Blue NCS"); - chartTheme->addItem("High Contrast"); - chartTheme->addItem("Blue Icy"); - connect(chartTheme, SIGNAL(currentIndexChanged(int)), - this, SLOT(changeChartTheme(int))); - grid->addWidget(new QLabel("Chart theme:"), 8, 0); - grid->addWidget(chartTheme, 8, 1); -} - -// Different check boxes for customizing chart -void MainWidget::initCheckboxes(QGridLayout *grid) -{ - // TODO: setZoomEnabled slot has been removed from QChartView -> Re-implement zoom on/off - QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom"); -// connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartView, SLOT(setZoomEnabled(bool))); - zoomCheckBox->setChecked(true); - grid->addWidget(zoomCheckBox, grid->rowCount(), 0); - - QCheckBox *aliasCheckBox = new QCheckBox("Anti-alias"); - connect(aliasCheckBox, SIGNAL(toggled(bool)), this, SLOT(antiAliasToggled(bool))); - aliasCheckBox->setChecked(false); - grid->addWidget(aliasCheckBox, grid->rowCount(), 0); - - QCheckBox *openGLCheckBox = new QCheckBox("Use QGLWidget"); - connect(openGLCheckBox, SIGNAL(toggled(bool)), this, SLOT(openGLToggled(bool))); - openGLCheckBox->setChecked(false); - grid->addWidget(openGLCheckBox, grid->rowCount(), 0); -} - -void MainWidget::antiAliasToggled(bool enabled) -{ - m_chartView->setRenderHint(QPainter::Antialiasing, enabled); -} - -void MainWidget::openGLToggled(bool enabled) -{ - if (enabled) { - QGLFormat f = QGLFormat::defaultFormat(); - f.setSampleBuffers(true); - f.setSamples(4); - QGLFormat::setDefaultFormat(f); - QGLWidget *g = new QGLWidget(); - m_chartView->setViewport(g); - } else { - m_chartView->setViewport(0); - } -} - -void MainWidget::addSeries() -{ - if (!m_addSerieDialog) { - m_addSerieDialog = new DataSerieDialog(this); - connect(m_addSerieDialog, SIGNAL(accepted(QString,int,int,QString,bool)), - this, SLOT(addSeries(QString,int,int,QString,bool))); - } - m_addSerieDialog->exec(); -} - -QList MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics) -{ - // TODO: dataCharacteristics - QList testData; - for (int j(0); j < columnCount; j++) { - QList newColumn; - for (int i(0); i < rowCount; i++) { - if (dataCharacteristics == "Sin") { - newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100)); - } else if (dataCharacteristics == "Sin + random") { - newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); - } else if (dataCharacteristics == "Random") { - newColumn.append(rand() % 10 + (qreal) rand() / (qreal) RAND_MAX); - } else if (dataCharacteristics == "Linear") { - //newColumn.append(i * (j + 1.0)); - // TODO: temporary hack to make pie work; prevent zero values: - newColumn.append(i * (j + 1.0) + 0.1); - } else { // "constant" - newColumn.append((j + 1.0)); - } - } - testData.append(newColumn); - } - return testData; -} - -QStringList MainWidget::generateLabels(int count) -{ - QStringList result; - for (int i(0); i < count; i++) - result.append("label" + QString::number(i)); - return result; -} - -void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QString dataCharacteristics, bool labelsEnabled) -{ - qDebug() << "addSeries: " << seriesName - << " columnCount: " << columnCount - << " rowCount: " << rowCount - << " dataCharacteristics: " << dataCharacteristics - << " labels enabled: " << labelsEnabled; - m_defaultSeriesName = seriesName; - - QList data = generateTestData(columnCount, rowCount, dataCharacteristics); - - // Line series and scatter series use similar data - if (seriesName == "Line") { - for (int j(0); j < data.count(); j ++) { - QList column = data.at(j); - QLineSeries *series = new QLineSeries(); - series->setName("line" + QString::number(j)); - for (int i(0); i < column.count(); i++) - series->append(i, column.at(i)); - m_chart->addSeries(series); - } - } else if (seriesName == "Area") { - // TODO: lower series for the area? - for (int j(0); j < data.count(); j ++) { - QList column = data.at(j); - QLineSeries *lineSeries = new QLineSeries(); - for (int i(0); i < column.count(); i++) - lineSeries->append(i, column.at(i)); - QAreaSeries *areaSeries = new QAreaSeries(lineSeries); - areaSeries->setName("area" + QString::number(j)); - m_chart->addSeries(areaSeries); - } - } else if (seriesName == "Scatter") { - for (int j(0); j < data.count(); j++) { - QList column = data.at(j); - QScatterSeries *series = new QScatterSeries(); - series->setName("scatter" + QString::number(j)); - for (int i(0); i < column.count(); i++) - series->append(i, column.at(i)); - m_chart->addSeries(series); - } - } else if (seriesName == "Pie") { - QStringList labels = generateLabels(rowCount); - for (int j(0); j < data.count(); j++) { - QPieSeries *series = new QPieSeries(); - QList column = data.at(j); - for (int i(0); i < column.count(); i++) - series->append(labels.at(i), column.at(i)); - m_chart->addSeries(series); - } - } else if (seriesName == "Bar" - || seriesName == "Stacked bar" - || seriesName == "Percent bar") { - QStringList category; - QStringList labels = generateLabels(rowCount); - foreach(QString label, labels) - category << label; - QAbstractBarSeries* series = 0; - if (seriesName == "Bar") { - series = new QBarSeries(this); - QBarCategoryAxis* axis = new QBarCategoryAxis(); - axis->append(category); - m_chart->setAxisX(axis,series); - } else if (seriesName == "Stacked bar") { - series = new QStackedBarSeries(this); - QBarCategoryAxis* axis = new QBarCategoryAxis(); - axis->append(category); - m_chart->setAxisX(axis,series); - } else { - series = new QPercentBarSeries(this); - QBarCategoryAxis* axis = new QBarCategoryAxis(); - axis->append(category); - m_chart->setAxisX(axis,series); - } - - for (int j(0); j < data.count(); j++) { - QList column = data.at(j); - QBarSet *set = new QBarSet("set" + QString::number(j)); - for (int i(0); i < column.count(); i++) - *set << column.at(i); - series->append(set); - } - - m_chart->addSeries(series); - } else if (seriesName == "Spline") { - for (int j(0); j < data.count(); j ++) { - QList column = data.at(j); - QSplineSeries *series = new QSplineSeries(); - for (int i(0); i < column.count(); i++) - series->append(i, column.at(i)); - m_chart->addSeries(series); - } - } - m_chart->createDefaultAxes(); -} - -void MainWidget::backgroundChanged(int itemIndex) -{ - qDebug() << "backgroundChanged: " << itemIndex; -} - -void MainWidget::autoScaleChanged(int value) -{ - if (value) { - // TODO: enable auto scaling - } else { - // TODO: set scaling manually (and disable auto scaling) - } - - m_xMinSpin->setEnabled(!value); - m_xMaxSpin->setEnabled(!value); - m_yMinSpin->setEnabled(!value); - m_yMaxSpin->setEnabled(!value); -} - -void MainWidget::xMinChanged(int value) -{ - qDebug() << "xMinChanged: " << value; -} - -void MainWidget::xMaxChanged(int value) -{ - qDebug() << "xMaxChanged: " << value; -} - -void MainWidget::yMinChanged(int value) -{ - qDebug() << "yMinChanged: " << value; -} - -void MainWidget::yMaxChanged(int value) -{ - qDebug() << "yMaxChanged: " << value; -} - -void MainWidget::changeChartTheme(int themeIndex) -{ - qDebug() << "changeChartTheme: " << themeIndex; - m_chart->setTheme((QChart::ChartTheme) themeIndex); -} diff --git a/tests/chartwidgettest/mainwidget.h b/tests/chartwidgettest/mainwidget.h deleted file mode 100644 index f4e2412..0000000 --- a/tests/chartwidgettest/mainwidget.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef MAINWIDGET_H -#define MAINWIDGET_H - -#include "qchartglobal.h" -#include "qchart.h" -#include "qchartview.h" -#include - -class QSpinBox; -class QCheckBox; -class QGridLayout; - -QTCOMMERCIALCHART_USE_NAMESPACE - -#define RealList QList -class DataSerieDialog; - -class MainWidget : public QWidget -{ - Q_OBJECT -public: - explicit MainWidget(QWidget *parent = 0); - -signals: - -private: - void initBackroundCombo(QGridLayout *grid); - void initScaleControls(QGridLayout *grid); - void initThemeCombo(QGridLayout *grid); - void initCheckboxes(QGridLayout *grid); - -private slots: - void addSeries(); - void addSeries(QString series, int columnCount, int rowCount, QString dataCharacteristics, bool labelsEnabled); - void backgroundChanged(int itemIndex); - void autoScaleChanged(int value); - void xMinChanged(int value); - void xMaxChanged(int value); - void yMinChanged(int value); - void yMaxChanged(int value); - void antiAliasToggled(bool enabled); - void openGLToggled(bool enabled); - void changeChartTheme(int themeIndex); - QList generateTestData(int columnCount, int rowCount, QString dataCharacteristics); - QStringList generateLabels(int count); - -private: - DataSerieDialog *m_addSerieDialog; - QChart *m_chart; - QChartView *m_chartView; - QCheckBox *m_autoScaleCheck; - QSpinBox *m_xMinSpin; - QSpinBox *m_xMaxSpin; - QSpinBox *m_yMinSpin; - QSpinBox *m_yMaxSpin; - QString m_defaultSeriesName; - QGridLayout *m_scatterLayout; -}; - -#endif // MAINWIDGET_H diff --git a/tests/qmlchartaxis/main.cpp b/tests/qmlchartaxis/main.cpp deleted file mode 100644 index da1873a..0000000 --- a/tests/qmlchartaxis/main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** 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 "qmlapplicationviewer.h" - -Q_DECL_EXPORT int main(int argc, char *argv[]) -{ - QScopedPointer app(createApplication(argc, argv)); - QScopedPointer viewer(QmlApplicationViewer::create()); - - viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); - viewer->setSource(QUrl("qrc:/qml/qmlchartaxis/main.qml")); - viewer->showExpanded(); - - return app->exec(); -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Button.qml b/tests/qmlchartaxis/qml/qmlchartaxis/Button.qml deleted file mode 100644 index 9186740..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Button.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: button - height: 25 - width: 140 - color: unpressedColor - radius: 5 - property color unpressedColor: "#afafaf" - - property string text: "button" - signal clicked - - Text { - id: buttonText - anchors.centerIn: parent - text: button.text - } - - MouseArea { - anchors.fill: parent - onClicked: { - button.clicked(); - } - onPressedChanged: { - if (pressed) { - button.color = "#efefef"; - } else { - button.color = unpressedColor; - } - } - onPressAndHold: { - repeatTimer.start(); - } - onReleased: { - repeatTimer.stop(); - } - } - - Timer { - id: repeatTimer - interval: 140 - repeat: true - triggeredOnStart: false - running: false - onTriggered: { - button.clicked(); - } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxes.qml b/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxes.qml deleted file mode 100644 index 2cebc7b..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxes.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chartView - title: "chart axes" - - // TODO: Do we need a property for orientation or properties "axisX" and "axisY" on ChartView - // to make an axis the default axis for all series with no other axes defined...? -// ValueAxis { -// orientation: ValueAxis.AxisX -// min: 0 -// max: 10 -// } -// axisX: ValueAxis { -// min: 0 -// max: 10 -// } - // ...Now that we don't have this implementation, the following axes won't have any affect: - ValueAxis { - min: 0 - max: 10 - } - ValueAxis { - min: 0 - max: 5 - } - - LineSeries { - name: "line series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - ScatterSeries { - name: "scatter series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - -// Component.onCompleted: { -// // You can also set the axes dynamically -// chartView.setAxisX(axisX, scatter); -// } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxesRevert.qml b/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxesRevert.qml deleted file mode 100644 index e4945d2..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/ChartAxesRevert.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chartView - title: "chart axes reverted" - - ValueAxis { - min: 0 - max: 10 - } - ValueAxis { - min: 0 - max: 5 - } - - ScatterSeries { - name: "scatter series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - LineSeries { - name: "line series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/ConfiguringDynamically.qml b/tests/qmlchartaxis/qml/qmlchartaxis/ConfiguringDynamically.qml deleted file mode 100644 index f13a814..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/ConfiguringDynamically.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "configuring dynamically" - id: chartView - property int index: 0 - - Timer { - interval: 1000 - repeat: true - running: true - onTriggered: { - switch (index) { - case 0: - chartView.axisX(lineSeries).max = 6; - chartView.axisY(lineSeries).max = 6; - break; - case 1: - chartView.axisX(scatterSeries).max = 10; - chartView.axisY(scatterSeries).max = 10; - break; - default: - chartView.axisX().max = 4; - chartView.axisY().max = 4; - } - index = (index + 1) % 3; - } - } - - LineSeries { - id: lineSeries - name: "line series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - ScatterSeries { - id: scatterSeries - name: "scatter series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/CreatingDynamically.qml b/tests/qmlchartaxis/qml/qmlchartaxis/CreatingDynamically.qml deleted file mode 100644 index be3a97f..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/CreatingDynamically.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chartView - title: "creating dyn. new series" - property int index: 0 - - Timer { - interval: 1000 - repeat: true - running: true - onTriggered: { - switch (index) { - case 0: - var count = chartView.count; - var line = chartView.createSeries(ChartView.SeriesTypeLine, "line"); - line.append(0, 0); - line.append(1, 1); - line.append(2, 2); - line.append(3, 3); - line.append(4, 4); - break; - case 1: - chartView.axisX().min = 0; - chartView.axisX().max = 4.5; - chartView.axisY().min = 0; - chartView.axisY().max = 4.5; - break; - case 2: - var scatter = chartView.createSeries(ChartView.SeriesTypeScatter, "scatter"); - scatter.append(0, 0); - scatter.append(0.5, 1); - scatter.append(1, 2); - scatter.append(1.5, 3); - scatter.append(2, 4); - scatter.append(1, 1); - scatter.append(2, 2); - scatter.append(3, 3); - scatter.append(4, 4); - break; - default: - chartView.removeAllSeries(); - } - index = (index + 1) % 4; - } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAndUserDefined.qml b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAndUserDefined.qml deleted file mode 100644 index 07f887e..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAndUserDefined.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "default + user defined" - - ValueAxis { - id: axisX - min: 0 - max: 6 - } - - ValueAxis { - id: axisY - min: 0 - max: 6 - } - - LineSeries { - name: "line series 1" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - ScatterSeries { - name: "scatter series" - axisX: axisX - axisY: axisY - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - LineSeries { - name: "line series 2" - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxes.qml b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxes.qml deleted file mode 100644 index 003f7de..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxes.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chartView - title: "default axes" - - LineSeries { - name: "line series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - ScatterSeries { - name: "scatter series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxesRevert.qml b/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxesRevert.qml deleted file mode 100644 index 07c1680..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/DefaultAxesRevert.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chartView - title: "default axes" - - ScatterSeries { - name: "scatter series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - LineSeries { - name: "line series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/Legacy.qml b/tests/qmlchartaxis/qml/qmlchartaxis/Legacy.qml deleted file mode 100644 index 727282b..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/Legacy.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chartView - title: "Deprecated code" - property int index: 0 - - Component.onCompleted: { - // Calling createDefaultAxes in onCompleted is now deprecated. It needs to be tested, - // though, because some application may still use it - chartView.createDefaultAxes(); - } - - LineSeries { - name: "line series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - ScatterSeries { - name: "scatter series" - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/SeriesSpecificDynamic.qml b/tests/qmlchartaxis/qml/qmlchartaxis/SeriesSpecificDynamic.qml deleted file mode 100644 index cb32a7a..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/SeriesSpecificDynamic.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "series specific dynamic axes" - id: chartView - property int index: 0 - - Timer { - interval: 1000 - repeat: true - running: true - onTriggered: { - switch (index) { - case 0: - lineAxisX.max = 6; - lineAxisY.max = 6; - scatterAxisX.max = 10; - scatterAxisY.max = 10; - break; - case 1: - lineAxisX.max = 10; - lineAxisY.max = 10; - scatterAxisX.max = 6; - scatterAxisY.max = 6; - break; - default: - chartView.axisX().max = 4; - chartView.axisY().max = 4; - } - index = (index + 1) % 3; - } - } - - LineSeries { - id: lineSeries - name: "line series" - axisX: ValueAxis { id: lineAxisX } - axisY: ValueAxis { id: lineAxisY } - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - ScatterSeries { - id: scatterSeries - name: "scatter series" - axisX: ValueAxis { id: scatterAxisX } - axisY: ValueAxis { id: scatterAxisY } - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/SwitchingDynamically.qml b/tests/qmlchartaxis/qml/qmlchartaxis/SwitchingDynamically.qml deleted file mode 100644 index 9fd6510..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/SwitchingDynamically.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chartView - title: "switching axes dynamically" - - Timer { - interval: 1000 - repeat: true - running: true - onTriggered: { - //console.log("current axisX: " + lineSeries.axisX + " 1: " + valueAxis1 + " 2: " +valueAxis2); - - // Note: an axis is destroyed if it is not used anymore - if (lineSeries.axisX == valueAxis1) - lineSeries.axisX = valueAxis2; - else if (lineSeries.axisX == valueAxis2) - lineSeries.axisX = valueAxis3; - } - } - - ValueAxis { - id: valueAxis1 - min: 0 - max: 5 - } - - ValueAxis { - id: valueAxis2 - min: 1 - max: 6 - } - - ValueAxis { - id: valueAxis3 - min: 2 - max: 7 - } - - LineSeries { - id: lineSeries - name: "line series" - axisX: valueAxis1 - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/UserDefined.qml b/tests/qmlchartaxis/qml/qmlchartaxis/UserDefined.qml deleted file mode 100644 index c08dd57..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/UserDefined.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "user defined" - - ValueAxis { - id: axisX - min: 0 - max: 6 - } - - ValueAxis { - id: axisY - min: 0 - max: 6 - } - - LineSeries { - name: "line series" - axisX: axisX - axisY: axisY - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - ScatterSeries { - name: "scatter series" - axisX: axisX - axisY: axisY - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/UserDefinedRevert.qml b/tests/qmlchartaxis/qml/qmlchartaxis/UserDefinedRevert.qml deleted file mode 100644 index bb62adc..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/UserDefinedRevert.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "user defined reverted" - - ValueAxis { - id: axisX - min: 0 - max: 6 - } - - ValueAxis { - id: axisY - min: 0 - max: 6 - } - - ScatterSeries { - name: "scatter series" - axisX: axisX - axisY: axisY - XYPoint { x: 0; y: 0 } - XYPoint { x: 0.5; y: 1 } - XYPoint { x: 1; y: 2 } - XYPoint { x: 1.5; y: 3 } - XYPoint { x: 2; y: 4 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } - - LineSeries { - name: "line series" - axisX: axisX - axisY: axisY - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 2 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 4 } - } -} diff --git a/tests/qmlchartaxis/qml/qmlchartaxis/main.qml b/tests/qmlchartaxis/qml/qmlchartaxis/main.qml deleted file mode 100644 index c013b33..0000000 --- a/tests/qmlchartaxis/qml/qmlchartaxis/main.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: main - width: 400 - height: 300 - property string viewName: "DefaultAxes" - - Row { - anchors.fill: parent - anchors.topMargin: 10 - - Loader { - id: chartLoader - width: parent.width - buttonColumn.width - height: parent.height - source: viewName + ".qml" - } - - Column { - id: buttonColumn - width: 150 - height: parent.height - spacing: 5 - - Button { - text: "Default axes" - onClicked: viewName = "DefaultAxes"; - } - Button { - text: "Default axes reverted" - onClicked: viewName = "DefaultAxesRevert"; - } - Button { - text: "User defined" - onClicked: viewName = "UserDefined"; - } - Button { - text: "User defined reverted" - onClicked: viewName = "UserDefinedRevert"; - } - Button { - text: "Chart axes" - onClicked: viewName = "ChartAxes"; - } - Button { - text: "Chart axes reverted" - onClicked: viewName = "ChartAxesRevert"; - } - Button { - text: "Configuring dynamically" - onClicked: viewName = "ConfiguringDynamically"; - } - Button { - text: "Series specific dynamic" - onClicked: viewName = "SeriesSpecificDynamic"; - } - Button { - text: "Creating dynamically" - onClicked: viewName = "CreatingDynamically"; - } - Button { - text: "Switching dynamically" - onClicked: viewName = "SwitchingDynamically"; - } - Button { - text: "Default + User defined" - onClicked: viewName = "DefaultAndUserDefined"; - } - Button { - text: "Legacy" - onClicked: viewName = "Legacy"; - } - } - } -} diff --git a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.cpp b/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.cpp deleted file mode 100644 index 8ba6e88..0000000 --- a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// checksum 0x78c version 0x60010 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#include "qmlapplicationviewer.h" - -#include -#include -#include -#include -#include -#include - -#include // MEEGO_EDITION_HARMATTAN - -#ifdef HARMATTAN_BOOSTER -#include -#endif - -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 - -#include - -#if !defined(NO_JSDEBUGGER) -#include -#endif -#if !defined(NO_QMLOBSERVER) -#include -#endif - -// Enable debugging before any QDeclarativeEngine is created -struct QmlJsDebuggingEnabler -{ - QmlJsDebuggingEnabler() - { - QDeclarativeDebugHelper::enableDebugging(); - } -}; - -// Execute code in constructor before first QDeclarativeEngine is instantiated -static QmlJsDebuggingEnabler enableDebuggingHelper; - -#endif // QMLJSDEBUGGER - -class QmlApplicationViewerPrivate -{ - QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} - - QString mainQmlFile; - QDeclarativeView *view; - friend class QmlApplicationViewer; - QString adjustPath(const QString &path); -}; - -QString QmlApplicationViewerPrivate::adjustPath(const QString &path) -{ -#ifdef Q_OS_UNIX -#ifdef Q_OS_MAC - if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#endif -#endif - return path; -} - -QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) - : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate(this)) -{ - connect(engine(), SIGNAL(quit()), SLOT(close())); - setResizeMode(QDeclarativeView::SizeRootObjectToView); - // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 -#if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); -#endif -#if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); -#endif -#endif -} - -QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) - : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate(view)) -{ - connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); - view->setResizeMode(QDeclarativeView::SizeRootObjectToView); - // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 -#if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); -#endif -#if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); -#endif -#endif -} - -QmlApplicationViewer::~QmlApplicationViewer() -{ - delete d; -} - -QmlApplicationViewer *QmlApplicationViewer::create() -{ -#ifdef HARMATTAN_BOOSTER - return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); -#else - return new QmlApplicationViewer(); -#endif -} - -void QmlApplicationViewer::setMainQmlFile(const QString &file) -{ - d->mainQmlFile = d->adjustPath(file); - d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); -} - -void QmlApplicationViewer::addImportPath(const QString &path) -{ - d->view->engine()->addImportPath(d->adjustPath(path)); -} - -void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) -{ -#if defined(Q_OS_SYMBIAN) - // If the version of Qt on the device is < 4.7.2, that attribute won't work - if (orientation != ScreenOrientationAuto) { - const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); - if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { - qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); - return; - } - } -#endif // Q_OS_SYMBIAN - - Qt::WidgetAttribute attribute; - switch (orientation) { -#if QT_VERSION < 0x040702 - // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes - case ScreenOrientationLockPortrait: - attribute = static_cast(128); - break; - case ScreenOrientationLockLandscape: - attribute = static_cast(129); - break; - default: - case ScreenOrientationAuto: - attribute = static_cast(130); - break; -#else // QT_VERSION < 0x040702 - case ScreenOrientationLockPortrait: - attribute = Qt::WA_LockPortraitOrientation; - break; - case ScreenOrientationLockLandscape: - attribute = Qt::WA_LockLandscapeOrientation; - break; - default: - case ScreenOrientationAuto: - attribute = Qt::WA_AutoOrientation; - break; -#endif // QT_VERSION < 0x040702 - }; - setAttribute(attribute, true); -} - -void QmlApplicationViewer::showExpanded() -{ -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); -#else - d->view->show(); -#endif -} - -QApplication *createApplication(int &argc, char **argv) -{ -#ifdef HARMATTAN_BOOSTER - return MDeclarativeCache::qApplication(argc, argv); -#else - return new QApplication(argc, argv); -#endif -} diff --git a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.h b/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.h deleted file mode 100644 index f8008f5..0000000 --- a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.h +++ /dev/null @@ -1,47 +0,0 @@ -// checksum 0x82ed version 0x60010 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#ifndef QMLAPPLICATIONVIEWER_H -#define QMLAPPLICATIONVIEWER_H - -#include - -class QmlApplicationViewer : public QDeclarativeView -{ - Q_OBJECT - -public: - enum ScreenOrientation { - ScreenOrientationLockPortrait, - ScreenOrientationLockLandscape, - ScreenOrientationAuto - }; - - explicit QmlApplicationViewer(QWidget *parent = 0); - virtual ~QmlApplicationViewer(); - - static QmlApplicationViewer *create(); - - void setMainQmlFile(const QString &file); - void addImportPath(const QString &path); - - // Note that this will only have an effect on Symbian and Fremantle. - void setOrientation(ScreenOrientation orientation); - - void showExpanded(); - -private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); - class QmlApplicationViewerPrivate *d; -}; - -QApplication *createApplication(int &argc, char **argv); - -#endif // QMLAPPLICATIONVIEWER_H diff --git a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.pri b/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.pri deleted file mode 100644 index 567c6dc..0000000 --- a/tests/qmlchartaxis/qmlapplicationviewer/qmlapplicationviewer.pri +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += $$PWD/qmlapplicationviewer.cpp -HEADERS += $$PWD/qmlapplicationviewer.h -INCLUDEPATH += $$PWD - -# Include JS debugger library if QMLJSDEBUGGER_PATH is set -!isEmpty(QMLJSDEBUGGER_PATH) { - include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) -} else { - DEFINES -= QMLJSDEBUGGER -} - diff --git a/tests/qmlchartaxis/qmlchartaxis.pro b/tests/qmlchartaxis/qmlchartaxis.pro deleted file mode 100644 index fccb2d4..0000000 --- a/tests/qmlchartaxis/qmlchartaxis.pro +++ /dev/null @@ -1,8 +0,0 @@ -!include( ../tests.pri ) { - error( "Couldn't find the test.pri file!" ) -} - -RESOURCES += resources.qrc -SOURCES += main.cpp - -include(qmlapplicationviewer/qmlapplicationviewer.pri) diff --git a/tests/qmlchartaxis/resources.qrc b/tests/qmlchartaxis/resources.qrc deleted file mode 100644 index 2f9f4b6..0000000 --- a/tests/qmlchartaxis/resources.qrc +++ /dev/null @@ -1,18 +0,0 @@ - - - qml/qmlchartaxis/main.qml - qml/qmlchartaxis/Button.qml - qml/qmlchartaxis/DefaultAxes.qml - qml/qmlchartaxis/DefaultAxesRevert.qml - qml/qmlchartaxis/UserDefined.qml - qml/qmlchartaxis/UserDefinedRevert.qml - qml/qmlchartaxis/ChartAxes.qml - qml/qmlchartaxis/ChartAxesRevert.qml - qml/qmlchartaxis/ConfiguringDynamically.qml - qml/qmlchartaxis/SeriesSpecificDynamic.qml - qml/qmlchartaxis/CreatingDynamically.qml - qml/qmlchartaxis/SwitchingDynamically.qml - qml/qmlchartaxis/DefaultAndUserDefined.qml - qml/qmlchartaxis/Legacy.qml - - diff --git a/tests/qmlchartproperties/main.cpp b/tests/qmlchartproperties/main.cpp deleted file mode 100644 index 2689717..0000000 --- a/tests/qmlchartproperties/main.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** 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 "qmlapplicationviewer.h" - -Q_DECL_EXPORT int main(int argc, char *argv[]) -{ - QScopedPointer app(createApplication(argc, argv)); - QScopedPointer viewer(QmlApplicationViewer::create()); - - viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); - viewer->setSource(QUrl("qrc:/qml/qmlchartproperties/loader.qml")); - viewer->setRenderHint(QPainter::Antialiasing, true); - viewer->showExpanded(); - - return app->exec(); -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml deleted file mode 100644 index 9fa4b08..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaChart.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "area series" - anchors.fill: parent - animationOptions: ChartView.SeriesAnimations - - property variant series: areaSeries - - AreaSeries { - id: areaSeries - name: "area 1" - - upperSeries: LineSeries { - XYPoint { x: 0; y: 1 } - XYPoint { x: 1; y: 1 } - XYPoint { x: 2; y: 3 } - XYPoint { x: 3; y: 3 } - XYPoint { x: 4; y: 2 } - XYPoint { x: 5; y: 0 } - XYPoint { x: 6; y: 2 } - XYPoint { x: 7; y: 1 } - XYPoint { x: 8; y: 2 } - XYPoint { x: 9; y: 1 } - XYPoint { x: 10; y: 3 } - XYPoint { x: 11; y: 3 } - } - lowerSeries: LineSeries { - XYPoint { x: 0; y: 0 } - XYPoint { x: 1; y: 0 } - XYPoint { x: 2; y: 0 } - XYPoint { x: 3; y: 0 } - XYPoint { x: 4; y: 0 } - XYPoint { x: 5; y: 0 } - XYPoint { x: 6; y: 0 } - XYPoint { x: 7; y: 0 } - XYPoint { x: 8; y: 0 } - XYPoint { x: 9; y: 0 } - XYPoint { x: 10; y: 0 } - XYPoint { x: 11; y: 0 } - } - - onNameChanged: console.log(name + ".onNameChanged: " + name); - onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible); - onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - onSelected: console.log(name + ".onSelected"); - onColorChanged: console.log(name + ".onColorChanged: " + color); - onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); - onBorderWidthChanged: console.log(name + ".onBorderChanged: " + borderWidth); -// onCountChanged: console.log(name + ".onCountChanged: " + count); - } - - AreaSeries { - name: "area 2" - - upperSeries: LineSeries { - XYPoint { x: 0; y: 0.5 } - XYPoint { x: 1; y: 1.5 } - XYPoint { x: 2; y: 0.3 } - XYPoint { x: 3; y: 1.5 } - XYPoint { x: 4; y: 0.1 } - XYPoint { x: 5; y: 0.3 } - XYPoint { x: 6; y: 1.2 } - XYPoint { x: 7; y: 1.3 } - XYPoint { x: 8; y: 0.2 } - XYPoint { x: 9; y: 0.1 } - XYPoint { x: 10; y: 3.2 } - XYPoint { x: 11; y: 4.6 } - } - - onNameChanged: console.log(name + ".onNameChanged: " + name); - onVisibleChanged: console.log(name + ".onVisibleChanged: " + visible); - onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - onSelected: console.log(name + ".onSelected"); - onColorChanged: console.log(name + ".onColorChanged: " + color); - onBorderColorChanged: console.log(name + ".onBorderColorChanged: " + borderColor); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml deleted file mode 100644 index 70b0913..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/AreaEditor.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Flow { - id: flow - spacing: 5 - flow: Flow.TopToBottom - property variant series - - Button { - text: "visible" - onClicked: series.visible = !series.visible; - } - Button { - text: "color" - onClicked: series.color = main.nextColor(); - } - Button { - text: "borderColor" - onClicked: series.borderColor = main.nextColor(); - } - Button { - text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : "" - onClicked: series.borderWidth += 0.5; - } - Button { - text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : "" - onClicked: series.borderWidth -= 0.5; - } - Button { - id: upperButton - text: "upper series" - unpressedColor: "#79bd8f" - onClicked: { - lineEditor.visible = true; - color = "#00a388"; - lowerButton.color = "#79bd8f"; - lineEditor.series = series.upperSeries; - } - } - Button { - id: lowerButton - text: "lower series" - unpressedColor: "#79bd8f" - onClicked: { - lineEditor.visible = true; - color = "#00a388"; - upperButton.color = "#79bd8f"; - lineEditor.series = series.lowerSeries; - } - } - LineEditor { - id: lineEditor - visible: false - } - - onSeriesChanged: lineEditor.series = series.upperSeries; -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml deleted file mode 100644 index ce6c14e..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarChart.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "Bar series" - anchors.fill: parent - theme: ChartView.ChartThemeLight - legend.alignment: Qt.AlignBottom - animationOptions: ChartView.SeriesAnimations - - property variant series: mySeries - - - BarSeries { - id: mySeries - name: "bar" - axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] - onClicked: console.log("barset.onClicked: " + index); - onHovered: console.log("barset.onHovered: " + status); - onPenChanged: console.log("barset.onPenChanged: " + pen); - onBrushChanged: console.log("barset.onBrushChanged: " + brush); - onLabelChanged: console.log("barset.onLabelChanged: " + label); - onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); - onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); - onColorChanged: console.log("barset.onColorChanged: " + color); - onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); - onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); - onCountChanged: console.log("barset.onCountChanged: " + count); - onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); - onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); - onValueChanged: console.log("barset.onValuesChanged: " + index); - } - BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } - BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } - - onNameChanged: console.log("groupedBarSeries.onNameChanged: " + series.name); - onVisibleChanged: console.log("groupedBarSeries.onVisibleChanged: " + series.visible); - onClicked: console.log("groupedBarSeries.onClicked: " + barset + " " + index); - onHovered: console.log("groupedBarSeries.onHovered: " + barset + " " + status); - onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); - onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml deleted file mode 100644 index 15d68c5..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/BarEditor.qml +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Row { - anchors.fill: parent - spacing: 5 - property variant series - - // buttons for selecting the edited object: series, barset or label - Flow { - spacing: 5 - flow: Flow.TopToBottom - Button { - id: seriesButton - text: "series" - unpressedColor: "#79bd8f" - onClicked: { - seriesFlow.visible = true; - setFlow.visible = false; - labelsFlow.visible = false; - color = "#00a388"; - sliceButton.color = "#79bd8f"; - labelButton.color = "#79bd8f"; - } - } - Button { - id: setButton - text: "BarSet" - unpressedColor: "#79bd8f" - onClicked: { - seriesFlow.visible = false; - setFlow.visible = true; - labelsFlow.visible = false; - color = "#00a388"; - seriesButton.color = "#79bd8f"; - labelButton.color = "#79bd8f"; - } - } - Button { - id: labelButton - text: "label" - unpressedColor: "#79bd8f" - onClicked: { - seriesFlow.visible = false; - setFlow.visible = false; - labelsFlow.visible = true; - color = "#00a388"; - seriesButton.color = "#79bd8f"; - sliceButton.color = "#79bd8f"; - } - } - } - - // Buttons for editing series - Flow { - id: seriesFlow - spacing: 5 - flow: Flow.TopToBottom - visible: false - - Button { - text: "visible" - onClicked: series.visible = !series.visible; - } - Button { - text: "bar width +" - onClicked: series.barWidth += 0.1; - } - Button { - text: "bar width -" - onClicked: series.barWidth -= 0.1; - } - } - - // Buttons for editing sets - Flow { - id: setFlow - spacing: 5 - flow: Flow.TopToBottom - visible: false - - Button { - text: "append set" - onClicked: { - var count = series.count; - series.append("set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]); - } - } - Button { - text: "insert set" - onClicked: { - var count = series.count; - series.insert(count - 1, "set" + count, [0, 0.1 * count, 0.2 * count, 0.3 * count, 0.4 * count, 0.5 * count, 0.6 * count]); - } - } - Button { - text: "remove set" - onClicked: series.remove(series.at(series.count - 1)); - } - Button { - text: "clear sets" - onClicked: series.clear(); - } - - Button { - text: "set 1 append" - onClicked: series.at(0).append(series.at(0).count + 1); - } - Button { - text: "set 1 replace" - onClicked: series.at(0).replace(series.at(0).count - 1, series.at(0).at(series.at(0).count - 1) + 1.5); - } - Button { - text: "set 1 remove" - onClicked: series.at(0).remove(series.at(0).count - 1); - } - - Button { - text: "set 1 color" - onClicked: series.at(0).color = main.nextColor(); - } - Button { - text: "set 1 border color" - onClicked: series.at(0).borderColor = main.nextColor(); - } - Button { - text: "set 1 borderWidth +" - onClicked: series.at(0).borderWidth += 0.5; - } - Button { - text: "set 1 borderWidth -" - onClicked: series.at(0).borderWidth -= 0.5; - } - } - - - Flow { - id: labelsFlow - spacing: 5 - flow: Flow.TopToBottom - visible: false - - Button { - text: "labels visible" - onClicked: series.labelsVisible = !series.labelsVisible; - } - Button { - text: "set 1 label color" - onClicked: series.at(0).labelColor = main.nextColor(); - } - FontEditor { - id: fontEditor - fontDescription: "label" - function editedFont() { - return series.at(0).labelFont; - } - } - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/Button.qml b/tests/qmlchartproperties/qml/qmlchartproperties/Button.qml deleted file mode 100644 index 9186740..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/Button.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: button - height: 25 - width: 140 - color: unpressedColor - radius: 5 - property color unpressedColor: "#afafaf" - - property string text: "button" - signal clicked - - Text { - id: buttonText - anchors.centerIn: parent - text: button.text - } - - MouseArea { - anchors.fill: parent - onClicked: { - button.clicked(); - } - onPressedChanged: { - if (pressed) { - button.color = "#efefef"; - } else { - button.color = unpressedColor; - } - } - onPressAndHold: { - repeatTimer.start(); - } - onReleased: { - repeatTimer.stop(); - } - } - - Timer { - id: repeatTimer - interval: 140 - repeat: true - triggeredOnStart: false - running: false - onTriggered: { - button.clicked(); - } - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml deleted file mode 100644 index 6e69175..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/Chart.qml +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chartView - title: "Chart Title" - anchors.fill: parent - property variant series: chartView - - LineSeries { - name: "line" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1.1; y: 2.1 } - XYPoint { x: 1.9; y: 3.3 } - XYPoint { x: 2.1; y: 2.1 } - XYPoint { x: 2.9; y: 4.9 } - XYPoint { x: 3.4; y: 3.0 } - XYPoint { x: 4.1; y: 3.3 } - } - - onVisibleChanged: console.log("chart.onVisibleChanged: " + visible); - onTitleColorChanged: console.log("chart.onTitleColorChanged: " + color); - onBackgroundColorChanged: console.log("chart.onBackgroundColorChanged: " + series.backgroundColor); - onDropShadowEnabledChanged: console.log("chart.onDropShadowEnabledChanged: " + enabled); - - legend.onVisibleChanged: console.log("legend.onVisibleChanged: " + series.legend.visible); - legend.onBackgroundVisibleChanged: console.log("legend.onBackgroundVisibleChanged: " + visible); - legend.onColorChanged: console.log("legend.onColorChanged: " + color); - legend.onBorderColorChanged: console.log("legend.onBorderColorChanged: " + color); - legend.onLabelColorChanged: console.log("legend.onLabelColorChanged: " + color); - minimumMargins.onTopChanged: console.log("chart.minimumMargins.onTopChanged: " + top ); - minimumMargins.onBottomChanged: console.log("chart.minimumMargins.onBottomChanged: " + bottom); - minimumMargins.onLeftChanged: console.log("chart.minimumMargins.onLeftChanged: " + left); - minimumMargins.onRightChanged: console.log("chart.minimumMargins.onRightChanged: " + right); - onPlotAreaChanged: { - console.log("chart.onPlotAreaChanged, width: " + chartView.plotArea.width - + " height: " + chartView.plotArea.height - + " y: " + chartView.plotArea.y - + " x: " + chartView.plotArea.x); - marginVisualizer.opacity = 1.0; - } - - ValueAxis{ - onColorChanged: console.log("axisX.onColorChanged: " + color); - onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible); - onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color); - onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible); - onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible); - onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible); - onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color); - onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color); - onMinChanged: console.log("axisX.onMinChanged: " + min); - onMaxChanged: console.log("axisX.onMaxChanged: " + max); - } - - ValueAxis{ - onColorChanged: console.log("axisY.onColorChanged: " + color); - onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible); - onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color); - onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible); - onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible); - onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible); - onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color); - onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color); - onMinChanged: console.log("axisY.onMinChanged: " + min); - onMaxChanged: console.log("axisY.onMaxChanged: " + max); - } - - Rectangle { - id: marginVisualizer - color: "transparent" - border.color: "red" - anchors.fill: parent - anchors.topMargin: chartView.minimumMargins.top - anchors.bottomMargin: chartView.minimumMargins.bottom - anchors.leftMargin: chartView.minimumMargins.left - anchors.rightMargin: chartView.minimumMargins.right - opacity: 0.0 - onOpacityChanged: if (opacity > 0.9) opacity = 0.0; - Behavior on opacity { - NumberAnimation { duration: 800 } - } - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml deleted file mode 100644 index 84f8e6b..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditor.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: chartEditor - property variant series // TODO: rename to chart - onSeriesChanged: { - if (loader.item != undefined) - loader.item.chart = series; - } - - function selectButton(button) { - chartButton.color = "#79bd8f"; - titleButton.color = "#79bd8f"; - legendButton.color = "#79bd8f"; - axisXButton.color = "#79bd8f"; - axisYButton.color = "#79bd8f"; - button.color = "#00a388"; - } - - Flow { - id: selectorFlow - anchors.top: parent.top - height: 90 - anchors.left: parent.left - anchors.right: parent.right - spacing: 5 - flow: Flow.TopToBottom - - Button { - id: chartButton - text: "Chart properties" - unpressedColor: "#79bd8f" - onClicked: { - selectButton(chartButton); - loader.source = "ChartEditorProperties.qml"; - loader.item.chart = series; - } - } - Button { - id: titleButton - text: "Title properties" - unpressedColor: "#79bd8f" - onClicked: { - selectButton(titleButton); - loader.source = "ChartEditorTitle.qml"; - loader.item.chart = series; - } - } - Button { - id: legendButton - text: "Legend properties" - unpressedColor: "#79bd8f" - onClicked: { - selectButton(legendButton); - loader.source = "ChartEditorLegend.qml"; - loader.item.chartLegend = series.legend; - } - } - Button { - id: axisXButton - text: "Axis X properties" - unpressedColor: "#79bd8f" - onClicked: { - selectButton(axisXButton); - loader.source = "ChartEditorAxis.qml"; - loader.item.axis = series.axisX; - } - } - Button { - id: axisYButton - text: "Axis Y properties" - unpressedColor: "#79bd8f" - onClicked: { - selectButton(axisYButton); - loader.source = "ChartEditorAxis.qml"; - loader.item.axis = series.axisY; - } - } - } - - Loader { - id: loader - anchors.top: selectorFlow.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorAxis.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorAxis.qml deleted file mode 100644 index 50eb7ce..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorAxis.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Row { - anchors.fill: parent - spacing: 5 - property variant axis - - Flow { - spacing: 5 - flow: Flow.TopToBottom - - Button { - text: "axis visible" - onClicked: axis.visible = !axis.visible; - } - Button { - text: "axis grid visible" - onClicked: axis.gridVisible = !axis.gridVisible; - } - Button { - text: "axis color" - onClicked: axis.color = main.nextColor(); - } - Button { - text: "axis labels color" - onClicked: axis.labelsColor = main.nextColor(); - } - Button { - text: "axis labels angle +" - onClicked: axis.labelsAngle += 5; - } - Button { - text: "axis labels angle -" - onClicked: axis.labelsAngle -= 5; - } - Button { - text: "axis shades visible" - onClicked: axis.shadesVisible = !axis.shadesVisible; - } - Button { - text: "axis shades color" - onClicked: axis.shadesColor = main.nextColor(); - } - Button { - text: "axis shades bcolor" - onClicked: axis.shadesBorderColor = main.nextColor(); - } - Button { - text: "axis max +" - onClicked: axis.max += 0.1; - } - Button { - text: "axis max -" - onClicked: axis.max -= 0.1; - } - Button { - text: "axis min +" - onClicked: axis.min += 0.1; - } - Button { - text: "axis min -" - onClicked: axis.min -= 0.1; - } - Button { - text: "axis ticks count +" - onClicked: axis.ticksCount++; - } - Button { - text: "axis ticks count -" - onClicked: axis.ticksCount--; - } - Button { - text: "axis nice nmb" - onClicked: axis.niceNumbersEnabled = !axis.niceNumbersEnabled; - } - } - - FontEditor { - id: fontEditor - fontDescription: "axis" - function editedFont() { - return axis.labelsFont; - } - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorLegend.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorLegend.qml deleted file mode 100644 index 12d62b9..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorLegend.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Row { - anchors.fill: parent - spacing: 5 - property variant chartLegend - - Flow { - spacing: 5 - flow: Flow.TopToBottom - - Button { - text: "legend visible" - onClicked: chartLegend.visible = !chartLegend.visible; - } - Button { - text: "legend bckgrd visible" - onClicked: chartLegend.backgroundVisible = !chartLegend.backgroundVisible; - } - Button { - text: "legend color" - onClicked: chartLegend.color = main.nextColor(); - } - Button { - text: "legend border color" - onClicked: chartLegend.borderColor = main.nextColor(); - } - Button { - text: "legend label color" - onClicked: chartLegend.labelColor = main.nextColor(); - } - Button { - text: "legend top" - onClicked: chartLegend.alignment ^= Qt.AlignTop; - } - Button { - text: "legend bottom" - onClicked: chartLegend.alignment ^= Qt.AlignBottom; - } - Button { - text: "legend left" - onClicked: chartLegend.alignment ^= Qt.AlignLeft; - } - Button { - text: "legend right" - onClicked: chartLegend.alignment ^= Qt.AlignRight; - } - } - - FontEditor { - fontDescription: "legend" - function editedFont() { - return chartLegend.font; - } - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorProperties.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorProperties.qml deleted file mode 100644 index 69df56d..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorProperties.qml +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Flow { - anchors.fill: parent - property variant chart - flow: Flow.TopToBottom - spacing: 5 - Button { - text: "visible" - onClicked: chart.visible = !chart.visible; - } - Button { - text: "theme +" - onClicked: chart.theme++; - } - Button { - text: "theme -" - onClicked: chart.theme--; - } - Button { - text: "animation opt +" - onClicked: chart.animationOptions++; - } - Button { - text: "animation opt -" - onClicked: chart.animationOptions--; - } - Button { - text: "background color" - onClicked: chart.backgroundColor = main.nextColor(); - } - Button { - text: "drop shadow enabled" - onClicked: chart.dropShadowEnabled = !chart.dropShadowEnabled; - } - Button { - text: "zoom +" - onClicked: chart.zoom(2); - } - Button { - text: "zoom -" - onClicked: chart.zoom(0.5); - } - Button { - text: "scroll left" - onClicked: chart.scrollLeft(10); - } - Button { - text: "scroll right" - onClicked: chart.scrollRight(10); - } - Button { - text: "scroll up" - onClicked: chart.scrollUp(10); - } - Button { - text: "scroll down" - onClicked: chart.scrollDown(10); - } - Button { - text: "title color" - onClicked: chart.titleColor = main.nextColor(); - } - Button { - text: "zoom -" - onClicked: chart.zoom(0.5); - } - Button { - text: "top min margin +" - onClicked: chart.minimumMargins.top += 5; - } - Button { - text: "top min margin -" - onClicked: chart.minimumMargins.top -= 5; - } - Button { - text: "bottom min margin +" - onClicked: chart.minimumMargins.bottom += 5; - } - Button { - text: "bottom min margin -" - onClicked: chart.minimumMargins.bottom -= 5; - } - Button { - text: "left min margin +" - onClicked: chart.minimumMargins.left += 5; - } - Button { - text: "left min margin -" - onClicked: chart.minimumMargins.left -= 5; - } - Button { - text: "right min margin +" - onClicked: chart.minimumMargins.right += 5; - } - Button { - text: "right min margin -" - onClicked: chart.minimumMargins.right -= 5; - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorTitle.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorTitle.qml deleted file mode 100644 index 03638f8..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ChartEditorTitle.qml +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Flow { - property variant chart - anchors.fill: parent - flow: Flow.TopToBottom - spacing: 5 - - FontEditor { - fontDescription: "title" - function editedFont() { - return chart.titleFont; - } - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/FontEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/FontEditor.qml deleted file mode 100644 index 984acd9..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/FontEditor.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Flow { - flow: Flow.TopToBottom - spacing: 5 - property string fontDescription: "" - - Button { - text: fontDescription + " bold" - onClicked: editedFont().bold = !editedFont().bold; - } - Button { - text: fontDescription + " capitalization" - onClicked: editedFont().capitalization++; - } - Button { - text: fontDescription + " font family" - onClicked: editedFont().family = "courier"; - } - Button { - text: fontDescription + " font italic" - onClicked: editedFont().italic = !editedFont().italic; - } - Button { - text: fontDescription + " letterSpacing +" - onClicked: editedFont().letterSpacing++; - } - Button { - text: fontDescription + " letterSpacing -" - onClicked: editedFont().letterSpacing--; - } - Button { - text: fontDescription + " pixelSize +" - onClicked: editedFont().pixelSize++; - } - Button { - text: fontDescription + " pixelSize -" - onClicked: editedFont().pixelSize--; - } - Button { - text: fontDescription + " pointSize +" - onClicked: editedFont().pointSize++; - } - Button { - text: fontDescription + " pointSize -" - onClicked: editedFont().pointSize--; - } - Button { - text: fontDescription + " strikeout" - onClicked: editedFont().strikeout = !editedFont().strikeout; - } - Button { - text: fontDescription + " underline" - onClicked: editedFont().underline = !editedFont().underline; - } - Button { - text: fontDescription + " weight +" - onClicked: editedFont().weight++; - } - Button { - text: fontDescription + " weight -" - onClicked: editedFont().weight--; - } - Button { - text: fontDescription + " wordSpacing +" - onClicked: editedFont().wordSpacing++; - } - Button { - text: fontDescription + " wordSpacing -" - onClicked: editedFont().wordSpacing--; - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml deleted file mode 100644 index 561a8cd..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalBarChart.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "Bar series" - anchors.fill: parent - theme: ChartView.ChartThemeLight - legend.alignment: Qt.AlignBottom - animationOptions: ChartView.SeriesAnimations - - property variant series: mySeries - - HorizontalBarSeries { - id: mySeries - name: "bar" - axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] - onClicked: console.log("barset.onClicked: " + index); - onHovered: console.log("barset.onHovered: " + status); - onPenChanged: console.log("barset.onPenChanged: " + pen); - onBrushChanged: console.log("barset.onBrushChanged: " + brush); - onLabelChanged: console.log("barset.onLabelChanged: " + label); - onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); - onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); - onColorChanged: console.log("barset.onColorChanged: " + color); - onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); - onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); - onCountChanged: console.log("barset.onCountChanged: " + count); - onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); - onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); - onValueChanged: console.log("barset.onValuesChanged: " + index); - } - BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } - BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } - - onNameChanged: console.log("groupedBarSeries.onNameChanged: " + series.name); - onVisibleChanged: console.log("groupedBarSeries.onVisibleChanged: " + series.visible); - onClicked: console.log("groupedBarSeries.onClicked: " + barset + " " + index); - onHovered: console.log("groupedBarSeries.onHovered: " + barset + " " + status); - onLabelsVisibleChanged: console.log("groupedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); - onCountChanged: console.log("groupedBarSeries.onCountChanged: " + count); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml deleted file mode 100644 index c93fa91..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalPercentBarChart.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "Percent bar series" - anchors.fill: parent - theme: ChartView.ChartThemeLight - legend.alignment: Qt.AlignBottom - animationOptions: ChartView.SeriesAnimations - - property variant series: mySeries - - HorizontalPercentBarSeries { - id: mySeries - name: "bar" - axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] - onClicked: console.log("barset.onClicked: " + index); - onHovered: console.log("barset.onHovered: " + status); - onPenChanged: console.log("barset.onPenChanged: " + pen); - onBrushChanged: console.log("barset.onBrushChanged: " + brush); - onLabelChanged: console.log("barset.onLabelChanged: " + label); - onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); - onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); - onColorChanged: console.log("barset.onColorChanged: " + color); - onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); - onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); - onCountChanged: console.log("barset.onCountChanged: " + count); - onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); - onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); - onValueChanged: console.log("barset.onValuesChanged: " + index); - } - BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } - BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } - - onNameChanged: console.log("percentBarSeries.onNameChanged: " + series.name); - onVisibleChanged: console.log("percentBarSeries.onVisibleChanged: " + series.visible); - onClicked: console.log("percentBarSeries.onClicked: " + barset + " " + index); - onHovered: console.log("percentBarSeries.onHovered: " + barset + " " + status); - onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); - onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml deleted file mode 100644 index cfc858c..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/HorizontalStackedBarChart.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "Stacked bar series" - anchors.fill: parent - theme: ChartView.ChartThemeLight - legend.alignment: Qt.AlignBottom - animationOptions: ChartView.SeriesAnimations - - property variant series: mySeries - - HorizontalStackedBarSeries { - id: mySeries - name: "bar" - axisY: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] - onClicked: console.log("barset.onClicked: " + index); - onHovered: console.log("barset.onHovered: " + status); - onPenChanged: console.log("barset.onPenChanged: " + pen); - onBrushChanged: console.log("barset.onBrushChanged: " + brush); - onLabelChanged: console.log("barset.onLabelChanged: " + label); - onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); - onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); - onColorChanged: console.log("barset.onColorChanged: " + color); - onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); - onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); - onCountChanged: console.log("barset.onCountChanged: " + count); - onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); - onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); - onValueChanged: console.log("barset.onValuesChanged: " + index); - } - BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } - BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } - - onNameChanged: console.log("stackedBarSeries.onNameChanged: " + series.name); - onVisibleChanged: console.log("stackedBarSeries.onVisibleChanged: " + series.visible); - onClicked: console.log("stackedBarSeries.onClicked: " + barset + " " + index); - onHovered: console.log("stackedBarSeries.onHovered: " + barset + " " + status); - onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); - onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml deleted file mode 100644 index 2171708..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/LineChart.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - property variant series: lineSeries - - title: "line series" - anchors.fill: parent - animationOptions: ChartView.SeriesAnimations - - LineSeries { - id: lineSeries - name: "line 1" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1.1; y: 2.1 } - XYPoint { x: 1.9; y: 3.3 } - XYPoint { x: 2.1; y: 2.1 } - XYPoint { x: 2.9; y: 4.9 } - XYPoint { x: 3.4; y: 3.0 } - XYPoint { x: 4.1; y: 3.3 } - - onNameChanged: console.log("lineSeries.onNameChanged: " + name); - onVisibleChanged: console.log("lineSeries.onVisibleChanged: " + visible); - onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - onPointReplaced: console.log("lineSeries.onPointReplaced: " + index); - onPointRemoved: console.log("lineSeries.onPointRemoved: " + index); - onPointAdded: console.log("lineSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y); - onColorChanged: console.log("lineSeries.onColorChanged: " + color); - onWidthChanged: console.log("lineSeries.onWidthChanged: " + width); - onStyleChanged: console.log("lineSeries.onStyleChanged: " + style); - onCapStyleChanged: console.log("lineSeries.onCapStyleChanged: " + capStyle); - onCountChanged: console.log("lineSeries.onCountChanged: " + count); - } - - LineSeries { - name: "line 2" - XYPoint { x: 1.1; y: 1.1 } - XYPoint { x: 1.9; y: 2.3 } - XYPoint { x: 2.1; y: 1.1 } - XYPoint { x: 2.9; y: 3.9 } - XYPoint { x: 3.4; y: 2.0 } - XYPoint { x: 4.1; y: 2.3 } - onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml deleted file mode 100644 index da18917..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/LineEditor.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - - -Flow { - id: flow - spacing: 5 - flow: Flow.TopToBottom - property variant series - - Button { - text: "visible" - onClicked: series.visible = !series.visible; - } - Button { - text: "color" - onClicked: series.color = main.nextColor(); - } - Button { - text: series != undefined ? "width + (" + series.width + ")" : "" - onClicked: series.width += 0.5; - } - Button { - text: series != undefined ? "width - (" + series.width + ")" : "" - onClicked: series.width -= 0.5; - } - Button { - text: series != undefined ? "style + (" + series.style + ")" : "" - onClicked: series.style++; - } - Button { - text: series != undefined ? "style - (" + series.style + ")" : "" - onClicked: series.style--; - } - Button { - text: series != undefined ? "cap style + (" + series.capStyle + ")" : "" - onClicked: series.capStyle++; - } - Button { - text: series != undefined ? "cap style - (" +series.capStyle + ")" : "" - onClicked: series.capStyle--; - } - Button { - text: "points visible" - onClicked: series.pointsVisible = !series.pointsVisible; - } - Button { - text: "append point" - onClicked: series.append(series.count - 1, series.count - 1); - } - Button { - text: "replace point" - onClicked: { - var xyPoint = series.at(series.count - 1); - series.replace(xyPoint.x, xyPoint.y, xyPoint.x, xyPoint.y + 0.1); - } - } - Button { - text: "remove point" - onClicked: series.remove(series.at(series.count - 1).x, series.at(series.count - 1).y); - } - Button { - text: "insert point" - onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); - } - Button { - text: "clear" - onClicked: series.clear(); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml deleted file mode 100644 index 39509d5..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PercentBarChart.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "Percent bar series" - anchors.fill: parent - theme: ChartView.ChartThemeLight - legend.alignment: Qt.AlignBottom - animationOptions: ChartView.SeriesAnimations - - property variant series: mySeries - - PercentBarSeries { - id: mySeries - name: "bar" - axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } - - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] - onClicked: console.log("barset.onClicked: " + index); - onHovered: console.log("barset.onHovered: " + status); - onPenChanged: console.log("barset.onPenChanged: " + pen); - onBrushChanged: console.log("barset.onBrushChanged: " + brush); - onLabelChanged: console.log("barset.onLabelChanged: " + label); - onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); - onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); - onColorChanged: console.log("barset.onColorChanged: " + color); - onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); - onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); - onCountChanged: console.log("barset.onCountChanged: " + count); - onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); - onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); - onValueChanged: console.log("barset.onValuesChanged: " + index); - } - BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } - BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } - - onNameChanged: console.log("percentBarSeries.onNameChanged: " + series.name); - onVisibleChanged: console.log("percentBarSeries.onVisibleChanged: " + series.visible); - onClicked: console.log("percentBarSeries.onClicked: " + barset + " " + index); - onHovered: console.log("percentBarSeries.onHovered: " + barset + " " + status); - onLabelsVisibleChanged: console.log("percentBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); - onCountChanged: console.log("percentBarSeries.onCountChanged: " + count); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml deleted file mode 100644 index 2ba116b..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PieChart.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - id: chart - title: "pie series" - animationOptions: ChartView.SeriesAnimations - - property variant series: pieSeries - - PieSeries { - id: pieSeries - name: "pie" - PieSlice { label: "slice1"; value: 11; - onValueChanged: console.log("slice.onValueChanged: " + value); - onLabelVisibleChanged: console.log("slice.onLabelVisibleChanged: " + labelVisible); - onPenChanged: console.log("slice.onPenChanged: " + pen); - onBorderColorChanged: console.log("slice.onBorderColorChanged: " + borderColor); - onBorderWidthChanged: console.log("slice.onBorderWidthChanged: " + borderWidth); - onBrushChanged: console.log("slice.onBrushChanged: " + brush); - onColorChanged: console.log("slice.onColorChanged: " + color); - onLabelColorChanged: console.log("slice.onLabelColorChanged: " + labelColor); - onLabelBrushChanged: console.log("slice.onLabelBrushChanged: " + labelBrush); - onLabelFontChanged: console.log("slice.onLabelFontChanged: " + labelFont); - onPercentageChanged: console.log("slice.onPercentageChanged: " + percentage); - onStartAngleChanged: console.log("slice.onStartAngleChanged: " + startAngle); - onAngleSpanChanged: console.log("slice.onAngleSpanChanged: " + angleSpan); - onClicked: console.log("slice.onClicked: " + label); - onHovered: console.log("slice.onHovered: " + state); - } - PieSlice { label: "slice2"; value: 22 } - PieSlice { label: "slice3"; value: 33 } - PieSlice { label: "slice4"; value: 44 } - - onNameChanged: console.log("pieSeries.onNameChanged: " + series.name); - onVisibleChanged: console.log("pieSeries.onVisibleChanged: " + series.visible); - onClicked: console.log("pieSeries.onClicked: " + slice.label); - onHovered: console.log("pieSeries.onHovered: " + slice.label); - onAdded: console.log("pieSeries.onAdded: " + slices); - onSliceAdded: console.log("pieSeries.onSliceAdded: " + slice.label); - onRemoved: console.log("pieSeries.onRemoved: " + slices); - onSliceRemoved: console.log("pieSeries.onSliceRemoved: " + slice.label); - onCountChanged: console.log("pieSeries.onCountChanged: " + series.count); - onSumChanged: console.log("pieSeries.onSumChanged: " + series.sum); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml deleted file mode 100644 index 1fe06e8..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/PieEditor.qml +++ /dev/null @@ -1,220 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -Row { - anchors.fill: parent - spacing: 5 - property variant series - property int sliceIndex: 0 - - // buttons for selecting the edited object: series, slice or label - Flow { - spacing: 5 - flow: Flow.TopToBottom - Button { - id: seriesButton - text: "series" - unpressedColor: "#79bd8f" - onClicked: { - seriesFlow.visible = true; - slicesFlow.visible = false; - labelsFlow.visible = false; - color = "#00a388"; - sliceButton.color = "#79bd8f"; - labelButton.color = "#79bd8f"; - } - } - Button { - id: sliceButton - text: "slice" - unpressedColor: "#79bd8f" - onClicked: { - seriesFlow.visible = false; - slicesFlow.visible = true; - labelsFlow.visible = false; - color = "#00a388"; - seriesButton.color = "#79bd8f"; - labelButton.color = "#79bd8f"; - } - } - Button { - id: labelButton - text: "label" - unpressedColor: "#79bd8f" - onClicked: { - seriesFlow.visible = false; - slicesFlow.visible = false; - labelsFlow.visible = true; - color = "#00a388"; - seriesButton.color = "#79bd8f"; - sliceButton.color = "#79bd8f"; - } - } - } - - // Buttons for editing series - Flow { - id: seriesFlow - spacing: 5 - flow: Flow.TopToBottom - visible: false - Button { - text: "visible" - onClicked: series.visible = !series.visible; - } - Button { - text: "series hpos +" - onClicked: series.horizontalPosition += 0.1; - } - Button { - text: "series hpos -" - onClicked: series.horizontalPosition -= 0.1; - } - Button { - text: "series vpos +" - onClicked: series.verticalPosition += 0.1; - } - Button { - text: "series vpos -" - onClicked: series.verticalPosition -= 0.1; - } - Button { - text: "series size +" - onClicked: series.size += 0.1; - } - Button { - text: "series size -" - onClicked: series.size -= 0.1; - } - Button { - text: "series start angle +" - onClicked: series.startAngle += 1.1; - } - Button { - text: "series start angle -" - onClicked: series.startAngle -= 1.1; - } - Button { - text: "series end angle +" - onClicked: series.endAngle += 1.1; - } - Button { - text: "series end angle -" - onClicked: series.endAngle -= 1.1; - } - } - - // Buttons for editing slices - Flow { - id: slicesFlow - spacing: 5 - flow: Flow.TopToBottom - visible: false - - Button { - text: "append slice" - onClicked: series.append("slice" + (series.count + 1), 3.0); - } - Button { - text: "remove slice" - onClicked: series.remove(series.at(series.count - 1)); - } - Button { - text: "slice color" - onClicked: series.at(sliceIndex).color = main.nextColor(); - } - Button { - text: "slice border color" - onClicked: series.at(sliceIndex).borderColor = main.nextColor(); - } - Button { - text: "slice border width +" - onClicked: series.at(sliceIndex).borderWidth++; - } - Button { - text: "slice border width -" - onClicked: series.at(sliceIndex).borderWidth--; - } - Button { - text: "slice exploded" - onClicked: series.at(sliceIndex).exploded = !series.at(sliceIndex).exploded; - } - Button { - text: "slice explode dist +" - onClicked: series.at(sliceIndex).explodeDistanceFactor += 0.1; - } - Button { - text: "slice explode dist -" - onClicked: series.at(sliceIndex).explodeDistanceFactor -= 0.1; - } - } - - // Buttons for editing labels - Flow { - id: labelsFlow - spacing: 5 - flow: Flow.TopToBottom - visible: false - - Button { - text: "label visible" - onClicked: series.at(sliceIndex).labelVisible = !series.at(sliceIndex).labelVisible; - } - Button { - text: "LabelInsideNormal" - onClicked: series.at(sliceIndex).labelPosition = PieSlice.LabelInsideNormal; - } - Button { - text: "LabelInsideHorizontal" - onClicked: series.at(sliceIndex).labelPosition = PieSlice.LabelInsideHorizontal; - } - Button { - text: "LabelInsideTangential" - onClicked: series.at(sliceIndex).labelPosition = PieSlice.LabelInsideTangential; - } - Button { - text: "LabelOutside" - onClicked: series.at(sliceIndex).labelPosition = PieSlice.LabelOutside; - } - Button { - text: "label arm len +" - onClicked: series.at(sliceIndex).labelArmLengthFactor += 0.1; - } - Button { - text: "label arm len -" - onClicked: series.at(sliceIndex).labelArmLengthFactor -= 0.1; - } - Button { - text: "slice label color" - onClicked: series.at(sliceIndex).labelColor = main.nextColor(); - } - - FontEditor { - id: fontEditor - fontDescription: "label" - function editedFont() { - return series.at(sliceIndex).labelFont; - } - } - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml deleted file mode 100644 index 8f3f5e3..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterChart.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "scatter series" - property variant series: scatterSeries - animationOptions: ChartView.SeriesAnimations - - ScatterSeries { - id: scatterSeries - name: "scatter 1" - XYPoint { x: 1.5; y: 1.5 } - XYPoint { x: 1.5; y: 1.6 } - XYPoint { x: 1.57; y: 1.55 } - XYPoint { x: 1.8; y: 1.8 } - XYPoint { x: 1.9; y: 1.6 } - XYPoint { x: 2.1; y: 1.3 } - XYPoint { x: 2.5; y: 2.1 } - - onNameChanged: console.log("scatterSeries.onNameChanged: " + name); - onVisibleChanged: console.log("scatterSeries.onVisibleChanged: " + visible); - onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - onPointReplaced: console.log("scatterSeries.onPointReplaced: " + index); - onPointRemoved: console.log("scatterSeries.onPointRemoved: " + index); - onPointAdded: console.log("scatterSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y); - onColorChanged: console.log("scatterSeries.onColorChanged: " + color); - onBorderColorChanged: console.log("scatterSeries.onBorderColorChanged: " + borderColor); - onBorderWidthChanged: console.log("scatterSeries.onBorderChanged: " + borderWidth); - onCountChanged: console.log("scatterSeries.onCountChanged: " + count); - } - - ScatterSeries { - name: "scatter2" - XYPoint { x: 2.0; y: 2.0 } - XYPoint { x: 2.0; y: 2.1 } - XYPoint { x: 2.07; y: 2.05 } - XYPoint { x: 2.2; y: 2.9 } - XYPoint { x: 2.4; y: 2.7 } - XYPoint { x: 2.67; y: 2.65 } - onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml b/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml deleted file mode 100644 index e4b4160..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/ScatterEditor.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Flow { - id: flow - spacing: 5 - flow: Flow.TopToBottom - property variant series - - Button { - text: "visible" - onClicked: series.visible = !series.visible; - } - Button { - text: "color" - onClicked: series.color = main.nextColor(); - } - Button { - text: "borderColor" - onClicked: series.borderColor = main.nextColor(); - } - Button { - text: series != undefined ? "borderWidth + (" + series.borderWidth + ")" : "" - onClicked: series.borderWidth += 0.5; - } - Button { - text: series != undefined ? "borderWidth - (" + series.borderWidth + ")" : "" - onClicked: series.borderWidth -= 0.5; - } - Button { - text: "markerSize +" - onClicked: series.markerSize += 1.0; - } - Button { - text: "markerSize -" - onClicked: series.markerSize -= 1.0; - } - Button { - text: "markerShape" - onClicked: series.markerShape = ((series.markerShape + 1) % 2); - } - Button { - text: "append point" - onClicked: series.append(series.count - 1, series.count - 1); - } - Button { - text: "replace point" - onClicked: { - var xyPoint = series.at(series.count - 1); - series.replace(xyPoint.x, xyPoint.y, xyPoint.x, xyPoint.y + 0.1); - } - } - Button { - text: "remove point" - onClicked: series.remove(series.at(series.count - 1).x, series.at(series.count - 1).y); - } - Button { - text: "insert point" - onClicked: series.insert(series.count - 2, series.count - 2, series.count - 2); - } - Button { - text: "clear" - onClicked: series.clear(); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml deleted file mode 100644 index 13af6af..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/SplineChart.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "spline series" - anchors.fill: parent - property variant series: splineSeries - animationOptions: ChartView.SeriesAnimations - - SplineSeries { - id: splineSeries - name: "spline 1" - XYPoint { x: 0; y: 0 } - XYPoint { x: 1.1; y: 2.1 } - XYPoint { x: 1.9; y: 3.3 } - XYPoint { x: 2.1; y: 2.1 } - XYPoint { x: 2.9; y: 4.9 } - XYPoint { x: 3.4; y: 3.0 } - XYPoint { x: 4.1; y: 3.3 } - - onNameChanged: console.log("splineSeries.onNameChanged: " + name); - onVisibleChanged: console.log("splineSeries.onVisibleChanged: " + visible); - onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - onPointReplaced: console.log("splineSeries.onPointReplaced: " + index); - onPointRemoved: console.log("splineSeries.onPointRemoved: " + index); - onPointAdded: console.log("splineSeries.onPointAdded: " + series.at(index).x + ", " + series.at(index).y); - onColorChanged: console.log("splineSeries.onColorChanged: " + color); - onWidthChanged: console.log("splineSeries.onWidthChanged: " + width); - onStyleChanged: console.log("splineSeries.onStyleChanged: " + style); - onCapStyleChanged: console.log("splineSeries.onCapStyleChanged: " + capStyle); - onCountChanged: console.log("splineSeries.onCountChanged: " + count); - } - - SplineSeries { - name: "spline 2" - XYPoint { x: 1.1; y: 1.1 } - XYPoint { x: 1.9; y: 2.3 } - XYPoint { x: 2.1; y: 1.1 } - XYPoint { x: 2.9; y: 3.9 } - XYPoint { x: 3.4; y: 2.0 } - XYPoint { x: 4.1; y: 2.3 } - onClicked: console.log(name + ".onClicked: " + point.x + ", " + point.y); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml b/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml deleted file mode 100644 index e2e1d9b..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/StackedBarChart.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtCommercial.Chart 1.1 - -ChartView { - title: "Stacked bar series" - anchors.fill: parent - theme: ChartView.ChartThemeLight - legend.alignment: Qt.AlignBottom - animationOptions: ChartView.SeriesAnimations - - property variant series: mySeries - - StackedBarSeries { - id: mySeries - name: "bar" - axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] } - BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] - onClicked: console.log("barset.onClicked: " + index); - onHovered: console.log("barset.onHovered: " + status); - onPenChanged: console.log("barset.onPenChanged: " + pen); - onBrushChanged: console.log("barset.onBrushChanged: " + brush); - onLabelChanged: console.log("barset.onLabelChanged: " + label); - onLabelBrushChanged: console.log("barset.onLabelBrushChanged: " + labelBrush); - onLabelFontChanged: console.log("barset.onLabelFontChanged: " + labelFont); - onColorChanged: console.log("barset.onColorChanged: " + color); - onBorderColorChanged: console.log("barset.onBorderColorChanged: " + color); - onLabelColorChanged: console.log("barset.onLabelColorChanged: " + color); - onCountChanged: console.log("barset.onCountChanged: " + count); - onValuesAdded: console.log("barset.onValuesAdded: " + index + ", " + count); - onValuesRemoved: console.log("barset.onValuesRemoved: " + index + ", " + count); - onValueChanged: console.log("barset.onValuesChanged: " + index); - } - BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] } - BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] } - - onNameChanged: console.log("stackedBarSeries.onNameChanged: " + series.name); - onVisibleChanged: console.log("stackedBarSeries.onVisibleChanged: " + series.visible); - onClicked: console.log("stackedBarSeries.onClicked: " + barset + " " + index); - onHovered: console.log("stackedBarSeries.onHovered: " + barset + " " + status); - onLabelsVisibleChanged: console.log("stackedBarSeries.onLabelsVisibleChanged: " + series.labelsVisible); - onCountChanged: console.log("stackedBarSeries.onCountChanged: " + count); - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/loader.qml b/tests/qmlchartproperties/qml/qmlchartproperties/loader.qml deleted file mode 100644 index 77df7be..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/loader.qml +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: container - width: 640 - height: 500 - Component.onCompleted: { - var co = Qt.createComponent("main.qml") - if (co.status == Component.Ready) { - var o = co.createObject(container) - } else { - console.log(co.errorString()) - console.log("QtCommercial.Chart 1.1 not available") - console.log("Please use correct QML_IMPORT_PATH export") - } - } -} diff --git a/tests/qmlchartproperties/qml/qmlchartproperties/main.qml b/tests/qmlchartproperties/qml/qmlchartproperties/main.qml deleted file mode 100644 index 8ba55a3..0000000 --- a/tests/qmlchartproperties/qml/qmlchartproperties/main.qml +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: main - width: parent.width - height: parent.height - property int viewCount: 9 - property variant colors: ["#637D74", "#403D3A", "#8C3B3B", "#AB6937", "#D4A960"] - property int colorIndex: 0 - property int buttonWidth: 42 - - function nextColor() { - colorIndex++; - return colors[colorIndex % colors.length]; - } - - Row { - anchors.top: parent.top - anchors.bottom: buttonRow.top - anchors.bottomMargin: 10 - anchors.left: parent.left - anchors.right: parent.right - - Loader { - id: chartLoader - width: main.width - editorLoader.width - height: parent.height - source: "Chart.qml" - onStatusChanged: { - if (status == Loader.Ready && editorLoader.status == Loader.Ready && chartLoader.item) - editorLoader.item.series = chartLoader.item.series; - } - } - - Loader { - id: editorLoader - width: 280 - height: parent.height - source: "ChartEditor.qml" - onStatusChanged: { - if (status == Loader.Ready && chartLoader.status == Loader.Ready && chartLoader.item) - editorLoader.item.series = chartLoader.item.series; - } - } - } - - Row { - id: buttonRow - height: 40 - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - spacing: 10 - - Button { - text: "chart" - width: buttonWidth - onClicked: { - chartLoader.source = "Chart.qml"; - editorLoader.source = "ChartEditor.qml"; - } - } - Button { - text: "pie" - width: buttonWidth - onClicked: { - chartLoader.source = "PieChart.qml"; - editorLoader.source = "PieEditor.qml"; - } - } - Button { - text: "line" - width: buttonWidth - onClicked: { - chartLoader.source = "LineChart.qml"; - editorLoader.source = "LineEditor.qml"; - } - } - Button { - text: "spline" - width: buttonWidth - onClicked: { - chartLoader.source = "SplineChart.qml"; - editorLoader.source = "LineEditor.qml"; - } - } - Button { - text: "scatter" - width: buttonWidth - onClicked: { - chartLoader.source = "ScatterChart.qml"; - editorLoader.source = "ScatterEditor.qml"; - } - } - Button { - text: "area" - width: buttonWidth - onClicked: { - chartLoader.source = "AreaChart.qml"; - editorLoader.source = "AreaEditor.qml"; - } - } - Button { - text: "bar" - width: buttonWidth - onClicked: { - chartLoader.source = "BarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } - } - Button { - text: "sbar" - width: buttonWidth - onClicked: { - chartLoader.source = "StackedBarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } - } - Button { - text: "pbar" - width: buttonWidth - onClicked: { - chartLoader.source = "PercentBarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } - } - Button { - text: "hbar" - width: buttonWidth - onClicked: { - chartLoader.source = "HorizontalBarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } - } - Button { - text: "hsbar" - width: buttonWidth - onClicked: { - chartLoader.source = "HorizontalStackedBarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } - } - Button { - text: "hpbar" - width: buttonWidth - onClicked: { - chartLoader.source = "HorizontalPercentBarChart.qml"; - editorLoader.source = "BarEditor.qml"; - } - } - } -} diff --git a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.cpp b/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.cpp deleted file mode 100644 index 8ba6e88..0000000 --- a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// checksum 0x78c version 0x60010 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#include "qmlapplicationviewer.h" - -#include -#include -#include -#include -#include -#include - -#include // MEEGO_EDITION_HARMATTAN - -#ifdef HARMATTAN_BOOSTER -#include -#endif - -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 - -#include - -#if !defined(NO_JSDEBUGGER) -#include -#endif -#if !defined(NO_QMLOBSERVER) -#include -#endif - -// Enable debugging before any QDeclarativeEngine is created -struct QmlJsDebuggingEnabler -{ - QmlJsDebuggingEnabler() - { - QDeclarativeDebugHelper::enableDebugging(); - } -}; - -// Execute code in constructor before first QDeclarativeEngine is instantiated -static QmlJsDebuggingEnabler enableDebuggingHelper; - -#endif // QMLJSDEBUGGER - -class QmlApplicationViewerPrivate -{ - QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} - - QString mainQmlFile; - QDeclarativeView *view; - friend class QmlApplicationViewer; - QString adjustPath(const QString &path); -}; - -QString QmlApplicationViewerPrivate::adjustPath(const QString &path) -{ -#ifdef Q_OS_UNIX -#ifdef Q_OS_MAC - if (!QDir::isAbsolutePath(path)) - return QCoreApplication::applicationDirPath() - + QLatin1String("/../Resources/") + path; -#else - QString pathInInstallDir; - const QString applicationDirPath = QCoreApplication::applicationDirPath(); - pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); - - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#endif -#endif - return path; -} - -QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) - : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate(this)) -{ - connect(engine(), SIGNAL(quit()), SLOT(close())); - setResizeMode(QDeclarativeView::SizeRootObjectToView); - // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 -#if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); -#endif -#if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); -#endif -#endif -} - -QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) - : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate(view)) -{ - connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); - view->setResizeMode(QDeclarativeView::SizeRootObjectToView); - // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in -#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 -#if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); -#endif -#if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); -#endif -#endif -} - -QmlApplicationViewer::~QmlApplicationViewer() -{ - delete d; -} - -QmlApplicationViewer *QmlApplicationViewer::create() -{ -#ifdef HARMATTAN_BOOSTER - return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); -#else - return new QmlApplicationViewer(); -#endif -} - -void QmlApplicationViewer::setMainQmlFile(const QString &file) -{ - d->mainQmlFile = d->adjustPath(file); - d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); -} - -void QmlApplicationViewer::addImportPath(const QString &path) -{ - d->view->engine()->addImportPath(d->adjustPath(path)); -} - -void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) -{ -#if defined(Q_OS_SYMBIAN) - // If the version of Qt on the device is < 4.7.2, that attribute won't work - if (orientation != ScreenOrientationAuto) { - const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); - if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { - qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); - return; - } - } -#endif // Q_OS_SYMBIAN - - Qt::WidgetAttribute attribute; - switch (orientation) { -#if QT_VERSION < 0x040702 - // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes - case ScreenOrientationLockPortrait: - attribute = static_cast(128); - break; - case ScreenOrientationLockLandscape: - attribute = static_cast(129); - break; - default: - case ScreenOrientationAuto: - attribute = static_cast(130); - break; -#else // QT_VERSION < 0x040702 - case ScreenOrientationLockPortrait: - attribute = Qt::WA_LockPortraitOrientation; - break; - case ScreenOrientationLockLandscape: - attribute = Qt::WA_LockLandscapeOrientation; - break; - default: - case ScreenOrientationAuto: - attribute = Qt::WA_AutoOrientation; - break; -#endif // QT_VERSION < 0x040702 - }; - setAttribute(attribute, true); -} - -void QmlApplicationViewer::showExpanded() -{ -#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); -#elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); -#else - d->view->show(); -#endif -} - -QApplication *createApplication(int &argc, char **argv) -{ -#ifdef HARMATTAN_BOOSTER - return MDeclarativeCache::qApplication(argc, argv); -#else - return new QApplication(argc, argv); -#endif -} diff --git a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.h b/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.h deleted file mode 100644 index f8008f5..0000000 --- a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.h +++ /dev/null @@ -1,47 +0,0 @@ -// checksum 0x82ed version 0x60010 -/* - This file was generated by the Qt Quick Application wizard of Qt Creator. - QmlApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#ifndef QMLAPPLICATIONVIEWER_H -#define QMLAPPLICATIONVIEWER_H - -#include - -class QmlApplicationViewer : public QDeclarativeView -{ - Q_OBJECT - -public: - enum ScreenOrientation { - ScreenOrientationLockPortrait, - ScreenOrientationLockLandscape, - ScreenOrientationAuto - }; - - explicit QmlApplicationViewer(QWidget *parent = 0); - virtual ~QmlApplicationViewer(); - - static QmlApplicationViewer *create(); - - void setMainQmlFile(const QString &file); - void addImportPath(const QString &path); - - // Note that this will only have an effect on Symbian and Fremantle. - void setOrientation(ScreenOrientation orientation); - - void showExpanded(); - -private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); - class QmlApplicationViewerPrivate *d; -}; - -QApplication *createApplication(int &argc, char **argv); - -#endif // QMLAPPLICATIONVIEWER_H diff --git a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.pri b/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.pri deleted file mode 100644 index 567c6dc..0000000 --- a/tests/qmlchartproperties/qmlapplicationviewer/qmlapplicationviewer.pri +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += $$PWD/qmlapplicationviewer.cpp -HEADERS += $$PWD/qmlapplicationviewer.h -INCLUDEPATH += $$PWD - -# Include JS debugger library if QMLJSDEBUGGER_PATH is set -!isEmpty(QMLJSDEBUGGER_PATH) { - include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) -} else { - DEFINES -= QMLJSDEBUGGER -} - diff --git a/tests/qmlchartproperties/qmlchartproperties.pro b/tests/qmlchartproperties/qmlchartproperties.pro deleted file mode 100644 index fccb2d4..0000000 --- a/tests/qmlchartproperties/qmlchartproperties.pro +++ /dev/null @@ -1,8 +0,0 @@ -!include( ../tests.pri ) { - error( "Couldn't find the test.pri file!" ) -} - -RESOURCES += resources.qrc -SOURCES += main.cpp - -include(qmlapplicationviewer/qmlapplicationviewer.pri) diff --git a/tests/qmlchartproperties/resources.qrc b/tests/qmlchartproperties/resources.qrc deleted file mode 100644 index fdf8a01..0000000 --- a/tests/qmlchartproperties/resources.qrc +++ /dev/null @@ -1,30 +0,0 @@ - - - qml/qmlchartproperties/loader.qml - qml/qmlchartproperties/main.qml - qml/qmlchartproperties/Button.qml - qml/qmlchartproperties/PieChart.qml - qml/qmlchartproperties/PieEditor.qml - qml/qmlchartproperties/LineChart.qml - qml/qmlchartproperties/LineEditor.qml - qml/qmlchartproperties/SplineChart.qml - qml/qmlchartproperties/ScatterChart.qml - qml/qmlchartproperties/AreaChart.qml - qml/qmlchartproperties/BarChart.qml - qml/qmlchartproperties/BarEditor.qml - qml/qmlchartproperties/ScatterEditor.qml - qml/qmlchartproperties/AreaEditor.qml - qml/qmlchartproperties/StackedBarChart.qml - qml/qmlchartproperties/PercentBarChart.qml - qml/qmlchartproperties/Chart.qml - qml/qmlchartproperties/ChartEditor.qml - qml/qmlchartproperties/FontEditor.qml - qml/qmlchartproperties/HorizontalBarChart.qml - qml/qmlchartproperties/HorizontalPercentBarChart.qml - qml/qmlchartproperties/HorizontalStackedBarChart.qml - qml/qmlchartproperties/ChartEditorAxis.qml - qml/qmlchartproperties/ChartEditorLegend.qml - qml/qmlchartproperties/ChartEditorProperties.qml - qml/qmlchartproperties/ChartEditorTitle.qml - - diff --git a/tests/tests.pri b/tests/tests.pri deleted file mode 100644 index 85e0705..0000000 --- a/tests/tests.pri +++ /dev/null @@ -1,14 +0,0 @@ -!include( ../config.pri ) { - error( "Couldn't find the config.pri file!" ) -} - -TEMPLATE = app - -DESTDIR = $$CHART_BUILD_BIN_DIR -OBJECTS_DIR = $$CHART_BUILD_DIR/tests/$$TARGET -MOC_DIR = $$CHART_BUILD_DIR/tests/$$TARGET -UI_DIR = $$CHART_BUILD_DIR/tests/$$TARGET -RCC_DIR = $$CHART_BUILD_DIR/tests/$$TARGET - -# staticlib config causes problems when building executables -staticlib: CONFIG-=staticlib diff --git a/tests/tests.pro b/tests/tests.pro deleted file mode 100644 index a02f302..0000000 --- a/tests/tests.pro +++ /dev/null @@ -1,16 +0,0 @@ -!include( ../config.pri ) { - error( "Couldn't find the config.pri file!" ) -} - -TEMPLATE = subdirs -SUBDIRS += \ - auto \ - qmlchartproperties \ - qmlchartaxis - -contains(QT_CONFIG, opengl) { - SUBDIRS += chartwidgettest \ - wavechart -} else { - message("OpenGL not available. Some test apps are disabled") -} diff --git a/tests/wavechart/main.cpp b/tests/wavechart/main.cpp deleted file mode 100644 index 95cc5f3..0000000 --- a/tests/wavechart/main.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** 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 "wavechart.h" -#include -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - QMainWindow window; - QChart *chart = new QChart(); - WaveChart *waveChart = new WaveChart(chart,&window); - - waveChart->setViewport( new QGLWidget() ); - waveChart->setRenderHint(QPainter::Antialiasing); - chart->setAnimationOptions(QChart::AllAnimations); - chart->setTitle("This is wave generator."); - - window.setCentralWidget(waveChart); - window.resize(400, 300); - window.show(); - - return a.exec(); -} diff --git a/tests/wavechart/wavechart.cpp b/tests/wavechart/wavechart.cpp deleted file mode 100644 index 73c39f0..0000000 --- a/tests/wavechart/wavechart.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** 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 "wavechart.h" -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -#define PI 3.14159265358979 -static const int numPoints =100; - -WaveChart::WaveChart(QChart* chart, QWidget* parent) : - QChartView(chart, parent), - m_series(new QLineSeries()), - m_wave(0), - m_step(2 * PI / numPoints) -{ - QPen blue(Qt::blue); - blue.setWidth(3); - m_series->setPen(blue); - - chart->legend()->setVisible(false); - - QTime now = QTime::currentTime(); - qsrand((uint) now.msec()); - - int fluctuate = 100; - - for (qreal x = 0; x <= 2 * PI; x += m_step) { - m_series->append(x, fabs(sin(x) * fluctuate)); - } - - chart->addSeries(m_series); - chart->createDefaultAxes(); - - QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(update())); - m_timer.setInterval(5000); - m_timer.start(); -} - -void WaveChart::update() -{ - - int fluctuate; - const QList& points = m_series->points(); - for (qreal i = 0, x = 0; x <= 2 * PI; x += m_step, i++) { - fluctuate = qrand() % 100; - m_series->replace(x,points[i].y(),x,fabs(sin(x) * fluctuate)); - - } - -} diff --git a/tests/wavechart/wavechart.h b/tests/wavechart/wavechart.h deleted file mode 100644 index 82b2ffb..0000000 --- a/tests/wavechart/wavechart.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef WAVECHART_H -#define WAVECHART_H - -#include -#include -#include -#include -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class WaveChart: public QChartView -{ - Q_OBJECT - -public: - WaveChart(QChart* chart, QWidget* parent); - -private slots: - void update(); - -private: - QLineSeries* m_series; - int m_wave; - qreal m_step; - QTimer m_timer; -}; - -#endif diff --git a/tests/wavechart/wavechart.pro b/tests/wavechart/wavechart.pro deleted file mode 100644 index aed0c39..0000000 --- a/tests/wavechart/wavechart.pro +++ /dev/null @@ -1,7 +0,0 @@ -!include( ../tests.pri ) { - error( "Couldn't find the examples.pri file!" ) -} -QT+=opengl -TARGET = wavechart -SOURCES += main.cpp wavechart.cpp -HEADERS += wavechart.h