##// END OF EJS Templates
Adds tst_qml basic stub for checking plugin loading qml
Michal Klocek -
r1997:de2e1700342f
parent child
Show More
@@ -0,0 +1,5
1 !include( ../auto.pri ) {
2 error( "Couldn't find the auto.pri file!" )
3 }
4 SOURCES += tst_qml.cpp
5 QT += declarative
@@ -0,0 +1,120
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20 #include <QtTest/QtTest>
21 #include <QDeclarativeEngine>
22 #include <QDeclarativeComponent>
23 #include "tst_definitions.h"
24
25 class tst_QML : public QObject
26 {
27 Q_OBJECT
28
29 public slots:
30 void initTestCase();
31 void cleanupTestCase();
32 void init();
33 void cleanup();
34 private slots:
35 void checkPlugin_data();
36 void checkPlugin();
37 private:
38 QString componentErrors(const QDeclarativeComponent* component) const;
39 QString imports();
40
41 };
42
43 QString tst_QML::componentErrors(const QDeclarativeComponent* component) const
44 {
45 Q_ASSERT(component);
46
47 QStringList errors;
48
49 foreach (QDeclarativeError const& error, component->errors()) {
50 errors << error.toString();
51 }
52
53 return errors.join("\n");
54 }
55
56 QString tst_QML::imports()
57 {
58 return "import QtQuick 1.0 \n"
59 "import QtCommercial.Chart 1.1 \n";
60 }
61
62
63 void tst_QML::initTestCase()
64 {
65 }
66
67 void tst_QML::cleanupTestCase()
68 {
69 }
70
71 void tst_QML::init()
72 {
73
74 }
75
76 void tst_QML::cleanup()
77 {
78
79 }
80
81 void tst_QML::checkPlugin_data()
82 {
83 QTest::addColumn<QString>("source");
84 QTest::newRow("createChartView") << imports() + "ChartView{}";
85 QTest::newRow("lineSeries") << imports() + "LineSeries{}";
86 QTest::newRow("splineSeries") << imports() + "SplineSeries{}";
87 QTest::newRow("scatterSeries") << imports() + "ScatterSeries{}";
88 QTest::newRow("areaSeries") << imports() + "AreaSeries{}";
89 QTest::newRow("barSeries") << imports() + "BarSeries{}";
90 QTest::newRow("stackedBarSeries") << imports() + "StackedBarSeries{}";
91 QTest::newRow("precentBarSeries") << imports() + "PercentBarSeries{}";
92 QTest::newRow("horizonatlBarSeries") << imports() + "HorizontalBarSeries{}";
93 QTest::newRow("horizonatlStackedBarSeries") << imports() + "HorizontalStackedBarSeries{}";
94 QTest::newRow("horizonatlstackedBarSeries") << imports() + "HorizontalPercentBarSeries{}";
95 QTest::newRow("pieSeries") << imports() + "PieSeries{}";
96 }
97
98
99 void tst_QML::checkPlugin()
100 {
101 QFETCH(QString, source);
102 QDeclarativeEngine engine;
103 QDeclarativeComponent component(&engine);
104 component.setData(source.toLatin1(), QUrl());
105 QVERIFY2(!component.isError(), qPrintable(componentErrors(&component)));
106 TRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
107 QObject *obj = component.create();
108 QVERIFY(obj != 0);
109
110 //
111 //TODO:
112 // QCOMPARE(obj->property("something").toInt(), 0);
113
114 delete obj;
115 }
116
117 QTEST_MAIN(tst_QML)
118
119 #include "tst_qml.moc"
120
@@ -24,7 +24,8 SUBDIRS += \
24 24 qcategoryaxis \
25 25 qbarcategoryaxis \
26 26 domain \
27 chartdataset
27 chartdataset \
28 qml
28 29
29 30 !linux-arm*: {
30 31 SUBDIRS += \
General Comments 0
You need to be logged in to leave comments. Login now