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