##// END OF EJS Templates
Qt5: declarative fix part4...
Marek Rosa -
r2055:b660f2141c18
parent child
Show More
@@ -1,49 +1,48
1 !include(config.pri) {
1 !include(config.pri) {
2 error('Missing config.pri')
2 error('Missing config.pri')
3 }
3 }
4
4
5 TEMPLATE = subdirs
5 TEMPLATE = subdirs
6 SUBDIRS = src plugins demos examples
6 SUBDIRS = src plugins demos examples tests
7 # tests
8
7
9 development_build: message('Development build')
8 development_build: message('Development build')
10
9
11 CONFIG += ordered
10 CONFIG += ordered
12 QMAKE_CXXFLAGS += -g -Wall
11 QMAKE_CXXFLAGS += -g -Wall
13 unix:QMAKE_DISTCLEAN += -r build bin include lib doc/html
12 unix:QMAKE_DISTCLEAN += -r build bin include lib doc/html
14 win32:QMAKE_DISTCLEAN += /Q /s build bin include lib doc\\html
13 win32:QMAKE_DISTCLEAN += /Q /s build bin include lib doc\\html
15
14
16 # install feature file
15 # install feature file
17 feature.path = $$[QT_INSTALL_DATA]/mkspecs/features
16 feature.path = $$[QT_INSTALL_DATA]/mkspecs/features
18 feature.files = $$PWD/features/qtcommercialchart.prf
17 feature.files = $$PWD/features/qtcommercialchart.prf
19 INSTALLS += feature
18 INSTALLS += feature
20
19
21 docs.target = docs
20 docs.target = docs
22 win32:{
21 win32:{
23 docs.commands = qdoc3 $$CHART_BUILD_DOC_DIR\\qcharts.qdocconf
22 docs.commands = qdoc3 $$CHART_BUILD_DOC_DIR\\qcharts.qdocconf
24 }else{
23 }else{
25 docs.commands = qdoc3 $$CHART_BUILD_DOC_DIR/qcharts.qdocconf
24 docs.commands = qdoc3 $$CHART_BUILD_DOC_DIR/qcharts.qdocconf
26 }
25 }
27 docs.depends = FORCE
26 docs.depends = FORCE
28 QMAKE_EXTRA_TARGETS += docs
27 QMAKE_EXTRA_TARGETS += docs
29
28
30 unix:coverage:{
29 unix:coverage:{
31 QMAKE_DISTCLEAN += -r ./coverage
30 QMAKE_DISTCLEAN += -r ./coverage
32 QMAKE_CLEAN += build/*.gcda build/*.gcno
31 QMAKE_CLEAN += build/*.gcda build/*.gcno
33 QMAKE_EXTRA_TARGETS += buildcoverage runcoverage gencoverage
32 QMAKE_EXTRA_TARGETS += buildcoverage runcoverage gencoverage
34
33
35 buildcoverage.target = build_coverage
34 buildcoverage.target = build_coverage
36 buildcoverage.depends = all
35 buildcoverage.depends = all
37 buildcoverage.commands = mkdir -p ./coverage; \
36 buildcoverage.commands = mkdir -p ./coverage; \
38 make -C src prepare_coverage;
37 make -C src prepare_coverage;
39
38
40 runcoverage.target = run_coverage
39 runcoverage.target = run_coverage
41 runcoverage.depends = buildcoverage
40 runcoverage.depends = buildcoverage
42 runcoverage.commands = for f in `ls ./bin/tst_*` ; do echo "processing \$\$f test..."; \$\$f >> unit.log; done ; exit 0;
41 runcoverage.commands = for f in `ls ./bin/tst_*` ; do echo "processing \$\$f test..."; \$\$f >> unit.log; done ; exit 0;
43
42
44 gencoverage.target = gen_coverage
43 gencoverage.target = gen_coverage
45 gencoverage.depends = runcoverage
44 gencoverage.depends = runcoverage
46 gencoverage.commands = make -C src gen_coverage; \
45 gencoverage.commands = make -C src gen_coverage; \
47 genhtml -o ./coverage ./coverage/coverage.info --prefix $$PWD
46 genhtml -o ./coverage ./coverage/coverage.info --prefix $$PWD
48 }
47 }
49
48
@@ -1,18 +1,18
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 greaterThan(QT_MAJOR_VERSION, 4) {
5 greaterThan(QT_MAJOR_VERSION, 4) {
6 QT += testlib
6 QT += testlib widgets
7 } else {
7 } else {
8 CONFIG += qtestlib
8 CONFIG += qtestlib
9 }
9 }
10 !contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_")
10 !contains(TARGET, ^tst_.*):TARGET = $$join(TARGET,,"tst_")
11
11
12 INCLUDEPATH += ../inc
12 INCLUDEPATH += ../inc
13 HEADERS += ../inc/tst_definitions.h
13 HEADERS += ../inc/tst_definitions.h
14
14
15 OBJECTS_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET
15 OBJECTS_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET
16 MOC_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET
16 MOC_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET
17 UI_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET
17 UI_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET
18 RCC_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET
18 RCC_DIR = $$CHART_BUILD_DIR/tests/auto/$$TARGET
@@ -1,644 +1,648
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 #ifndef BUILD_PRIVATE_UNIT_TESTS
20 #ifndef BUILD_PRIVATE_UNIT_TESTS
21 #include <QtTest/QtTest>
21 #include <QtTest/QtTest>
22
22
23 class tst_ChartDataSet: public QObject {
23 class tst_ChartDataSet: public QObject {
24
24
25 Q_OBJECT
25 Q_OBJECT
26
26
27 private Q_SLOTS:
27 private Q_SLOTS:
28 void skip();
28 void skip();
29
29
30 };
30 };
31
31
32 void tst_ChartDataSet::skip()
32 void tst_ChartDataSet::skip()
33 {
33 {
34 #ifdef QT5_QUICK_1
35 QSKIP("This test requires the debug version of library");
36 #else
34 QSKIP("This test requires the debug version of library", SkipAll);
37 QSKIP("This test requires the debug version of library", SkipAll);
38 #endif
35 }
39 }
36
40
37 QTEST_MAIN(tst_ChartDataSet)
41 QTEST_MAIN(tst_ChartDataSet)
38 #include "tst_chartdataset.moc"
42 #include "tst_chartdataset.moc"
39
43
40 #else
44 #else
41
45
42 #include <QtTest/QtTest>
46 #include <QtTest/QtTest>
43 #include <qabstractaxis.h>
47 #include <qabstractaxis.h>
44 #include <qvalueaxis.h>
48 #include <qvalueaxis.h>
45 #include <qbarcategoryaxis.h>
49 #include <qbarcategoryaxis.h>
46 #include <qlineseries.h>
50 #include <qlineseries.h>
47 #include <qareaseries.h>
51 #include <qareaseries.h>
48 #include <qscatterseries.h>
52 #include <qscatterseries.h>
49 #include <qsplineseries.h>
53 #include <qsplineseries.h>
50 #include <qpieseries.h>
54 #include <qpieseries.h>
51 #include <qbarseries.h>
55 #include <qbarseries.h>
52 #include <qpercentbarseries.h>
56 #include <qpercentbarseries.h>
53 #include <qstackedbarseries.h>
57 #include <qstackedbarseries.h>
54 #include <private/chartdataset_p.h>
58 #include <private/chartdataset_p.h>
55 #include <private/domain_p.h>
59 #include <private/domain_p.h>
56 #include <tst_definitions.h>
60 #include <tst_definitions.h>
57
61
58 QTCOMMERCIALCHART_USE_NAMESPACE
62 QTCOMMERCIALCHART_USE_NAMESPACE
59
63
60 Q_DECLARE_METATYPE(Domain *)
64 Q_DECLARE_METATYPE(Domain *)
61 Q_DECLARE_METATYPE(QAbstractAxis *)
65 Q_DECLARE_METATYPE(QAbstractAxis *)
62 Q_DECLARE_METATYPE(QAbstractSeries *)
66 Q_DECLARE_METATYPE(QAbstractSeries *)
63 Q_DECLARE_METATYPE(QList<QAbstractSeries *>)
67 Q_DECLARE_METATYPE(QList<QAbstractSeries *>)
64 Q_DECLARE_METATYPE(QList<QAbstractAxis *>)
68 Q_DECLARE_METATYPE(QList<QAbstractAxis *>)
65 Q_DECLARE_METATYPE(QLineSeries *)
69 Q_DECLARE_METATYPE(QLineSeries *)
66
70
67 class tst_ChartDataSet: public QObject {
71 class tst_ChartDataSet: public QObject {
68
72
69 Q_OBJECT
73 Q_OBJECT
70
74
71 public Q_SLOTS:
75 public Q_SLOTS:
72 void initTestCase();
76 void initTestCase();
73 void cleanupTestCase();
77 void cleanupTestCase();
74 void init();
78 void init();
75 void cleanup();
79 void cleanup();
76
80
77 private Q_SLOTS:
81 private Q_SLOTS:
78 void chartdataset_data();
82 void chartdataset_data();
79 void chartdataset();
83 void chartdataset();
80 void addSeries_data();
84 void addSeries_data();
81 void addSeries();
85 void addSeries();
82 void setAxisX_data();
86 void setAxisX_data();
83 void setAxisX();
87 void setAxisX();
84 void setAxisY_data();
88 void setAxisY_data();
85 void setAxisY();
89 void setAxisY();
86 void removeSeries_data();
90 void removeSeries_data();
87 void removeSeries();
91 void removeSeries();
88 void removeAllSeries_data();
92 void removeAllSeries_data();
89 void removeAllSeries();
93 void removeAllSeries();
90 void seriesCount_data();
94 void seriesCount_data();
91 void seriesCount();
95 void seriesCount();
92 void seriesIndex_data();
96 void seriesIndex_data();
93 void seriesIndex();
97 void seriesIndex();
94 void domain_data();
98 void domain_data();
95 void domain();
99 void domain();
96 void zoomInDomain_data();
100 void zoomInDomain_data();
97 void zoomInDomain();
101 void zoomInDomain();
98 void zoomOutDomain_data();
102 void zoomOutDomain_data();
99 void zoomOutDomain();
103 void zoomOutDomain();
100 void scrollDomain_data();
104 void scrollDomain_data();
101 void scrollDomain();
105 void scrollDomain();
102
106
103 private:
107 private:
104 ChartDataSet* m_dataset;
108 ChartDataSet* m_dataset;
105 };
109 };
106
110
107 void tst_ChartDataSet::initTestCase()
111 void tst_ChartDataSet::initTestCase()
108 {
112 {
109 qRegisterMetaType<Domain*>();
113 qRegisterMetaType<Domain*>();
110 qRegisterMetaType<QAbstractAxis*>();
114 qRegisterMetaType<QAbstractAxis*>();
111 qRegisterMetaType<QAbstractSeries*>();
115 qRegisterMetaType<QAbstractSeries*>();
112 }
116 }
113
117
114 void tst_ChartDataSet::cleanupTestCase()
118 void tst_ChartDataSet::cleanupTestCase()
115 {
119 {
116 }
120 }
117
121
118 void tst_ChartDataSet::init()
122 void tst_ChartDataSet::init()
119 {
123 {
120 m_dataset = new ChartDataSet();
124 m_dataset = new ChartDataSet();
121 }
125 }
122
126
123
127
124 void tst_ChartDataSet::cleanup()
128 void tst_ChartDataSet::cleanup()
125 {
129 {
126 QList<QAbstractSeries*> series = m_dataset->series();
130 QList<QAbstractSeries*> series = m_dataset->series();
127 foreach(QAbstractSeries* serie, series)
131 foreach(QAbstractSeries* serie, series)
128 {
132 {
129 m_dataset->removeSeries(serie);
133 m_dataset->removeSeries(serie);
130 }
134 }
131 }
135 }
132
136
133 void tst_ChartDataSet::chartdataset_data()
137 void tst_ChartDataSet::chartdataset_data()
134 {
138 {
135 }
139 }
136
140
137 void tst_ChartDataSet::chartdataset()
141 void tst_ChartDataSet::chartdataset()
138 {
142 {
139 QVERIFY(m_dataset->axisX(0) == 0);
143 QVERIFY(m_dataset->axisX(0) == 0);
140 QVERIFY(m_dataset->axisY(0) == 0);
144 QVERIFY(m_dataset->axisY(0) == 0);
141 QLineSeries* series = new QLineSeries(this);
145 QLineSeries* series = new QLineSeries(this);
142 QCOMPARE(m_dataset->seriesIndex(series),-1);
146 QCOMPARE(m_dataset->seriesIndex(series),-1);
143 QVERIFY(m_dataset->domain(series) == 0);
147 QVERIFY(m_dataset->domain(series) == 0);
144 QVERIFY(m_dataset->axisX(series) == 0);
148 QVERIFY(m_dataset->axisX(series) == 0);
145 QVERIFY(m_dataset->axisY(series) == 0);
149 QVERIFY(m_dataset->axisY(series) == 0);
146 m_dataset->createDefaultAxes();
150 m_dataset->createDefaultAxes();
147 }
151 }
148
152
149
153
150 void tst_ChartDataSet::addSeries_data()
154 void tst_ChartDataSet::addSeries_data()
151 {
155 {
152 QTest::addColumn<QAbstractSeries*>("series");
156 QTest::addColumn<QAbstractSeries*>("series");
153
157
154 QAbstractSeries* line = new QLineSeries(this);
158 QAbstractSeries* line = new QLineSeries(this);
155 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
159 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
156 QAbstractSeries* scatter = new QScatterSeries(this);
160 QAbstractSeries* scatter = new QScatterSeries(this);
157 QAbstractSeries* spline = new QSplineSeries(this);
161 QAbstractSeries* spline = new QSplineSeries(this);
158 QAbstractSeries* pie = new QPieSeries(this);
162 QAbstractSeries* pie = new QPieSeries(this);
159 QAbstractSeries* bar = new QBarSeries(this);
163 QAbstractSeries* bar = new QBarSeries(this);
160 QAbstractSeries* percent = new QPercentBarSeries(this);
164 QAbstractSeries* percent = new QPercentBarSeries(this);
161 QAbstractSeries* stacked = new QStackedBarSeries(this);
165 QAbstractSeries* stacked = new QStackedBarSeries(this);
162
166
163 QTest::newRow("line") << line;
167 QTest::newRow("line") << line;
164 QTest::newRow("area") << area;
168 QTest::newRow("area") << area;
165 QTest::newRow("scatter") << scatter;
169 QTest::newRow("scatter") << scatter;
166 QTest::newRow("spline") << spline;
170 QTest::newRow("spline") << spline;
167 QTest::newRow("pie") << pie;
171 QTest::newRow("pie") << pie;
168 QTest::newRow("bar") << bar;
172 QTest::newRow("bar") << bar;
169 QTest::newRow("percent") << percent;
173 QTest::newRow("percent") << percent;
170 QTest::newRow("stacked") << stacked;
174 QTest::newRow("stacked") << stacked;
171 }
175 }
172
176
173 void tst_ChartDataSet::addSeries()
177 void tst_ChartDataSet::addSeries()
174 {
178 {
175
179
176 QFETCH(QAbstractSeries*, series);
180 QFETCH(QAbstractSeries*, series);
177
181
178 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*, Domain *)));
182 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*, Domain *)));
179 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
183 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
180 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
184 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
181 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
185 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
182
186
183 m_dataset->addSeries(series);
187 m_dataset->addSeries(series);
184 m_dataset->createDefaultAxes();
188 m_dataset->createDefaultAxes();
185 if(series->type()==QAbstractSeries::SeriesTypePie){
189 if(series->type()==QAbstractSeries::SeriesTypePie){
186 TRY_COMPARE(spy0.count(), 0);
190 TRY_COMPARE(spy0.count(), 0);
187 }else{
191 }else{
188 TRY_COMPARE(spy0.count(), 2);
192 TRY_COMPARE(spy0.count(), 2);
189 }
193 }
190 TRY_COMPARE(spy1.count(), 0);
194 TRY_COMPARE(spy1.count(), 0);
191 TRY_COMPARE(spy2.count(), 1);
195 TRY_COMPARE(spy2.count(), 1);
192 TRY_COMPARE(spy3.count(), 0);
196 TRY_COMPARE(spy3.count(), 0);
193 }
197 }
194
198
195
199
196 void tst_ChartDataSet::setAxisX_data()
200 void tst_ChartDataSet::setAxisX_data()
197 {
201 {
198 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
202 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
199 QTest::addColumn<QList<QAbstractAxis*> >("axisList");
203 QTest::addColumn<QList<QAbstractAxis*> >("axisList");
200 QTest::addColumn<int>("axisCount");
204 QTest::addColumn<int>("axisCount");
201
205
202 QAbstractSeries* line = new QLineSeries(this);
206 QAbstractSeries* line = new QLineSeries(this);
203 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
207 QAbstractSeries* area = new QAreaSeries(static_cast<QLineSeries*>(line));
204 QAbstractSeries* scatter = new QScatterSeries(this);
208 QAbstractSeries* scatter = new QScatterSeries(this);
205 QAbstractSeries* spline = new QSplineSeries(this);
209 QAbstractSeries* spline = new QSplineSeries(this);
206 /*QAbstractSeries* pie = */new QPieSeries(this);
210 /*QAbstractSeries* pie = */new QPieSeries(this);
207 /*QAbstractSeries* bar = */new QBarSeries(this);
211 /*QAbstractSeries* bar = */new QBarSeries(this);
208 /*QAbstractSeries* percent = */new QPercentBarSeries(this);
212 /*QAbstractSeries* percent = */new QPercentBarSeries(this);
209 /*QAbstractSeries* stacked = */new QStackedBarSeries(this);
213 /*QAbstractSeries* stacked = */new QStackedBarSeries(this);
210
214
211 QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2")
215 QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2")
212 << (QList<QAbstractSeries*>() << line << spline << scatter)
216 << (QList<QAbstractSeries*>() << line << spline << scatter)
213 << (QList<QAbstractAxis*>() << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this)) << 3;
217 << (QList<QAbstractAxis*>() << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this)) << 3;
214
218
215 QTest::newRow("area: axis 0") << (QList<QAbstractSeries*>() << area)
219 QTest::newRow("area: axis 0") << (QList<QAbstractSeries*>() << area)
216 << (QList<QAbstractAxis*>() << new QValueAxis(this)) << 1;
220 << (QList<QAbstractAxis*>() << new QValueAxis(this)) << 1;
217
221
218 QList<QAbstractAxis*> axes0;
222 QList<QAbstractAxis*> axes0;
219 axes0 << new QValueAxis(this) << new QValueAxis(this);
223 axes0 << new QValueAxis(this) << new QValueAxis(this);
220 axes0 << axes0.last();
224 axes0 << axes0.last();
221 QTest::newRow("line,spline,scatter: axis 0 axis1 axis 1")
225 QTest::newRow("line,spline,scatter: axis 0 axis1 axis 1")
222 << (QList<QAbstractSeries*>() << line << spline << scatter)
226 << (QList<QAbstractSeries*>() << line << spline << scatter)
223 << axes0 << 2;
227 << axes0 << 2;
224 //TODO: add more test cases
228 //TODO: add more test cases
225 }
229 }
226
230
227 void tst_ChartDataSet::setAxisX()
231 void tst_ChartDataSet::setAxisX()
228 {
232 {
229 QFETCH(QList<QAbstractSeries*>, seriesList);
233 QFETCH(QList<QAbstractSeries*>, seriesList);
230 QFETCH(QList<QAbstractAxis*>, axisList);
234 QFETCH(QList<QAbstractAxis*>, axisList);
231 QFETCH(int, axisCount);
235 QFETCH(int, axisCount);
232
236
233 Q_ASSERT(seriesList.count() == axisList.count());
237 Q_ASSERT(seriesList.count() == axisList.count());
234
238
235 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *,Domain*)));
239 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *,Domain*)));
236 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
240 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
237 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*)));
241 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*)));
238 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
242 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
239
243
240 foreach(QAbstractSeries* series, seriesList){
244 foreach(QAbstractSeries* series, seriesList){
241 m_dataset->addSeries(series);
245 m_dataset->addSeries(series);
242 }
246 }
243
247
244 TRY_COMPARE(spy0.count(), 0);
248 TRY_COMPARE(spy0.count(), 0);
245 TRY_COMPARE(spy1.count(), 0);
249 TRY_COMPARE(spy1.count(), 0);
246 TRY_COMPARE(spy2.count(), seriesList.count());
250 TRY_COMPARE(spy2.count(), seriesList.count());
247 TRY_COMPARE(spy3.count(), 0);
251 TRY_COMPARE(spy3.count(), 0);
248
252
249 QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*)));
253 QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*)));
250 QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
254 QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
251 QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*)));
255 QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*)));
252 QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
256 QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
253
257
254 for(int i=0 ; i < seriesList.count(); i++){
258 for(int i=0 ; i < seriesList.count(); i++){
255 m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Horizontal);
259 m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Horizontal);
256 }
260 }
257
261
258 TRY_COMPARE(spy4.count(), axisCount);
262 TRY_COMPARE(spy4.count(), axisCount);
259 TRY_COMPARE(spy5.count(), 0);
263 TRY_COMPARE(spy5.count(), 0);
260 TRY_COMPARE(spy6.count(), 0);
264 TRY_COMPARE(spy6.count(), 0);
261 TRY_COMPARE(spy7.count(), 0);
265 TRY_COMPARE(spy7.count(), 0);
262
266
263 for(int i=0 ; i < seriesList.count(); i++){
267 for(int i=0 ; i < seriesList.count(); i++){
264 QVERIFY(m_dataset->axisX(seriesList.at(i)) == axisList.at(i));
268 QVERIFY(m_dataset->axisX(seriesList.at(i)) == axisList.at(i));
265 }
269 }
266 }
270 }
267
271
268 void tst_ChartDataSet::setAxisY_data()
272 void tst_ChartDataSet::setAxisY_data()
269 {
273 {
270 setAxisX_data();
274 setAxisX_data();
271 }
275 }
272
276
273 void tst_ChartDataSet::setAxisY()
277 void tst_ChartDataSet::setAxisY()
274 {
278 {
275 QFETCH(QList<QAbstractSeries*>, seriesList);
279 QFETCH(QList<QAbstractSeries*>, seriesList);
276 QFETCH(QList<QAbstractAxis*>, axisList);
280 QFETCH(QList<QAbstractAxis*>, axisList);
277 QFETCH(int, axisCount);
281 QFETCH(int, axisCount);
278
282
279 Q_ASSERT(seriesList.count() == axisList.count());
283 Q_ASSERT(seriesList.count() == axisList.count());
280
284
281 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*)));
285 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*)));
282 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
286 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
283 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*)));
287 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*)));
284 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
288 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
285
289
286 foreach(QAbstractSeries* series, seriesList){
290 foreach(QAbstractSeries* series, seriesList){
287 m_dataset->addSeries(series);
291 m_dataset->addSeries(series);
288 }
292 }
289
293
290 TRY_COMPARE(spy0.count(), 0);
294 TRY_COMPARE(spy0.count(), 0);
291 TRY_COMPARE(spy1.count(), 0);
295 TRY_COMPARE(spy1.count(), 0);
292 TRY_COMPARE(spy2.count(), seriesList.count());
296 TRY_COMPARE(spy2.count(), seriesList.count());
293 TRY_COMPARE(spy3.count(), 0);
297 TRY_COMPARE(spy3.count(), 0);
294
298
295 QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*)));
299 QSignalSpy spy4(m_dataset, SIGNAL(axisAdded(QAbstractAxis*,Domain*)));
296 QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
300 QSignalSpy spy5(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
297 QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*)));
301 QSignalSpy spy6(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *,Domain*)));
298 QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
302 QSignalSpy spy7(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
299
303
300 for(int i=0 ; i < seriesList.count(); i++){
304 for(int i=0 ; i < seriesList.count(); i++){
301 m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Vertical);
305 m_dataset->setAxis(seriesList.at(i),axisList.at(i),Qt::Vertical);
302 }
306 }
303
307
304 TRY_COMPARE(spy4.count(), axisCount);
308 TRY_COMPARE(spy4.count(), axisCount);
305 TRY_COMPARE(spy5.count(), 0);
309 TRY_COMPARE(spy5.count(), 0);
306 TRY_COMPARE(spy6.count(), 0);
310 TRY_COMPARE(spy6.count(), 0);
307 TRY_COMPARE(spy7.count(), 0);
311 TRY_COMPARE(spy7.count(), 0);
308
312
309 for(int i=0 ; i < seriesList.count(); i++){
313 for(int i=0 ; i < seriesList.count(); i++){
310 QVERIFY(m_dataset->axisY(seriesList.at(i)) == axisList.at(i));
314 QVERIFY(m_dataset->axisY(seriesList.at(i)) == axisList.at(i));
311 }
315 }
312 }
316 }
313
317
314 void tst_ChartDataSet::removeSeries_data()
318 void tst_ChartDataSet::removeSeries_data()
315 {
319 {
316 addSeries_data();
320 addSeries_data();
317 }
321 }
318
322
319 void tst_ChartDataSet::removeSeries()
323 void tst_ChartDataSet::removeSeries()
320 {
324 {
321 QFETCH(QAbstractSeries*, series);
325 QFETCH(QAbstractSeries*, series);
322
326
323 m_dataset->addSeries(series);
327 m_dataset->addSeries(series);
324 m_dataset->createDefaultAxes();
328 m_dataset->createDefaultAxes();
325
329
326 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*, Domain *)));
330 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*, Domain *)));
327 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
331 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*)));
328 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
332 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
329 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
333 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
330
334
331 m_dataset->removeSeries(series);
335 m_dataset->removeSeries(series);
332
336
333 TRY_COMPARE(spy0.count(), 0);
337 TRY_COMPARE(spy0.count(), 0);
334 if (series->type() == QAbstractSeries::SeriesTypePie) {
338 if (series->type() == QAbstractSeries::SeriesTypePie) {
335 TRY_COMPARE(spy1.count(), 0);
339 TRY_COMPARE(spy1.count(), 0);
336 }
340 }
337 else {
341 else {
338 TRY_COMPARE(spy1.count(), 2);
342 TRY_COMPARE(spy1.count(), 2);
339 }
343 }
340 TRY_COMPARE(spy2.count(), 0);
344 TRY_COMPARE(spy2.count(), 0);
341 TRY_COMPARE(spy3.count(), 1);
345 TRY_COMPARE(spy3.count(), 1);
342 }
346 }
343
347
344 void tst_ChartDataSet::removeAllSeries_data()
348 void tst_ChartDataSet::removeAllSeries_data()
345 {
349 {
346 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
350 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
347 QTest::addColumn<QList<QAbstractAxis*> >("axisList");
351 QTest::addColumn<QList<QAbstractAxis*> >("axisList");
348 QTest::addColumn<int>("axisCount");
352 QTest::addColumn<int>("axisCount");
349
353
350 QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2")
354 QTest::newRow("line,spline,scatter: axis 0 axis1 axis 2")
351 << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QSplineSeries(this)
355 << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QSplineSeries(this)
352 << new QScatterSeries(this))
356 << new QScatterSeries(this))
353 << (QList<QAbstractAxis*>() << new QValueAxis(this) << new QValueAxis(this)
357 << (QList<QAbstractAxis*>() << new QValueAxis(this) << new QValueAxis(this)
354 << new QValueAxis(this)) << 3;
358 << new QValueAxis(this)) << 3;
355 //TODO:
359 //TODO:
356 }
360 }
357
361
358 void tst_ChartDataSet::removeAllSeries()
362 void tst_ChartDataSet::removeAllSeries()
359 {
363 {
360 QFETCH(QList<QAbstractSeries*>, seriesList);
364 QFETCH(QList<QAbstractSeries*>, seriesList);
361 QFETCH(QList<QAbstractAxis*>, axisList);
365 QFETCH(QList<QAbstractAxis*>, axisList);
362 QFETCH(int, axisCount);
366 QFETCH(int, axisCount);
363
367
364 foreach(QAbstractSeries* series, seriesList) {
368 foreach(QAbstractSeries* series, seriesList) {
365 m_dataset->addSeries(series);
369 m_dataset->addSeries(series);
366 }
370 }
367
371
368 for (int i = 0; i < seriesList.count(); i++) {
372 for (int i = 0; i < seriesList.count(); i++) {
369 m_dataset->setAxis(seriesList.at(i), axisList.at(i),Qt::Horizontal);
373 m_dataset->setAxis(seriesList.at(i), axisList.at(i),Qt::Horizontal);
370 }
374 }
371
375
372 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *)));
376 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *)));
373 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
377 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
374 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
378 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
375 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
379 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
376
380
377 m_dataset->removeAllSeries();
381 m_dataset->removeAllSeries();
378
382
379 TRY_COMPARE(spy0.count(), 0);
383 TRY_COMPARE(spy0.count(), 0);
380 TRY_COMPARE(spy1.count(), axisCount);
384 TRY_COMPARE(spy1.count(), axisCount);
381 TRY_COMPARE(spy2.count(), 0);
385 TRY_COMPARE(spy2.count(), 0);
382 TRY_COMPARE(spy3.count(), seriesList.count());
386 TRY_COMPARE(spy3.count(), seriesList.count());
383 }
387 }
384
388
385
389
386 void tst_ChartDataSet::seriesCount_data()
390 void tst_ChartDataSet::seriesCount_data()
387 {
391 {
388 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
392 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
389 QTest::addColumn<int>("seriesCount");
393 QTest::addColumn<int>("seriesCount");
390
394
391 QTest::newRow("line,line, line, spline 3") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ) << 3;
395 QTest::newRow("line,line, line, spline 3") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) ) << 3;
392 QTest::newRow("scatter,scatter, line, line 2") << (QList<QAbstractSeries*>() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) ) << 2;
396 QTest::newRow("scatter,scatter, line, line 2") << (QList<QAbstractSeries*>() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) ) << 2;
393 }
397 }
394
398
395 void tst_ChartDataSet::seriesCount()
399 void tst_ChartDataSet::seriesCount()
396 {
400 {
397 QFETCH(QList<QAbstractSeries*>, seriesList);
401 QFETCH(QList<QAbstractSeries*>, seriesList);
398 QFETCH(int, seriesCount);
402 QFETCH(int, seriesCount);
399
403
400 foreach(QAbstractSeries* series, seriesList){
404 foreach(QAbstractSeries* series, seriesList){
401 m_dataset->addSeries(series);
405 m_dataset->addSeries(series);
402 }
406 }
403
407
404 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *)));
408 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *)));
405 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
409 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
406 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
410 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
407 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
411 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
408
412
409 QCOMPARE(m_dataset->seriesCount(seriesList.at(0)->type()),seriesCount);
413 QCOMPARE(m_dataset->seriesCount(seriesList.at(0)->type()),seriesCount);
410 TRY_COMPARE(spy0.count(), 0);
414 TRY_COMPARE(spy0.count(), 0);
411 TRY_COMPARE(spy1.count(), 0);
415 TRY_COMPARE(spy1.count(), 0);
412 TRY_COMPARE(spy2.count(), 0);
416 TRY_COMPARE(spy2.count(), 0);
413 TRY_COMPARE(spy3.count(), 0);
417 TRY_COMPARE(spy3.count(), 0);
414 }
418 }
415
419
416 void tst_ChartDataSet::seriesIndex_data()
420 void tst_ChartDataSet::seriesIndex_data()
417 {
421 {
418 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
422 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
419
423
420 QTest::newRow("line,line, line, spline") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) );
424 QTest::newRow("line,line, line, spline") << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) );
421 QTest::newRow("scatter,scatter, line, line") << (QList<QAbstractSeries*>() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) );
425 QTest::newRow("scatter,scatter, line, line") << (QList<QAbstractSeries*>() << new QScatterSeries(this) << new QScatterSeries(this) << new QLineSeries(this) << new QLineSeries(this) );
422 }
426 }
423
427
424 void tst_ChartDataSet::seriesIndex()
428 void tst_ChartDataSet::seriesIndex()
425 {
429 {
426
430
427 QFETCH(QList<QAbstractSeries*>, seriesList);
431 QFETCH(QList<QAbstractSeries*>, seriesList);
428
432
429 foreach(QAbstractSeries* series, seriesList) {
433 foreach(QAbstractSeries* series, seriesList) {
430 m_dataset->addSeries(series);
434 m_dataset->addSeries(series);
431 }
435 }
432
436
433 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *,Domain*)));
437 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *,Domain*)));
434 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
438 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
435 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*)));
439 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*,Domain*)));
436 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)));
440 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)));
437
441
438 for (int i = 0; i < seriesList.count(); i++) {
442 for (int i = 0; i < seriesList.count(); i++) {
439 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
443 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
440 }
444 }
441
445
442 TRY_COMPARE(spy0.count(), 0);
446 TRY_COMPARE(spy0.count(), 0);
443 TRY_COMPARE(spy1.count(), 0);
447 TRY_COMPARE(spy1.count(), 0);
444 TRY_COMPARE(spy2.count(), 0);
448 TRY_COMPARE(spy2.count(), 0);
445 TRY_COMPARE(spy3.count(), 0);
449 TRY_COMPARE(spy3.count(), 0);
446
450
447 foreach(QAbstractSeries* series, seriesList) {
451 foreach(QAbstractSeries* series, seriesList) {
448 m_dataset->removeSeries(series);
452 m_dataset->removeSeries(series);
449 }
453 }
450
454
451 for (int i = 0; i < seriesList.count(); i++) {
455 for (int i = 0; i < seriesList.count(); i++) {
452 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1);
456 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1);
453 }
457 }
454
458
455 foreach(QAbstractSeries* series, seriesList) {
459 foreach(QAbstractSeries* series, seriesList) {
456 m_dataset->addSeries(series);
460 m_dataset->addSeries(series);
457 }
461 }
458
462
459 for (int i = 0; i < seriesList.count(); i++) {
463 for (int i = 0; i < seriesList.count(); i++) {
460 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
464 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
461 }
465 }
462
466
463 m_dataset->removeSeries(seriesList.at(1));
467 m_dataset->removeSeries(seriesList.at(1));
464
468
465 for (int i = 0; i < seriesList.count(); i++) {
469 for (int i = 0; i < seriesList.count(); i++) {
466 if (i != 1)
470 if (i != 1)
467 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
471 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
468 else
472 else
469 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1);
473 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1);
470 }
474 }
471
475
472 m_dataset->addSeries(seriesList.at(1));
476 m_dataset->addSeries(seriesList.at(1));
473
477
474 for (int i = 0; i < seriesList.count(); i++) {
478 for (int i = 0; i < seriesList.count(); i++) {
475 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
479 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
476 }
480 }
477
481
478 m_dataset->removeSeries(seriesList.at(2));
482 m_dataset->removeSeries(seriesList.at(2));
479
483
480 for (int i = 0; i < seriesList.count(); i++) {
484 for (int i = 0; i < seriesList.count(); i++) {
481 if (i != 2)
485 if (i != 2)
482 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
486 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
483 else
487 else
484 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1);
488 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1);
485 }
489 }
486
490
487 m_dataset->removeSeries(seriesList.at(0));
491 m_dataset->removeSeries(seriesList.at(0));
488
492
489 for (int i = 0; i < seriesList.count(); i++) {
493 for (int i = 0; i < seriesList.count(); i++) {
490 if (i != 2 && i != 0)
494 if (i != 2 && i != 0)
491 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
495 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
492 else
496 else
493 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1);
497 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), -1);
494 }
498 }
495
499
496 m_dataset->addSeries(seriesList.at(2));
500 m_dataset->addSeries(seriesList.at(2));
497 m_dataset->addSeries(seriesList.at(0));
501 m_dataset->addSeries(seriesList.at(0));
498
502
499 for (int i = 0; i < seriesList.count(); i++) {
503 for (int i = 0; i < seriesList.count(); i++) {
500 if (i == 2)
504 if (i == 2)
501 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 0);
505 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 0);
502 else if (i == 0)
506 else if (i == 0)
503 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 2);
507 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), 2);
504 else
508 else
505 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
509 QCOMPARE(m_dataset->seriesIndex(seriesList.at(i)), i);
506 }
510 }
507
511
508 }
512 }
509
513
510 void tst_ChartDataSet::domain_data()
514 void tst_ChartDataSet::domain_data()
511 {
515 {
512 addSeries_data();
516 addSeries_data();
513 }
517 }
514
518
515 void tst_ChartDataSet::domain()
519 void tst_ChartDataSet::domain()
516 {
520 {
517 QFETCH(QAbstractSeries*, series);
521 QFETCH(QAbstractSeries*, series);
518
522
519 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *)));
523 QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis *, Domain *)));
520 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
524 QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis *)));
521 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
525 QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries *, Domain *)));
522 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
526 QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries *)));
523
527
524 m_dataset->addSeries(series);
528 m_dataset->addSeries(series);
525 QVERIFY(m_dataset->domain(series));
529 QVERIFY(m_dataset->domain(series));
526
530
527
531
528 TRY_COMPARE(spy0.count(), 0);
532 TRY_COMPARE(spy0.count(), 0);
529 TRY_COMPARE(spy1.count(), 0);
533 TRY_COMPARE(spy1.count(), 0);
530 TRY_COMPARE(spy2.count(), 1);
534 TRY_COMPARE(spy2.count(), 1);
531
535
532 QList<QVariant> arguments = spy2.takeFirst();
536 QList<QVariant> arguments = spy2.takeFirst();
533 Domain *domain = (Domain *) arguments.at(1).value<Domain *>();
537 Domain *domain = (Domain *) arguments.at(1).value<Domain *>();
534 QVERIFY(m_dataset->domain(series) == domain);
538 QVERIFY(m_dataset->domain(series) == domain);
535
539
536 TRY_COMPARE(spy3.count(), 0);
540 TRY_COMPARE(spy3.count(), 0);
537
541
538 }
542 }
539
543
540 void tst_ChartDataSet::zoomInDomain_data()
544 void tst_ChartDataSet::zoomInDomain_data()
541 {
545 {
542 QTest::addColumn<bool >("sameAxis");
546 QTest::addColumn<bool >("sameAxis");
543 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
547 QTest::addColumn<QList<QAbstractSeries*> >("seriesList");
544 QTest::newRow("sameAxis: line,line, line, spline") << true << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) );
548 QTest::newRow("sameAxis: line,line, line, spline") << true << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) );
545 QTest::newRow("separeateAxis: line,line, line, spline") << false << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) );
549 QTest::newRow("separeateAxis: line,line, line, spline") << false << (QList<QAbstractSeries*>() << new QLineSeries(this) << new QLineSeries(this) << new QLineSeries(this) << new QSplineSeries(this) );
546 }
550 }
547
551
548 void tst_ChartDataSet::zoomInDomain()
552 void tst_ChartDataSet::zoomInDomain()
549 {
553 {
550 QFETCH(bool, sameAxis);
554 QFETCH(bool, sameAxis);
551 QFETCH(QList<QAbstractSeries*>, seriesList);
555 QFETCH(QList<QAbstractSeries*>, seriesList);
552
556
553 foreach(QAbstractSeries* series, seriesList) {
557 foreach(QAbstractSeries* series, seriesList) {
554 m_dataset->addSeries(series);
558 m_dataset->addSeries(series);
555 }
559 }
556
560
557 if(sameAxis) m_dataset->createDefaultAxes();
561 if(sameAxis) m_dataset->createDefaultAxes();
558
562
559 QList<QSignalSpy*> spyList;
563 QList<QSignalSpy*> spyList;
560
564
561 foreach(QAbstractSeries* series, seriesList) {
565 foreach(QAbstractSeries* series, seriesList) {
562 spyList << new QSignalSpy(m_dataset->domain(series),SIGNAL(updated()));
566 spyList << new QSignalSpy(m_dataset->domain(series),SIGNAL(updated()));
563 }
567 }
564
568
565 m_dataset->zoomInDomain(QRect(0, 0, 100, 100), QSize(1000, 1000));
569 m_dataset->zoomInDomain(QRect(0, 0, 100, 100), QSize(1000, 1000));
566
570
567 foreach(QSignalSpy* spy, spyList) {
571 foreach(QSignalSpy* spy, spyList) {
568 TRY_COMPARE(spy->count(), 1);
572 TRY_COMPARE(spy->count(), 1);
569 }
573 }
570
574
571 qDeleteAll(spyList);
575 qDeleteAll(spyList);
572 }
576 }
573
577
574
578
575
579
576 void tst_ChartDataSet::zoomOutDomain_data()
580 void tst_ChartDataSet::zoomOutDomain_data()
577 {
581 {
578 zoomInDomain_data();
582 zoomInDomain_data();
579 }
583 }
580
584
581 void tst_ChartDataSet::zoomOutDomain()
585 void tst_ChartDataSet::zoomOutDomain()
582 {
586 {
583 QFETCH(bool, sameAxis);
587 QFETCH(bool, sameAxis);
584 QFETCH(QList<QAbstractSeries*>, seriesList);
588 QFETCH(QList<QAbstractSeries*>, seriesList);
585
589
586 foreach(QAbstractSeries* series, seriesList) {
590 foreach(QAbstractSeries* series, seriesList) {
587 m_dataset->addSeries(series);
591 m_dataset->addSeries(series);
588 }
592 }
589
593
590 if (sameAxis)
594 if (sameAxis)
591 m_dataset->createDefaultAxes();
595 m_dataset->createDefaultAxes();
592
596
593 QList<QSignalSpy*> spyList;
597 QList<QSignalSpy*> spyList;
594
598
595 foreach(QAbstractSeries* series, seriesList) {
599 foreach(QAbstractSeries* series, seriesList) {
596 spyList << new QSignalSpy(m_dataset->domain(series), SIGNAL(updated()));
600 spyList << new QSignalSpy(m_dataset->domain(series), SIGNAL(updated()));
597 }
601 }
598
602
599 m_dataset->zoomOutDomain(QRect(0, 0, 100, 100), QSize(1000, 1000));
603 m_dataset->zoomOutDomain(QRect(0, 0, 100, 100), QSize(1000, 1000));
600
604
601 foreach(QSignalSpy* spy, spyList) {
605 foreach(QSignalSpy* spy, spyList) {
602 TRY_COMPARE(spy->count(), 1);
606 TRY_COMPARE(spy->count(), 1);
603 }
607 }
604
608
605 qDeleteAll (spyList);
609 qDeleteAll (spyList);
606 }
610 }
607
611
608 void tst_ChartDataSet::scrollDomain_data()
612 void tst_ChartDataSet::scrollDomain_data()
609 {
613 {
610 zoomInDomain_data();
614 zoomInDomain_data();
611 }
615 }
612
616
613 void tst_ChartDataSet::scrollDomain()
617 void tst_ChartDataSet::scrollDomain()
614 {
618 {
615 QFETCH(bool, sameAxis);
619 QFETCH(bool, sameAxis);
616 QFETCH(QList<QAbstractSeries*>, seriesList);
620 QFETCH(QList<QAbstractSeries*>, seriesList);
617
621
618 foreach(QAbstractSeries* series, seriesList) {
622 foreach(QAbstractSeries* series, seriesList) {
619 m_dataset->addSeries(series);
623 m_dataset->addSeries(series);
620 }
624 }
621
625
622 if (sameAxis)
626 if (sameAxis)
623 m_dataset->createDefaultAxes();
627 m_dataset->createDefaultAxes();
624
628
625 QList<QSignalSpy*> spyList;
629 QList<QSignalSpy*> spyList;
626
630
627 foreach(QAbstractSeries* series, seriesList) {
631 foreach(QAbstractSeries* series, seriesList) {
628 spyList
632 spyList
629 << new QSignalSpy(m_dataset->domain(series),
633 << new QSignalSpy(m_dataset->domain(series),
630 SIGNAL(updated()));
634 SIGNAL(updated()));
631 }
635 }
632
636
633 m_dataset->scrollDomain(10, 10, QSize(1000, 1000));
637 m_dataset->scrollDomain(10, 10, QSize(1000, 1000));
634
638
635 foreach(QSignalSpy* spy, spyList) {
639 foreach(QSignalSpy* spy, spyList) {
636 TRY_COMPARE(spy->count(), 1);
640 TRY_COMPARE(spy->count(), 1);
637 }
641 }
638
642
639 qDeleteAll(spyList);
643 qDeleteAll(spyList);
640 }
644 }
641
645
642 QTEST_MAIN(tst_ChartDataSet)
646 QTEST_MAIN(tst_ChartDataSet)
643 #include "tst_chartdataset.moc"
647 #include "tst_chartdataset.moc"
644 #endif
648 #endif
@@ -1,703 +1,707
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 #ifndef BUILD_PRIVATE_UNIT_TESTS
20 #ifndef BUILD_PRIVATE_UNIT_TESTS
21
21
22 #include <QtTest/QtTest>
22 #include <QtTest/QtTest>
23
23
24 class tst_Domain: public QObject {
24 class tst_Domain: public QObject {
25
25
26 Q_OBJECT
26 Q_OBJECT
27
27
28 private Q_SLOTS:
28 private Q_SLOTS:
29 void skip();
29 void skip();
30
30
31 };
31 };
32
32
33 void tst_Domain::skip()
33 void tst_Domain::skip()
34 {
34 {
35 #ifdef QT5_QUICK_1
36 QSKIP("This test requires the debug version of library");
37 #else
35 QSKIP("This test requires the debug version of library", SkipAll);
38 QSKIP("This test requires the debug version of library", SkipAll);
39 #endif
36 }
40 }
37
41
38 QTEST_MAIN(tst_Domain)
42 QTEST_MAIN(tst_Domain)
39 #include "tst_domain.moc"
43 #include "tst_domain.moc"
40
44
41 #else
45 #else
42
46
43 #include <QtTest/QtTest>
47 #include <QtTest/QtTest>
44 #include <private/domain_p.h>
48 #include <private/domain_p.h>
45 #include <private/qabstractaxis_p.h>
49 #include <private/qabstractaxis_p.h>
46 #include <tst_definitions.h>
50 #include <tst_definitions.h>
47
51
48 QTCOMMERCIALCHART_USE_NAMESPACE
52 QTCOMMERCIALCHART_USE_NAMESPACE
49
53
50 Q_DECLARE_METATYPE(Domain*)
54 Q_DECLARE_METATYPE(Domain*)
51 Q_DECLARE_METATYPE(QSizeF)
55 Q_DECLARE_METATYPE(QSizeF)
52
56
53
57
54 class AxisMock: public QAbstractAxisPrivate
58 class AxisMock: public QAbstractAxisPrivate
55 {
59 {
56 Q_OBJECT
60 Q_OBJECT
57 public:
61 public:
58 AxisMock(Qt::Orientation orientation):QAbstractAxisPrivate(0){ setOrientation(orientation);};
62 AxisMock(Qt::Orientation orientation):QAbstractAxisPrivate(0){ setOrientation(orientation);};
59 ChartAxis* createGraphics(ChartPresenter* presenter)
63 ChartAxis* createGraphics(ChartPresenter* presenter)
60 {
64 {
61 Q_UNUSED(presenter);
65 Q_UNUSED(presenter);
62 return 0;
66 return 0;
63 };
67 };
64 void intializeDomain(Domain* domain)
68 void intializeDomain(Domain* domain)
65 {
69 {
66 Q_UNUSED(domain);
70 Q_UNUSED(domain);
67 };
71 };
68 void setMin(const QVariant &min)
72 void setMin(const QVariant &min)
69 {
73 {
70 Q_UNUSED(min);
74 Q_UNUSED(min);
71 }
75 }
72 qreal min() { return m_min;}
76 qreal min() { return m_min;}
73 void setMax(const QVariant &max)
77 void setMax(const QVariant &max)
74 {
78 {
75 Q_UNUSED(max);
79 Q_UNUSED(max);
76 }
80 }
77 qreal max() { return m_max; }
81 qreal max() { return m_max; }
78 void setRange(const QVariant &min, const QVariant &max)
82 void setRange(const QVariant &min, const QVariant &max)
79 {
83 {
80 Q_UNUSED(min);
84 Q_UNUSED(min);
81 Q_UNUSED(max);
85 Q_UNUSED(max);
82 };
86 };
83
87
84 int count () const { return m_count; }
88 int count () const { return m_count; }
85
89
86 void handleDomainUpdated(){};
90 void handleDomainUpdated(){};
87 public:
91 public:
88 int m_count;
92 int m_count;
89 qreal m_min;
93 qreal m_min;
90 qreal m_max;
94 qreal m_max;
91 };
95 };
92
96
93 class tst_Domain: public QObject
97 class tst_Domain: public QObject
94 {
98 {
95 Q_OBJECT
99 Q_OBJECT
96
100
97 public Q_SLOTS:
101 public Q_SLOTS:
98 void initTestCase();
102 void initTestCase();
99 void cleanupTestCase();
103 void cleanupTestCase();
100 void init();
104 void init();
101 void cleanup();
105 void cleanup();
102
106
103 private Q_SLOTS:
107 private Q_SLOTS:
104 void domain();
108 void domain();
105 void handleAxisUpdatedX_data();
109 void handleAxisUpdatedX_data();
106 void handleAxisUpdatedX();
110 void handleAxisUpdatedX();
107 void handleAxisUpdatedY_data();
111 void handleAxisUpdatedY_data();
108 void handleAxisUpdatedY();
112 void handleAxisUpdatedY();
109 void isEmpty_data();
113 void isEmpty_data();
110 void isEmpty();
114 void isEmpty();
111 void maxX_data();
115 void maxX_data();
112 void maxX();
116 void maxX();
113 void maxY_data();
117 void maxY_data();
114 void maxY();
118 void maxY();
115 void minX_data();
119 void minX_data();
116 void minX();
120 void minX();
117 void minY_data();
121 void minY_data();
118 void minY();
122 void minY();
119 void operatorEquals_data();
123 void operatorEquals_data();
120 void operatorEquals();
124 void operatorEquals();
121 void setRange_data();
125 void setRange_data();
122 void setRange();
126 void setRange();
123 void setRangeX_data();
127 void setRangeX_data();
124 void setRangeX();
128 void setRangeX();
125 void setRangeY_data();
129 void setRangeY_data();
126 void setRangeY();
130 void setRangeY();
127 void spanX_data();
131 void spanX_data();
128 void spanX();
132 void spanX();
129 void spanY_data();
133 void spanY_data();
130 void spanY();
134 void spanY();
131 void zoom_data();
135 void zoom_data();
132 void zoom();
136 void zoom();
133 void move_data();
137 void move_data();
134 void move();
138 void move();
135 };
139 };
136
140
137 void tst_Domain::initTestCase()
141 void tst_Domain::initTestCase()
138 {
142 {
139 }
143 }
140
144
141 void tst_Domain::cleanupTestCase()
145 void tst_Domain::cleanupTestCase()
142 {
146 {
143 }
147 }
144
148
145 void tst_Domain::init()
149 void tst_Domain::init()
146 {
150 {
147 }
151 }
148
152
149 void tst_Domain::cleanup()
153 void tst_Domain::cleanup()
150 {
154 {
151 }
155 }
152
156
153 void tst_Domain::domain()
157 void tst_Domain::domain()
154 {
158 {
155 Domain domain;
159 Domain domain;
156
160
157 QCOMPARE(domain.isEmpty(), true);
161 QCOMPARE(domain.isEmpty(), true);
158 QCOMPARE(domain.maxX(), 0.0);
162 QCOMPARE(domain.maxX(), 0.0);
159 QCOMPARE(domain.maxY(), 0.0);
163 QCOMPARE(domain.maxY(), 0.0);
160 QCOMPARE(domain.minX(), 0.0);
164 QCOMPARE(domain.minX(), 0.0);
161 QCOMPARE(domain.minY(), 0.0);
165 QCOMPARE(domain.minY(), 0.0);
162 }
166 }
163
167
164 void tst_Domain::handleAxisUpdatedX_data()
168 void tst_Domain::handleAxisUpdatedX_data()
165 {
169 {
166 QTest::addColumn<qreal>("min");
170 QTest::addColumn<qreal>("min");
167 QTest::addColumn<qreal>("max");
171 QTest::addColumn<qreal>("max");
168 QTest::newRow("-1 1") << -1.0 << 1.0;
172 QTest::newRow("-1 1") << -1.0 << 1.0;
169 QTest::newRow("0 1") << 0.0 << 1.0;
173 QTest::newRow("0 1") << 0.0 << 1.0;
170 QTest::newRow("-1 0") << -1.0 << 0.0;
174 QTest::newRow("-1 0") << -1.0 << 0.0;
171 }
175 }
172
176
173 void tst_Domain::handleAxisUpdatedX()
177 void tst_Domain::handleAxisUpdatedX()
174 {
178 {
175 QFETCH(qreal, min);
179 QFETCH(qreal, min);
176 QFETCH(qreal, max);
180 QFETCH(qreal, max);
177
181
178 Domain domain;
182 Domain domain;
179
183
180 QSignalSpy spy0(&domain, SIGNAL(updated()));
184 QSignalSpy spy0(&domain, SIGNAL(updated()));
181 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
185 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
182 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
186 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
183
187
184 AxisMock axis(Qt::Horizontal);
188 AxisMock axis(Qt::Horizontal);
185 QObject::connect(&axis,SIGNAL(updated()),&domain,SLOT(handleAxisUpdated()));
189 QObject::connect(&axis,SIGNAL(updated()),&domain,SLOT(handleAxisUpdated()));
186 axis.m_min=min;
190 axis.m_min=min;
187 axis.m_max=max;
191 axis.m_max=max;
188 axis.emitUpdated();
192 axis.emitUpdated();
189
193
190 QVERIFY(qFuzzyIsNull(domain.minX() - min));
194 QVERIFY(qFuzzyIsNull(domain.minX() - min));
191 QVERIFY(qFuzzyIsNull(domain.maxX() - max));
195 QVERIFY(qFuzzyIsNull(domain.maxX() - max));
192
196
193 QList<QVariant> arg1 = spy1.first();
197 QList<QVariant> arg1 = spy1.first();
194 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
198 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
195 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
199 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
196
200
197 TRY_COMPARE(spy0.count(), 1);
201 TRY_COMPARE(spy0.count(), 1);
198 TRY_COMPARE(spy1.count(), 1);
202 TRY_COMPARE(spy1.count(), 1);
199 TRY_COMPARE(spy2.count(), 0);
203 TRY_COMPARE(spy2.count(), 0);
200
204
201 }
205 }
202
206
203 void tst_Domain::handleAxisUpdatedY_data()
207 void tst_Domain::handleAxisUpdatedY_data()
204 {
208 {
205 QTest::addColumn<qreal>("min");
209 QTest::addColumn<qreal>("min");
206 QTest::addColumn<qreal>("max");
210 QTest::addColumn<qreal>("max");
207 QTest::newRow("-1 1") << -1.0 << 1.0;
211 QTest::newRow("-1 1") << -1.0 << 1.0;
208 QTest::newRow("0 1") << 0.0 << 1.0;
212 QTest::newRow("0 1") << 0.0 << 1.0;
209 QTest::newRow("-1 0") << -1.0 << 0.0;
213 QTest::newRow("-1 0") << -1.0 << 0.0;
210 }
214 }
211
215
212 void tst_Domain::handleAxisUpdatedY()
216 void tst_Domain::handleAxisUpdatedY()
213 {
217 {
214 QFETCH(qreal, min);
218 QFETCH(qreal, min);
215 QFETCH(qreal, max);
219 QFETCH(qreal, max);
216
220
217 Domain domain;
221 Domain domain;
218
222
219 QSignalSpy spy0(&domain, SIGNAL(updated()));
223 QSignalSpy spy0(&domain, SIGNAL(updated()));
220 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
224 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
221 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
225 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
222
226
223 AxisMock axis(Qt::Vertical);
227 AxisMock axis(Qt::Vertical);
224 QObject::connect(&axis, SIGNAL(updated()), &domain, SLOT(handleAxisUpdated()));
228 QObject::connect(&axis, SIGNAL(updated()), &domain, SLOT(handleAxisUpdated()));
225 axis.m_min = min;
229 axis.m_min = min;
226 axis.m_max = max;
230 axis.m_max = max;
227 axis.emitUpdated();
231 axis.emitUpdated();
228
232
229 QVERIFY(qFuzzyIsNull(domain.minY() - min));
233 QVERIFY(qFuzzyIsNull(domain.minY() - min));
230 QVERIFY(qFuzzyIsNull(domain.maxY() - max));
234 QVERIFY(qFuzzyIsNull(domain.maxY() - max));
231
235
232 QList<QVariant> arg1 = spy2.first();
236 QList<QVariant> arg1 = spy2.first();
233 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
237 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
234 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
238 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
235
239
236 TRY_COMPARE(spy0.count(), 1);
240 TRY_COMPARE(spy0.count(), 1);
237 TRY_COMPARE(spy1.count(), 0);
241 TRY_COMPARE(spy1.count(), 0);
238 TRY_COMPARE(spy2.count(), 1);
242 TRY_COMPARE(spy2.count(), 1);
239 }
243 }
240
244
241 void tst_Domain::isEmpty_data()
245 void tst_Domain::isEmpty_data()
242 {
246 {
243 QTest::addColumn<qreal>("minX");
247 QTest::addColumn<qreal>("minX");
244 QTest::addColumn<qreal>("maxX");
248 QTest::addColumn<qreal>("maxX");
245 QTest::addColumn<qreal>("minY");
249 QTest::addColumn<qreal>("minY");
246 QTest::addColumn<qreal>("maxY");
250 QTest::addColumn<qreal>("maxY");
247 QTest::addColumn<bool>("isEmpty");
251 QTest::addColumn<bool>("isEmpty");
248 QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true;
252 QTest::newRow("0 0 0 0") << 0.0 << 0.0 << 0.0 << 0.0 << true;
249 QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true;
253 QTest::newRow("0 1 0 0") << 0.0 << 1.0 << 0.0 << 0.0 << true;
250 QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true;
254 QTest::newRow("0 0 0 1") << 0.0 << 1.0 << 0.0 << 0.0 << true;
251 QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false;
255 QTest::newRow("0 1 0 1") << 0.0 << 1.0 << 0.0 << 1.0 << false;
252 }
256 }
253
257
254 void tst_Domain::isEmpty()
258 void tst_Domain::isEmpty()
255 {
259 {
256 QFETCH(qreal, minX);
260 QFETCH(qreal, minX);
257 QFETCH(qreal, maxX);
261 QFETCH(qreal, maxX);
258 QFETCH(qreal, minY);
262 QFETCH(qreal, minY);
259 QFETCH(qreal, maxY);
263 QFETCH(qreal, maxY);
260 QFETCH(bool, isEmpty);
264 QFETCH(bool, isEmpty);
261
265
262 Domain domain;
266 Domain domain;
263 domain.setRange(minX, maxX, minY, maxY);
267 domain.setRange(minX, maxX, minY, maxY);
264 QCOMPARE(domain.isEmpty(), isEmpty);
268 QCOMPARE(domain.isEmpty(), isEmpty);
265 }
269 }
266
270
267 void tst_Domain::maxX_data()
271 void tst_Domain::maxX_data()
268 {
272 {
269 QTest::addColumn<qreal>("maxX1");
273 QTest::addColumn<qreal>("maxX1");
270 QTest::addColumn<qreal>("maxX2");
274 QTest::addColumn<qreal>("maxX2");
271 QTest::addColumn<int>("count");
275 QTest::addColumn<int>("count");
272 QTest::newRow("1") << 0.0 << 1.0 << 1;
276 QTest::newRow("1") << 0.0 << 1.0 << 1;
273 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
277 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
274 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
278 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
275 }
279 }
276
280
277 void tst_Domain::maxX()
281 void tst_Domain::maxX()
278 {
282 {
279 QFETCH(qreal, maxX1);
283 QFETCH(qreal, maxX1);
280 QFETCH(qreal, maxX2);
284 QFETCH(qreal, maxX2);
281 QFETCH(int, count);
285 QFETCH(int, count);
282
286
283 Domain domain;
287 Domain domain;
284
288
285 QSignalSpy spy0(&domain, SIGNAL(updated()));
289 QSignalSpy spy0(&domain, SIGNAL(updated()));
286 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
290 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
287 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
291 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
288
292
289 domain.setMaxX(maxX1);
293 domain.setMaxX(maxX1);
290 QCOMPARE(domain.maxX(), maxX1);
294 QCOMPARE(domain.maxX(), maxX1);
291 domain.setMaxX(maxX2);
295 domain.setMaxX(maxX2);
292 QCOMPARE(domain.maxX(), maxX2);
296 QCOMPARE(domain.maxX(), maxX2);
293
297
294 TRY_COMPARE(spy0.count(), count);
298 TRY_COMPARE(spy0.count(), count);
295 TRY_COMPARE(spy1.count(), count);
299 TRY_COMPARE(spy1.count(), count);
296 TRY_COMPARE(spy2.count(), 0);
300 TRY_COMPARE(spy2.count(), 0);
297
301
298 }
302 }
299
303
300 void tst_Domain::maxY_data()
304 void tst_Domain::maxY_data()
301 {
305 {
302 QTest::addColumn<qreal>("maxY1");
306 QTest::addColumn<qreal>("maxY1");
303 QTest::addColumn<qreal>("maxY2");
307 QTest::addColumn<qreal>("maxY2");
304 QTest::addColumn<int>("count");
308 QTest::addColumn<int>("count");
305 QTest::newRow("1") << 0.0 << 1.0 << 1;
309 QTest::newRow("1") << 0.0 << 1.0 << 1;
306 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
310 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
307 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
311 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
308 }
312 }
309
313
310 void tst_Domain::maxY()
314 void tst_Domain::maxY()
311 {
315 {
312 QFETCH(qreal, maxY1);
316 QFETCH(qreal, maxY1);
313 QFETCH(qreal, maxY2);
317 QFETCH(qreal, maxY2);
314 QFETCH(int, count);
318 QFETCH(int, count);
315
319
316 Domain domain;
320 Domain domain;
317
321
318 QSignalSpy spy0(&domain, SIGNAL(updated()));
322 QSignalSpy spy0(&domain, SIGNAL(updated()));
319 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
323 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
320 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
324 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
321
325
322 domain.setMaxY(maxY1);
326 domain.setMaxY(maxY1);
323 QCOMPARE(domain.maxY(), maxY1);
327 QCOMPARE(domain.maxY(), maxY1);
324 domain.setMaxY(maxY2);
328 domain.setMaxY(maxY2);
325 QCOMPARE(domain.maxY(), maxY2);
329 QCOMPARE(domain.maxY(), maxY2);
326
330
327 TRY_COMPARE(spy0.count(), count);
331 TRY_COMPARE(spy0.count(), count);
328 TRY_COMPARE(spy1.count(), 0);
332 TRY_COMPARE(spy1.count(), 0);
329 TRY_COMPARE(spy2.count(), count);
333 TRY_COMPARE(spy2.count(), count);
330 }
334 }
331
335
332 void tst_Domain::minX_data()
336 void tst_Domain::minX_data()
333 {
337 {
334 QTest::addColumn<qreal>("minX1");
338 QTest::addColumn<qreal>("minX1");
335 QTest::addColumn<qreal>("minX2");
339 QTest::addColumn<qreal>("minX2");
336 QTest::addColumn<int>("count");
340 QTest::addColumn<int>("count");
337 QTest::newRow("1") << 0.0 << 1.0 << 1;
341 QTest::newRow("1") << 0.0 << 1.0 << 1;
338 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
342 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
339 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
343 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
340 }
344 }
341
345
342 void tst_Domain::minX()
346 void tst_Domain::minX()
343 {
347 {
344 QFETCH(qreal, minX1);
348 QFETCH(qreal, minX1);
345 QFETCH(qreal, minX2);
349 QFETCH(qreal, minX2);
346 QFETCH(int, count);
350 QFETCH(int, count);
347
351
348 Domain domain;
352 Domain domain;
349
353
350 QSignalSpy spy0(&domain, SIGNAL(updated()));
354 QSignalSpy spy0(&domain, SIGNAL(updated()));
351 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
355 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
352 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
356 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
353
357
354 domain.setMinX(minX1);
358 domain.setMinX(minX1);
355 QCOMPARE(domain.minX(), minX1);
359 QCOMPARE(domain.minX(), minX1);
356 domain.setMinX(minX2);
360 domain.setMinX(minX2);
357 QCOMPARE(domain.minX(), minX2);
361 QCOMPARE(domain.minX(), minX2);
358
362
359 TRY_COMPARE(spy0.count(), count);
363 TRY_COMPARE(spy0.count(), count);
360 TRY_COMPARE(spy1.count(), count);
364 TRY_COMPARE(spy1.count(), count);
361 TRY_COMPARE(spy2.count(), 0);
365 TRY_COMPARE(spy2.count(), 0);
362 }
366 }
363
367
364 void tst_Domain::minY_data()
368 void tst_Domain::minY_data()
365 {
369 {
366 QTest::addColumn<qreal>("minY1");
370 QTest::addColumn<qreal>("minY1");
367 QTest::addColumn<qreal>("minY2");
371 QTest::addColumn<qreal>("minY2");
368 QTest::addColumn<int>("count");
372 QTest::addColumn<int>("count");
369 QTest::newRow("1") << 0.0 << 1.0 << 1;
373 QTest::newRow("1") << 0.0 << 1.0 << 1;
370 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
374 QTest::newRow("1.0") << 1.0 << 1.0 << 1;
371 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
375 QTest::newRow("2.0") << 1.0 << 0.0 << 2;
372 }
376 }
373
377
374 void tst_Domain::minY()
378 void tst_Domain::minY()
375 {
379 {
376 QFETCH(qreal, minY1);
380 QFETCH(qreal, minY1);
377 QFETCH(qreal, minY2);
381 QFETCH(qreal, minY2);
378 QFETCH(int, count);
382 QFETCH(int, count);
379
383
380 Domain domain;
384 Domain domain;
381
385
382 QSignalSpy spy0(&domain, SIGNAL(updated()));
386 QSignalSpy spy0(&domain, SIGNAL(updated()));
383 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
387 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
384 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
388 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
385
389
386 domain.setMinY(minY1);
390 domain.setMinY(minY1);
387 QCOMPARE(domain.minY(), minY1);
391 QCOMPARE(domain.minY(), minY1);
388 domain.setMinY(minY2);
392 domain.setMinY(minY2);
389 QCOMPARE(domain.minY(), minY2);
393 QCOMPARE(domain.minY(), minY2);
390
394
391 TRY_COMPARE(spy0.count(), count);
395 TRY_COMPARE(spy0.count(), count);
392 TRY_COMPARE(spy1.count(), 0);
396 TRY_COMPARE(spy1.count(), 0);
393 TRY_COMPARE(spy2.count(), count);
397 TRY_COMPARE(spy2.count(), count);
394 }
398 }
395
399
396 void tst_Domain::operatorEquals_data()
400 void tst_Domain::operatorEquals_data()
397 {
401 {
398
402
399 QTest::addColumn<Domain*>("domain1");
403 QTest::addColumn<Domain*>("domain1");
400 QTest::addColumn<Domain*>("domain2");
404 QTest::addColumn<Domain*>("domain2");
401 QTest::addColumn<bool>("equals");
405 QTest::addColumn<bool>("equals");
402 QTest::addColumn<bool>("notEquals");
406 QTest::addColumn<bool>("notEquals");
403 Domain* a;
407 Domain* a;
404 Domain* b;
408 Domain* b;
405 a = new Domain();
409 a = new Domain();
406 a->setRange(0, 100, 0, 100);
410 a->setRange(0, 100, 0, 100);
407 b = new Domain();
411 b = new Domain();
408 b->setRange(0, 100, 0, 100);
412 b->setRange(0, 100, 0, 100);
409 QTest::newRow("equals") << a << b << true << false;
413 QTest::newRow("equals") << a << b << true << false;
410 a = new Domain();
414 a = new Domain();
411 a->setRange(0, 100, 0, 100);
415 a->setRange(0, 100, 0, 100);
412 b = new Domain();
416 b = new Domain();
413 b->setRange(0, 100, 0, 1);
417 b->setRange(0, 100, 0, 1);
414 QTest::newRow("equals") << a << b << false << true;
418 QTest::newRow("equals") << a << b << false << true;
415 a = new Domain();
419 a = new Domain();
416 a->setRange(0, 100, 0, 100);
420 a->setRange(0, 100, 0, 100);
417 b = new Domain();
421 b = new Domain();
418 b->setRange(0, 1, 0, 100);
422 b->setRange(0, 1, 0, 100);
419 QTest::newRow("equals") << a << b << false << true;
423 QTest::newRow("equals") << a << b << false << true;
420
424
421 }
425 }
422
426
423 void tst_Domain::operatorEquals()
427 void tst_Domain::operatorEquals()
424 {
428 {
425 QFETCH(Domain*, domain1);
429 QFETCH(Domain*, domain1);
426 QFETCH(Domain*, domain2);
430 QFETCH(Domain*, domain2);
427 QFETCH(bool, equals);
431 QFETCH(bool, equals);
428 QFETCH(bool, notEquals);
432 QFETCH(bool, notEquals);
429
433
430 Domain domain;
434 Domain domain;
431
435
432 QSignalSpy spy0(&domain, SIGNAL(updated()));
436 QSignalSpy spy0(&domain, SIGNAL(updated()));
433 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
437 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
434 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
438 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
435
439
436 QCOMPARE(*domain1==*domain2, equals);
440 QCOMPARE(*domain1==*domain2, equals);
437 QCOMPARE(*domain1!=*domain2, notEquals);
441 QCOMPARE(*domain1!=*domain2, notEquals);
438
442
439 TRY_COMPARE(spy0.count(), 0);
443 TRY_COMPARE(spy0.count(), 0);
440 TRY_COMPARE(spy1.count(), 0);
444 TRY_COMPARE(spy1.count(), 0);
441 TRY_COMPARE(spy2.count(), 0);
445 TRY_COMPARE(spy2.count(), 0);
442 }
446 }
443
447
444 void tst_Domain::setRange_data()
448 void tst_Domain::setRange_data()
445 {
449 {
446 QTest::addColumn<qreal>("minX");
450 QTest::addColumn<qreal>("minX");
447 QTest::addColumn<qreal>("maxX");
451 QTest::addColumn<qreal>("maxX");
448 QTest::addColumn<qreal>("minY");
452 QTest::addColumn<qreal>("minY");
449 QTest::addColumn<qreal>("maxY");
453 QTest::addColumn<qreal>("maxY");
450 QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0;
454 QTest::newRow("1,2,1,2") << 1.0 << 2.0 << 1.0 << 2.0;
451 QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0;
455 QTest::newRow("1,3,1,3") << 1.0 << 3.0 << 1.0 << 3.0;
452 QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0;
456 QTest::newRow("-1,5,-2,-1") << -1.0 << 5.0 << -2.0 << -1.0;
453 }
457 }
454
458
455 void tst_Domain::setRange()
459 void tst_Domain::setRange()
456 {
460 {
457 QFETCH(qreal, minX);
461 QFETCH(qreal, minX);
458 QFETCH(qreal, maxX);
462 QFETCH(qreal, maxX);
459 QFETCH(qreal, minY);
463 QFETCH(qreal, minY);
460 QFETCH(qreal, maxY);
464 QFETCH(qreal, maxY);
461
465
462 Domain domain;
466 Domain domain;
463
467
464 QSignalSpy spy0(&domain, SIGNAL(updated()));
468 QSignalSpy spy0(&domain, SIGNAL(updated()));
465 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
469 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
466 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
470 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
467
471
468 domain.setRange(minX, maxX, minY, maxY);
472 domain.setRange(minX, maxX, minY, maxY);
469
473
470 QCOMPARE(domain.minX(), minX);
474 QCOMPARE(domain.minX(), minX);
471 QCOMPARE(domain.maxX(), maxX);
475 QCOMPARE(domain.maxX(), maxX);
472 QCOMPARE(domain.minY(), minY);
476 QCOMPARE(domain.minY(), minY);
473 QCOMPARE(domain.maxY(), maxY);
477 QCOMPARE(domain.maxY(), maxY);
474
478
475 TRY_COMPARE(spy0.count(), 1);
479 TRY_COMPARE(spy0.count(), 1);
476 TRY_COMPARE(spy1.count(), 1);
480 TRY_COMPARE(spy1.count(), 1);
477 TRY_COMPARE(spy2.count(), 1);
481 TRY_COMPARE(spy2.count(), 1);
478
482
479 }
483 }
480
484
481 void tst_Domain::setRangeX_data()
485 void tst_Domain::setRangeX_data()
482 {
486 {
483 QTest::addColumn<qreal>("min");
487 QTest::addColumn<qreal>("min");
484 QTest::addColumn<qreal>("max");
488 QTest::addColumn<qreal>("max");
485 QTest::newRow("-1 1") << -1.0 << 1.0;
489 QTest::newRow("-1 1") << -1.0 << 1.0;
486 QTest::newRow("0 1") << 0.0 << 1.0;
490 QTest::newRow("0 1") << 0.0 << 1.0;
487 QTest::newRow("-1 0") << -1.0 << 0.0;
491 QTest::newRow("-1 0") << -1.0 << 0.0;
488 }
492 }
489
493
490 void tst_Domain::setRangeX()
494 void tst_Domain::setRangeX()
491 {
495 {
492 QFETCH(qreal, min);
496 QFETCH(qreal, min);
493 QFETCH(qreal, max);
497 QFETCH(qreal, max);
494
498
495 Domain domain;
499 Domain domain;
496
500
497 QSignalSpy spy0(&domain, SIGNAL(updated()));
501 QSignalSpy spy0(&domain, SIGNAL(updated()));
498 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
502 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
499 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
503 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
500
504
501 domain.setRangeX(min, max);
505 domain.setRangeX(min, max);
502
506
503 QVERIFY(qFuzzyIsNull(domain.minX() - min));
507 QVERIFY(qFuzzyIsNull(domain.minX() - min));
504 QVERIFY(qFuzzyIsNull(domain.maxX() - max));
508 QVERIFY(qFuzzyIsNull(domain.maxX() - max));
505
509
506 QList<QVariant> arg1 = spy1.first();
510 QList<QVariant> arg1 = spy1.first();
507 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
511 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
508 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
512 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
509
513
510 TRY_COMPARE(spy0.count(), 1);
514 TRY_COMPARE(spy0.count(), 1);
511 TRY_COMPARE(spy1.count(), 1);
515 TRY_COMPARE(spy1.count(), 1);
512 TRY_COMPARE(spy2.count(), 0);
516 TRY_COMPARE(spy2.count(), 0);
513 }
517 }
514
518
515 void tst_Domain::setRangeY_data()
519 void tst_Domain::setRangeY_data()
516 {
520 {
517 QTest::addColumn<qreal>("min");
521 QTest::addColumn<qreal>("min");
518 QTest::addColumn<qreal>("max");
522 QTest::addColumn<qreal>("max");
519 QTest::newRow("-1 1") << -1.0 << 1.0;
523 QTest::newRow("-1 1") << -1.0 << 1.0;
520 QTest::newRow("0 1") << 0.0 << 1.0;
524 QTest::newRow("0 1") << 0.0 << 1.0;
521 QTest::newRow("-1 0") << -1.0 << 0.0;
525 QTest::newRow("-1 0") << -1.0 << 0.0;
522 }
526 }
523
527
524 void tst_Domain::setRangeY()
528 void tst_Domain::setRangeY()
525 {
529 {
526 QFETCH(qreal, min);
530 QFETCH(qreal, min);
527 QFETCH(qreal, max);
531 QFETCH(qreal, max);
528
532
529 Domain domain;
533 Domain domain;
530
534
531 QSignalSpy spy0(&domain, SIGNAL(updated()));
535 QSignalSpy spy0(&domain, SIGNAL(updated()));
532 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
536 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
533 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
537 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
534
538
535 domain.setRangeY(min, max);
539 domain.setRangeY(min, max);
536
540
537 QVERIFY(qFuzzyIsNull(domain.minY() - min));
541 QVERIFY(qFuzzyIsNull(domain.minY() - min));
538 QVERIFY(qFuzzyIsNull(domain.maxY() - max));
542 QVERIFY(qFuzzyIsNull(domain.maxY() - max));
539
543
540 QList<QVariant> arg1 = spy2.first();
544 QList<QVariant> arg1 = spy2.first();
541 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
545 QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min));
542 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
546 QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max));
543
547
544 TRY_COMPARE(spy0.count(), 1);
548 TRY_COMPARE(spy0.count(), 1);
545 TRY_COMPARE(spy1.count(), 0);
549 TRY_COMPARE(spy1.count(), 0);
546 TRY_COMPARE(spy2.count(), 1);
550 TRY_COMPARE(spy2.count(), 1);
547 }
551 }
548
552
549 void tst_Domain::spanX_data()
553 void tst_Domain::spanX_data()
550 {
554 {
551 QTest::addColumn<qreal>("minX");
555 QTest::addColumn<qreal>("minX");
552 QTest::addColumn<qreal>("maxX");
556 QTest::addColumn<qreal>("maxX");
553 QTest::addColumn<qreal>("spanX");
557 QTest::addColumn<qreal>("spanX");
554 QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0;
558 QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0;
555 QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0;
559 QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0;
556 }
560 }
557
561
558 void tst_Domain::spanX()
562 void tst_Domain::spanX()
559 {
563 {
560 QFETCH(qreal, minX);
564 QFETCH(qreal, minX);
561 QFETCH(qreal, maxX);
565 QFETCH(qreal, maxX);
562 QFETCH(qreal, spanX);
566 QFETCH(qreal, spanX);
563
567
564 Domain domain;
568 Domain domain;
565
569
566 domain.setRangeX(minX, maxX);
570 domain.setRangeX(minX, maxX);
567
571
568 QSignalSpy spy0(&domain, SIGNAL(updated()));
572 QSignalSpy spy0(&domain, SIGNAL(updated()));
569 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
573 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
570 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
574 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
571
575
572 QCOMPARE(domain.spanX(), spanX);
576 QCOMPARE(domain.spanX(), spanX);
573
577
574 TRY_COMPARE(spy0.count(), 0);
578 TRY_COMPARE(spy0.count(), 0);
575 TRY_COMPARE(spy1.count(), 0);
579 TRY_COMPARE(spy1.count(), 0);
576 TRY_COMPARE(spy2.count(), 0);
580 TRY_COMPARE(spy2.count(), 0);
577 }
581 }
578
582
579 void tst_Domain::spanY_data()
583 void tst_Domain::spanY_data()
580 {
584 {
581 QTest::addColumn<qreal>("minY");
585 QTest::addColumn<qreal>("minY");
582 QTest::addColumn<qreal>("maxY");
586 QTest::addColumn<qreal>("maxY");
583 QTest::addColumn<qreal>("spanY");
587 QTest::addColumn<qreal>("spanY");
584 QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0;
588 QTest::newRow("1 2 1") << 1.0 << 2.0 << 1.0;
585 QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0;
589 QTest::newRow("0 2 2") << 1.0 << 2.0 << 1.0;
586 }
590 }
587
591
588 void tst_Domain::spanY()
592 void tst_Domain::spanY()
589 {
593 {
590 QFETCH(qreal, minY);
594 QFETCH(qreal, minY);
591 QFETCH(qreal, maxY);
595 QFETCH(qreal, maxY);
592 QFETCH(qreal, spanY);
596 QFETCH(qreal, spanY);
593
597
594 Domain domain;
598 Domain domain;
595
599
596 domain.setRangeY(minY, maxY);
600 domain.setRangeY(minY, maxY);
597
601
598 QSignalSpy spy0(&domain, SIGNAL(updated()));
602 QSignalSpy spy0(&domain, SIGNAL(updated()));
599 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
603 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
600 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
604 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
601
605
602 QCOMPARE(domain.spanY(), spanY);
606 QCOMPARE(domain.spanY(), spanY);
603
607
604 TRY_COMPARE(spy0.count(), 0);
608 TRY_COMPARE(spy0.count(), 0);
605 TRY_COMPARE(spy1.count(), 0);
609 TRY_COMPARE(spy1.count(), 0);
606 TRY_COMPARE(spy2.count(), 0);
610 TRY_COMPARE(spy2.count(), 0);
607 }
611 }
608
612
609 void tst_Domain::zoom_data()
613 void tst_Domain::zoom_data()
610 {
614 {
611 QTest::addColumn<QRectF>("rect0");
615 QTest::addColumn<QRectF>("rect0");
612 QTest::addColumn<QSizeF>("size0");
616 QTest::addColumn<QSizeF>("size0");
613 QTest::addColumn<QRectF>("rect1");
617 QTest::addColumn<QRectF>("rect1");
614 QTest::addColumn<QSizeF>("size1");
618 QTest::addColumn<QSizeF>("size1");
615 QTest::addColumn<QRectF>("rect2");
619 QTest::addColumn<QRectF>("rect2");
616 QTest::addColumn<QSizeF>("size2");
620 QTest::addColumn<QSizeF>("size2");
617 QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000)
621 QTest::newRow("first") << QRectF(10, 10, 100, 100) << QSizeF(1000, 1000)
618 << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100)
622 << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100)
619 << QSizeF(1000, 1000);
623 << QSizeF(1000, 1000);
620 QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000)
624 QTest::newRow("scound") << QRectF(10, 10, 50, 50) << QSizeF(1000, 1000)
621 << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100)
625 << QRectF(20, 20, 100, 100) << QSizeF(1000, 1000) << QRectF(50, 50, 100, 100)
622 << QSizeF(1000, 1000);
626 << QSizeF(1000, 1000);
623 QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20)
627 QTest::newRow("third") << QRectF(10, 10, 10, 10) << QSizeF(100, 100) << QRectF(20, 20, 20, 20)
624 << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100);
628 << QSizeF(100, 100) << QRectF(50, 50, 50, 50) << QSizeF(100, 100);
625 }
629 }
626
630
627 void tst_Domain::zoom()
631 void tst_Domain::zoom()
628 {
632 {
629 QFETCH(QRectF, rect0);
633 QFETCH(QRectF, rect0);
630 QFETCH(QSizeF, size0);
634 QFETCH(QSizeF, size0);
631 QFETCH(QRectF, rect1);
635 QFETCH(QRectF, rect1);
632 QFETCH(QSizeF, size1);
636 QFETCH(QSizeF, size1);
633 QFETCH(QRectF, rect2);
637 QFETCH(QRectF, rect2);
634 QFETCH(QSizeF, size2);
638 QFETCH(QSizeF, size2);
635
639
636 Domain domain;
640 Domain domain;
637
641
638 domain.setRange(0, 1000, 0, 1000);
642 domain.setRange(0, 1000, 0, 1000);
639
643
640 QSignalSpy spy0(&domain, SIGNAL(updated()));
644 QSignalSpy spy0(&domain, SIGNAL(updated()));
641 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
645 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
642 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
646 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
643
647
644 Domain domain0;
648 Domain domain0;
645 domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY());
649 domain0.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY());
646 domain.zoomIn(rect0, size0);
650 domain.zoomIn(rect0, size0);
647 Domain domain1;
651 Domain domain1;
648 domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY());
652 domain1.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY());
649 domain.zoomIn(rect1, size1);
653 domain.zoomIn(rect1, size1);
650 Domain domain2;
654 Domain domain2;
651 domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY());
655 domain2.setRange(domain.minX(), domain.maxX(), domain.minY(), domain.maxY());
652 domain.zoomIn(rect2, size2);
656 domain.zoomIn(rect2, size2);
653 domain.zoomOut(rect2, size2);
657 domain.zoomOut(rect2, size2);
654 QCOMPARE(domain == domain2, true);
658 QCOMPARE(domain == domain2, true);
655 domain.zoomOut(rect1, size1);
659 domain.zoomOut(rect1, size1);
656 QCOMPARE(domain == domain1, true);
660 QCOMPARE(domain == domain1, true);
657 domain.zoomOut(rect0, size0);
661 domain.zoomOut(rect0, size0);
658 QCOMPARE(domain == domain0, true);
662 QCOMPARE(domain == domain0, true);
659 TRY_COMPARE(spy0.count(), 6);
663 TRY_COMPARE(spy0.count(), 6);
660 TRY_COMPARE(spy1.count(), 6);
664 TRY_COMPARE(spy1.count(), 6);
661 TRY_COMPARE(spy2.count(), 6);
665 TRY_COMPARE(spy2.count(), 6);
662 }
666 }
663
667
664 void tst_Domain::move_data()
668 void tst_Domain::move_data()
665 {
669 {
666 QTest::addColumn<int>("dx");
670 QTest::addColumn<int>("dx");
667 QTest::addColumn<int>("dy");
671 QTest::addColumn<int>("dy");
668 QTest::addColumn<QSizeF>("size");
672 QTest::addColumn<QSizeF>("size");
669 QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000);
673 QTest::newRow("dx 100, dy 0, size 1000x1000") << 100 << 0 << QSizeF(1000, 1000);
670 QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000);
674 QTest::newRow("dx 0, dy 100, size 1000x1000") << 0 << 100 << QSizeF(1000, 1000);
671 QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000);
675 QTest::newRow("dx -100, dy 0, size 1000x1000") << -100 << 0 << QSizeF(1000, 1000);
672 QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000);
676 QTest::newRow("dx 0, dy -100, size 1000x1000") << 0 << -100 << QSizeF(1000, 1000);
673 QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000);
677 QTest::newRow("dx 100, dy 100, size 1000x1000") << 100 << 100 << QSizeF(1000, 1000);
674 QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000);
678 QTest::newRow("dx 100, dy 50, size 1000x1000") << 100 << 50 << QSizeF(1000, 1000);
675 }
679 }
676
680
677 void tst_Domain::move()
681 void tst_Domain::move()
678 {
682 {
679 QFETCH(int, dx);
683 QFETCH(int, dx);
680 QFETCH(int, dy);
684 QFETCH(int, dy);
681 QFETCH(QSizeF, size);
685 QFETCH(QSizeF, size);
682 Domain domain;
686 Domain domain;
683
687
684 domain.setRange(0, size.width(), 0, size.height());
688 domain.setRange(0, size.width(), 0, size.height());
685
689
686 QSignalSpy spy0(&domain, SIGNAL(updated()));
690 QSignalSpy spy0(&domain, SIGNAL(updated()));
687 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
691 QSignalSpy spy1(&domain, SIGNAL(rangeXChanged(qreal,qreal)));
688 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
692 QSignalSpy spy2(&domain, SIGNAL(rangeYChanged(qreal,qreal)));
689
693
690 domain.move(dx, dy, size);
694 domain.move(dx, dy, size);
691
695
692 Domain result;
696 Domain result;
693 result.setRange(dx, size.width() + dx, dy, size.height() + dy);
697 result.setRange(dx, size.width() + dx, dy, size.height() + dy);
694
698
695 QCOMPARE(domain == result, true);
699 QCOMPARE(domain == result, true);
696 TRY_COMPARE(spy0.count(), 1);
700 TRY_COMPARE(spy0.count(), 1);
697 TRY_COMPARE(spy1.count(), (dx != 0 ? 1 : 0));
701 TRY_COMPARE(spy1.count(), (dx != 0 ? 1 : 0));
698 TRY_COMPARE(spy2.count(), (dy != 0 ? 1 : 0));
702 TRY_COMPARE(spy2.count(), (dy != 0 ? 1 : 0));
699 }
703 }
700
704
701 QTEST_MAIN(tst_Domain)
705 QTEST_MAIN(tst_Domain)
702 #include "tst_domain.moc"
706 #include "tst_domain.moc"
703 #endif
707 #endif
@@ -1,847 +1,863
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
20
21 #include "tst_qabstractaxis.h"
21 #include "tst_qabstractaxis.h"
22
22
23 Q_DECLARE_METATYPE(QPen)
23 Q_DECLARE_METATYPE(QPen)
24 Q_DECLARE_METATYPE(Qt::Orientation)
24 Q_DECLARE_METATYPE(Qt::Orientation)
25
25
26 void tst_QAbstractAxis::initTestCase()
26 void tst_QAbstractAxis::initTestCase()
27 {
27 {
28 }
28 }
29
29
30 void tst_QAbstractAxis::cleanupTestCase()
30 void tst_QAbstractAxis::cleanupTestCase()
31 {
31 {
32 }
32 }
33
33
34 void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series)
34 void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series)
35 {
35 {
36 m_axis = axis;
36 m_axis = axis;
37 m_series = series;
37 m_series = series;
38 m_view = new QChartView(new QChart());
38 m_view = new QChartView(new QChart());
39 m_chart = m_view->chart();
39 m_chart = m_view->chart();
40 }
40 }
41
41
42 void tst_QAbstractAxis::cleanup()
42 void tst_QAbstractAxis::cleanup()
43 {
43 {
44 delete m_view;
44 delete m_view;
45 m_view = 0;
45 m_view = 0;
46 m_chart = 0;
46 m_chart = 0;
47 m_axis = 0;
47 m_axis = 0;
48 }
48 }
49
49
50 void tst_QAbstractAxis::qabstractaxis()
50 void tst_QAbstractAxis::qabstractaxis()
51 {
51 {
52 QCOMPARE(m_axis->linePen(), QPen());
52 QCOMPARE(m_axis->linePen(), QPen());
53 //TODO QCOMPARE(m_axis->axisPenColor(), QColor());
53 //TODO QCOMPARE(m_axis->axisPenColor(), QColor());
54 QCOMPARE(m_axis->gridLinePen(), QPen());
54 QCOMPARE(m_axis->gridLinePen(), QPen());
55 QCOMPARE(m_axis->isLineVisible(), true);
55 QCOMPARE(m_axis->isLineVisible(), true);
56 QCOMPARE(m_axis->isGridLineVisible(), true);
56 QCOMPARE(m_axis->isGridLineVisible(), true);
57 QCOMPARE(m_axis->isVisible(), false);
57 QCOMPARE(m_axis->isVisible(), false);
58 QCOMPARE(m_axis->labelsAngle(), 0);
58 QCOMPARE(m_axis->labelsAngle(), 0);
59 QCOMPARE(m_axis->labelsBrush(), QBrush());
59 QCOMPARE(m_axis->labelsBrush(), QBrush());
60 //TODO QCOMPARE(m_axis->labelsColor(), QColor());
60 //TODO QCOMPARE(m_axis->labelsColor(), QColor());
61 QCOMPARE(m_axis->labelsFont(), QFont());
61 QCOMPARE(m_axis->labelsFont(), QFont());
62 QCOMPARE(m_axis->labelsPen(), QPen());
62 QCOMPARE(m_axis->labelsPen(), QPen());
63 QCOMPARE(m_axis->labelsVisible(), true);
63 QCOMPARE(m_axis->labelsVisible(), true);
64 QCOMPARE(m_axis->orientation(), Qt::Orientation(0));
64 QCOMPARE(m_axis->orientation(), Qt::Orientation(0));
65 m_axis->setLineVisible(false);
65 m_axis->setLineVisible(false);
66 m_axis->setLinePen(QPen());
66 m_axis->setLinePen(QPen());
67 m_axis->setLinePenColor(QColor());
67 m_axis->setLinePenColor(QColor());
68 m_axis->setGridLinePen(QPen());
68 m_axis->setGridLinePen(QPen());
69 m_axis->setGridLineVisible(false);
69 m_axis->setGridLineVisible(false);
70 m_axis->setLabelsAngle(-1);
70 m_axis->setLabelsAngle(-1);
71 m_axis->setLabelsBrush(QBrush());
71 m_axis->setLabelsBrush(QBrush());
72 m_axis->setLabelsColor(QColor());
72 m_axis->setLabelsColor(QColor());
73 m_axis->setLabelsFont(QFont());
73 m_axis->setLabelsFont(QFont());
74 m_axis->setLabelsPen(QPen());
74 m_axis->setLabelsPen(QPen());
75 m_axis->setLabelsVisible(false);
75 m_axis->setLabelsVisible(false);
76 m_axis->setMax(QVariant());
76 m_axis->setMax(QVariant());
77 m_axis->setMin(QVariant());
77 m_axis->setMin(QVariant());
78 m_axis->setRange(QVariant(), QVariant());
78 m_axis->setRange(QVariant(), QVariant());
79 m_axis->setShadesBorderColor(QColor());
79 m_axis->setShadesBorderColor(QColor());
80 m_axis->setShadesBrush(QBrush());
80 m_axis->setShadesBrush(QBrush());
81 m_axis->setShadesColor(QColor());
81 m_axis->setShadesColor(QColor());
82 m_axis->setShadesPen(QPen());
82 m_axis->setShadesPen(QPen());
83 m_axis->setShadesVisible(false);
83 m_axis->setShadesVisible(false);
84 m_axis->setVisible(false);
84 m_axis->setVisible(false);
85 //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor());
85 //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor());
86 //TODO QCOMPARE(m_axis->shadesBrush(), QBrush());
86 //TODO QCOMPARE(m_axis->shadesBrush(), QBrush());
87 //TODO QCOMPARE(m_axis->shadesColor(), QColor());
87 //TODO QCOMPARE(m_axis->shadesColor(), QColor());
88 QCOMPARE(m_axis->shadesPen(), QPen());
88 QCOMPARE(m_axis->shadesPen(), QPen());
89 QCOMPARE(m_axis->shadesVisible(), false);
89 QCOMPARE(m_axis->shadesVisible(), false);
90 m_axis->show();
90 m_axis->show();
91 m_axis->hide();
91 m_axis->hide();
92 }
92 }
93
93
94 void tst_QAbstractAxis::axisPen_data()
94 void tst_QAbstractAxis::axisPen_data()
95 {
95 {
96 QTest::addColumn<QPen>("axisPen");
96 QTest::addColumn<QPen>("axisPen");
97 QTest::newRow("null") << QPen();
97 QTest::newRow("null") << QPen();
98 QTest::newRow("blue") << QPen(Qt::blue);
98 QTest::newRow("blue") << QPen(Qt::blue);
99 QTest::newRow("black") << QPen(Qt::black);
99 QTest::newRow("black") << QPen(Qt::black);
100 QTest::newRow("red") << QPen(Qt::red);
100 QTest::newRow("red") << QPen(Qt::red);
101 }
101 }
102
102
103 void tst_QAbstractAxis::axisPen()
103 void tst_QAbstractAxis::axisPen()
104 {
104 {
105 QFETCH(QPen, axisPen);
105 QFETCH(QPen, axisPen);
106
106
107 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
107 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
108 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
108 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
109 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
109 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
110 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
110 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
111 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
111 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
112 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
112 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
113 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
113 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
114 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
114 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
115 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
115 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
116
116
117 m_axis->setLinePen(axisPen);
117 m_axis->setLinePen(axisPen);
118 QCOMPARE(m_axis->linePen(), axisPen);
118 QCOMPARE(m_axis->linePen(), axisPen);
119
119
120 QCOMPARE(spy0.count(), 0);
120 QCOMPARE(spy0.count(), 0);
121 QCOMPARE(spy1.count(), 0);
121 QCOMPARE(spy1.count(), 0);
122 QCOMPARE(spy2.count(), 0);
122 QCOMPARE(spy2.count(), 0);
123 QCOMPARE(spy3.count(), 0);
123 QCOMPARE(spy3.count(), 0);
124 QCOMPARE(spy4.count(), 0);
124 QCOMPARE(spy4.count(), 0);
125 QCOMPARE(spy5.count(), 0);
125 QCOMPARE(spy5.count(), 0);
126 QCOMPARE(spy6.count(), 0);
126 QCOMPARE(spy6.count(), 0);
127 QCOMPARE(spy7.count(), 0);
127 QCOMPARE(spy7.count(), 0);
128 QCOMPARE(spy8.count(), 0);
128 QCOMPARE(spy8.count(), 0);
129
129
130 m_chart->setAxisX(m_axis, m_series);
130 m_chart->setAxisX(m_axis, m_series);
131 m_view->show();
131 m_view->show();
132 QTest::qWaitForWindowShown(m_view);
132 QTest::qWaitForWindowShown(m_view);
133 //TODO QCOMPARE(m_axis->axisPen(), axisPen);
133 //TODO QCOMPARE(m_axis->axisPen(), axisPen);
134 }
134 }
135
135
136 void tst_QAbstractAxis::axisPenColor_data()
136 void tst_QAbstractAxis::axisPenColor_data()
137 {
137 {
138 }
138 }
139
139
140 void tst_QAbstractAxis::axisPenColor()
140 void tst_QAbstractAxis::axisPenColor()
141 {
141 {
142 #ifdef QT5_QUICK_1
143 QSKIP("Test is not implemented. This is depreciated function");
144 #else
142 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
145 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
146 #endif
143 }
147 }
144
148
145 void tst_QAbstractAxis::gridLinePen_data()
149 void tst_QAbstractAxis::gridLinePen_data()
146 {
150 {
147
151
148 QTest::addColumn<QPen>("gridLinePen");
152 QTest::addColumn<QPen>("gridLinePen");
149 QTest::newRow("null") << QPen();
153 QTest::newRow("null") << QPen();
150 QTest::newRow("blue") << QPen(Qt::blue);
154 QTest::newRow("blue") << QPen(Qt::blue);
151 QTest::newRow("black") << QPen(Qt::black);
155 QTest::newRow("black") << QPen(Qt::black);
152 QTest::newRow("red") << QPen(Qt::red);
156 QTest::newRow("red") << QPen(Qt::red);
153
157
154 }
158 }
155
159
156 void tst_QAbstractAxis::gridLinePen()
160 void tst_QAbstractAxis::gridLinePen()
157 {
161 {
158 QFETCH(QPen, gridLinePen);
162 QFETCH(QPen, gridLinePen);
159
163
160 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
164 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
161 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
165 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
162 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
166 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
163 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
167 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
164 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
168 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
165 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
169 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
166 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
170 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
167 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
171 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
168 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
172 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
169
173
170 m_axis->setGridLinePen(gridLinePen);
174 m_axis->setGridLinePen(gridLinePen);
171 QCOMPARE(m_axis->gridLinePen(), gridLinePen);
175 QCOMPARE(m_axis->gridLinePen(), gridLinePen);
172
176
173 QCOMPARE(spy0.count(), 0);
177 QCOMPARE(spy0.count(), 0);
174 QCOMPARE(spy1.count(), 0);
178 QCOMPARE(spy1.count(), 0);
175 QCOMPARE(spy2.count(), 0);
179 QCOMPARE(spy2.count(), 0);
176 QCOMPARE(spy3.count(), 0);
180 QCOMPARE(spy3.count(), 0);
177 QCOMPARE(spy4.count(), 0);
181 QCOMPARE(spy4.count(), 0);
178 QCOMPARE(spy5.count(), 0);
182 QCOMPARE(spy5.count(), 0);
179 QCOMPARE(spy6.count(), 0);
183 QCOMPARE(spy6.count(), 0);
180 QCOMPARE(spy7.count(), 0);
184 QCOMPARE(spy7.count(), 0);
181 QCOMPARE(spy8.count(), 0);
185 QCOMPARE(spy8.count(), 0);
182
186
183 m_chart->setAxisX(m_axis, m_series);
187 m_chart->setAxisX(m_axis, m_series);
184 m_view->show();
188 m_view->show();
185 QTest::qWaitForWindowShown(m_view);
189 QTest::qWaitForWindowShown(m_view);
186 //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen);
190 //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen);
187 }
191 }
188
192
189 void tst_QAbstractAxis::lineVisible_data()
193 void tst_QAbstractAxis::lineVisible_data()
190 {
194 {
191 QTest::addColumn<bool>("lineVisible");
195 QTest::addColumn<bool>("lineVisible");
192 QTest::newRow("true") << true;
196 QTest::newRow("true") << true;
193 QTest::newRow("false") << false;
197 QTest::newRow("false") << false;
194 }
198 }
195
199
196 void tst_QAbstractAxis::lineVisible()
200 void tst_QAbstractAxis::lineVisible()
197 {
201 {
198 QFETCH(bool, lineVisible);
202 QFETCH(bool, lineVisible);
199
203
200 m_axis->setLineVisible(!lineVisible);
204 m_axis->setLineVisible(!lineVisible);
201
205
202 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
206 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
203 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
207 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
204 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
208 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
205 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
209 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
206 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
210 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
207 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
211 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
208 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
212 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
209 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
213 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
210 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
214 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
211
215
212 m_axis->setLineVisible(lineVisible);
216 m_axis->setLineVisible(lineVisible);
213 QCOMPARE(m_axis->isLineVisible(), lineVisible);
217 QCOMPARE(m_axis->isLineVisible(), lineVisible);
214
218
215 QCOMPARE(spy0.count(), 1);
219 QCOMPARE(spy0.count(), 1);
216 QCOMPARE(spy1.count(), 0);
220 QCOMPARE(spy1.count(), 0);
217 QCOMPARE(spy2.count(), 0);
221 QCOMPARE(spy2.count(), 0);
218 QCOMPARE(spy3.count(), 0);
222 QCOMPARE(spy3.count(), 0);
219 QCOMPARE(spy4.count(), 0);
223 QCOMPARE(spy4.count(), 0);
220 QCOMPARE(spy5.count(), 0);
224 QCOMPARE(spy5.count(), 0);
221 QCOMPARE(spy6.count(), 0);
225 QCOMPARE(spy6.count(), 0);
222 QCOMPARE(spy7.count(), 0);
226 QCOMPARE(spy7.count(), 0);
223 QCOMPARE(spy8.count(), 0);
227 QCOMPARE(spy8.count(), 0);
224
228
225 m_chart->setAxisX(m_axis, m_series);
229 m_chart->setAxisX(m_axis, m_series);
226 m_view->show();
230 m_view->show();
227 QTest::qWaitForWindowShown(m_view);
231 QTest::qWaitForWindowShown(m_view);
228 QCOMPARE(m_axis->isLineVisible(), lineVisible);
232 QCOMPARE(m_axis->isLineVisible(), lineVisible);
229 }
233 }
230
234
231 void tst_QAbstractAxis::gridLineVisible_data()
235 void tst_QAbstractAxis::gridLineVisible_data()
232 {
236 {
233 QTest::addColumn<bool>("gridLineVisible");
237 QTest::addColumn<bool>("gridLineVisible");
234 QTest::newRow("true") << true;
238 QTest::newRow("true") << true;
235 QTest::newRow("false") << false;
239 QTest::newRow("false") << false;
236 }
240 }
237
241
238 void tst_QAbstractAxis::gridLineVisible()
242 void tst_QAbstractAxis::gridLineVisible()
239 {
243 {
240 QFETCH(bool, gridLineVisible);
244 QFETCH(bool, gridLineVisible);
241
245
242 m_axis->setGridLineVisible(!gridLineVisible);
246 m_axis->setGridLineVisible(!gridLineVisible);
243
247
244 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
248 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
245 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
249 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
246 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
250 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
247 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
251 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
248 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
252 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
249 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
253 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
250 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
254 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
251 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
255 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
252 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
256 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
253
257
254 m_axis->setGridLineVisible(gridLineVisible);
258 m_axis->setGridLineVisible(gridLineVisible);
255 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
259 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
256
260
257 QCOMPARE(spy0.count(), 0);
261 QCOMPARE(spy0.count(), 0);
258 QCOMPARE(spy1.count(), 0);
262 QCOMPARE(spy1.count(), 0);
259 QCOMPARE(spy2.count(), 1);
263 QCOMPARE(spy2.count(), 1);
260 QCOMPARE(spy3.count(), 0);
264 QCOMPARE(spy3.count(), 0);
261 QCOMPARE(spy4.count(), 0);
265 QCOMPARE(spy4.count(), 0);
262 QCOMPARE(spy5.count(), 0);
266 QCOMPARE(spy5.count(), 0);
263 QCOMPARE(spy6.count(), 0);
267 QCOMPARE(spy6.count(), 0);
264 QCOMPARE(spy7.count(), 0);
268 QCOMPARE(spy7.count(), 0);
265 QCOMPARE(spy8.count(), 0);
269 QCOMPARE(spy8.count(), 0);
266
270
267 m_chart->setAxisX(m_axis, m_series);
271 m_chart->setAxisX(m_axis, m_series);
268 m_view->show();
272 m_view->show();
269 QTest::qWaitForWindowShown(m_view);
273 QTest::qWaitForWindowShown(m_view);
270 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
274 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
271
275
272 }
276 }
273
277
274 void tst_QAbstractAxis::visible_data()
278 void tst_QAbstractAxis::visible_data()
275 {
279 {
276 QTest::addColumn<bool>("visible");
280 QTest::addColumn<bool>("visible");
277 QTest::newRow("true") << true;
281 QTest::newRow("true") << true;
278 QTest::newRow("false") << false;
282 QTest::newRow("false") << false;
279 }
283 }
280
284
281 void tst_QAbstractAxis::visible()
285 void tst_QAbstractAxis::visible()
282 {
286 {
283 QFETCH(bool, visible);
287 QFETCH(bool, visible);
284
288
285 m_axis->setVisible(!visible);
289 m_axis->setVisible(!visible);
286
290
287 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
291 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
288 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
292 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
289 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
293 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
290 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
294 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
291 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
295 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
292 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
296 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
293 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
297 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
294 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
298 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
295 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
299 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
296
300
297 m_axis->setVisible(visible);
301 m_axis->setVisible(visible);
298 QCOMPARE(m_axis->isVisible(), visible);
302 QCOMPARE(m_axis->isVisible(), visible);
299
303
300 QCOMPARE(spy0.count(), 0);
304 QCOMPARE(spy0.count(), 0);
301 QCOMPARE(spy1.count(), 0);
305 QCOMPARE(spy1.count(), 0);
302 QCOMPARE(spy2.count(), 0);
306 QCOMPARE(spy2.count(), 0);
303 QCOMPARE(spy3.count(), 0);
307 QCOMPARE(spy3.count(), 0);
304 QCOMPARE(spy4.count(), 0);
308 QCOMPARE(spy4.count(), 0);
305 QCOMPARE(spy5.count(), 0);
309 QCOMPARE(spy5.count(), 0);
306 QCOMPARE(spy6.count(), 0);
310 QCOMPARE(spy6.count(), 0);
307 QCOMPARE(spy7.count(), 0);
311 QCOMPARE(spy7.count(), 0);
308 QCOMPARE(spy8.count(), 1);
312 QCOMPARE(spy8.count(), 1);
309
313
310 m_chart->setAxisX(m_axis, m_series);
314 m_chart->setAxisX(m_axis, m_series);
311 m_view->show();
315 m_view->show();
312 QTest::qWaitForWindowShown(m_view);
316 QTest::qWaitForWindowShown(m_view);
313 QCOMPARE(m_axis->isVisible(), true);
317 QCOMPARE(m_axis->isVisible(), true);
314 }
318 }
315
319
316 void tst_QAbstractAxis::labelsAngle_data()
320 void tst_QAbstractAxis::labelsAngle_data()
317 {
321 {
318 QTest::addColumn<int>("labelsAngle");
322 QTest::addColumn<int>("labelsAngle");
319 QTest::newRow("0") << 0;
323 QTest::newRow("0") << 0;
320 QTest::newRow("45") << 45;
324 QTest::newRow("45") << 45;
321 QTest::newRow("90") << 90;
325 QTest::newRow("90") << 90;
322 }
326 }
323
327
324 void tst_QAbstractAxis::labelsAngle()
328 void tst_QAbstractAxis::labelsAngle()
325 {
329 {
326 QFETCH(int, labelsAngle);
330 QFETCH(int, labelsAngle);
327
331
328 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
332 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
329 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
333 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
330 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
334 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
331 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
335 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
332 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
336 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
333 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
337 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
334 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
338 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
335 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
339 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
336 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
340 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
337
341
338 m_axis->setLabelsAngle(labelsAngle);
342 m_axis->setLabelsAngle(labelsAngle);
339 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
343 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
340
344
341 QCOMPARE(spy0.count(), 0);
345 QCOMPARE(spy0.count(), 0);
342 QCOMPARE(spy1.count(), 0);
346 QCOMPARE(spy1.count(), 0);
343 QCOMPARE(spy2.count(), 0);
347 QCOMPARE(spy2.count(), 0);
344 QCOMPARE(spy3.count(), 0);
348 QCOMPARE(spy3.count(), 0);
345 QCOMPARE(spy4.count(), 0);
349 QCOMPARE(spy4.count(), 0);
346 QCOMPARE(spy5.count(), 0);
350 QCOMPARE(spy5.count(), 0);
347 QCOMPARE(spy6.count(), 0);
351 QCOMPARE(spy6.count(), 0);
348 QCOMPARE(spy7.count(), 0);
352 QCOMPARE(spy7.count(), 0);
349 QCOMPARE(spy8.count(), 0);
353 QCOMPARE(spy8.count(), 0);
350
354
351 m_chart->setAxisX(m_axis, m_series);
355 m_chart->setAxisX(m_axis, m_series);
352 m_view->show();
356 m_view->show();
353 QTest::qWaitForWindowShown(m_view);
357 QTest::qWaitForWindowShown(m_view);
354 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
358 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
355 }
359 }
356
360
357 void tst_QAbstractAxis::labelsBrush_data()
361 void tst_QAbstractAxis::labelsBrush_data()
358 {
362 {
359 QTest::addColumn<QBrush>("labelsBrush");
363 QTest::addColumn<QBrush>("labelsBrush");
360 QTest::newRow("null") << QBrush();
364 QTest::newRow("null") << QBrush();
361 QTest::newRow("blue") << QBrush(Qt::blue);
365 QTest::newRow("blue") << QBrush(Qt::blue);
362 QTest::newRow("black") << QBrush(Qt::black);
366 QTest::newRow("black") << QBrush(Qt::black);
363
367
364 }
368 }
365
369
366 void tst_QAbstractAxis::labelsBrush()
370 void tst_QAbstractAxis::labelsBrush()
367 {
371 {
368
372
369 QFETCH(QBrush, labelsBrush);
373 QFETCH(QBrush, labelsBrush);
370
374
371 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
375 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
372 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
376 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
373 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
377 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
374 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
378 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
375 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
379 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
376 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
380 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
377 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
381 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
378 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
382 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
379 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
383 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
380
384
381 m_axis->setLabelsBrush(labelsBrush);
385 m_axis->setLabelsBrush(labelsBrush);
382 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
386 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
383
387
384 QCOMPARE(spy0.count(), 0);
388 QCOMPARE(spy0.count(), 0);
385 QCOMPARE(spy1.count(), 0);
389 QCOMPARE(spy1.count(), 0);
386 QCOMPARE(spy2.count(), 0);
390 QCOMPARE(spy2.count(), 0);
387 QCOMPARE(spy3.count(), 0);
391 QCOMPARE(spy3.count(), 0);
388 QCOMPARE(spy4.count(), 0);
392 QCOMPARE(spy4.count(), 0);
389 QCOMPARE(spy5.count(), 0);
393 QCOMPARE(spy5.count(), 0);
390 //TODO QCOMPARE(spy6.count(), 0);
394 //TODO QCOMPARE(spy6.count(), 0);
391 QCOMPARE(spy7.count(), 0);
395 QCOMPARE(spy7.count(), 0);
392 QCOMPARE(spy8.count(), 0);
396 QCOMPARE(spy8.count(), 0);
393
397
394 m_view->show();
398 m_view->show();
395 QTest::qWaitForWindowShown(m_view);
399 QTest::qWaitForWindowShown(m_view);
396 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
400 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
397
401
398 }
402 }
399
403
400 void tst_QAbstractAxis::labelsColor_data()
404 void tst_QAbstractAxis::labelsColor_data()
401 {
405 {
402
406
403 }
407 }
404
408
405 void tst_QAbstractAxis::labelsColor()
409 void tst_QAbstractAxis::labelsColor()
406 {
410 {
411 #ifdef QT5_QUICK_1
412 QSKIP("Test is not implemented. This is depreciated function");
413 #else
407 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
414 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
415 #endif
408 }
416 }
409
417
410 void tst_QAbstractAxis::labelsFont_data()
418 void tst_QAbstractAxis::labelsFont_data()
411 {
419 {
412 QTest::addColumn<QFont>("labelsFont");
420 QTest::addColumn<QFont>("labelsFont");
413 QTest::newRow("null") << QFont();
421 QTest::newRow("null") << QFont();
414 QTest::newRow("serif") << QFont("SansSerif");
422 QTest::newRow("serif") << QFont("SansSerif");
415 }
423 }
416
424
417 void tst_QAbstractAxis::labelsFont()
425 void tst_QAbstractAxis::labelsFont()
418 {
426 {
419
427
420 QFETCH(QFont, labelsFont);
428 QFETCH(QFont, labelsFont);
421
429
422 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
430 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
423 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
431 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
424 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
432 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
425 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
433 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
426 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
434 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
427 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
435 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
428 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
436 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
429 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
437 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
430 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
438 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
431
439
432 m_axis->setLabelsFont(labelsFont);
440 m_axis->setLabelsFont(labelsFont);
433 QCOMPARE(m_axis->labelsFont(), labelsFont);
441 QCOMPARE(m_axis->labelsFont(), labelsFont);
434
442
435 QCOMPARE(spy0.count(), 0);
443 QCOMPARE(spy0.count(), 0);
436 QCOMPARE(spy1.count(), 0);
444 QCOMPARE(spy1.count(), 0);
437 QCOMPARE(spy2.count(), 0);
445 QCOMPARE(spy2.count(), 0);
438 QCOMPARE(spy3.count(), 0);
446 QCOMPARE(spy3.count(), 0);
439 QCOMPARE(spy4.count(), 0);
447 QCOMPARE(spy4.count(), 0);
440 QCOMPARE(spy5.count(), 0);
448 QCOMPARE(spy5.count(), 0);
441 QCOMPARE(spy6.count(), 0);
449 QCOMPARE(spy6.count(), 0);
442 QCOMPARE(spy7.count(), 0);
450 QCOMPARE(spy7.count(), 0);
443 QCOMPARE(spy8.count(), 0);
451 QCOMPARE(spy8.count(), 0);
444
452
445 m_view->show();
453 m_view->show();
446 QTest::qWaitForWindowShown(m_view);
454 QTest::qWaitForWindowShown(m_view);
447 QCOMPARE(m_axis->labelsFont(), labelsFont);
455 QCOMPARE(m_axis->labelsFont(), labelsFont);
448
456
449 }
457 }
450
458
451 void tst_QAbstractAxis::labelsPen_data()
459 void tst_QAbstractAxis::labelsPen_data()
452 {
460 {
453 QTest::addColumn<QPen>("labelsPen");
461 QTest::addColumn<QPen>("labelsPen");
454 QTest::newRow("null") << QPen();
462 QTest::newRow("null") << QPen();
455 QTest::newRow("blue") << QPen(Qt::blue);
463 QTest::newRow("blue") << QPen(Qt::blue);
456 QTest::newRow("black") << QPen(Qt::black);
464 QTest::newRow("black") << QPen(Qt::black);
457 QTest::newRow("red") << QPen(Qt::red);
465 QTest::newRow("red") << QPen(Qt::red);
458 }
466 }
459
467
460 void tst_QAbstractAxis::labelsPen()
468 void tst_QAbstractAxis::labelsPen()
461 {
469 {
462 QFETCH(QPen, labelsPen);
470 QFETCH(QPen, labelsPen);
463
471
464 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
472 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
465 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
473 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
466 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
474 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
467 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
475 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
468 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
476 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
469 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
477 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
470 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
478 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
471 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
479 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
472 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
480 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
473
481
474 m_axis->setLabelsPen(labelsPen);
482 m_axis->setLabelsPen(labelsPen);
475 QCOMPARE(m_axis->labelsPen(), labelsPen);
483 QCOMPARE(m_axis->labelsPen(), labelsPen);
476
484
477 QCOMPARE(spy0.count(), 0);
485 QCOMPARE(spy0.count(), 0);
478 QCOMPARE(spy1.count(), 0);
486 QCOMPARE(spy1.count(), 0);
479 QCOMPARE(spy2.count(), 0);
487 QCOMPARE(spy2.count(), 0);
480 QCOMPARE(spy3.count(), 0);
488 QCOMPARE(spy3.count(), 0);
481 QCOMPARE(spy4.count(), 0);
489 QCOMPARE(spy4.count(), 0);
482 QCOMPARE(spy5.count(), 0);
490 QCOMPARE(spy5.count(), 0);
483 QCOMPARE(spy6.count(), 0);
491 QCOMPARE(spy6.count(), 0);
484 QCOMPARE(spy7.count(), 0);
492 QCOMPARE(spy7.count(), 0);
485 QCOMPARE(spy8.count(), 0);
493 QCOMPARE(spy8.count(), 0);
486
494
487 m_chart->setAxisX(m_axis, m_series);
495 m_chart->setAxisX(m_axis, m_series);
488 m_view->show();
496 m_view->show();
489 QTest::qWaitForWindowShown(m_view);
497 QTest::qWaitForWindowShown(m_view);
490 //TODO QCOMPARE(m_axis->labelsPen(), labelsPen);
498 //TODO QCOMPARE(m_axis->labelsPen(), labelsPen);
491 }
499 }
492
500
493 void tst_QAbstractAxis::labelsVisible_data()
501 void tst_QAbstractAxis::labelsVisible_data()
494 {
502 {
495 QTest::addColumn<bool>("labelsVisible");
503 QTest::addColumn<bool>("labelsVisible");
496 QTest::newRow("true") << true;
504 QTest::newRow("true") << true;
497 QTest::newRow("false") << false;
505 QTest::newRow("false") << false;
498 }
506 }
499
507
500 void tst_QAbstractAxis::labelsVisible()
508 void tst_QAbstractAxis::labelsVisible()
501 {
509 {
502 QFETCH(bool, labelsVisible);
510 QFETCH(bool, labelsVisible);
503
511
504 m_axis->setLabelsVisible(!labelsVisible);
512 m_axis->setLabelsVisible(!labelsVisible);
505
513
506 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
514 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
507 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
515 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
508 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
516 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
509 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
517 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
510 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
518 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
511 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
519 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
512 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
520 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
513 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
521 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
514 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
522 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
515
523
516 m_axis->setLabelsVisible(labelsVisible);
524 m_axis->setLabelsVisible(labelsVisible);
517 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
525 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
518
526
519 QCOMPARE(spy0.count(), 0);
527 QCOMPARE(spy0.count(), 0);
520 QCOMPARE(spy1.count(), 0);
528 QCOMPARE(spy1.count(), 0);
521 QCOMPARE(spy2.count(), 0);
529 QCOMPARE(spy2.count(), 0);
522 QCOMPARE(spy3.count(), 0);
530 QCOMPARE(spy3.count(), 0);
523 QCOMPARE(spy4.count(), 1);
531 QCOMPARE(spy4.count(), 1);
524 QCOMPARE(spy5.count(), 0);
532 QCOMPARE(spy5.count(), 0);
525 QCOMPARE(spy6.count(), 0);
533 QCOMPARE(spy6.count(), 0);
526 QCOMPARE(spy7.count(), 0);
534 QCOMPARE(spy7.count(), 0);
527 QCOMPARE(spy8.count(), 0);
535 QCOMPARE(spy8.count(), 0);
528
536
529 m_chart->setAxisX(m_axis, m_series);
537 m_chart->setAxisX(m_axis, m_series);
530 m_view->show();
538 m_view->show();
531 QTest::qWaitForWindowShown(m_view);
539 QTest::qWaitForWindowShown(m_view);
532 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
540 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
533 }
541 }
534
542
535 void tst_QAbstractAxis::orientation_data()
543 void tst_QAbstractAxis::orientation_data()
536 {
544 {
537 QTest::addColumn<Qt::Orientation>("orientation");
545 QTest::addColumn<Qt::Orientation>("orientation");
538 QTest::newRow("Vertical") << Qt::Vertical;
546 QTest::newRow("Vertical") << Qt::Vertical;
539 QTest::newRow("Horizontal") << Qt::Horizontal;
547 QTest::newRow("Horizontal") << Qt::Horizontal;
540 }
548 }
541
549
542 void tst_QAbstractAxis::orientation()
550 void tst_QAbstractAxis::orientation()
543 {
551 {
544 QFETCH(Qt::Orientation, orientation);
552 QFETCH(Qt::Orientation, orientation);
545
553
546 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
554 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
547 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
555 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
548 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
556 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
549 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
557 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
550 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
558 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
551 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
559 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
552 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
560 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
553 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
561 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
554 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
562 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
555
563
556 if(orientation==Qt::Vertical){
564 if(orientation==Qt::Vertical){
557 m_chart->setAxisY(m_axis,m_series);
565 m_chart->setAxisY(m_axis,m_series);
558 }else{
566 }else{
559 m_chart->setAxisX(m_axis,m_series);
567 m_chart->setAxisX(m_axis,m_series);
560 }
568 }
561 QCOMPARE(m_axis->orientation(), orientation);
569 QCOMPARE(m_axis->orientation(), orientation);
562
570
563 QCOMPARE(spy0.count(), 0);
571 QCOMPARE(spy0.count(), 0);
564 QCOMPARE(spy1.count(), 0);
572 QCOMPARE(spy1.count(), 0);
565 QCOMPARE(spy2.count(), 0);
573 QCOMPARE(spy2.count(), 0);
566 QCOMPARE(spy3.count(), 0);
574 QCOMPARE(spy3.count(), 0);
567 QCOMPARE(spy4.count(), 0);
575 QCOMPARE(spy4.count(), 0);
568 QCOMPARE(spy5.count(), 0);
576 QCOMPARE(spy5.count(), 0);
569 QCOMPARE(spy6.count(), 0);
577 QCOMPARE(spy6.count(), 0);
570 QCOMPARE(spy7.count(), 0);
578 QCOMPARE(spy7.count(), 0);
571 QCOMPARE(spy8.count(), 1);
579 QCOMPARE(spy8.count(), 1);
572
580
573 m_view->show();
581 m_view->show();
574 QTest::qWaitForWindowShown(m_view);
582 QTest::qWaitForWindowShown(m_view);
575 QCOMPARE(m_axis->orientation(), orientation);
583 QCOMPARE(m_axis->orientation(), orientation);
576 }
584 }
577
585
578 void tst_QAbstractAxis::setMax_data()
586 void tst_QAbstractAxis::setMax_data()
579 {
587 {
580 //just check if it does not crash
588 //just check if it does not crash
581 QTest::addColumn<QVariant>("max");
589 QTest::addColumn<QVariant>("max");
582 QTest::newRow("something") << QVariant("something");
590 QTest::newRow("something") << QVariant("something");
583 QTest::newRow("1.0") << QVariant(1.0);
591 QTest::newRow("1.0") << QVariant(1.0);
584 }
592 }
585
593
586 void tst_QAbstractAxis::setMax()
594 void tst_QAbstractAxis::setMax()
587 {
595 {
588 QFETCH(QVariant, max);
596 QFETCH(QVariant, max);
589 m_axis->setMax(max);
597 m_axis->setMax(max);
590 }
598 }
591
599
592 void tst_QAbstractAxis::setMin_data()
600 void tst_QAbstractAxis::setMin_data()
593 {
601 {
594 //just check if it does not crash
602 //just check if it does not crash
595 QTest::addColumn<QVariant>("min");
603 QTest::addColumn<QVariant>("min");
596 QTest::newRow("something") << QVariant("something");
604 QTest::newRow("something") << QVariant("something");
597 QTest::newRow("1.0") << QVariant(1.0);
605 QTest::newRow("1.0") << QVariant(1.0);
598 }
606 }
599
607
600 // public void setMin(QVariant const& min)
608 // public void setMin(QVariant const& min)
601 void tst_QAbstractAxis::setMin()
609 void tst_QAbstractAxis::setMin()
602 {
610 {
603 QFETCH(QVariant, min);
611 QFETCH(QVariant, min);
604 m_axis->setMin(min);
612 m_axis->setMin(min);
605 }
613 }
606
614
607 void tst_QAbstractAxis::setRange_data()
615 void tst_QAbstractAxis::setRange_data()
608 {
616 {
609 //just check if it does not crash
617 //just check if it does not crash
610 QTest::addColumn<QVariant>("min");
618 QTest::addColumn<QVariant>("min");
611 QTest::addColumn<QVariant>("max");
619 QTest::addColumn<QVariant>("max");
612 QTest::newRow("something") << QVariant("something0") << QVariant("something1");
620 QTest::newRow("something") << QVariant("something0") << QVariant("something1");
613 QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0);
621 QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0);
614 }
622 }
615
623
616 // public void setRange(QVariant const& min, QVariant const& max)
624 // public void setRange(QVariant const& min, QVariant const& max)
617 void tst_QAbstractAxis::setRange()
625 void tst_QAbstractAxis::setRange()
618 {
626 {
619
627
620 QFETCH(QVariant, min);
628 QFETCH(QVariant, min);
621 QFETCH(QVariant, max);
629 QFETCH(QVariant, max);
622 m_axis->setRange(min,max);
630 m_axis->setRange(min,max);
623 }
631 }
624
632
625 void tst_QAbstractAxis::shadesBorderColor_data()
633 void tst_QAbstractAxis::shadesBorderColor_data()
626 {
634 {
627
635
628 }
636 }
629
637
630 void tst_QAbstractAxis::shadesBorderColor()
638 void tst_QAbstractAxis::shadesBorderColor()
631 {
639 {
640 #ifdef QT5_QUICK_1
641 QSKIP("Test is not implemented. This is depreciated function");
642 #else
632 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
643 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
644 #endif
633 }
645 }
634
646
635 void tst_QAbstractAxis::shadesBrush_data()
647 void tst_QAbstractAxis::shadesBrush_data()
636 {
648 {
637 QTest::addColumn<QBrush>("shadesBrush");
649 QTest::addColumn<QBrush>("shadesBrush");
638 QTest::newRow("null") << QBrush();
650 QTest::newRow("null") << QBrush();
639 QTest::newRow("blue") << QBrush(Qt::blue);
651 QTest::newRow("blue") << QBrush(Qt::blue);
640 QTest::newRow("black") << QBrush(Qt::black);
652 QTest::newRow("black") << QBrush(Qt::black);
641 }
653 }
642
654
643 void tst_QAbstractAxis::shadesBrush()
655 void tst_QAbstractAxis::shadesBrush()
644 {
656 {
645 QFETCH(QBrush, shadesBrush);
657 QFETCH(QBrush, shadesBrush);
646
658
647 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
659 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
648 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
660 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
649 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
661 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
650 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
662 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
651 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
663 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
652 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
664 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
653 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
665 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
654 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
666 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
655 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
667 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
656
668
657 m_axis->setShadesBrush(shadesBrush);
669 m_axis->setShadesBrush(shadesBrush);
658 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
670 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
659
671
660 QCOMPARE(spy0.count(), 0);
672 QCOMPARE(spy0.count(), 0);
661 QCOMPARE(spy1.count(), 0);
673 QCOMPARE(spy1.count(), 0);
662 QCOMPARE(spy2.count(), 0);
674 QCOMPARE(spy2.count(), 0);
663 QCOMPARE(spy3.count(), 0);
675 QCOMPARE(spy3.count(), 0);
664 QCOMPARE(spy4.count(), 0);
676 QCOMPARE(spy4.count(), 0);
665 QCOMPARE(spy5.count(), 0);
677 QCOMPARE(spy5.count(), 0);
666 //TODO QCOMPARE(spy6.count(), 0);
678 //TODO QCOMPARE(spy6.count(), 0);
667 QCOMPARE(spy7.count(), 0);
679 QCOMPARE(spy7.count(), 0);
668 QCOMPARE(spy8.count(), 0);
680 QCOMPARE(spy8.count(), 0);
669
681
670 m_view->show();
682 m_view->show();
671 QTest::qWaitForWindowShown(m_view);
683 QTest::qWaitForWindowShown(m_view);
672 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
684 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
673 }
685 }
674
686
675 void tst_QAbstractAxis::shadesColor_data()
687 void tst_QAbstractAxis::shadesColor_data()
676 {
688 {
677 }
689 }
678
690
679 // public QColor shadesColor() const
691 // public QColor shadesColor() const
680 void tst_QAbstractAxis::shadesColor()
692 void tst_QAbstractAxis::shadesColor()
681 {
693 {
694 #ifdef QT5_QUICK_1
695 QSKIP("Test is not implemented. This is depreciated function");
696 #else
682 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
697 QSKIP("Test is not implemented. This is depreciated function", SkipAll);
698 #endif
683 }
699 }
684
700
685 void tst_QAbstractAxis::shadesPen_data()
701 void tst_QAbstractAxis::shadesPen_data()
686 {
702 {
687 QTest::addColumn<QPen>("shadesPen");
703 QTest::addColumn<QPen>("shadesPen");
688 QTest::newRow("null") << QPen();
704 QTest::newRow("null") << QPen();
689 QTest::newRow("blue") << QPen(Qt::blue);
705 QTest::newRow("blue") << QPen(Qt::blue);
690 QTest::newRow("black") << QPen(Qt::black);
706 QTest::newRow("black") << QPen(Qt::black);
691 QTest::newRow("red") << QPen(Qt::red);
707 QTest::newRow("red") << QPen(Qt::red);
692 }
708 }
693
709
694 void tst_QAbstractAxis::shadesPen()
710 void tst_QAbstractAxis::shadesPen()
695 {
711 {
696 QFETCH(QPen, shadesPen);
712 QFETCH(QPen, shadesPen);
697
713
698 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
714 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
699 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
715 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
700 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
716 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
701 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
717 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
702 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
718 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
703 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
719 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
704 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
720 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
705 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
721 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
706 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
722 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
707
723
708 m_axis->setShadesPen(shadesPen);
724 m_axis->setShadesPen(shadesPen);
709 QCOMPARE(m_axis->shadesPen(), shadesPen);
725 QCOMPARE(m_axis->shadesPen(), shadesPen);
710
726
711 QCOMPARE(spy0.count(), 0);
727 QCOMPARE(spy0.count(), 0);
712 QCOMPARE(spy1.count(), 0);
728 QCOMPARE(spy1.count(), 0);
713 QCOMPARE(spy2.count(), 0);
729 QCOMPARE(spy2.count(), 0);
714 QCOMPARE(spy3.count(), 0);
730 QCOMPARE(spy3.count(), 0);
715 QCOMPARE(spy4.count(), 0);
731 QCOMPARE(spy4.count(), 0);
716 QCOMPARE(spy5.count(), 0);
732 QCOMPARE(spy5.count(), 0);
717 QCOMPARE(spy6.count(), 0);
733 QCOMPARE(spy6.count(), 0);
718 QCOMPARE(spy7.count(), 0);
734 QCOMPARE(spy7.count(), 0);
719 QCOMPARE(spy8.count(), 0);
735 QCOMPARE(spy8.count(), 0);
720
736
721 m_chart->setAxisX(m_axis, m_series);
737 m_chart->setAxisX(m_axis, m_series);
722 m_view->show();
738 m_view->show();
723 QTest::qWaitForWindowShown(m_view);
739 QTest::qWaitForWindowShown(m_view);
724 QCOMPARE(m_axis->shadesPen(), shadesPen);
740 QCOMPARE(m_axis->shadesPen(), shadesPen);
725 }
741 }
726
742
727 void tst_QAbstractAxis::shadesVisible_data()
743 void tst_QAbstractAxis::shadesVisible_data()
728 {
744 {
729 QTest::addColumn<bool>("shadesVisible");
745 QTest::addColumn<bool>("shadesVisible");
730 QTest::newRow("true") << true;
746 QTest::newRow("true") << true;
731 QTest::newRow("false") << false;
747 QTest::newRow("false") << false;
732 }
748 }
733
749
734 void tst_QAbstractAxis::shadesVisible()
750 void tst_QAbstractAxis::shadesVisible()
735 {
751 {
736 QFETCH(bool, shadesVisible);
752 QFETCH(bool, shadesVisible);
737
753
738 m_axis->setShadesVisible(!shadesVisible);
754 m_axis->setShadesVisible(!shadesVisible);
739
755
740 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
756 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
741 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
757 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
742 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
758 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
743 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
759 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
744 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
760 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
745 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
761 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
746 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
762 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
747 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
763 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
748 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
764 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
749
765
750 m_axis->setShadesVisible(shadesVisible);
766 m_axis->setShadesVisible(shadesVisible);
751 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
767 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
752
768
753 QCOMPARE(spy0.count(), 0);
769 QCOMPARE(spy0.count(), 0);
754 QCOMPARE(spy1.count(), 0);
770 QCOMPARE(spy1.count(), 0);
755 QCOMPARE(spy2.count(), 0);
771 QCOMPARE(spy2.count(), 0);
756 QCOMPARE(spy3.count(), 0);
772 QCOMPARE(spy3.count(), 0);
757 QCOMPARE(spy4.count(), 0);
773 QCOMPARE(spy4.count(), 0);
758 QCOMPARE(spy5.count(), 0);
774 QCOMPARE(spy5.count(), 0);
759 QCOMPARE(spy6.count(), 0);
775 QCOMPARE(spy6.count(), 0);
760 QCOMPARE(spy7.count(), 1);
776 QCOMPARE(spy7.count(), 1);
761 QCOMPARE(spy8.count(), 0);
777 QCOMPARE(spy8.count(), 0);
762
778
763 m_chart->setAxisX(m_axis, m_series);
779 m_chart->setAxisX(m_axis, m_series);
764 m_view->show();
780 m_view->show();
765 QTest::qWaitForWindowShown(m_view);
781 QTest::qWaitForWindowShown(m_view);
766 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
782 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
767 }
783 }
768
784
769 void tst_QAbstractAxis::show_data()
785 void tst_QAbstractAxis::show_data()
770 {
786 {
771
787
772 }
788 }
773
789
774 void tst_QAbstractAxis::show()
790 void tst_QAbstractAxis::show()
775 {
791 {
776 m_axis->hide();
792 m_axis->hide();
777 QCOMPARE(m_axis->isVisible(), false);
793 QCOMPARE(m_axis->isVisible(), false);
778
794
779 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
795 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
780 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
796 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
781 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
797 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
782 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
798 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
783 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
799 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
784 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
800 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
785 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
801 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
786 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
802 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
787 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
803 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
788
804
789 m_axis->show();
805 m_axis->show();
790
806
791 QCOMPARE(spy0.count(), 0);
807 QCOMPARE(spy0.count(), 0);
792 QCOMPARE(spy1.count(), 0);
808 QCOMPARE(spy1.count(), 0);
793 QCOMPARE(spy2.count(), 0);
809 QCOMPARE(spy2.count(), 0);
794 QCOMPARE(spy3.count(), 0);
810 QCOMPARE(spy3.count(), 0);
795 QCOMPARE(spy4.count(), 0);
811 QCOMPARE(spy4.count(), 0);
796 QCOMPARE(spy5.count(), 0);
812 QCOMPARE(spy5.count(), 0);
797 QCOMPARE(spy6.count(), 0);
813 QCOMPARE(spy6.count(), 0);
798 QCOMPARE(spy7.count(), 0);
814 QCOMPARE(spy7.count(), 0);
799 QCOMPARE(spy8.count(), 1);
815 QCOMPARE(spy8.count(), 1);
800 QCOMPARE(m_axis->isVisible(), true);
816 QCOMPARE(m_axis->isVisible(), true);
801 }
817 }
802
818
803 void tst_QAbstractAxis::hide_data()
819 void tst_QAbstractAxis::hide_data()
804 {
820 {
805
821
806 }
822 }
807
823
808 void tst_QAbstractAxis::hide()
824 void tst_QAbstractAxis::hide()
809 {
825 {
810 m_axis->show();
826 m_axis->show();
811 QCOMPARE(m_axis->isVisible(),true);
827 QCOMPARE(m_axis->isVisible(),true);
812
828
813 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
829 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
814 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
830 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
815 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
831 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
816 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
832 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
817 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
833 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
818 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
834 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
819 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
835 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
820 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
836 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
821 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
837 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
822
838
823 m_axis->hide();
839 m_axis->hide();
824
840
825 QCOMPARE(spy0.count(), 0);
841 QCOMPARE(spy0.count(), 0);
826 QCOMPARE(spy1.count(), 0);
842 QCOMPARE(spy1.count(), 0);
827 QCOMPARE(spy2.count(), 0);
843 QCOMPARE(spy2.count(), 0);
828 QCOMPARE(spy3.count(), 0);
844 QCOMPARE(spy3.count(), 0);
829 QCOMPARE(spy4.count(), 0);
845 QCOMPARE(spy4.count(), 0);
830 QCOMPARE(spy5.count(), 0);
846 QCOMPARE(spy5.count(), 0);
831 QCOMPARE(spy6.count(), 0);
847 QCOMPARE(spy6.count(), 0);
832 QCOMPARE(spy7.count(), 0);
848 QCOMPARE(spy7.count(), 0);
833 QCOMPARE(spy8.count(), 1);
849 QCOMPARE(spy8.count(), 1);
834 QCOMPARE(m_axis->isVisible(),false);
850 QCOMPARE(m_axis->isVisible(),false);
835 }
851 }
836
852
837
853
838
854
839
855
840
856
841
857
842
858
843
859
844
860
845
861
846
862
847
863
@@ -1,35 +1,35
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
20
21 #include <QApplication>
21 #include <QApplication>
22 #include <QDeclarativeEngine>
22 #include <QDeclarativeEngine>
23 #include "qmlapplicationviewer.h"
23 #include "qmlapplicationviewer.h"
24
24
25 Q_DECL_EXPORT int main(int argc, char *argv[])
25 Q_DECL_EXPORT int main(int argc, char *argv[])
26 {
26 {
27 QScopedPointer<QApplication> app(createApplication(argc, argv));
27 QScopedPointer<QApplication> app(createApplication(argc, argv));
28 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
28 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
29
29
30 viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
30 // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
31 viewer->setSource(QUrl("qrc:/qml/qmlchartaxis/main.qml"));
31 viewer->setSource(QUrl("qrc:/qml/qmlchartaxis/main.qml"));
32 viewer->showExpanded();
32 viewer->showExpanded();
33
33
34 return app->exec();
34 return app->exec();
35 }
35 }
@@ -1,200 +1,206
1 // checksum 0x78c version 0x60010
1 // checksum 0x78c version 0x60010
2 /*
2 /*
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
4 QmlApplicationViewer is a convenience class containing mobile device specific
4 QmlApplicationViewer is a convenience class containing mobile device specific
5 code such as screen orientation handling. Also QML paths and debugging are
5 code such as screen orientation handling. Also QML paths and debugging are
6 handled here.
6 handled here.
7 It is recommended not to modify this file, since newer versions of Qt Creator
7 It is recommended not to modify this file, since newer versions of Qt Creator
8 may offer an updated version of it.
8 may offer an updated version of it.
9 */
9 */
10
10
11 #include "qmlapplicationviewer.h"
11 #include "qmlapplicationviewer.h"
12
12
13 #include <QtCore/QDir>
13 #include <QtCore/QDir>
14 #include <QtCore/QFileInfo>
14 #include <QtCore/QFileInfo>
15 #include <QtDeclarative/QDeclarativeComponent>
15 #ifdef QT5_QUICK_1
16 #include <QtDeclarative/QDeclarativeEngine>
16 #include <QtQuick1/QDeclarativeComponent>
17 #include <QtDeclarative/QDeclarativeContext>
17 #include <QtQuick1/QDeclarativeEngine>
18 #include <QtQuick1/QDeclarativeContext>
19 #else
20 #include <QtDeclarative/QDeclarativeComponent>
21 #include <QtDeclarative/QDeclarativeEngine>
22 #include <QtDeclarative/QDeclarativeContext>
23 #endif
18 #include <QApplication>
24 #include <QApplication>
19
25
20 #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
26 #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
21
27
22 #ifdef HARMATTAN_BOOSTER
28 #ifdef HARMATTAN_BOOSTER
23 #include <MDeclarativeCache>
29 #include <MDeclarativeCache>
24 #endif
30 #endif
25
31
26 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
32 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
27
33
28 #include <qt_private/qdeclarativedebughelper_p.h>
34 #include <qt_private/qdeclarativedebughelper_p.h>
29
35
30 #if !defined(NO_JSDEBUGGER)
36 #if !defined(NO_JSDEBUGGER)
31 #include <jsdebuggeragent.h>
37 #include <jsdebuggeragent.h>
32 #endif
38 #endif
33 #if !defined(NO_QMLOBSERVER)
39 #if !defined(NO_QMLOBSERVER)
34 #include <qdeclarativeviewobserver.h>
40 #include <qdeclarativeviewobserver.h>
35 #endif
41 #endif
36
42
37 // Enable debugging before any QDeclarativeEngine is created
43 // Enable debugging before any QDeclarativeEngine is created
38 struct QmlJsDebuggingEnabler
44 struct QmlJsDebuggingEnabler
39 {
45 {
40 QmlJsDebuggingEnabler()
46 QmlJsDebuggingEnabler()
41 {
47 {
42 QDeclarativeDebugHelper::enableDebugging();
48 QDeclarativeDebugHelper::enableDebugging();
43 }
49 }
44 };
50 };
45
51
46 // Execute code in constructor before first QDeclarativeEngine is instantiated
52 // Execute code in constructor before first QDeclarativeEngine is instantiated
47 static QmlJsDebuggingEnabler enableDebuggingHelper;
53 static QmlJsDebuggingEnabler enableDebuggingHelper;
48
54
49 #endif // QMLJSDEBUGGER
55 #endif // QMLJSDEBUGGER
50
56
51 class QmlApplicationViewerPrivate
57 class QmlApplicationViewerPrivate
52 {
58 {
53 QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
59 QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
54
60
55 QString mainQmlFile;
61 QString mainQmlFile;
56 QDeclarativeView *view;
62 QDeclarativeView *view;
57 friend class QmlApplicationViewer;
63 friend class QmlApplicationViewer;
58 QString adjustPath(const QString &path);
64 QString adjustPath(const QString &path);
59 };
65 };
60
66
61 QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
67 QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
62 {
68 {
63 #ifdef Q_OS_UNIX
69 #ifdef Q_OS_UNIX
64 #ifdef Q_OS_MAC
70 #ifdef Q_OS_MAC
65 if (!QDir::isAbsolutePath(path))
71 if (!QDir::isAbsolutePath(path))
66 return QCoreApplication::applicationDirPath()
72 return QCoreApplication::applicationDirPath()
67 + QLatin1String("/../Resources/") + path;
73 + QLatin1String("/../Resources/") + path;
68 #else
74 #else
69 QString pathInInstallDir;
75 QString pathInInstallDir;
70 const QString applicationDirPath = QCoreApplication::applicationDirPath();
76 const QString applicationDirPath = QCoreApplication::applicationDirPath();
71 pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
77 pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
72
78
73 if (QFileInfo(pathInInstallDir).exists())
79 if (QFileInfo(pathInInstallDir).exists())
74 return pathInInstallDir;
80 return pathInInstallDir;
75 #endif
81 #endif
76 #endif
82 #endif
77 return path;
83 return path;
78 }
84 }
79
85
80 QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
86 QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
81 : QDeclarativeView(parent)
87 : QDeclarativeView(parent)
82 , d(new QmlApplicationViewerPrivate(this))
88 , d(new QmlApplicationViewerPrivate(this))
83 {
89 {
84 connect(engine(), SIGNAL(quit()), SLOT(close()));
90 connect(engine(), SIGNAL(quit()), SLOT(close()));
85 setResizeMode(QDeclarativeView::SizeRootObjectToView);
91 setResizeMode(QDeclarativeView::SizeRootObjectToView);
86 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
92 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
87 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
93 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
88 #if !defined(NO_JSDEBUGGER)
94 #if !defined(NO_JSDEBUGGER)
89 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
95 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
90 #endif
96 #endif
91 #if !defined(NO_QMLOBSERVER)
97 #if !defined(NO_QMLOBSERVER)
92 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
98 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
93 #endif
99 #endif
94 #endif
100 #endif
95 }
101 }
96
102
97 QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
103 QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
98 : QDeclarativeView(parent)
104 : QDeclarativeView(parent)
99 , d(new QmlApplicationViewerPrivate(view))
105 , d(new QmlApplicationViewerPrivate(view))
100 {
106 {
101 connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
107 connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
102 view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
108 view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
103 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
109 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
104 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
110 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
105 #if !defined(NO_JSDEBUGGER)
111 #if !defined(NO_JSDEBUGGER)
106 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
112 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
107 #endif
113 #endif
108 #if !defined(NO_QMLOBSERVER)
114 #if !defined(NO_QMLOBSERVER)
109 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
115 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
110 #endif
116 #endif
111 #endif
117 #endif
112 }
118 }
113
119
114 QmlApplicationViewer::~QmlApplicationViewer()
120 QmlApplicationViewer::~QmlApplicationViewer()
115 {
121 {
116 delete d;
122 delete d;
117 }
123 }
118
124
119 QmlApplicationViewer *QmlApplicationViewer::create()
125 QmlApplicationViewer *QmlApplicationViewer::create()
120 {
126 {
121 #ifdef HARMATTAN_BOOSTER
127 #ifdef HARMATTAN_BOOSTER
122 return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
128 return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
123 #else
129 #else
124 return new QmlApplicationViewer();
130 return new QmlApplicationViewer();
125 #endif
131 #endif
126 }
132 }
127
133
128 void QmlApplicationViewer::setMainQmlFile(const QString &file)
134 void QmlApplicationViewer::setMainQmlFile(const QString &file)
129 {
135 {
130 d->mainQmlFile = d->adjustPath(file);
136 d->mainQmlFile = d->adjustPath(file);
131 d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
137 d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
132 }
138 }
133
139
134 void QmlApplicationViewer::addImportPath(const QString &path)
140 void QmlApplicationViewer::addImportPath(const QString &path)
135 {
141 {
136 d->view->engine()->addImportPath(d->adjustPath(path));
142 d->view->engine()->addImportPath(d->adjustPath(path));
137 }
143 }
138
144
139 void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
145 //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
140 {
146 //{
141 #if defined(Q_OS_SYMBIAN)
147 //#if defined(Q_OS_SYMBIAN)
142 // If the version of Qt on the device is < 4.7.2, that attribute won't work
148 // // If the version of Qt on the device is < 4.7.2, that attribute won't work
143 if (orientation != ScreenOrientationAuto) {
149 // if (orientation != ScreenOrientationAuto) {
144 const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
150 // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
145 if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
151 // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
146 qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
152 // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
147 return;
153 // return;
148 }
154 // }
149 }
155 // }
150 #endif // Q_OS_SYMBIAN
156 //#endif // Q_OS_SYMBIAN
151
157
152 Qt::WidgetAttribute attribute;
158 // Qt::WidgetAttribute attribute;
153 switch (orientation) {
159 // switch (orientation) {
154 #if QT_VERSION < 0x040702
160 //#if QT_VERSION < 0x040702
155 // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
161 // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
156 case ScreenOrientationLockPortrait:
162 // case ScreenOrientationLockPortrait:
157 attribute = static_cast<Qt::WidgetAttribute>(128);
163 // attribute = static_cast<Qt::WidgetAttribute>(128);
158 break;
164 // break;
159 case ScreenOrientationLockLandscape:
165 // case ScreenOrientationLockLandscape:
160 attribute = static_cast<Qt::WidgetAttribute>(129);
166 // attribute = static_cast<Qt::WidgetAttribute>(129);
161 break;
167 // break;
162 default:
168 // default:
163 case ScreenOrientationAuto:
169 // case ScreenOrientationAuto:
164 attribute = static_cast<Qt::WidgetAttribute>(130);
170 // attribute = static_cast<Qt::WidgetAttribute>(130);
165 break;
171 // break;
166 #else // QT_VERSION < 0x040702
172 //#else // QT_VERSION < 0x040702
167 case ScreenOrientationLockPortrait:
173 // case ScreenOrientationLockPortrait:
168 attribute = Qt::WA_LockPortraitOrientation;
174 // attribute = Qt::WA_LockPortraitOrientation;
169 break;
175 // break;
170 case ScreenOrientationLockLandscape:
176 // case ScreenOrientationLockLandscape:
171 attribute = Qt::WA_LockLandscapeOrientation;
177 // attribute = Qt::WA_LockLandscapeOrientation;
172 break;
178 // break;
173 default:
179 // default:
174 case ScreenOrientationAuto:
180 // case ScreenOrientationAuto:
175 attribute = Qt::WA_AutoOrientation;
181 // attribute = Qt::WA_AutoOrientation;
176 break;
182 // break;
177 #endif // QT_VERSION < 0x040702
183 //#endif // QT_VERSION < 0x040702
178 };
184 // };
179 setAttribute(attribute, true);
185 // setAttribute(attribute, true);
180 }
186 //}
181
187
182 void QmlApplicationViewer::showExpanded()
188 void QmlApplicationViewer::showExpanded()
183 {
189 {
184 #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
190 #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
185 d->view->showFullScreen();
191 d->view->showFullScreen();
186 #elif defined(Q_WS_MAEMO_5)
192 #elif defined(Q_WS_MAEMO_5)
187 d->view->showMaximized();
193 d->view->showMaximized();
188 #else
194 #else
189 d->view->show();
195 d->view->show();
190 #endif
196 #endif
191 }
197 }
192
198
193 QApplication *createApplication(int &argc, char **argv)
199 QApplication *createApplication(int &argc, char **argv)
194 {
200 {
195 #ifdef HARMATTAN_BOOSTER
201 #ifdef HARMATTAN_BOOSTER
196 return MDeclarativeCache::qApplication(argc, argv);
202 return MDeclarativeCache::qApplication(argc, argv);
197 #else
203 #else
198 return new QApplication(argc, argv);
204 return new QApplication(argc, argv);
199 #endif
205 #endif
200 }
206 }
@@ -1,47 +1,51
1 // checksum 0x82ed version 0x60010
1 // checksum 0x82ed version 0x60010
2 /*
2 /*
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
4 QmlApplicationViewer is a convenience class containing mobile device specific
4 QmlApplicationViewer is a convenience class containing mobile device specific
5 code such as screen orientation handling. Also QML paths and debugging are
5 code such as screen orientation handling. Also QML paths and debugging are
6 handled here.
6 handled here.
7 It is recommended not to modify this file, since newer versions of Qt Creator
7 It is recommended not to modify this file, since newer versions of Qt Creator
8 may offer an updated version of it.
8 may offer an updated version of it.
9 */
9 */
10
10
11 #ifndef QMLAPPLICATIONVIEWER_H
11 #ifndef QMLAPPLICATIONVIEWER_H
12 #define QMLAPPLICATIONVIEWER_H
12 #define QMLAPPLICATIONVIEWER_H
13
13
14 #include <QtDeclarative/QDeclarativeView>
14 #ifdef QT5_QUICK_1
15 #include <QtQuick1/QDeclarativeView>
16 #else
17 #include <QtDeclarative/QDeclarativeView>
18 #endif
15
19
16 class QmlApplicationViewer : public QDeclarativeView
20 class QmlApplicationViewer : public QDeclarativeView
17 {
21 {
18 Q_OBJECT
22 Q_OBJECT
19
23
20 public:
24 public:
21 enum ScreenOrientation {
25 enum ScreenOrientation {
22 ScreenOrientationLockPortrait,
26 ScreenOrientationLockPortrait,
23 ScreenOrientationLockLandscape,
27 ScreenOrientationLockLandscape,
24 ScreenOrientationAuto
28 ScreenOrientationAuto
25 };
29 };
26
30
27 explicit QmlApplicationViewer(QWidget *parent = 0);
31 explicit QmlApplicationViewer(QWidget *parent = 0);
28 virtual ~QmlApplicationViewer();
32 virtual ~QmlApplicationViewer();
29
33
30 static QmlApplicationViewer *create();
34 static QmlApplicationViewer *create();
31
35
32 void setMainQmlFile(const QString &file);
36 void setMainQmlFile(const QString &file);
33 void addImportPath(const QString &path);
37 void addImportPath(const QString &path);
34
38
35 // Note that this will only have an effect on Symbian and Fremantle.
39 // Note that this will only have an effect on Symbian and Fremantle.
36 void setOrientation(ScreenOrientation orientation);
40 // void setOrientation(ScreenOrientation orientation);
37
41
38 void showExpanded();
42 void showExpanded();
39
43
40 private:
44 private:
41 explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
45 explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
42 class QmlApplicationViewerPrivate *d;
46 class QmlApplicationViewerPrivate *d;
43 };
47 };
44
48
45 QApplication *createApplication(int &argc, char **argv);
49 QApplication *createApplication(int &argc, char **argv);
46
50
47 #endif // QMLAPPLICATIONVIEWER_H
51 #endif // QMLAPPLICATIONVIEWER_H
@@ -1,36 +1,36
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
20
21 #include <QApplication>
21 #include <QApplication>
22 #include <QDeclarativeEngine>
22 #include <QDeclarativeEngine>
23 #include "qmlapplicationviewer.h"
23 #include "qmlapplicationviewer.h"
24
24
25 Q_DECL_EXPORT int main(int argc, char *argv[])
25 Q_DECL_EXPORT int main(int argc, char *argv[])
26 {
26 {
27 QScopedPointer<QApplication> app(createApplication(argc, argv));
27 QScopedPointer<QApplication> app(createApplication(argc, argv));
28 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
28 QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());
29
29
30 viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
30 // // viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
31 viewer->setSource(QUrl("qrc:/qml/qmlchartproperties/loader.qml"));
31 viewer->setSource(QUrl("qrc:/qml/qmlchartproperties/loader.qml"));
32 viewer->setRenderHint(QPainter::Antialiasing, true);
32 viewer->setRenderHint(QPainter::Antialiasing, true);
33 viewer->showExpanded();
33 viewer->showExpanded();
34
34
35 return app->exec();
35 return app->exec();
36 }
36 }
@@ -1,200 +1,206
1 // checksum 0x78c version 0x60010
1 // checksum 0x78c version 0x60010
2 /*
2 /*
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
4 QmlApplicationViewer is a convenience class containing mobile device specific
4 QmlApplicationViewer is a convenience class containing mobile device specific
5 code such as screen orientation handling. Also QML paths and debugging are
5 code such as screen orientation handling. Also QML paths and debugging are
6 handled here.
6 handled here.
7 It is recommended not to modify this file, since newer versions of Qt Creator
7 It is recommended not to modify this file, since newer versions of Qt Creator
8 may offer an updated version of it.
8 may offer an updated version of it.
9 */
9 */
10
10
11 #include "qmlapplicationviewer.h"
11 #include "qmlapplicationviewer.h"
12
12
13 #include <QtCore/QDir>
13 #include <QtCore/QDir>
14 #include <QtCore/QFileInfo>
14 #include <QtCore/QFileInfo>
15 #include <QtDeclarative/QDeclarativeComponent>
15 #ifdef QT5_QUICK_1
16 #include <QtDeclarative/QDeclarativeEngine>
16 #include <QtQuick1/QDeclarativeComponent>
17 #include <QtDeclarative/QDeclarativeContext>
17 #include <QtQuick1/QDeclarativeEngine>
18 #include <QtQuick1/QDeclarativeContext>
19 #else
20 #include <QtDeclarative/QDeclarativeComponent>
21 #include <QtDeclarative/QDeclarativeEngine>
22 #include <QtDeclarative/QDeclarativeContext>
23 #endif
18 #include <QApplication>
24 #include <QApplication>
19
25
20 #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
26 #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN
21
27
22 #ifdef HARMATTAN_BOOSTER
28 #ifdef HARMATTAN_BOOSTER
23 #include <MDeclarativeCache>
29 #include <MDeclarativeCache>
24 #endif
30 #endif
25
31
26 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
32 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
27
33
28 #include <qt_private/qdeclarativedebughelper_p.h>
34 #include <qt_private/qdeclarativedebughelper_p.h>
29
35
30 #if !defined(NO_JSDEBUGGER)
36 #if !defined(NO_JSDEBUGGER)
31 #include <jsdebuggeragent.h>
37 #include <jsdebuggeragent.h>
32 #endif
38 #endif
33 #if !defined(NO_QMLOBSERVER)
39 #if !defined(NO_QMLOBSERVER)
34 #include <qdeclarativeviewobserver.h>
40 #include <qdeclarativeviewobserver.h>
35 #endif
41 #endif
36
42
37 // Enable debugging before any QDeclarativeEngine is created
43 // Enable debugging before any QDeclarativeEngine is created
38 struct QmlJsDebuggingEnabler
44 struct QmlJsDebuggingEnabler
39 {
45 {
40 QmlJsDebuggingEnabler()
46 QmlJsDebuggingEnabler()
41 {
47 {
42 QDeclarativeDebugHelper::enableDebugging();
48 QDeclarativeDebugHelper::enableDebugging();
43 }
49 }
44 };
50 };
45
51
46 // Execute code in constructor before first QDeclarativeEngine is instantiated
52 // Execute code in constructor before first QDeclarativeEngine is instantiated
47 static QmlJsDebuggingEnabler enableDebuggingHelper;
53 static QmlJsDebuggingEnabler enableDebuggingHelper;
48
54
49 #endif // QMLJSDEBUGGER
55 #endif // QMLJSDEBUGGER
50
56
51 class QmlApplicationViewerPrivate
57 class QmlApplicationViewerPrivate
52 {
58 {
53 QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
59 QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {}
54
60
55 QString mainQmlFile;
61 QString mainQmlFile;
56 QDeclarativeView *view;
62 QDeclarativeView *view;
57 friend class QmlApplicationViewer;
63 friend class QmlApplicationViewer;
58 QString adjustPath(const QString &path);
64 QString adjustPath(const QString &path);
59 };
65 };
60
66
61 QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
67 QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
62 {
68 {
63 #ifdef Q_OS_UNIX
69 #ifdef Q_OS_UNIX
64 #ifdef Q_OS_MAC
70 #ifdef Q_OS_MAC
65 if (!QDir::isAbsolutePath(path))
71 if (!QDir::isAbsolutePath(path))
66 return QCoreApplication::applicationDirPath()
72 return QCoreApplication::applicationDirPath()
67 + QLatin1String("/../Resources/") + path;
73 + QLatin1String("/../Resources/") + path;
68 #else
74 #else
69 QString pathInInstallDir;
75 QString pathInInstallDir;
70 const QString applicationDirPath = QCoreApplication::applicationDirPath();
76 const QString applicationDirPath = QCoreApplication::applicationDirPath();
71 pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
77 pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path);
72
78
73 if (QFileInfo(pathInInstallDir).exists())
79 if (QFileInfo(pathInInstallDir).exists())
74 return pathInInstallDir;
80 return pathInInstallDir;
75 #endif
81 #endif
76 #endif
82 #endif
77 return path;
83 return path;
78 }
84 }
79
85
80 QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
86 QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
81 : QDeclarativeView(parent)
87 : QDeclarativeView(parent)
82 , d(new QmlApplicationViewerPrivate(this))
88 , d(new QmlApplicationViewerPrivate(this))
83 {
89 {
84 connect(engine(), SIGNAL(quit()), SLOT(close()));
90 connect(engine(), SIGNAL(quit()), SLOT(close()));
85 setResizeMode(QDeclarativeView::SizeRootObjectToView);
91 setResizeMode(QDeclarativeView::SizeRootObjectToView);
86 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
92 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
87 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
93 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
88 #if !defined(NO_JSDEBUGGER)
94 #if !defined(NO_JSDEBUGGER)
89 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
95 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
90 #endif
96 #endif
91 #if !defined(NO_QMLOBSERVER)
97 #if !defined(NO_QMLOBSERVER)
92 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
98 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
93 #endif
99 #endif
94 #endif
100 #endif
95 }
101 }
96
102
97 QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
103 QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent)
98 : QDeclarativeView(parent)
104 : QDeclarativeView(parent)
99 , d(new QmlApplicationViewerPrivate(view))
105 , d(new QmlApplicationViewerPrivate(view))
100 {
106 {
101 connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
107 connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
102 view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
108 view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
103 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
109 // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
104 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
110 #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
105 #if !defined(NO_JSDEBUGGER)
111 #if !defined(NO_JSDEBUGGER)
106 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
112 new QmlJSDebugger::JSDebuggerAgent(d->view->engine());
107 #endif
113 #endif
108 #if !defined(NO_QMLOBSERVER)
114 #if !defined(NO_QMLOBSERVER)
109 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
115 new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view);
110 #endif
116 #endif
111 #endif
117 #endif
112 }
118 }
113
119
114 QmlApplicationViewer::~QmlApplicationViewer()
120 QmlApplicationViewer::~QmlApplicationViewer()
115 {
121 {
116 delete d;
122 delete d;
117 }
123 }
118
124
119 QmlApplicationViewer *QmlApplicationViewer::create()
125 QmlApplicationViewer *QmlApplicationViewer::create()
120 {
126 {
121 #ifdef HARMATTAN_BOOSTER
127 #ifdef HARMATTAN_BOOSTER
122 return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
128 return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0);
123 #else
129 #else
124 return new QmlApplicationViewer();
130 return new QmlApplicationViewer();
125 #endif
131 #endif
126 }
132 }
127
133
128 void QmlApplicationViewer::setMainQmlFile(const QString &file)
134 void QmlApplicationViewer::setMainQmlFile(const QString &file)
129 {
135 {
130 d->mainQmlFile = d->adjustPath(file);
136 d->mainQmlFile = d->adjustPath(file);
131 d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
137 d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile));
132 }
138 }
133
139
134 void QmlApplicationViewer::addImportPath(const QString &path)
140 void QmlApplicationViewer::addImportPath(const QString &path)
135 {
141 {
136 d->view->engine()->addImportPath(d->adjustPath(path));
142 d->view->engine()->addImportPath(d->adjustPath(path));
137 }
143 }
138
144
139 void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
145 //void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
140 {
146 //{
141 #if defined(Q_OS_SYMBIAN)
147 //#if defined(Q_OS_SYMBIAN)
142 // If the version of Qt on the device is < 4.7.2, that attribute won't work
148 // // If the version of Qt on the device is < 4.7.2, that attribute won't work
143 if (orientation != ScreenOrientationAuto) {
149 // if (orientation != ScreenOrientationAuto) {
144 const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
150 // const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.'));
145 if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
151 // if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) {
146 qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
152 // qWarning("Screen orientation locking only supported with Qt 4.7.2 and above");
147 return;
153 // return;
148 }
154 // }
149 }
155 // }
150 #endif // Q_OS_SYMBIAN
156 //#endif // Q_OS_SYMBIAN
151
157
152 Qt::WidgetAttribute attribute;
158 // Qt::WidgetAttribute attribute;
153 switch (orientation) {
159 // switch (orientation) {
154 #if QT_VERSION < 0x040702
160 //#if QT_VERSION < 0x040702
155 // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
161 // // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
156 case ScreenOrientationLockPortrait:
162 // case ScreenOrientationLockPortrait:
157 attribute = static_cast<Qt::WidgetAttribute>(128);
163 // attribute = static_cast<Qt::WidgetAttribute>(128);
158 break;
164 // break;
159 case ScreenOrientationLockLandscape:
165 // case ScreenOrientationLockLandscape:
160 attribute = static_cast<Qt::WidgetAttribute>(129);
166 // attribute = static_cast<Qt::WidgetAttribute>(129);
161 break;
167 // break;
162 default:
168 // default:
163 case ScreenOrientationAuto:
169 // case ScreenOrientationAuto:
164 attribute = static_cast<Qt::WidgetAttribute>(130);
170 // attribute = static_cast<Qt::WidgetAttribute>(130);
165 break;
171 // break;
166 #else // QT_VERSION < 0x040702
172 //#else // QT_VERSION < 0x040702
167 case ScreenOrientationLockPortrait:
173 // case ScreenOrientationLockPortrait:
168 attribute = Qt::WA_LockPortraitOrientation;
174 // attribute = Qt::WA_LockPortraitOrientation;
169 break;
175 // break;
170 case ScreenOrientationLockLandscape:
176 // case ScreenOrientationLockLandscape:
171 attribute = Qt::WA_LockLandscapeOrientation;
177 // attribute = Qt::WA_LockLandscapeOrientation;
172 break;
178 // break;
173 default:
179 // default:
174 case ScreenOrientationAuto:
180 // case ScreenOrientationAuto:
175 attribute = Qt::WA_AutoOrientation;
181 // attribute = Qt::WA_AutoOrientation;
176 break;
182 // break;
177 #endif // QT_VERSION < 0x040702
183 //#endif // QT_VERSION < 0x040702
178 };
184 // };
179 setAttribute(attribute, true);
185 // setAttribute(attribute, true);
180 }
186 //}
181
187
182 void QmlApplicationViewer::showExpanded()
188 void QmlApplicationViewer::showExpanded()
183 {
189 {
184 #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
190 #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR)
185 d->view->showFullScreen();
191 d->view->showFullScreen();
186 #elif defined(Q_WS_MAEMO_5)
192 #elif defined(Q_WS_MAEMO_5)
187 d->view->showMaximized();
193 d->view->showMaximized();
188 #else
194 #else
189 d->view->show();
195 d->view->show();
190 #endif
196 #endif
191 }
197 }
192
198
193 QApplication *createApplication(int &argc, char **argv)
199 QApplication *createApplication(int &argc, char **argv)
194 {
200 {
195 #ifdef HARMATTAN_BOOSTER
201 #ifdef HARMATTAN_BOOSTER
196 return MDeclarativeCache::qApplication(argc, argv);
202 return MDeclarativeCache::qApplication(argc, argv);
197 #else
203 #else
198 return new QApplication(argc, argv);
204 return new QApplication(argc, argv);
199 #endif
205 #endif
200 }
206 }
@@ -1,47 +1,51
1 // checksum 0x82ed version 0x60010
1 // checksum 0x82ed version 0x60010
2 /*
2 /*
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
3 This file was generated by the Qt Quick Application wizard of Qt Creator.
4 QmlApplicationViewer is a convenience class containing mobile device specific
4 QmlApplicationViewer is a convenience class containing mobile device specific
5 code such as screen orientation handling. Also QML paths and debugging are
5 code such as screen orientation handling. Also QML paths and debugging are
6 handled here.
6 handled here.
7 It is recommended not to modify this file, since newer versions of Qt Creator
7 It is recommended not to modify this file, since newer versions of Qt Creator
8 may offer an updated version of it.
8 may offer an updated version of it.
9 */
9 */
10
10
11 #ifndef QMLAPPLICATIONVIEWER_H
11 #ifndef QMLAPPLICATIONVIEWER_H
12 #define QMLAPPLICATIONVIEWER_H
12 #define QMLAPPLICATIONVIEWER_H
13
13
14 #include <QtDeclarative/QDeclarativeView>
14 #ifdef QT5_QUICK_1
15 #include <QtQuick1/QDeclarativeView>
16 #else
17 #include <QtDeclarative/QDeclarativeView>
18 #endif
15
19
16 class QmlApplicationViewer : public QDeclarativeView
20 class QmlApplicationViewer : public QDeclarativeView
17 {
21 {
18 Q_OBJECT
22 Q_OBJECT
19
23
20 public:
24 public:
21 enum ScreenOrientation {
25 enum ScreenOrientation {
22 ScreenOrientationLockPortrait,
26 ScreenOrientationLockPortrait,
23 ScreenOrientationLockLandscape,
27 ScreenOrientationLockLandscape,
24 ScreenOrientationAuto
28 ScreenOrientationAuto
25 };
29 };
26
30
27 explicit QmlApplicationViewer(QWidget *parent = 0);
31 explicit QmlApplicationViewer(QWidget *parent = 0);
28 virtual ~QmlApplicationViewer();
32 virtual ~QmlApplicationViewer();
29
33
30 static QmlApplicationViewer *create();
34 static QmlApplicationViewer *create();
31
35
32 void setMainQmlFile(const QString &file);
36 void setMainQmlFile(const QString &file);
33 void addImportPath(const QString &path);
37 void addImportPath(const QString &path);
34
38
35 // Note that this will only have an effect on Symbian and Fremantle.
39 // Note that this will only have an effect on Symbian and Fremantle.
36 void setOrientation(ScreenOrientation orientation);
40 // void setOrientation(ScreenOrientation orientation);
37
41
38 void showExpanded();
42 void showExpanded();
39
43
40 private:
44 private:
41 explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
45 explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent);
42 class QmlApplicationViewerPrivate *d;
46 class QmlApplicationViewerPrivate *d;
43 };
47 };
44
48
45 QApplication *createApplication(int &argc, char **argv);
49 QApplication *createApplication(int &argc, char **argv);
46
50
47 #endif // QMLAPPLICATIONVIEWER_H
51 #endif // QMLAPPLICATIONVIEWER_H
General Comments 0
You need to be logged in to leave comments. Login now