@@ -1,120 +1,136 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 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(); |
|
39 | QString imports(); | |
40 |
|
40 | |||
41 | }; |
|
41 | }; | |
42 |
|
42 | |||
43 | QString tst_QML::componentErrors(const QDeclarativeComponent* component) const |
|
43 | QString tst_QML::componentErrors(const QDeclarativeComponent* component) const | |
44 | { |
|
44 | { | |
45 | Q_ASSERT(component); |
|
45 | Q_ASSERT(component); | |
46 |
|
46 | |||
47 | QStringList errors; |
|
47 | QStringList errors; | |
48 |
|
48 | |||
49 | foreach (QDeclarativeError const& error, component->errors()) { |
|
49 | foreach (QDeclarativeError const& error, component->errors()) { | |
50 | errors << error.toString(); |
|
50 | errors << error.toString(); | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | return errors.join("\n"); |
|
53 | return errors.join("\n"); | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 | QString tst_QML::imports() |
|
56 | QString tst_QML::imports() | |
57 | { |
|
57 | { | |
58 | return "import QtQuick 1.0 \n" |
|
58 | return "import QtQuick 1.0 \n" | |
59 | "import QtCommercial.Chart 1.1 \n"; |
|
59 | "import QtCommercial.Chart 1.1 \n"; | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 |
|
62 | |||
63 | void tst_QML::initTestCase() |
|
63 | void tst_QML::initTestCase() | |
64 | { |
|
64 | { | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | void tst_QML::cleanupTestCase() |
|
67 | void tst_QML::cleanupTestCase() | |
68 | { |
|
68 | { | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | void tst_QML::init() |
|
71 | void tst_QML::init() | |
72 | { |
|
72 | { | |
73 |
|
73 | |||
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | void tst_QML::cleanup() |
|
76 | void tst_QML::cleanup() | |
77 | { |
|
77 | { | |
78 |
|
78 | |||
79 | } |
|
79 | } | |
80 |
|
80 | |||
81 | void tst_QML::checkPlugin_data() |
|
81 | void tst_QML::checkPlugin_data() | |
82 | { |
|
82 | { | |
83 | QTest::addColumn<QString>("source"); |
|
83 | QTest::addColumn<QString>("source"); | |
|
84 | ||||
84 | QTest::newRow("createChartView") << imports() + "ChartView{}"; |
|
85 | QTest::newRow("createChartView") << imports() + "ChartView{}"; | |
|
86 | QTest::newRow("XYPoint") << imports() + "XYPoint{}"; | |||
|
87 | QTest::newRow("scatterSeries") << imports() + "ScatterSeries{}"; | |||
85 | QTest::newRow("lineSeries") << imports() + "LineSeries{}"; |
|
88 | QTest::newRow("lineSeries") << imports() + "LineSeries{}"; | |
86 | QTest::newRow("splineSeries") << imports() + "SplineSeries{}"; |
|
89 | QTest::newRow("splineSeries") << imports() + "SplineSeries{}"; | |
87 | QTest::newRow("scatterSeries") << imports() + "ScatterSeries{}"; |
|
|||
88 | QTest::newRow("areaSeries") << imports() + "AreaSeries{}"; |
|
90 | QTest::newRow("areaSeries") << imports() + "AreaSeries{}"; | |
89 | QTest::newRow("barSeries") << imports() + "BarSeries{}"; |
|
91 | QTest::newRow("barSeries") << imports() + "BarSeries{}"; | |
90 | QTest::newRow("stackedBarSeries") << imports() + "StackedBarSeries{}"; |
|
92 | QTest::newRow("stackedBarSeries") << imports() + "StackedBarSeries{}"; | |
91 | QTest::newRow("precentBarSeries") << imports() + "PercentBarSeries{}"; |
|
93 | QTest::newRow("precentBarSeries") << imports() + "PercentBarSeries{}"; | |
92 | QTest::newRow("horizonatlBarSeries") << imports() + "HorizontalBarSeries{}"; |
|
94 | QTest::newRow("horizonatlBarSeries") << imports() + "HorizontalBarSeries{}"; | |
93 | QTest::newRow("horizonatlStackedBarSeries") << imports() + "HorizontalStackedBarSeries{}"; |
|
95 | QTest::newRow("horizonatlStackedBarSeries") << imports() + "HorizontalStackedBarSeries{}"; | |
94 | QTest::newRow("horizonatlstackedBarSeries") << imports() + "HorizontalPercentBarSeries{}"; |
|
96 | QTest::newRow("horizonatlstackedBarSeries") << imports() + "HorizontalPercentBarSeries{}"; | |
95 | QTest::newRow("pieSeries") << imports() + "PieSeries{}"; |
|
97 | QTest::newRow("pieSeries") << imports() + "PieSeries{}"; | |
|
98 | QTest::newRow("PieSlice") << imports() + "PieSlice{}"; | |||
|
99 | QTest::newRow("BarSet") << imports() + "BarSet{}"; | |||
|
100 | QTest::newRow("HXYModelMapper") << imports() + "HXYModelMapper{}"; | |||
|
101 | QTest::newRow("VXYModelMapper") << imports() + "VXYModelMapper{}"; | |||
|
102 | QTest::newRow("HPieModelMapper") << imports() + "HPieModelMapper{}"; | |||
|
103 | QTest::newRow("HPieModelMapper") << imports() + "HPieModelMapper{}"; | |||
|
104 | QTest::newRow("HBarModelMapper") << imports() + "HBarModelMapper{}"; | |||
|
105 | QTest::newRow("VBarModelMapper") << imports() + "VBarModelMapper{}"; | |||
|
106 | QTest::newRow("ValueAxis") << imports() + "ValueAxis{}"; | |||
|
107 | #ifndef QT_ON_ARM | |||
|
108 | QTest::newRow("DateTimeAxis") << imports() + "DateTimeAxis{}"; | |||
|
109 | #endif | |||
|
110 | QTest::newRow("CategoryAxis") << imports() + "CategoryAxis{}"; | |||
|
111 | QTest::newRow("CategoryRange") << imports() + "CategoryRange{}"; | |||
|
112 | QTest::newRow("BarCategoryAxis") << imports() + "BarCategoryAxis{}"; | |||
96 | } |
|
113 | } | |
97 |
|
114 | |||
98 |
|
||||
99 | void tst_QML::checkPlugin() |
|
115 | void tst_QML::checkPlugin() | |
100 | { |
|
116 | { | |
101 | QFETCH(QString, source); |
|
117 | QFETCH(QString, source); | |
102 | QDeclarativeEngine engine; |
|
118 | QDeclarativeEngine engine; | |
103 | QDeclarativeComponent component(&engine); |
|
119 | QDeclarativeComponent component(&engine); | |
104 | component.setData(source.toLatin1(), QUrl()); |
|
120 | component.setData(source.toLatin1(), QUrl()); | |
105 | QVERIFY2(!component.isError(), qPrintable(componentErrors(&component))); |
|
121 | QVERIFY2(!component.isError(), qPrintable(componentErrors(&component))); | |
106 | TRY_COMPARE(component.status(), QDeclarativeComponent::Ready); |
|
122 | TRY_COMPARE(component.status(), QDeclarativeComponent::Ready); | |
107 | QObject *obj = component.create(); |
|
123 | QObject *obj = component.create(); | |
108 | QVERIFY(obj != 0); |
|
124 | QVERIFY(obj != 0); | |
109 |
|
125 | |||
110 | // |
|
126 | // | |
111 | //TODO: |
|
127 | //TODO: | |
112 | // QCOMPARE(obj->property("something").toInt(), 0); |
|
128 | // QCOMPARE(obj->property("something").toInt(), 0); | |
113 |
|
129 | |||
114 | delete obj; |
|
130 | delete obj; | |
115 | } |
|
131 | } | |
116 |
|
132 | |||
117 | QTEST_MAIN(tst_QML) |
|
133 | QTEST_MAIN(tst_QML) | |
118 |
|
134 | |||
119 | #include "tst_qml.moc" |
|
135 | #include "tst_qml.moc" | |
120 |
|
136 |
General Comments 0
You need to be logged in to leave comments.
Login now