tst_qml.cpp
202 lines
| 7.6 KiB
| text/x-c
|
CppLexer
|
r1997 | /**************************************************************************** | ||
** | ||||
|
r2776 | ** Copyright (C) 2015 The Qt Company Ltd | ||
|
r1997 | ** All rights reserved. | ||
|
r2776 | ** For any questions to The Qt Company, please use contact form at http://qt.io | ||
|
r1997 | ** | ||
|
r2740 | ** This file is part of the Qt Charts module. | ||
|
r1997 | ** | ||
|
r2740 | ** Licensees holding valid commercial license for Qt may use this file in | ||
** accordance with the Qt License Agreement provided with the Software | ||||
** or, alternatively, in accordance with the terms contained in a written | ||||
|
r2776 | ** agreement between you and The Qt Company. | ||
|
r1997 | ** | ||
** If you have questions regarding the use of this file, please use | ||||
|
r2740 | ** contact form at http://qt.io | ||
|
r1997 | ** | ||
****************************************************************************/ | ||||
#include <QtTest/QtTest> | ||||
|
r2712 | #include <QtQml/QQmlEngine> | ||
#include <QtQml/QQmlComponent> | ||||
|
r1997 | #include "tst_definitions.h" | ||
|
r2712 | class tst_qml : public QObject | ||
|
r1997 | { | ||
Q_OBJECT | ||||
public slots: | ||||
void initTestCase(); | ||||
void cleanupTestCase(); | ||||
void init(); | ||||
void cleanup(); | ||||
private slots: | ||||
void checkPlugin_data(); | ||||
void checkPlugin(); | ||||
private: | ||||
|
r2712 | QString componentErrors(const QQmlComponent* component) const; | ||
|
r2483 | QString imports_1_1(); | ||
QString imports_1_3(); | ||||
|
r2712 | QString imports_1_4(); | ||
QString imports_2_0(); | ||||
|
r2780 | QString imports_2_1(); | ||
|
r1997 | |||
}; | ||||
|
r2712 | QString tst_qml::componentErrors(const QQmlComponent* component) const | ||
|
r1997 | { | ||
Q_ASSERT(component); | ||||
QStringList errors; | ||||
|
r2712 | foreach (QQmlError const& error, component->errors()) { | ||
|
r1997 | errors << error.toString(); | ||
} | ||||
return errors.join("\n"); | ||||
} | ||||
|
r2712 | QString tst_qml::imports_1_1() | ||
|
r1997 | { | ||
|
r2712 | return "import QtQuick 2.0 \n" | ||
"import QtCharts 1.1 \n"; | ||||
|
r1997 | } | ||
|
r2712 | QString tst_qml::imports_1_3() | ||
|
r2483 | { | ||
|
r2712 | return "import QtQuick 2.0 \n" | ||
"import QtCharts 1.3 \n"; | ||||
|
r2483 | } | ||
|
r2712 | QString tst_qml::imports_1_4() | ||
{ | ||||
return "import QtQuick 2.0 \n" | ||||
"import QtCharts 1.4 \n"; | ||||
} | ||||
QString tst_qml::imports_2_0() | ||||
{ | ||||
return "import QtQuick 2.0 \n" | ||||
"import QtCharts 2.0 \n"; | ||||
} | ||||
|
r1997 | |||
|
r2780 | QString tst_qml::imports_2_1() | ||
{ | ||||
return "import QtQuick 2.1 \n" | ||||
"import QtCharts 2.1 \n"; | ||||
} | ||||
|
r2712 | void tst_qml::initTestCase() | ||
|
r1997 | { | ||
} | ||||
|
r2712 | void tst_qml::cleanupTestCase() | ||
|
r1997 | { | ||
} | ||||
|
r2712 | void tst_qml::init() | ||
|
r1997 | { | ||
} | ||||
|
r2712 | void tst_qml::cleanup() | ||
|
r1997 | { | ||
} | ||||
|
r2712 | void tst_qml::checkPlugin_data() | ||
|
r1997 | { | ||
QTest::addColumn<QString>("source"); | ||||
|
r2032 | |||
|
r2483 | QTest::newRow("createChartView") << imports_1_1() + "ChartView{}"; | ||
QTest::newRow("XYPoint") << imports_1_1() + "XYPoint{}"; | ||||
QTest::newRow("scatterSeries") << imports_1_1() + "ScatterSeries{}"; | ||||
QTest::newRow("lineSeries") << imports_1_1() + "LineSeries{}"; | ||||
QTest::newRow("splineSeries") << imports_1_1() + "SplineSeries{}"; | ||||
QTest::newRow("areaSeries") << imports_1_1() + "AreaSeries{}"; | ||||
QTest::newRow("barSeries") << imports_1_1() + "BarSeries{}"; | ||||
QTest::newRow("stackedBarSeries") << imports_1_1() + "StackedBarSeries{}"; | ||||
QTest::newRow("precentBarSeries") << imports_1_1() + "PercentBarSeries{}"; | ||||
QTest::newRow("horizonatlBarSeries") << imports_1_1() + "HorizontalBarSeries{}"; | ||||
QTest::newRow("horizonatlStackedBarSeries") << imports_1_1() + "HorizontalStackedBarSeries{}"; | ||||
QTest::newRow("horizonatlstackedBarSeries") << imports_1_1() + "HorizontalPercentBarSeries{}"; | ||||
QTest::newRow("pieSeries") << imports_1_1() + "PieSeries{}"; | ||||
QTest::newRow("PieSlice") << imports_1_1() + "PieSlice{}"; | ||||
QTest::newRow("BarSet") << imports_1_1() + "BarSet{}"; | ||||
QTest::newRow("HXYModelMapper") << imports_1_1() + "HXYModelMapper{}"; | ||||
QTest::newRow("VXYModelMapper") << imports_1_1() + "VXYModelMapper{}"; | ||||
QTest::newRow("HPieModelMapper") << imports_1_1() + "HPieModelMapper{}"; | ||||
QTest::newRow("HPieModelMapper") << imports_1_1() + "HPieModelMapper{}"; | ||||
QTest::newRow("HBarModelMapper") << imports_1_1() + "HBarModelMapper{}"; | ||||
QTest::newRow("VBarModelMapper") << imports_1_1() + "VBarModelMapper{}"; | ||||
QTest::newRow("ValueAxis") << imports_1_1() + "ValueAxis{}"; | ||||
|
r2032 | #ifndef QT_ON_ARM | ||
|
r2483 | QTest::newRow("DateTimeAxis") << imports_1_1() + "DateTimeAxis{}"; | ||
|
r2032 | #endif | ||
|
r2483 | QTest::newRow("CategoryAxis") << imports_1_1() + "CategoryAxis{}"; | ||
QTest::newRow("CategoryRange") << imports_1_1() + "CategoryRange{}"; | ||||
QTest::newRow("BarCategoryAxis") << imports_1_1() + "BarCategoryAxis{}"; | ||||
QTest::newRow("createPolarChartView") << imports_1_3() + "PolarChartView{}"; | ||||
|
r2499 | QTest::newRow("LogValueAxis") << imports_1_3() + "LogValueAxis{}"; | ||
|
r2712 | QTest::newRow("BoxPlotSeries") << imports_1_3() + "BoxPlotSeries{}"; | ||
QTest::newRow("BoxSet") << imports_1_3() + "BoxSet{}"; | ||||
QTest::newRow("createChartView_2_0") << imports_2_0() + "ChartView{}"; | ||||
QTest::newRow("XYPoint_2_0") << imports_2_0() + "XYPoint{}"; | ||||
QTest::newRow("scatterSeries_2_0") << imports_2_0() + "ScatterSeries{}"; | ||||
QTest::newRow("lineSeries_2_0") << imports_2_0() + "LineSeries{}"; | ||||
QTest::newRow("splineSeries_2_0") << imports_2_0() + "SplineSeries{}"; | ||||
QTest::newRow("areaSeries_2_0") << imports_2_0() + "AreaSeries{}"; | ||||
QTest::newRow("barSeries_2_0") << imports_2_0() + "BarSeries{}"; | ||||
QTest::newRow("stackedBarSeries_2_0") << imports_2_0() + "StackedBarSeries{}"; | ||||
QTest::newRow("precentBarSeries_2_0") << imports_2_0() + "PercentBarSeries{}"; | ||||
QTest::newRow("horizonatlBarSeries_2_0") << imports_2_0() + "HorizontalBarSeries{}"; | ||||
QTest::newRow("horizonatlStackedBarSeries_2_0") | ||||
<< imports_2_0() + "HorizontalStackedBarSeries{}"; | ||||
QTest::newRow("horizonatlstackedBarSeries_2_0") | ||||
<< imports_2_0() + "HorizontalPercentBarSeries{}"; | ||||
QTest::newRow("pieSeries_2_0") << imports_2_0() + "PieSeries{}"; | ||||
QTest::newRow("PieSlice_2_0") << imports_2_0() + "PieSlice{}"; | ||||
QTest::newRow("BarSet_2_0") << imports_2_0() + "BarSet{}"; | ||||
QTest::newRow("HXYModelMapper_2_0") << imports_2_0() + "HXYModelMapper{}"; | ||||
QTest::newRow("VXYModelMapper_2_0") << imports_2_0() + "VXYModelMapper{}"; | ||||
QTest::newRow("HPieModelMapper_2_0") << imports_2_0() + "HPieModelMapper{}"; | ||||
QTest::newRow("HPieModelMapper_2_0") << imports_2_0() + "HPieModelMapper{}"; | ||||
QTest::newRow("HBarModelMapper_2_0") << imports_2_0() + "HBarModelMapper{}"; | ||||
QTest::newRow("VBarModelMapper_2_0") << imports_2_0() + "VBarModelMapper{}"; | ||||
QTest::newRow("ValueAxis_2_0") << imports_2_0() + "ValueAxis{}"; | ||||
#ifndef QT_ON_ARM | ||||
QTest::newRow("DateTimeAxis_2_0") << imports_2_0() + "DateTimeAxis{}"; | ||||
#endif | ||||
QTest::newRow("CategoryAxis_2_0") << imports_2_0() + "CategoryAxis{}"; | ||||
QTest::newRow("CategoryRange_2_0") << imports_2_0() + "CategoryRange{}"; | ||||
QTest::newRow("BarCategoryAxis_2_0") << imports_2_0() + "BarCategoryAxis{}"; | ||||
QTest::newRow("createPolarChartView_2_0") << imports_2_0() + "PolarChartView{}"; | ||||
QTest::newRow("LogValueAxis_2_0") << imports_2_0() + "LogValueAxis{}"; | ||||
QTest::newRow("BoxPlotSeries_2_0") << imports_2_0() + "BoxPlotSeries{}"; | ||||
QTest::newRow("BoxSet_2_0") << imports_2_0() + "BoxSet{}"; | ||||
|
r2780 | |||
|
r2805 | QTest::newRow("CategoryAxis_2_1") << imports_2_1() + "CategoryAxis{}"; | ||
QTest::newRow("ScatterSeries_2_1") << imports_2_1() + "ScatterSeries{}"; | ||||
QTest::newRow("LineSeries_2_1") << imports_2_1() + "LineSeries{}"; | ||||
QTest::newRow("SplineSeries_2_1") << imports_2_1() + "SplineSeries{}"; | ||||
|
r1997 | } | ||
|
r2712 | void tst_qml::checkPlugin() | ||
|
r1997 | { | ||
QFETCH(QString, source); | ||||
|
r2712 | QQmlEngine engine; | ||
engine.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("qml"))); | ||||
QQmlComponent component(&engine); | ||||
|
r1997 | component.setData(source.toLatin1(), QUrl()); | ||
QVERIFY2(!component.isError(), qPrintable(componentErrors(&component))); | ||||
|
r2712 | TRY_COMPARE(component.status(), QQmlComponent::Ready); | ||
|
r1997 | QObject *obj = component.create(); | ||
QVERIFY(obj != 0); | ||||
delete obj; | ||||
} | ||||
|
r2712 | QTEST_MAIN(tst_qml) | ||
|
r1997 | |||
#include "tst_qml.moc" | ||||