diff --git a/test/auto/auto.pro b/test/auto/auto.pro index b1255f8..f0f4b8b 100644 --- a/test/auto/auto.pro +++ b/test/auto/auto.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS += chartdataset domain \ No newline at end of file +SUBDIRS += chartdataset domain qchartview \ No newline at end of file diff --git a/test/auto/domain/tst_domain.cpp b/test/auto/domain/tst_domain.cpp index c2b8444..20101cc 100644 --- a/test/auto/domain/tst_domain.cpp +++ b/test/auto/domain/tst_domain.cpp @@ -1,3 +1,23 @@ +/**************************************************************************** +** +** 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 @@ -11,13 +31,13 @@ class tst_Domain: public QObject { Q_OBJECT -public slots: +public Q_SLOTS: void initTestCase(); void cleanupTestCase(); void init(); void cleanup(); -private slots: +private Q_SLOTS: void domain(); void handleAxisRangeXChanged_data(); void handleAxisRangeXChanged(); diff --git a/test/auto/qchartview/qchartview.pro b/test/auto/qchartview/qchartview.pro new file mode 100644 index 0000000..8b27d7e --- /dev/null +++ b/test/auto/qchartview/qchartview.pro @@ -0,0 +1,4 @@ +!include( ../../test.pri ) { + error( "Couldn't find the test.pri file!" ) +} +SOURCES += tst_qchartview.cpp \ No newline at end of file diff --git a/test/auto/qchartview/tst_qchartview.cpp b/test/auto/qchartview/tst_qchartview.cpp new file mode 100644 index 0000000..fa5d802 --- /dev/null +++ b/test/auto/qchartview/tst_qchartview.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** 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 + +QTCOMMERCIALCHART_USE_NAMESPACE + + +Q_DECLARE_METATYPE(QChart*) +Q_DECLARE_METATYPE(QChartView::RubberBands) + +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() +{ +} + +void tst_QChartView::cleanupTestCase() +{ +} + +void tst_QChartView::init() +{ + m_view = new QChartView(new QChart()); +} + +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); + QTest::qWaitForWindowShown(m_view); +} + +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::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand); + QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand); + QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand); +} + +void tst_QChartView::rubberBand() +{ + QFETCH(QChartView::RubberBands, rubberBand); + m_view->setRubberBand(rubberBand); + QCOMPARE(m_view->rubberBand(), rubberBand); +} + +QTEST_MAIN(tst_QChartView) +#include "tst_qchartview.moc" +