diff options
author | Michal Klocek <michal.klocek@digia.com> | 2012-09-06 15:10:23 +0300 |
---|---|---|
committer | Michal Klocek <michal.klocek@digia.com> | 2012-09-06 15:10:42 +0300 |
commit | b9b0ebfe77eb7ce3ff154605460748dc794c8429 (patch) | |
tree | 741fec0d163244df9c95363b0ad310934ae74675 | |
parent | 257e3f1541a9653c4e963083da55aa7497365852 (diff) |
Adds tst_qml basic stub for checking plugin loading qml
-rw-r--r-- | tests/auto/auto.pro | 3 | ||||
-rw-r--r-- | tests/auto/qml/qml.pro | 5 | ||||
-rw-r--r-- | tests/auto/qml/tst_qml.cpp | 120 |
3 files changed, 127 insertions, 1 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index acbf1728..b325b842 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -24,7 +24,8 @@ SUBDIRS += \ qcategoryaxis \ qbarcategoryaxis \ domain \ - chartdataset + chartdataset \ + qml !linux-arm*: { SUBDIRS += \ diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro new file mode 100644 index 00000000..144e5db3 --- /dev/null +++ b/tests/auto/qml/qml.pro @@ -0,0 +1,5 @@ +!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 new file mode 100644 index 00000000..8d166d30 --- /dev/null +++ b/tests/auto/qml/tst_qml.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtTest/QtTest> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> +#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<QString>("source"); + QTest::newRow("createChartView") << imports() + "ChartView{}"; + QTest::newRow("lineSeries") << imports() + "LineSeries{}"; + QTest::newRow("splineSeries") << imports() + "SplineSeries{}"; + QTest::newRow("scatterSeries") << imports() + "ScatterSeries{}"; + 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{}"; +} + + +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" + |