From b9b0ebfe77eb7ce3ff154605460748dc794c8429 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 6 Sep 2012 15:10:23 +0300 Subject: Adds tst_qml basic stub for checking plugin loading qml --- tests/auto/auto.pro | 3 +- tests/auto/qml/qml.pro | 5 ++ tests/auto/qml/tst_qml.cpp | 120 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qml/qml.pro create mode 100644 tests/auto/qml/tst_qml.cpp 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 +#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("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" + -- cgit v1.2.3