@@ -0,0 +1,4 | |||||
|
1 | !include( ../auto.pri ) { | |||
|
2 | error( "Couldn't find the auto.pri file!" ) | |||
|
3 | } | |||
|
4 | SOURCES += tst_qlegend.cpp |
@@ -0,0 +1,224 | |||||
|
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 | ||||
|
21 | #include <QtTest/QtTest> | |||
|
22 | #include <qchartview.h> | |||
|
23 | #include <qlegend.h> | |||
|
24 | #include <qpieseries.h> | |||
|
25 | #include <qpielegendmarker.h> | |||
|
26 | #include <qareaseries.h> | |||
|
27 | #include <qarealegendmarker.h> | |||
|
28 | #include <qlineseries.h> | |||
|
29 | #include <qxylegendmarker.h> | |||
|
30 | #include <qbarseries.h> | |||
|
31 | #include <qbarset.h> | |||
|
32 | #include <qbarlegendmarker.h> | |||
|
33 | ||||
|
34 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
35 | ||||
|
36 | class tst_QLegend : public QObject | |||
|
37 | { | |||
|
38 | Q_OBJECT | |||
|
39 | ||||
|
40 | public slots: | |||
|
41 | void initTestCase(); | |||
|
42 | void cleanupTestCase(); | |||
|
43 | void init(); | |||
|
44 | void cleanup(); | |||
|
45 | ||||
|
46 | private slots: | |||
|
47 | void qlegend(); | |||
|
48 | void qpieLegendMarker(); | |||
|
49 | void qareaLegendMarker(); | |||
|
50 | void qxyLegendMarker(); | |||
|
51 | void qbarLegendMarker(); | |||
|
52 | ||||
|
53 | private: | |||
|
54 | ||||
|
55 | QChart *m_chart; | |||
|
56 | ||||
|
57 | }; | |||
|
58 | ||||
|
59 | void tst_QLegend::initTestCase() | |||
|
60 | { | |||
|
61 | } | |||
|
62 | ||||
|
63 | void tst_QLegend::cleanupTestCase() | |||
|
64 | { | |||
|
65 | } | |||
|
66 | ||||
|
67 | void tst_QLegend::init() | |||
|
68 | { | |||
|
69 | m_chart = new QChart(); | |||
|
70 | } | |||
|
71 | ||||
|
72 | void tst_QLegend::cleanup() | |||
|
73 | { | |||
|
74 | delete m_chart; | |||
|
75 | m_chart = 0; | |||
|
76 | } | |||
|
77 | ||||
|
78 | void tst_QLegend::qlegend() | |||
|
79 | { | |||
|
80 | QVERIFY(m_chart); | |||
|
81 | ||||
|
82 | QLegend *legend = m_chart->legend(); | |||
|
83 | QVERIFY(legend); | |||
|
84 | ||||
|
85 | QList<QLegendMarker*> markers = legend->markers(); | |||
|
86 | QVERIFY(markers.count() == 0); | |||
|
87 | } | |||
|
88 | ||||
|
89 | void tst_QLegend::qpieLegendMarker() | |||
|
90 | { | |||
|
91 | QVERIFY(m_chart); | |||
|
92 | QLegend *legend = m_chart->legend(); | |||
|
93 | ||||
|
94 | QPieSeries *series = new QPieSeries(); | |||
|
95 | QPieSlice *s1 = new QPieSlice(QString("s1"), 111.0); | |||
|
96 | series->append(s1); | |||
|
97 | m_chart->addSeries(series); | |||
|
98 | ||||
|
99 | // Should have one marker | |||
|
100 | QList<QLegendMarker*> markers = legend->markers(); | |||
|
101 | QVERIFY(markers.count() == 1); | |||
|
102 | QLegendMarker *m = markers.at(0); | |||
|
103 | ||||
|
104 | // Should be piemarker | |||
|
105 | QVERIFY(m->type() == QLegendMarker::LegendMarkerTypePie); | |||
|
106 | ||||
|
107 | // Related series and slice must match | |||
|
108 | QPieLegendMarker *pm = qobject_cast<QPieLegendMarker *> (m); | |||
|
109 | QVERIFY(pm); | |||
|
110 | QVERIFY(pm->series() == series); | |||
|
111 | QVERIFY(pm->slice() == s1); | |||
|
112 | ||||
|
113 | // Add another slice | |||
|
114 | QPieSlice *s2 = new QPieSlice(QString("s2"), 111.0); | |||
|
115 | series->append(s2); | |||
|
116 | ||||
|
117 | markers = legend->markers(); | |||
|
118 | QVERIFY(markers.count() == 2); | |||
|
119 | m = markers.at(1); | |||
|
120 | ||||
|
121 | QVERIFY(m->type() == QLegendMarker::LegendMarkerTypePie); | |||
|
122 | ||||
|
123 | // Related series and slice must match | |||
|
124 | pm = qobject_cast<QPieLegendMarker *> (m); | |||
|
125 | QVERIFY(pm); | |||
|
126 | QVERIFY(pm->series() == series); | |||
|
127 | QVERIFY(pm->slice() == s2); | |||
|
128 | } | |||
|
129 | ||||
|
130 | void tst_QLegend::qareaLegendMarker() | |||
|
131 | { | |||
|
132 | QVERIFY(m_chart); | |||
|
133 | QLegend *legend = m_chart->legend(); | |||
|
134 | QAreaSeries *series = new QAreaSeries(); | |||
|
135 | ||||
|
136 | QLineSeries *upper = new QLineSeries(); | |||
|
137 | QLineSeries *lower = new QLineSeries(); | |||
|
138 | ||||
|
139 | upper->append(1,1); | |||
|
140 | lower->append(1,0); | |||
|
141 | ||||
|
142 | series->setUpperSeries(upper); | |||
|
143 | series->setLowerSeries(lower); | |||
|
144 | ||||
|
145 | m_chart->addSeries(series); | |||
|
146 | ||||
|
147 | // Should have one marker | |||
|
148 | QList<QLegendMarker *> markers = legend->markers(); | |||
|
149 | QVERIFY(markers.count() == 1); | |||
|
150 | QLegendMarker *m = markers.at(0); | |||
|
151 | ||||
|
152 | QVERIFY(m->series() == series); | |||
|
153 | QVERIFY(m->type() == QLegendMarker::LegendMarkerTypeArea); | |||
|
154 | ||||
|
155 | QAreaLegendMarker *pm = qobject_cast<QAreaLegendMarker *> (m); | |||
|
156 | QVERIFY(pm); | |||
|
157 | QVERIFY(pm->series() == series); | |||
|
158 | } | |||
|
159 | ||||
|
160 | void tst_QLegend::qxyLegendMarker() | |||
|
161 | { | |||
|
162 | QVERIFY(m_chart); | |||
|
163 | QLegend *legend = m_chart->legend(); | |||
|
164 | ||||
|
165 | QLineSeries *series = new QLineSeries(); | |||
|
166 | m_chart->addSeries(series); | |||
|
167 | ||||
|
168 | // Should have one marker | |||
|
169 | QList<QLegendMarker *> markers = legend->markers(); | |||
|
170 | QVERIFY(markers.count() == 1); | |||
|
171 | QLegendMarker *m = markers.at(0); | |||
|
172 | ||||
|
173 | QVERIFY(m->series() == series); | |||
|
174 | QVERIFY(m->type() == QLegendMarker::LegendMarkerTypeXY); | |||
|
175 | ||||
|
176 | QXYLegendMarker *pm = qobject_cast<QXYLegendMarker *> (m); | |||
|
177 | QVERIFY(pm); | |||
|
178 | QVERIFY(pm->series() == series); | |||
|
179 | } | |||
|
180 | ||||
|
181 | void tst_QLegend::qbarLegendMarker() | |||
|
182 | { | |||
|
183 | QVERIFY(m_chart); | |||
|
184 | QLegend *legend = m_chart->legend(); | |||
|
185 | ||||
|
186 | QBarSeries *series = new QBarSeries(); | |||
|
187 | QBarSet *set0 = new QBarSet(QString("set0")); | |||
|
188 | series->append(set0); | |||
|
189 | m_chart->addSeries(series); | |||
|
190 | ||||
|
191 | // Should have one marker | |||
|
192 | QList<QLegendMarker *> markers = legend->markers(); | |||
|
193 | QVERIFY(markers.count() == 1); | |||
|
194 | QLegendMarker *m = markers.at(0); | |||
|
195 | ||||
|
196 | QVERIFY(m->series() == series); | |||
|
197 | QVERIFY(m->type() == QLegendMarker::LegendMarkerTypeBar); | |||
|
198 | ||||
|
199 | QBarLegendMarker *pm = qobject_cast<QBarLegendMarker *> (m); | |||
|
200 | QVERIFY(pm); | |||
|
201 | QVERIFY(pm->series() == series); | |||
|
202 | QVERIFY(pm->barset() == set0); | |||
|
203 | ||||
|
204 | // Add another barset | |||
|
205 | QBarSet *set1 = new QBarSet(QString("set0")); | |||
|
206 | series->append(set1); | |||
|
207 | ||||
|
208 | markers = legend->markers(); | |||
|
209 | QVERIFY(markers.count() == 2); | |||
|
210 | m = markers.at(1); | |||
|
211 | ||||
|
212 | QVERIFY(m->series() == series); | |||
|
213 | QVERIFY(m->type() == QLegendMarker::LegendMarkerTypeBar); | |||
|
214 | ||||
|
215 | pm = qobject_cast<QBarLegendMarker *> (m); | |||
|
216 | QVERIFY(pm); | |||
|
217 | QVERIFY(pm->series() == series); | |||
|
218 | QVERIFY(pm->barset() == set1); | |||
|
219 | } | |||
|
220 | ||||
|
221 | QTEST_MAIN(tst_QLegend) | |||
|
222 | ||||
|
223 | #include "tst_qlegend.moc" | |||
|
224 |
@@ -1,48 +1,49 | |||||
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 | qcategoryaxis \ |
|
24 | qcategoryaxis \ | |
25 | qbarcategoryaxis \ |
|
25 | qbarcategoryaxis \ | |
26 | domain \ |
|
26 | domain \ | |
27 | chartdataset |
|
27 | chartdataset \ | |
|
28 | qlegend | |||
28 |
|
29 | |||
29 | contains(QT_VERSION, ^4\\.[0-7]\\.[0-3]\\s*$) | contains(QT_VERSION, ^4\\.[0-6]\\..*) { |
|
30 | contains(QT_VERSION, ^4\\.[0-7]\\.[0-3]\\s*$) | contains(QT_VERSION, ^4\\.[0-6]\\..*) { | |
30 | warning("QtCommercial.Charts QML API requires at least Qt 4.7.4. You are using $${QT_VERSION} so the QML API is disabled.") |
|
31 | warning("QtCommercial.Charts QML API requires at least Qt 4.7.4. You are using $${QT_VERSION} so the QML API is disabled.") | |
31 | } else { |
|
32 | } else { | |
32 | SUBDIRS += qml |
|
33 | SUBDIRS += qml | |
33 |
|
34 | |||
34 | # Check if QtQuickTest is installed |
|
35 | # Check if QtQuickTest is installed | |
35 | exists($$(QTDIR)/lib/QtQuickTest.lib) { |
|
36 | exists($$(QTDIR)/lib/QtQuickTest.lib) { | |
36 | SUBDIRS += qml-qtquicktest |
|
37 | SUBDIRS += qml-qtquicktest | |
37 | } else { |
|
38 | } else { | |
38 | warning("QtQuickTest not found; cannot build QML api unit tests") |
|
39 | warning("QtQuickTest not found; cannot build QML api unit tests") | |
39 | } |
|
40 | } | |
40 | } |
|
41 | } | |
41 |
|
42 | |||
42 | !linux-arm*: { |
|
43 | !linux-arm*: { | |
43 | SUBDIRS += \ |
|
44 | SUBDIRS += \ | |
44 | qdatetimeaxis |
|
45 | qdatetimeaxis | |
45 | } |
|
46 | } | |
46 |
|
47 | |||
47 |
|
48 | |||
48 |
|
49 |
General Comments 0
You need to be logged in to leave comments.
Login now