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