##// END OF EJS Templates
Fix qml autotest after qtquick2 support was added...
Miikka Heikkinen -
r2499:08de4b5d40d1
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_quick2.cpp
5 QT += qml quick
@@ -0,0 +1,142
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 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 <QtQml/QQmlEngine>
22 #include <QtQml/QQmlComponent>
23 #include "tst_definitions.h"
24
25 class tst_quick2 : 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 QQmlComponent* component) const;
39 QString imports_1_1();
40 QString imports_1_3();
41
42 };
43
44 QString tst_quick2::componentErrors(const QQmlComponent* component) const
45 {
46 Q_ASSERT(component);
47
48 QStringList errors;
49
50 foreach (QQmlError const& error, component->errors()) {
51 errors << error.toString();
52 }
53
54 return errors.join("\n");
55 }
56
57 QString tst_quick2::imports_1_1()
58 {
59 return "import QtQuick 2.0 \n"
60 "import QtCommercial.Chart 1.1 \n";
61 }
62
63 QString tst_quick2::imports_1_3()
64 {
65 return "import QtQuick 2.0 \n"
66 "import QtCommercial.Chart 1.3 \n";
67 }
68
69
70 void tst_quick2::initTestCase()
71 {
72 }
73
74 void tst_quick2::cleanupTestCase()
75 {
76 }
77
78 void tst_quick2::init()
79 {
80
81 }
82
83 void tst_quick2::cleanup()
84 {
85
86 }
87
88 void tst_quick2::checkPlugin_data()
89 {
90 QTest::addColumn<QString>("source");
91
92 QTest::newRow("createChartView") << imports_1_1() + "ChartView{}";
93 QTest::newRow("XYPoint") << imports_1_1() + "XYPoint{}";
94 QTest::newRow("scatterSeries") << imports_1_1() + "ScatterSeries{}";
95 QTest::newRow("lineSeries") << imports_1_1() + "LineSeries{}";
96 QTest::newRow("splineSeries") << imports_1_1() + "SplineSeries{}";
97 QTest::newRow("areaSeries") << imports_1_1() + "AreaSeries{}";
98 QTest::newRow("barSeries") << imports_1_1() + "BarSeries{}";
99 QTest::newRow("stackedBarSeries") << imports_1_1() + "StackedBarSeries{}";
100 QTest::newRow("precentBarSeries") << imports_1_1() + "PercentBarSeries{}";
101 QTest::newRow("horizonatlBarSeries") << imports_1_1() + "HorizontalBarSeries{}";
102 QTest::newRow("horizonatlStackedBarSeries") << imports_1_1() + "HorizontalStackedBarSeries{}";
103 QTest::newRow("horizonatlstackedBarSeries") << imports_1_1() + "HorizontalPercentBarSeries{}";
104 QTest::newRow("pieSeries") << imports_1_1() + "PieSeries{}";
105 QTest::newRow("PieSlice") << imports_1_1() + "PieSlice{}";
106 QTest::newRow("BarSet") << imports_1_1() + "BarSet{}";
107 QTest::newRow("HXYModelMapper") << imports_1_1() + "HXYModelMapper{}";
108 QTest::newRow("VXYModelMapper") << imports_1_1() + "VXYModelMapper{}";
109 QTest::newRow("HPieModelMapper") << imports_1_1() + "HPieModelMapper{}";
110 QTest::newRow("HPieModelMapper") << imports_1_1() + "HPieModelMapper{}";
111 QTest::newRow("HBarModelMapper") << imports_1_1() + "HBarModelMapper{}";
112 QTest::newRow("VBarModelMapper") << imports_1_1() + "VBarModelMapper{}";
113 QTest::newRow("ValueAxis") << imports_1_1() + "ValueAxis{}";
114 #ifndef QT_ON_ARM
115 QTest::newRow("DateTimeAxis") << imports_1_1() + "DateTimeAxis{}";
116 #endif
117 QTest::newRow("CategoryAxis") << imports_1_1() + "CategoryAxis{}";
118 QTest::newRow("CategoryRange") << imports_1_1() + "CategoryRange{}";
119 QTest::newRow("BarCategoryAxis") << imports_1_1() + "BarCategoryAxis{}";
120
121 QTest::newRow("createPolarChartView") << imports_1_3() + "PolarChartView{}";
122 QTest::newRow("LogValueAxis") << imports_1_3() + "LogValueAxis{}";
123 }
124
125 void tst_quick2::checkPlugin()
126 {
127 QFETCH(QString, source);
128 QQmlEngine engine;
129 engine.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("qml")));
130 QQmlComponent component(&engine);
131 component.setData(source.toLatin1(), QUrl());
132 QVERIFY2(!component.isError(), qPrintable(componentErrors(&component)));
133 TRY_COMPARE(component.status(), QQmlComponent::Ready);
134 QObject *obj = component.create();
135 QVERIFY(obj != 0);
136 delete obj;
137 }
138
139 QTEST_MAIN(tst_quick2)
140
141 #include "tst_quick2.moc"
142
@@ -1,50 +1,54
1 !include( ../tests.pri ) {
1 !include( ../tests.pri ) {
2 error( "Couldn't find the tests.pri file!" )
2 error( "Couldn't find the tests.pri file!" )
3 }
3 }
4
4
5 TEMPLATE = subdirs
5 TEMPLATE = subdirs
6 SUBDIRS += \
6 SUBDIRS += \
7 qchartview \
7 qchartview \
8 qchart \
8 qchart \
9 qlineseries \
9 qlineseries \
10 qbarset \
10 qbarset \
11 qbarseries \
11 qbarseries \
12 qstackedbarseries \
12 qstackedbarseries \
13 qpercentbarseries \
13 qpercentbarseries \
14 qpieslice qpieseries \
14 qpieslice qpieseries \
15 qpiemodelmapper \
15 qpiemodelmapper \
16 qsplineseries \
16 qsplineseries \
17 qscatterseries \
17 qscatterseries \
18 qxymodelmapper \
18 qxymodelmapper \
19 qbarmodelmapper \
19 qbarmodelmapper \
20 qhorizontalbarseries \
20 qhorizontalbarseries \
21 qhorizontalstackedbarseries \
21 qhorizontalstackedbarseries \
22 qhorizontalpercentbarseries \
22 qhorizontalpercentbarseries \
23 qvalueaxis \
23 qvalueaxis \
24 qlogvalueaxis \
24 qlogvalueaxis \
25 qcategoryaxis \
25 qcategoryaxis \
26 qbarcategoryaxis \
26 qbarcategoryaxis \
27 domain \
27 domain \
28 chartdataset \
28 chartdataset \
29 qlegend
29 qlegend
30
30
31 contains(QT_VERSION, ^4\\.[0-7]\\.[0-3]\\s*$) | contains(QT_VERSION, ^4\\.[0-6]\\..*) {
31 contains(QT_VERSION, ^4\\.[0-7]\\.[0-3]\\s*$) | contains(QT_VERSION, ^4\\.[0-6]\\..*) {
32 warning("QtCommercial.Charts QML API requires at least Qt 4.7.4. You are using $${QT_VERSION} so the QML API is disabled.")
32 warning("QtCommercial.Charts QML API requires at least Qt 4.7.4. You are using $${QT_VERSION} so the QML API is disabled.")
33 } else {
33 } else {
34 SUBDIRS += qml
34 SUBDIRS += qml
35
35
36 # Check if QtQuickTest is installed
36 # Check if QtQuickTest is installed
37 exists($$(QTDIR)/mkspecs/features/qmltestcase.prf){
37 exists($$(QTDIR)/mkspecs/features/qmltestcase.prf){
38 SUBDIRS += qml-qtquicktest
38 SUBDIRS += qml-qtquicktest
39 } else {
39 } else {
40 warning("QtQuickTest not found; cannot build QML api unit tests")
40 warning("QtQuickTest not found; cannot build QML api unit tests")
41 }
41 }
42 }
42 }
43
43
44 !linux-arm*: {
44 !linux-arm*: {
45 SUBDIRS += \
45 SUBDIRS += \
46 qdatetimeaxis
46 qdatetimeaxis
47 }
47 }
48
48
49 contains(QT_VERSION, ^5\\..*\\..*$):qtHaveModule(quick) {
50 SUBDIRS += quick2
51 }
52
49
53
50
54
@@ -1,146 +1,147
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2013 Digia Plc
3 ** Copyright (C) 2013 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20 #include <QtTest/QtTest>
20 #include <QtTest/QtTest>
21 #include <QDeclarativeEngine>
21 #include <QDeclarativeEngine>
22 #include <QDeclarativeComponent>
22 #include <QDeclarativeComponent>
23 #include "tst_definitions.h"
23 #include "tst_definitions.h"
24
24
25 class tst_QML : public QObject
25 class tst_QML : public QObject
26 {
26 {
27 Q_OBJECT
27 Q_OBJECT
28
28
29 public slots:
29 public slots:
30 void initTestCase();
30 void initTestCase();
31 void cleanupTestCase();
31 void cleanupTestCase();
32 void init();
32 void init();
33 void cleanup();
33 void cleanup();
34 private slots:
34 private slots:
35 void checkPlugin_data();
35 void checkPlugin_data();
36 void checkPlugin();
36 void checkPlugin();
37 private:
37 private:
38 QString componentErrors(const QDeclarativeComponent* component) const;
38 QString componentErrors(const QDeclarativeComponent* component) const;
39 QString imports_1_1();
39 QString imports_1_1();
40 QString imports_1_3();
40 QString imports_1_3();
41
41
42 };
42 };
43
43
44 QString tst_QML::componentErrors(const QDeclarativeComponent* component) const
44 QString tst_QML::componentErrors(const QDeclarativeComponent* component) const
45 {
45 {
46 Q_ASSERT(component);
46 Q_ASSERT(component);
47
47
48 QStringList errors;
48 QStringList errors;
49
49
50 foreach (QDeclarativeError const& error, component->errors()) {
50 foreach (QDeclarativeError const& error, component->errors()) {
51 errors << error.toString();
51 errors << error.toString();
52 }
52 }
53
53
54 return errors.join("\n");
54 return errors.join("\n");
55 }
55 }
56
56
57 QString tst_QML::imports_1_1()
57 QString tst_QML::imports_1_1()
58 {
58 {
59 return "import QtQuick 1.0 \n"
59 return "import QtQuick 1.0 \n"
60 "import QtCommercial.Chart 1.1 \n";
60 "import QtCommercial.Chart 1.1 \n";
61 }
61 }
62
62
63 QString tst_QML::imports_1_3()
63 QString tst_QML::imports_1_3()
64 {
64 {
65 return "import QtQuick 1.0 \n"
65 return "import QtQuick 1.0 \n"
66 "import QtCommercial.Chart 1.3 \n";
66 "import QtCommercial.Chart 1.3 \n";
67 }
67 }
68
68
69
69
70 void tst_QML::initTestCase()
70 void tst_QML::initTestCase()
71 {
71 {
72 }
72 }
73
73
74 void tst_QML::cleanupTestCase()
74 void tst_QML::cleanupTestCase()
75 {
75 {
76 }
76 }
77
77
78 void tst_QML::init()
78 void tst_QML::init()
79 {
79 {
80
80
81 }
81 }
82
82
83 void tst_QML::cleanup()
83 void tst_QML::cleanup()
84 {
84 {
85
85
86 }
86 }
87
87
88 void tst_QML::checkPlugin_data()
88 void tst_QML::checkPlugin_data()
89 {
89 {
90 QTest::addColumn<QString>("source");
90 QTest::addColumn<QString>("source");
91
91
92 QTest::newRow("createChartView") << imports_1_1() + "ChartView{}";
92 QTest::newRow("createChartView") << imports_1_1() + "ChartView{}";
93 QTest::newRow("XYPoint") << imports_1_1() + "XYPoint{}";
93 QTest::newRow("XYPoint") << imports_1_1() + "XYPoint{}";
94 QTest::newRow("scatterSeries") << imports_1_1() + "ScatterSeries{}";
94 QTest::newRow("scatterSeries") << imports_1_1() + "ScatterSeries{}";
95 QTest::newRow("lineSeries") << imports_1_1() + "LineSeries{}";
95 QTest::newRow("lineSeries") << imports_1_1() + "LineSeries{}";
96 QTest::newRow("splineSeries") << imports_1_1() + "SplineSeries{}";
96 QTest::newRow("splineSeries") << imports_1_1() + "SplineSeries{}";
97 QTest::newRow("areaSeries") << imports_1_1() + "AreaSeries{}";
97 QTest::newRow("areaSeries") << imports_1_1() + "AreaSeries{}";
98 QTest::newRow("barSeries") << imports_1_1() + "BarSeries{}";
98 QTest::newRow("barSeries") << imports_1_1() + "BarSeries{}";
99 QTest::newRow("stackedBarSeries") << imports_1_1() + "StackedBarSeries{}";
99 QTest::newRow("stackedBarSeries") << imports_1_1() + "StackedBarSeries{}";
100 QTest::newRow("precentBarSeries") << imports_1_1() + "PercentBarSeries{}";
100 QTest::newRow("precentBarSeries") << imports_1_1() + "PercentBarSeries{}";
101 QTest::newRow("horizonatlBarSeries") << imports_1_1() + "HorizontalBarSeries{}";
101 QTest::newRow("horizonatlBarSeries") << imports_1_1() + "HorizontalBarSeries{}";
102 QTest::newRow("horizonatlStackedBarSeries") << imports_1_1() + "HorizontalStackedBarSeries{}";
102 QTest::newRow("horizonatlStackedBarSeries") << imports_1_1() + "HorizontalStackedBarSeries{}";
103 QTest::newRow("horizonatlstackedBarSeries") << imports_1_1() + "HorizontalPercentBarSeries{}";
103 QTest::newRow("horizonatlstackedBarSeries") << imports_1_1() + "HorizontalPercentBarSeries{}";
104 QTest::newRow("pieSeries") << imports_1_1() + "PieSeries{}";
104 QTest::newRow("pieSeries") << imports_1_1() + "PieSeries{}";
105 QTest::newRow("PieSlice") << imports_1_1() + "PieSlice{}";
105 QTest::newRow("PieSlice") << imports_1_1() + "PieSlice{}";
106 QTest::newRow("BarSet") << imports_1_1() + "BarSet{}";
106 QTest::newRow("BarSet") << imports_1_1() + "BarSet{}";
107 QTest::newRow("HXYModelMapper") << imports_1_1() + "HXYModelMapper{}";
107 QTest::newRow("HXYModelMapper") << imports_1_1() + "HXYModelMapper{}";
108 QTest::newRow("VXYModelMapper") << imports_1_1() + "VXYModelMapper{}";
108 QTest::newRow("VXYModelMapper") << imports_1_1() + "VXYModelMapper{}";
109 QTest::newRow("HPieModelMapper") << imports_1_1() + "HPieModelMapper{}";
109 QTest::newRow("HPieModelMapper") << imports_1_1() + "HPieModelMapper{}";
110 QTest::newRow("HPieModelMapper") << imports_1_1() + "HPieModelMapper{}";
110 QTest::newRow("HPieModelMapper") << imports_1_1() + "HPieModelMapper{}";
111 QTest::newRow("HBarModelMapper") << imports_1_1() + "HBarModelMapper{}";
111 QTest::newRow("HBarModelMapper") << imports_1_1() + "HBarModelMapper{}";
112 QTest::newRow("VBarModelMapper") << imports_1_1() + "VBarModelMapper{}";
112 QTest::newRow("VBarModelMapper") << imports_1_1() + "VBarModelMapper{}";
113 QTest::newRow("ValueAxis") << imports_1_1() + "ValueAxis{}";
113 QTest::newRow("ValueAxis") << imports_1_1() + "ValueAxis{}";
114 #ifndef QT_ON_ARM
114 #ifndef QT_ON_ARM
115 QTest::newRow("DateTimeAxis") << imports_1_1() + "DateTimeAxis{}";
115 QTest::newRow("DateTimeAxis") << imports_1_1() + "DateTimeAxis{}";
116 #endif
116 #endif
117 QTest::newRow("CategoryAxis") << imports_1_1() + "CategoryAxis{}";
117 QTest::newRow("CategoryAxis") << imports_1_1() + "CategoryAxis{}";
118 QTest::newRow("CategoryRange") << imports_1_1() + "CategoryRange{}";
118 QTest::newRow("CategoryRange") << imports_1_1() + "CategoryRange{}";
119 QTest::newRow("BarCategoryAxis") << imports_1_1() + "BarCategoryAxis{}";
119 QTest::newRow("BarCategoryAxis") << imports_1_1() + "BarCategoryAxis{}";
120
120
121 QTest::newRow("createPolarChartView") << imports_1_3() + "PolarChartView{}";
121 QTest::newRow("createPolarChartView") << imports_1_3() + "PolarChartView{}";
122 //QTest::newRow("LogValueAxis") << imports_1_3() + "LogValueAxis{}";
122 QTest::newRow("LogValueAxis") << imports_1_3() + "LogValueAxis{}";
123 }
123 }
124
124
125 void tst_QML::checkPlugin()
125 void tst_QML::checkPlugin()
126 {
126 {
127 QFETCH(QString, source);
127 QFETCH(QString, source);
128 QDeclarativeEngine engine;
128 QDeclarativeEngine engine;
129 engine.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), QLatin1String("imports")));
129 QDeclarativeComponent component(&engine);
130 QDeclarativeComponent component(&engine);
130 component.setData(source.toLatin1(), QUrl());
131 component.setData(source.toLatin1(), QUrl());
131 QVERIFY2(!component.isError(), qPrintable(componentErrors(&component)));
132 QVERIFY2(!component.isError(), qPrintable(componentErrors(&component)));
132 TRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
133 TRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
133 QObject *obj = component.create();
134 QObject *obj = component.create();
134 QVERIFY(obj != 0);
135 QVERIFY(obj != 0);
135
136
136 //
137 //
137 //TODO:
138 //TODO:
138 // QCOMPARE(obj->property("something").toInt(), 0);
139 // QCOMPARE(obj->property("something").toInt(), 0);
139
140
140 delete obj;
141 delete obj;
141 }
142 }
142
143
143 QTEST_MAIN(tst_QML)
144 QTEST_MAIN(tst_QML)
144
145
145 #include "tst_qml.moc"
146 #include "tst_qml.moc"
146
147
General Comments 0
You need to be logged in to leave comments. Login now