##// END OF EJS Templates
yet another feeble attempt to make bamboo tests pass
Jani Honkonen -
r2078:17fb919aec3a
parent child
Show More
@@ -1,223 +1,225
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 <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <qchartview.h>
22 #include <qchartview.h>
23 #include <qlineseries.h>
23 #include <qlineseries.h>
24 #include <cmath>
24 #include <cmath>
25 #include <tst_definitions.h>
25 #include <tst_definitions.h>
26 #include <qvalueaxis.h>
26 #include <qvalueaxis.h>
27
27
28 QTCOMMERCIALCHART_USE_NAMESPACE
28 QTCOMMERCIALCHART_USE_NAMESPACE
29
29
30
30
31 Q_DECLARE_METATYPE(QChart*)
31 Q_DECLARE_METATYPE(QChart*)
32 Q_DECLARE_METATYPE(QChartView::RubberBands)
32 Q_DECLARE_METATYPE(QChartView::RubberBands)
33 Q_DECLARE_METATYPE(Qt::Key)
33 Q_DECLARE_METATYPE(Qt::Key)
34
34
35 class tst_QChartView : public QObject
35 class tst_QChartView : public QObject
36 {
36 {
37 Q_OBJECT
37 Q_OBJECT
38
38
39 public Q_SLOTS:
39 public Q_SLOTS:
40 void initTestCase();
40 void initTestCase();
41 void cleanupTestCase();
41 void cleanupTestCase();
42 void init();
42 void init();
43 void cleanup();
43 void cleanup();
44
44
45 private Q_SLOTS:
45 private Q_SLOTS:
46 void qchartview_data();
46 void qchartview_data();
47 void qchartview();
47 void qchartview();
48 void chart_data();
48 void chart_data();
49 void chart();
49 void chart();
50 void rubberBand_data();
50 void rubberBand_data();
51 void rubberBand();
51 void rubberBand();
52 void setChart();
52 void setChart();
53
53
54 private:
54 private:
55 QChartView* m_view;
55 QChartView* m_view;
56 };
56 };
57
57
58 void tst_QChartView::initTestCase()
58 void tst_QChartView::initTestCase()
59 {
59 {
60 //test tracks mouse, give a while to user to relese it
60 //test tracks mouse, give a while to user to relese it
61 QTest::qWait(1000);
61 QTest::qWait(1000);
62 }
62 }
63
63
64 void tst_QChartView::cleanupTestCase()
64 void tst_QChartView::cleanupTestCase()
65 {
65 {
66 }
66 }
67
67
68 void tst_QChartView::init()
68 void tst_QChartView::init()
69 {
69 {
70 m_view = new QChartView(new QChart());
70 m_view = new QChartView(new QChart());
71 m_view->chart()->legend()->setVisible(false);
71 m_view->chart()->legend()->setVisible(false);
72 }
72 }
73
73
74 void tst_QChartView::cleanup()
74 void tst_QChartView::cleanup()
75 {
75 {
76 delete m_view;
76 delete m_view;
77 m_view =0;
77 m_view =0;
78 }
78 }
79
79
80 void tst_QChartView::qchartview_data()
80 void tst_QChartView::qchartview_data()
81 {
81 {
82
82
83 }
83 }
84
84
85 void tst_QChartView::qchartview()
85 void tst_QChartView::qchartview()
86 {
86 {
87 QVERIFY(m_view->chart());
87 QVERIFY(m_view->chart());
88 QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand);
88 QCOMPARE(m_view->rubberBand(), QChartView::NoRubberBand);
89 m_view->show();
89 m_view->show();
90 QTest::qWaitForWindowShown(m_view);
90 QTest::qWaitForWindowShown(m_view);
91
91
92 delete(new QChartView());
92 delete(new QChartView());
93
93
94 QChartView view;
94 QChartView view;
95 QVERIFY(view.chart());
95 QVERIFY(view.chart());
96
96
97 }
97 }
98
98
99 void tst_QChartView::chart_data()
99 void tst_QChartView::chart_data()
100 {
100 {
101
101
102 QTest::addColumn<QChart*>("chart");
102 QTest::addColumn<QChart*>("chart");
103 QTest::newRow("qchart") << new QChart();
103 QTest::newRow("qchart") << new QChart();
104 }
104 }
105
105
106 void tst_QChartView::chart()
106 void tst_QChartView::chart()
107 {
107 {
108 QFETCH(QChart*, chart);
108 QFETCH(QChart*, chart);
109 QChartView* view = new QChartView(chart);
109 QChartView* view = new QChartView(chart);
110 QCOMPARE(view->chart(), chart);
110 QCOMPARE(view->chart(), chart);
111 delete view;
111 delete view;
112 }
112 }
113
113
114 void tst_QChartView::rubberBand_data()
114 void tst_QChartView::rubberBand_data()
115 {
115 {
116 QTest::addColumn<QChartView::RubberBands>("rubberBand");
116 QTest::addColumn<QChartView::RubberBands>("rubberBand");
117 QTest::addColumn<int>("Xcount");
117 QTest::addColumn<int>("Xcount");
118 QTest::addColumn<int>("Ycount");
118 QTest::addColumn<int>("Ycount");
119
119
120 QTest::addColumn<QPoint>("min");
120 QTest::addColumn<QPoint>("min");
121 QTest::addColumn<QPoint>("max");
121 QTest::addColumn<QPoint>("max");
122
122
123 QTest::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand) << 0 << 1 << QPoint(5,5) << QPoint(5,5);
123 QTest::newRow("HorizonalRubberBand") << QChartView::RubberBands(QChartView::HorizonalRubberBand) << 0 << 1 << QPoint(5,5) << QPoint(5,5);
124 QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand) << 1 << 0 << QPoint(5,5) << QPoint(5,5);
124 QTest::newRow("VerticalRubberBand") << QChartView::RubberBands(QChartView::VerticalRubberBand) << 1 << 0 << QPoint(5,5) << QPoint(5,5);
125 QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand) << 1 << 1 << QPoint(5,5) << QPoint(5,5);
125 QTest::newRow("RectangleRubberBand") << QChartView::RubberBands(QChartView::RectangleRubberBand) << 1 << 1 << QPoint(5,5) << QPoint(5,5);
126 }
126 }
127
127
128 void tst_QChartView::rubberBand()
128 void tst_QChartView::rubberBand()
129 {
129 {
130 QFETCH(QChartView::RubberBands, rubberBand);
130 QFETCH(QChartView::RubberBands, rubberBand);
131 QFETCH(int, Xcount);
131 QFETCH(int, Xcount);
132 QFETCH(int, Ycount);
132 QFETCH(int, Ycount);
133 QFETCH(QPoint, min);
133 QFETCH(QPoint, min);
134 QFETCH(QPoint, max);
134 QFETCH(QPoint, max);
135
135
136 m_view->setRubberBand(rubberBand);
136 m_view->setRubberBand(rubberBand);
137
137
138 QCOMPARE(m_view->rubberBand(), rubberBand);
138 QCOMPARE(m_view->rubberBand(), rubberBand);
139
139
140 QLineSeries* line = new QLineSeries();
140 QLineSeries* line = new QLineSeries();
141 *line << QPointF(0, 0) << QPointF(200, 200);
141 *line << QPointF(0, 0) << QPointF(200, 200);
142
142
143 m_view->chart()->addSeries(line);
143 m_view->chart()->addSeries(line);
144 m_view->chart()->createDefaultAxes();
144 m_view->chart()->createDefaultAxes();
145 m_view->show();
145 m_view->show();
146 QTest::qWaitForWindowShown(m_view);
146
147
147 QRectF plotArea = m_view->chart()->plotArea();
148 QRectF plotArea = m_view->chart()->plotArea();
148 //this is hack since view does not get events otherwise
149 //this is hack since view does not get events otherwise
149 m_view->setMouseTracking(true);
150 m_view->setMouseTracking(true);
150
151
151 QAbstractAxis* axisY = m_view->chart()->axisY();
152 QAbstractAxis* axisY = m_view->chart()->axisY();
152 QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal,qreal)));
153 QSignalSpy spy0(axisY, SIGNAL(rangeChanged(qreal,qreal)));
153 QAbstractAxis* axisX = m_view->chart()->axisX();
154 QAbstractAxis* axisX = m_view->chart()->axisX();
154 QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal,qreal)));
155 QSignalSpy spy1(axisX, SIGNAL(rangeChanged(qreal,qreal)));
155
156
157 QValueAxis* vaxisX = qobject_cast<QValueAxis*>(axisX);
156 QValueAxis* vaxisX = qobject_cast<QValueAxis*>(axisX);
158 QValueAxis* vaxisY = qobject_cast<QValueAxis*>(axisY);
157 QValueAxis* vaxisY = qobject_cast<QValueAxis*>(axisY);
159
160 int minX = vaxisX->min();
158 int minX = vaxisX->min();
161 int minY = vaxisY->min();
159 int minY = vaxisY->min();
162 int maxX = vaxisX->max();
160 int maxX = vaxisX->max();
163 int maxY = vaxisY->max();
161 int maxY = vaxisY->max();
164
162
165 QTest::qWaitForWindowShown(m_view);
163 // try to ensure focus
166 QTest::mouseMove(m_view->viewport(), min + plotArea.topLeft().toPoint());
164 QApplication::setActiveWindow(m_view);
167 QTest::qWait(2000);
165 m_view->setFocus();
168 QTest::mousePress(m_view->viewport(), Qt::LeftButton, 0, min + plotArea.topLeft().toPoint());
166 QApplication::processEvents();
169 QTest::qWait(2000);
167 QVERIFY(m_view->isActiveWindow());
170 QTest::mouseMove(m_view->viewport(), plotArea.bottomRight().toPoint() - max);
168 QVERIFY(m_view->hasFocus());
171 QTest::qWait(2000);
169
172 QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, plotArea.bottomRight().toPoint() - max);
170 QTest::mouseMove(m_view->viewport(), min + plotArea.topLeft().toPoint(), 100);
171 QTest::mousePress(m_view->viewport(), Qt::LeftButton, 0, min + plotArea.topLeft().toPoint(), 100);
172 QTest::mouseMove(m_view->viewport(), plotArea.bottomRight().toPoint() - max, 100);
173 QTest::mouseRelease(m_view->viewport(), Qt::LeftButton, 0, plotArea.bottomRight().toPoint() - max, 100);
174 QApplication::processEvents();
173
175
174 TRY_COMPARE(spy0.count(), Xcount);
176 TRY_COMPARE(spy0.count(), Xcount);
175 TRY_COMPARE(spy1.count(), Ycount);
177 TRY_COMPARE(spy1.count(), Ycount);
176
178
177 //this is hack since view does not get events otherwise
179 //this is hack since view does not get events otherwise
178 m_view->setMouseTracking(false);
180 m_view->setMouseTracking(false);
179
181
180 QVERIFY(vaxisX->min() >= minX );
182 QVERIFY(vaxisX->min() >= minX );
181 QVERIFY(vaxisX->max() <= maxX );
183 QVERIFY(vaxisX->max() <= maxX );
182 QVERIFY(vaxisY->min() >= minY );
184 QVERIFY(vaxisY->min() >= minY );
183 QVERIFY(vaxisY->max() <= maxY );
185 QVERIFY(vaxisY->max() <= maxY );
184
186
185 }
187 }
186
188
187 void tst_QChartView::setChart()
189 void tst_QChartView::setChart()
188 {
190 {
189 QPointer<QChart> oldChart = m_view->chart();
191 QPointer<QChart> oldChart = m_view->chart();
190 QLineSeries *series1 = new QLineSeries();
192 QLineSeries *series1 = new QLineSeries();
191 series1->append(0,0);
193 series1->append(0,0);
192 series1->append(1,1);
194 series1->append(1,1);
193 oldChart->addSeries(series1);
195 oldChart->addSeries(series1);
194
196
195 QPointer<QChart> newChart = new QChart();
197 QPointer<QChart> newChart = new QChart();
196 QLineSeries *series2 = new QLineSeries();
198 QLineSeries *series2 = new QLineSeries();
197 series2->append(0,1);
199 series2->append(0,1);
198 series2->append(1,0);
200 series2->append(1,0);
199 newChart->addSeries(series2);
201 newChart->addSeries(series2);
200
202
201 // show current chart
203 // show current chart
202 m_view->show();
204 m_view->show();
203 QTest::qWaitForWindowShown(m_view);
205 QTest::qWaitForWindowShown(m_view);
204 QTest::qWait(1000);
206 QTest::qWait(1000);
205
207
206 // set new chart
208 // set new chart
207 m_view->setChart(newChart);
209 m_view->setChart(newChart);
208 QVERIFY(m_view->chart() == newChart);
210 QVERIFY(m_view->chart() == newChart);
209 QVERIFY(!oldChart.isNull()); // ownership of the oldChart is released and not deleted
211 QVERIFY(!oldChart.isNull()); // ownership of the oldChart is released and not deleted
210 QTest::qWait(1000);
212 QTest::qWait(1000);
211
213
212 // delete the view
214 // delete the view
213 delete m_view;
215 delete m_view;
214 m_view = 0;
216 m_view = 0;
215 QVERIFY(newChart.isNull()); // view owns and deletes it
217 QVERIFY(newChart.isNull()); // view owns and deletes it
216 QVERIFY(!oldChart.isNull()); // not owned by view
218 QVERIFY(!oldChart.isNull()); // not owned by view
217
219
218 delete oldChart;
220 delete oldChart;
219 }
221 }
220
222
221 QTEST_MAIN(tst_QChartView)
223 QTEST_MAIN(tst_QChartView)
222 #include "tst_qchartview.moc"
224 #include "tst_qchartview.moc"
223
225
@@ -1,649 +1,656
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 <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <qchartview.h>
22 #include <qchartview.h>
23 #include <qchart.h>
23 #include <qchart.h>
24 #include <qpieseries.h>
24 #include <qpieseries.h>
25 #include <qpieslice.h>
25 #include <qpieslice.h>
26 #include <qpiemodelmapper.h>
26 #include <qpiemodelmapper.h>
27 #include <QStandardItemModel>
27 #include <QStandardItemModel>
28 #include <tst_definitions.h>
28 #include <tst_definitions.h>
29
29
30 QTCOMMERCIALCHART_USE_NAMESPACE
30 QTCOMMERCIALCHART_USE_NAMESPACE
31
31
32 Q_DECLARE_METATYPE(QPieSlice*)
32 Q_DECLARE_METATYPE(QPieSlice*)
33 Q_DECLARE_METATYPE(QList<QPieSlice*>)
33 Q_DECLARE_METATYPE(QList<QPieSlice*>)
34
34
35 class tst_qpieseries : public QObject
35 class tst_qpieseries : public QObject
36 {
36 {
37 Q_OBJECT
37 Q_OBJECT
38
38
39 public slots:
39 public slots:
40 void initTestCase();
40 void initTestCase();
41 void cleanupTestCase();
41 void cleanupTestCase();
42 void init();
42 void init();
43 void cleanup();
43 void cleanup();
44
44
45 private slots:
45 private slots:
46 void properties();
46 void properties();
47 void append();
47 void append();
48 void appendAnimated();
48 void appendAnimated();
49 void insert();
49 void insert();
50 void insertAnimated();
50 void insertAnimated();
51 void remove();
51 void remove();
52 void removeAnimated();
52 void removeAnimated();
53 void take();
53 void take();
54 void takeAnimated();
54 void takeAnimated();
55 void calculatedValues();
55 void calculatedValues();
56 void clickedSignal();
56 void clickedSignal();
57 void hoverSignal();
57 void hoverSignal();
58 void sliceSeries();
58 void sliceSeries();
59 void destruction();
59 void destruction();
60
60
61 private:
61 private:
62 void verifyCalculatedData(const QPieSeries &series, bool *ok);
62 void verifyCalculatedData(const QPieSeries &series, bool *ok);
63 QList<QPoint> slicePoints(QRectF rect);
63 QList<QPoint> slicePoints(QRectF rect);
64
64
65 private:
65 private:
66 QChartView *m_view;
66 QChartView *m_view;
67 QPieSeries *m_series;
67 QPieSeries *m_series;
68 };
68 };
69
69
70 void tst_qpieseries::initTestCase()
70 void tst_qpieseries::initTestCase()
71 {
71 {
72 qRegisterMetaType<QPieSlice*>("QPieSlice*");
72 qRegisterMetaType<QPieSlice*>("QPieSlice*");
73 qRegisterMetaType<QList<QPieSlice*> >("QList<QPieSlice*>");
73 qRegisterMetaType<QList<QPieSlice*> >("QList<QPieSlice*>");
74 }
74 }
75
75
76 void tst_qpieseries::cleanupTestCase()
76 void tst_qpieseries::cleanupTestCase()
77 {
77 {
78 }
78 }
79
79
80 void tst_qpieseries::init()
80 void tst_qpieseries::init()
81 {
81 {
82 m_view = new QChartView();
82 m_view = new QChartView();
83 m_series = new QPieSeries(m_view);
83 m_series = new QPieSeries(m_view);
84 m_view->show();
84 m_view->show();
85 QTest::qWaitForWindowShown(m_view);
85 QTest::qWaitForWindowShown(m_view);
86
86
87 }
87 }
88
88
89 void tst_qpieseries::cleanup()
89 void tst_qpieseries::cleanup()
90 {
90 {
91 delete m_view;
91 delete m_view;
92 m_view = 0;
92 m_view = 0;
93 m_series = 0;
93 m_series = 0;
94 }
94 }
95
95
96 void tst_qpieseries::properties()
96 void tst_qpieseries::properties()
97 {
97 {
98 QSignalSpy countSpy(m_series, SIGNAL(countChanged()));
98 QSignalSpy countSpy(m_series, SIGNAL(countChanged()));
99 QSignalSpy sumSpy(m_series, SIGNAL(sumChanged()));
99 QSignalSpy sumSpy(m_series, SIGNAL(sumChanged()));
100 QSignalSpy opacitySpy(m_series, SIGNAL(opacityChanged()));
100 QSignalSpy opacitySpy(m_series, SIGNAL(opacityChanged()));
101
101
102 QVERIFY(m_series->type() == QAbstractSeries::SeriesTypePie);
102 QVERIFY(m_series->type() == QAbstractSeries::SeriesTypePie);
103 QVERIFY(m_series->count() == 0);
103 QVERIFY(m_series->count() == 0);
104 QVERIFY(m_series->isEmpty());
104 QVERIFY(m_series->isEmpty());
105 QCOMPARE(m_series->sum(), 0.0);
105 QCOMPARE(m_series->sum(), 0.0);
106 QCOMPARE(m_series->horizontalPosition(), 0.5);
106 QCOMPARE(m_series->horizontalPosition(), 0.5);
107 QCOMPARE(m_series->verticalPosition(), 0.5);
107 QCOMPARE(m_series->verticalPosition(), 0.5);
108 QCOMPARE(m_series->pieSize(), 0.7);
108 QCOMPARE(m_series->pieSize(), 0.7);
109 QCOMPARE(m_series->pieStartAngle(), 0.0);
109 QCOMPARE(m_series->pieStartAngle(), 0.0);
110 QCOMPARE(m_series->pieEndAngle(), 360.0);
110 QCOMPARE(m_series->pieEndAngle(), 360.0);
111 QCOMPARE(m_series->opacity(), 1.0);
111 QCOMPARE(m_series->opacity(), 1.0);
112
112
113 m_series->append("s1", 1);
113 m_series->append("s1", 1);
114 m_series->append("s2", 1);
114 m_series->append("s2", 1);
115 m_series->append("s3", 1);
115 m_series->append("s3", 1);
116 m_series->insert(1, new QPieSlice("s4", 1));
116 m_series->insert(1, new QPieSlice("s4", 1));
117 m_series->remove(m_series->slices().first());
117 m_series->remove(m_series->slices().first());
118 QCOMPARE(m_series->count(), 3);
118 QCOMPARE(m_series->count(), 3);
119 QCOMPARE(m_series->sum(), 3.0);
119 QCOMPARE(m_series->sum(), 3.0);
120 m_series->clear();
120 m_series->clear();
121 QCOMPARE(m_series->count(), 0);
121 QCOMPARE(m_series->count(), 0);
122 QCOMPARE(m_series->sum(), 0.0);
122 QCOMPARE(m_series->sum(), 0.0);
123 QCOMPARE(countSpy.count(), 6);
123 QCOMPARE(countSpy.count(), 6);
124 QCOMPARE(sumSpy.count(), 6);
124 QCOMPARE(sumSpy.count(), 6);
125
125
126 m_series->setPieSize(-1.0);
126 m_series->setPieSize(-1.0);
127 QCOMPARE(m_series->pieSize(), 0.0);
127 QCOMPARE(m_series->pieSize(), 0.0);
128 m_series->setPieSize(0.0);
128 m_series->setPieSize(0.0);
129 m_series->setPieSize(0.9);
129 m_series->setPieSize(0.9);
130 m_series->setPieSize(2.0);
130 m_series->setPieSize(2.0);
131 QCOMPARE(m_series->pieSize(), 1.0);
131 QCOMPARE(m_series->pieSize(), 1.0);
132
132
133 m_series->setPieSize(0.7);
133 m_series->setPieSize(0.7);
134 QCOMPARE(m_series->pieSize(), 0.7);
134 QCOMPARE(m_series->pieSize(), 0.7);
135
135
136 m_series->setHoleSize(-1.0);
136 m_series->setHoleSize(-1.0);
137 QCOMPARE(m_series->holeSize(), 0.0);
137 QCOMPARE(m_series->holeSize(), 0.0);
138 m_series->setHoleSize(0.5);
138 m_series->setHoleSize(0.5);
139 QCOMPARE(m_series->holeSize(), 0.5);
139 QCOMPARE(m_series->holeSize(), 0.5);
140
140
141 m_series->setHoleSize(0.8);
141 m_series->setHoleSize(0.8);
142 QCOMPARE(m_series->holeSize(), 0.8);
142 QCOMPARE(m_series->holeSize(), 0.8);
143 QCOMPARE(m_series->pieSize(), 0.8);
143 QCOMPARE(m_series->pieSize(), 0.8);
144
144
145 m_series->setPieSize(0.4);
145 m_series->setPieSize(0.4);
146 QCOMPARE(m_series->pieSize(), 0.4);
146 QCOMPARE(m_series->pieSize(), 0.4);
147 QCOMPARE(m_series->holeSize(), 0.4);
147 QCOMPARE(m_series->holeSize(), 0.4);
148
148
149 m_series->setPieStartAngle(0);
149 m_series->setPieStartAngle(0);
150 m_series->setPieStartAngle(-180);
150 m_series->setPieStartAngle(-180);
151 m_series->setPieStartAngle(180);
151 m_series->setPieStartAngle(180);
152 QCOMPARE(m_series->pieStartAngle(), 180.0);
152 QCOMPARE(m_series->pieStartAngle(), 180.0);
153
153
154 m_series->setPieEndAngle(360);
154 m_series->setPieEndAngle(360);
155 m_series->setPieEndAngle(-180);
155 m_series->setPieEndAngle(-180);
156 m_series->setPieEndAngle(180);
156 m_series->setPieEndAngle(180);
157 QCOMPARE(m_series->pieEndAngle(), 180.0);
157 QCOMPARE(m_series->pieEndAngle(), 180.0);
158
158
159 m_series->setHorizontalPosition(0.5);
159 m_series->setHorizontalPosition(0.5);
160 m_series->setHorizontalPosition(-1.0);
160 m_series->setHorizontalPosition(-1.0);
161 QCOMPARE(m_series->horizontalPosition(), 0.0);
161 QCOMPARE(m_series->horizontalPosition(), 0.0);
162 m_series->setHorizontalPosition(1.0);
162 m_series->setHorizontalPosition(1.0);
163 m_series->setHorizontalPosition(2.0);
163 m_series->setHorizontalPosition(2.0);
164 QCOMPARE(m_series->horizontalPosition(), 1.0);
164 QCOMPARE(m_series->horizontalPosition(), 1.0);
165
165
166 m_series->setVerticalPosition(0.5);
166 m_series->setVerticalPosition(0.5);
167 m_series->setVerticalPosition(-1.0);
167 m_series->setVerticalPosition(-1.0);
168 QCOMPARE(m_series->verticalPosition(), 0.0);
168 QCOMPARE(m_series->verticalPosition(), 0.0);
169 m_series->setVerticalPosition(1.0);
169 m_series->setVerticalPosition(1.0);
170 m_series->setVerticalPosition(2.0);
170 m_series->setVerticalPosition(2.0);
171 QCOMPARE(m_series->verticalPosition(), 1.0);
171 QCOMPARE(m_series->verticalPosition(), 1.0);
172
172
173 m_series->setOpacity(0.5);
173 m_series->setOpacity(0.5);
174 QCOMPARE(m_series->opacity(), 0.5);
174 QCOMPARE(m_series->opacity(), 0.5);
175 QCOMPARE(opacitySpy.count(), 1);
175 QCOMPARE(opacitySpy.count(), 1);
176 m_series->setOpacity(0.0);
176 m_series->setOpacity(0.0);
177 QCOMPARE(m_series->opacity(), 0.0);
177 QCOMPARE(m_series->opacity(), 0.0);
178 QCOMPARE(opacitySpy.count(), 2);
178 QCOMPARE(opacitySpy.count(), 2);
179 m_series->setOpacity(1.0);
179 m_series->setOpacity(1.0);
180 QCOMPARE(m_series->opacity(), 1.0);
180 QCOMPARE(m_series->opacity(), 1.0);
181 QCOMPARE(opacitySpy.count(), 3);
181 QCOMPARE(opacitySpy.count(), 3);
182 }
182 }
183
183
184 void tst_qpieseries::append()
184 void tst_qpieseries::append()
185 {
185 {
186 m_view->chart()->addSeries(m_series);
186 m_view->chart()->addSeries(m_series);
187 QSignalSpy addedSpy(m_series, SIGNAL(added(QList<QPieSlice*>)));
187 QSignalSpy addedSpy(m_series, SIGNAL(added(QList<QPieSlice*>)));
188
188
189 // append pointer
189 // append pointer
190 QPieSlice *slice1 = 0;
190 QPieSlice *slice1 = 0;
191 QVERIFY(!m_series->append(slice1));
191 QVERIFY(!m_series->append(slice1));
192 slice1 = new QPieSlice("slice 1", 1);
192 slice1 = new QPieSlice("slice 1", 1);
193 QVERIFY(m_series->append(slice1));
193 QVERIFY(m_series->append(slice1));
194 QVERIFY(!m_series->append(slice1));
194 QVERIFY(!m_series->append(slice1));
195 QCOMPARE(m_series->count(), 1);
195 QCOMPARE(m_series->count(), 1);
196 QCOMPARE(addedSpy.count(), 1);
196 QCOMPARE(addedSpy.count(), 1);
197 QList<QPieSlice*> added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(0).at(0));
197 QList<QPieSlice*> added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(0).at(0));
198 QCOMPARE(added.count(), 1);
198 QCOMPARE(added.count(), 1);
199 QCOMPARE(added.first(), slice1);
199 QCOMPARE(added.first(), slice1);
200
200
201 // try to append same slice to another series
201 // try to append same slice to another series
202 QPieSeries series2;
202 QPieSeries series2;
203 QVERIFY(!series2.append(slice1));
203 QVERIFY(!series2.append(slice1));
204
204
205 // append pointer list
205 // append pointer list
206 QList<QPieSlice *> list;
206 QList<QPieSlice *> list;
207 QVERIFY(!m_series->append(list));
207 QVERIFY(!m_series->append(list));
208 list << (QPieSlice *) 0;
208 list << (QPieSlice *) 0;
209 QVERIFY(!m_series->append(list));
209 QVERIFY(!m_series->append(list));
210 list.clear();
210 list.clear();
211 list << new QPieSlice("slice 2", 2);
211 list << new QPieSlice("slice 2", 2);
212 list << new QPieSlice("slice 3", 3);
212 list << new QPieSlice("slice 3", 3);
213 QVERIFY(m_series->append(list));
213 QVERIFY(m_series->append(list));
214 QVERIFY(!m_series->append(list));
214 QVERIFY(!m_series->append(list));
215 QCOMPARE(m_series->count(), 3);
215 QCOMPARE(m_series->count(), 3);
216 QCOMPARE(addedSpy.count(), 2);
216 QCOMPARE(addedSpy.count(), 2);
217 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(1).at(0));
217 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(1).at(0));
218 QCOMPARE(added.count(), 2);
218 QCOMPARE(added.count(), 2);
219 QCOMPARE(added, list);
219 QCOMPARE(added, list);
220
220
221 // append operator
221 // append operator
222 QPieSlice *slice4 = new QPieSlice("slice 4", 4);
222 QPieSlice *slice4 = new QPieSlice("slice 4", 4);
223 *m_series << slice4;
223 *m_series << slice4;
224 *m_series << slice1; // fails because already added
224 *m_series << slice1; // fails because already added
225 QCOMPARE(m_series->count(), 4);
225 QCOMPARE(m_series->count(), 4);
226 QCOMPARE(addedSpy.count(), 3);
226 QCOMPARE(addedSpy.count(), 3);
227 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(2).at(0));
227 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(2).at(0));
228 QCOMPARE(added.count(), 1);
228 QCOMPARE(added.count(), 1);
229 QCOMPARE(added.first(), slice4);
229 QCOMPARE(added.first(), slice4);
230
230
231 // append with params
231 // append with params
232 QPieSlice *slice5 = m_series->append("slice 5", 5);
232 QPieSlice *slice5 = m_series->append("slice 5", 5);
233 QVERIFY(slice5 != 0);
233 QVERIFY(slice5 != 0);
234 QCOMPARE(slice5->value(), 5.0);
234 QCOMPARE(slice5->value(), 5.0);
235 QCOMPARE(slice5->label(), QString("slice 5"));
235 QCOMPARE(slice5->label(), QString("slice 5"));
236 QCOMPARE(m_series->count(), 5);
236 QCOMPARE(m_series->count(), 5);
237 QCOMPARE(addedSpy.count(), 4);
237 QCOMPARE(addedSpy.count(), 4);
238 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(3).at(0));
238 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(3).at(0));
239 QCOMPARE(added.count(), 1);
239 QCOMPARE(added.count(), 1);
240 QCOMPARE(added.first(), slice5);
240 QCOMPARE(added.first(), slice5);
241
241
242 // check slices
242 // check slices
243 QVERIFY(!m_series->isEmpty());
243 QVERIFY(!m_series->isEmpty());
244 for (int i=0; i<m_series->count(); i++) {
244 for (int i=0; i<m_series->count(); i++) {
245 QCOMPARE(m_series->slices().at(i)->value(), (qreal) i+1);
245 QCOMPARE(m_series->slices().at(i)->value(), (qreal) i+1);
246 QCOMPARE(m_series->slices().at(i)->label(), QString("slice ") + QString::number(i+1));
246 QCOMPARE(m_series->slices().at(i)->label(), QString("slice ") + QString::number(i+1));
247 }
247 }
248 }
248 }
249
249
250 void tst_qpieseries::appendAnimated()
250 void tst_qpieseries::appendAnimated()
251 {
251 {
252 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
252 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
253 append();
253 append();
254 }
254 }
255
255
256 void tst_qpieseries::insert()
256 void tst_qpieseries::insert()
257 {
257 {
258 m_view->chart()->addSeries(m_series);
258 m_view->chart()->addSeries(m_series);
259 QSignalSpy addedSpy(m_series, SIGNAL(added(QList<QPieSlice*>)));
259 QSignalSpy addedSpy(m_series, SIGNAL(added(QList<QPieSlice*>)));
260
260
261 // insert one slice
261 // insert one slice
262 QPieSlice *slice1 = 0;
262 QPieSlice *slice1 = 0;
263 QVERIFY(!m_series->insert(0, slice1));
263 QVERIFY(!m_series->insert(0, slice1));
264 slice1 = new QPieSlice("slice 1", 1);
264 slice1 = new QPieSlice("slice 1", 1);
265 QVERIFY(!m_series->insert(-1, slice1));
265 QVERIFY(!m_series->insert(-1, slice1));
266 QVERIFY(!m_series->insert(5, slice1));
266 QVERIFY(!m_series->insert(5, slice1));
267 QVERIFY(m_series->insert(0, slice1));
267 QVERIFY(m_series->insert(0, slice1));
268 QVERIFY(!m_series->insert(0, slice1));
268 QVERIFY(!m_series->insert(0, slice1));
269 QCOMPARE(m_series->count(), 1);
269 QCOMPARE(m_series->count(), 1);
270 QCOMPARE(addedSpy.count(), 1);
270 QCOMPARE(addedSpy.count(), 1);
271 QList<QPieSlice*> added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(0).at(0));
271 QList<QPieSlice*> added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(0).at(0));
272 QCOMPARE(added.count(), 1);
272 QCOMPARE(added.count(), 1);
273 QCOMPARE(added.first(), slice1);
273 QCOMPARE(added.first(), slice1);
274
274
275 // try to insert same slice to another series
275 // try to insert same slice to another series
276 QPieSeries series2;
276 QPieSeries series2;
277 QVERIFY(!series2.insert(0, slice1));
277 QVERIFY(!series2.insert(0, slice1));
278
278
279 // add some more slices
279 // add some more slices
280 QPieSlice *slice2 = m_series->append("slice 2", 2);
280 QPieSlice *slice2 = m_series->append("slice 2", 2);
281 QPieSlice *slice4 = m_series->append("slice 4", 4);
281 QPieSlice *slice4 = m_series->append("slice 4", 4);
282 QCOMPARE(m_series->count(), 3);
282 QCOMPARE(m_series->count(), 3);
283 QCOMPARE(addedSpy.count(), 3);
283 QCOMPARE(addedSpy.count(), 3);
284 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(1).at(0));
284 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(1).at(0));
285 QCOMPARE(added.count(), 1);
285 QCOMPARE(added.count(), 1);
286 QCOMPARE(added.first(), slice2);
286 QCOMPARE(added.first(), slice2);
287 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(2).at(0));
287 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(2).at(0));
288 QCOMPARE(added.count(), 1);
288 QCOMPARE(added.count(), 1);
289 QCOMPARE(added.first(), slice4);
289 QCOMPARE(added.first(), slice4);
290
290
291 // insert between slices
291 // insert between slices
292 QPieSlice *slice3 = new QPieSlice("slice 3", 3);
292 QPieSlice *slice3 = new QPieSlice("slice 3", 3);
293 m_series->insert(2, slice3);
293 m_series->insert(2, slice3);
294 QCOMPARE(m_series->count(), 4);
294 QCOMPARE(m_series->count(), 4);
295 QCOMPARE(addedSpy.count(), 4);
295 QCOMPARE(addedSpy.count(), 4);
296 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(3).at(0));
296 added = qvariant_cast<QList<QPieSlice*> >(addedSpy.at(3).at(0));
297 QCOMPARE(added.count(), 1);
297 QCOMPARE(added.count(), 1);
298 QCOMPARE(added.first(), slice3);
298 QCOMPARE(added.first(), slice3);
299
299
300 // check slices
300 // check slices
301 for (int i=0; i<m_series->count(); i++) {
301 for (int i=0; i<m_series->count(); i++) {
302 QCOMPARE(m_series->slices().at(i)->value(), (qreal) i+1);
302 QCOMPARE(m_series->slices().at(i)->value(), (qreal) i+1);
303 QCOMPARE(m_series->slices().at(i)->label(), QString("slice ") + QString::number(i+1));
303 QCOMPARE(m_series->slices().at(i)->label(), QString("slice ") + QString::number(i+1));
304 QVERIFY(m_series->slices().at(i)->parent() == m_series);
304 QVERIFY(m_series->slices().at(i)->parent() == m_series);
305 }
305 }
306 }
306 }
307
307
308 void tst_qpieseries::insertAnimated()
308 void tst_qpieseries::insertAnimated()
309 {
309 {
310 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
310 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
311 insert();
311 insert();
312 }
312 }
313
313
314 void tst_qpieseries::remove()
314 void tst_qpieseries::remove()
315 {
315 {
316 m_view->chart()->addSeries(m_series);
316 m_view->chart()->addSeries(m_series);
317 QSignalSpy removedSpy(m_series, SIGNAL(removed(QList<QPieSlice*>)));
317 QSignalSpy removedSpy(m_series, SIGNAL(removed(QList<QPieSlice*>)));
318
318
319 // add some slices
319 // add some slices
320 QPieSlice *slice1 = m_series->append("slice 1", 1);
320 QPieSlice *slice1 = m_series->append("slice 1", 1);
321 QPieSlice *slice2 = m_series->append("slice 2", 2);
321 QPieSlice *slice2 = m_series->append("slice 2", 2);
322 QPieSlice *slice3 = m_series->append("slice 3", 3);
322 QPieSlice *slice3 = m_series->append("slice 3", 3);
323 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
323 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
324 QSignalSpy spy2(slice2, SIGNAL(destroyed()));
324 QSignalSpy spy2(slice2, SIGNAL(destroyed()));
325 QSignalSpy spy3(slice3, SIGNAL(destroyed()));
325 QSignalSpy spy3(slice3, SIGNAL(destroyed()));
326 QCOMPARE(m_series->count(), 3);
326 QCOMPARE(m_series->count(), 3);
327
327
328 // null pointer remove
328 // null pointer remove
329 QVERIFY(!m_series->remove(0));
329 QVERIFY(!m_series->remove(0));
330
330
331 // remove first
331 // remove first
332 QVERIFY(m_series->remove(slice1));
332 QVERIFY(m_series->remove(slice1));
333 QVERIFY(!m_series->remove(slice1));
333 QVERIFY(!m_series->remove(slice1));
334 QCOMPARE(m_series->count(), 2);
334 QCOMPARE(m_series->count(), 2);
335 QCOMPARE(m_series->slices().at(0)->label(), slice2->label());
335 QCOMPARE(m_series->slices().at(0)->label(), slice2->label());
336 QCOMPARE(removedSpy.count(), 1);
336 QCOMPARE(removedSpy.count(), 1);
337 QList<QPieSlice*> removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(0).at(0));
337 QList<QPieSlice*> removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(0).at(0));
338 QCOMPARE(removed.count(), 1);
338 QCOMPARE(removed.count(), 1);
339 QCOMPARE(removed.first(), slice1);
339 QCOMPARE(removed.first(), slice1);
340
340
341 // remove all
341 // remove all
342 m_series->clear();
342 m_series->clear();
343 QVERIFY(m_series->isEmpty());
343 QVERIFY(m_series->isEmpty());
344 QVERIFY(m_series->slices().isEmpty());
344 QVERIFY(m_series->slices().isEmpty());
345 QCOMPARE(m_series->count(), 0);
345 QCOMPARE(m_series->count(), 0);
346 QCOMPARE(removedSpy.count(), 2);
346 QCOMPARE(removedSpy.count(), 2);
347 removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(1).at(0));
347 removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(1).at(0));
348 QCOMPARE(removed.count(), 2);
348 QCOMPARE(removed.count(), 2);
349 QCOMPARE(removed.first(), slice2);
349 QCOMPARE(removed.first(), slice2);
350 QCOMPARE(removed.last(), slice3);
350 QCOMPARE(removed.last(), slice3);
351
351
352 // check that slices were actually destroyed
352 // check that slices were actually destroyed
353 TRY_COMPARE(spy1.count(), 1);
353 TRY_COMPARE(spy1.count(), 1);
354 TRY_COMPARE(spy2.count(), 1);
354 TRY_COMPARE(spy2.count(), 1);
355 TRY_COMPARE(spy3.count(), 1);
355 TRY_COMPARE(spy3.count(), 1);
356 }
356 }
357
357
358 void tst_qpieseries::removeAnimated()
358 void tst_qpieseries::removeAnimated()
359 {
359 {
360 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
360 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
361 remove();
361 remove();
362 }
362 }
363
363
364 void tst_qpieseries::take()
364 void tst_qpieseries::take()
365 {
365 {
366 m_view->chart()->addSeries(m_series);
366 m_view->chart()->addSeries(m_series);
367 QSignalSpy removedSpy(m_series, SIGNAL(removed(QList<QPieSlice*>)));
367 QSignalSpy removedSpy(m_series, SIGNAL(removed(QList<QPieSlice*>)));
368
368
369 // add some slices
369 // add some slices
370 QPieSlice *slice1 = m_series->append("slice 1", 1);
370 QPieSlice *slice1 = m_series->append("slice 1", 1);
371 QPieSlice *slice2 = m_series->append("slice 2", 2);
371 QPieSlice *slice2 = m_series->append("slice 2", 2);
372 m_series->append("slice 3", 3);
372 m_series->append("slice 3", 3);
373 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
373 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
374 QCOMPARE(m_series->count(), 3);
374 QCOMPARE(m_series->count(), 3);
375
375
376 // null pointer remove
376 // null pointer remove
377 QVERIFY(!m_series->take(0));
377 QVERIFY(!m_series->take(0));
378
378
379 // take first
379 // take first
380 QVERIFY(m_series->take(slice1));
380 QVERIFY(m_series->take(slice1));
381 TRY_COMPARE(spy1.count(), 0);
381 TRY_COMPARE(spy1.count(), 0);
382 QVERIFY(slice1->parent() == m_series); // series is still the parent object
382 QVERIFY(slice1->parent() == m_series); // series is still the parent object
383 QVERIFY(!m_series->take(slice1));
383 QVERIFY(!m_series->take(slice1));
384 QCOMPARE(m_series->count(), 2);
384 QCOMPARE(m_series->count(), 2);
385 QCOMPARE(m_series->slices().at(0)->label(), slice2->label());
385 QCOMPARE(m_series->slices().at(0)->label(), slice2->label());
386 QCOMPARE(removedSpy.count(), 1);
386 QCOMPARE(removedSpy.count(), 1);
387 QList<QPieSlice*> removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(0).at(0));
387 QList<QPieSlice*> removed = qvariant_cast<QList<QPieSlice*> >(removedSpy.at(0).at(0));
388 QCOMPARE(removed.count(), 1);
388 QCOMPARE(removed.count(), 1);
389 QCOMPARE(removed.first(), slice1);
389 QCOMPARE(removed.first(), slice1);
390 }
390 }
391
391
392 void tst_qpieseries::takeAnimated()
392 void tst_qpieseries::takeAnimated()
393 {
393 {
394 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
394 m_view->chart()->setAnimationOptions(QChart::AllAnimations);
395 take();
395 take();
396 }
396 }
397
397
398 void tst_qpieseries::calculatedValues()
398 void tst_qpieseries::calculatedValues()
399 {
399 {
400 m_view->chart()->addSeries(m_series);
400 m_view->chart()->addSeries(m_series);
401
401
402 QPieSlice *slice1 = new QPieSlice("slice 1", 1);
402 QPieSlice *slice1 = new QPieSlice("slice 1", 1);
403 QSignalSpy percentageSpy(slice1, SIGNAL(percentageChanged()));
403 QSignalSpy percentageSpy(slice1, SIGNAL(percentageChanged()));
404 QSignalSpy startAngleSpy(slice1, SIGNAL(startAngleChanged()));
404 QSignalSpy startAngleSpy(slice1, SIGNAL(startAngleChanged()));
405 QSignalSpy angleSpanSpy(slice1, SIGNAL(angleSpanChanged()));
405 QSignalSpy angleSpanSpy(slice1, SIGNAL(angleSpanChanged()));
406
406
407 // add a slice
407 // add a slice
408 m_series->append(slice1);
408 m_series->append(slice1);
409 bool ok;
409 bool ok;
410 verifyCalculatedData(*m_series, &ok);
410 verifyCalculatedData(*m_series, &ok);
411 if (!ok)
411 if (!ok)
412 return;
412 return;
413 QCOMPARE(percentageSpy.count(), 1);
413 QCOMPARE(percentageSpy.count(), 1);
414 QCOMPARE(startAngleSpy.count(), 0);
414 QCOMPARE(startAngleSpy.count(), 0);
415 QCOMPARE(angleSpanSpy.count(), 1);
415 QCOMPARE(angleSpanSpy.count(), 1);
416
416
417 // add some more slices
417 // add some more slices
418 QList<QPieSlice *> list;
418 QList<QPieSlice *> list;
419 list << new QPieSlice("slice 2", 2);
419 list << new QPieSlice("slice 2", 2);
420 list << new QPieSlice("slice 3", 3);
420 list << new QPieSlice("slice 3", 3);
421 m_series->append(list);
421 m_series->append(list);
422 verifyCalculatedData(*m_series, &ok);
422 verifyCalculatedData(*m_series, &ok);
423 if (!ok)
423 if (!ok)
424 return;
424 return;
425 QCOMPARE(percentageSpy.count(), 2);
425 QCOMPARE(percentageSpy.count(), 2);
426 QCOMPARE(startAngleSpy.count(), 0);
426 QCOMPARE(startAngleSpy.count(), 0);
427 QCOMPARE(angleSpanSpy.count(), 2);
427 QCOMPARE(angleSpanSpy.count(), 2);
428
428
429 // remove a slice
429 // remove a slice
430 m_series->remove(list.first()); // remove slice 2
430 m_series->remove(list.first()); // remove slice 2
431 verifyCalculatedData(*m_series, &ok);
431 verifyCalculatedData(*m_series, &ok);
432 if (!ok)
432 if (!ok)
433 return;
433 return;
434 QCOMPARE(percentageSpy.count(), 3);
434 QCOMPARE(percentageSpy.count(), 3);
435 QCOMPARE(startAngleSpy.count(), 0);
435 QCOMPARE(startAngleSpy.count(), 0);
436 QCOMPARE(angleSpanSpy.count(), 3);
436 QCOMPARE(angleSpanSpy.count(), 3);
437
437
438 // insert a slice
438 // insert a slice
439 m_series->insert(0, new QPieSlice("Slice 4", 4));
439 m_series->insert(0, new QPieSlice("Slice 4", 4));
440 verifyCalculatedData(*m_series, &ok);
440 verifyCalculatedData(*m_series, &ok);
441 if (!ok)
441 if (!ok)
442 return;
442 return;
443 QCOMPARE(percentageSpy.count(), 4);
443 QCOMPARE(percentageSpy.count(), 4);
444 QCOMPARE(startAngleSpy.count(), 1);
444 QCOMPARE(startAngleSpy.count(), 1);
445 QCOMPARE(angleSpanSpy.count(), 4);
445 QCOMPARE(angleSpanSpy.count(), 4);
446
446
447 // modify pie angles
447 // modify pie angles
448 m_series->setPieStartAngle(-90);
448 m_series->setPieStartAngle(-90);
449 m_series->setPieEndAngle(90);
449 m_series->setPieEndAngle(90);
450 verifyCalculatedData(*m_series, &ok);
450 verifyCalculatedData(*m_series, &ok);
451 if (!ok)
451 if (!ok)
452 return;
452 return;
453 QCOMPARE(percentageSpy.count(), 4);
453 QCOMPARE(percentageSpy.count(), 4);
454 QCOMPARE(startAngleSpy.count(), 3);
454 QCOMPARE(startAngleSpy.count(), 3);
455 QCOMPARE(angleSpanSpy.count(), 6);
455 QCOMPARE(angleSpanSpy.count(), 6);
456
456
457 // clear all
457 // clear all
458 m_series->clear();
458 m_series->clear();
459 verifyCalculatedData(*m_series, &ok);
459 verifyCalculatedData(*m_series, &ok);
460 if (!ok)
460 if (!ok)
461 return;
461 return;
462 QCOMPARE(percentageSpy.count(), 4);
462 QCOMPARE(percentageSpy.count(), 4);
463 QCOMPARE(startAngleSpy.count(), 3);
463 QCOMPARE(startAngleSpy.count(), 3);
464 QCOMPARE(angleSpanSpy.count(), 6);
464 QCOMPARE(angleSpanSpy.count(), 6);
465 }
465 }
466
466
467 void tst_qpieseries::verifyCalculatedData(const QPieSeries &series, bool *ok)
467 void tst_qpieseries::verifyCalculatedData(const QPieSeries &series, bool *ok)
468 {
468 {
469 *ok = false;
469 *ok = false;
470
470
471 qreal sum = 0;
471 qreal sum = 0;
472 foreach (const QPieSlice *slice, series.slices())
472 foreach (const QPieSlice *slice, series.slices())
473 sum += slice->value();
473 sum += slice->value();
474 QCOMPARE(series.sum(), sum);
474 QCOMPARE(series.sum(), sum);
475
475
476 qreal startAngle = series.pieStartAngle();
476 qreal startAngle = series.pieStartAngle();
477 qreal pieAngleSpan = series.pieEndAngle() - series.pieStartAngle();
477 qreal pieAngleSpan = series.pieEndAngle() - series.pieStartAngle();
478 foreach (const QPieSlice *slice, series.slices()) {
478 foreach (const QPieSlice *slice, series.slices()) {
479 qreal ratio = slice->value() / sum;
479 qreal ratio = slice->value() / sum;
480 qreal sliceSpan = pieAngleSpan * ratio;
480 qreal sliceSpan = pieAngleSpan * ratio;
481 QCOMPARE(slice->startAngle(), startAngle);
481 QCOMPARE(slice->startAngle(), startAngle);
482 QCOMPARE(slice->angleSpan(), sliceSpan);
482 QCOMPARE(slice->angleSpan(), sliceSpan);
483 QCOMPARE(slice->percentage(), ratio);
483 QCOMPARE(slice->percentage(), ratio);
484 startAngle += sliceSpan;
484 startAngle += sliceSpan;
485 }
485 }
486
486
487 if (!series.isEmpty())
487 if (!series.isEmpty())
488 QCOMPARE(series.slices().last()->startAngle() + series.slices().last()->angleSpan(), series.pieEndAngle());
488 QCOMPARE(series.slices().last()->startAngle() + series.slices().last()->angleSpan(), series.pieEndAngle());
489
489
490 *ok = true;
490 *ok = true;
491 }
491 }
492
492
493 void tst_qpieseries::clickedSignal()
493 void tst_qpieseries::clickedSignal()
494 {
494 {
495 // NOTE:
495 // NOTE:
496 // This test is the same as tst_qpieslice::clickedSignal()
496 // This test is the same as tst_qpieslice::clickedSignal()
497 // Just for different signals.
497 // Just for different signals.
498
498
499 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
499 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
500
500
501 // add some slices
501 // add some slices
502 QPieSlice *s1 = m_series->append("slice 1", 1);
502 QPieSlice *s1 = m_series->append("slice 1", 1);
503 QPieSlice *s2 = m_series->append("slice 2", 1);
503 QPieSlice *s2 = m_series->append("slice 2", 1);
504 QPieSlice *s3 = m_series->append("slice 3", 1);
504 QPieSlice *s3 = m_series->append("slice 3", 1);
505 QPieSlice *s4 = m_series->append("slice 4", 1);
505 QPieSlice *s4 = m_series->append("slice 4", 1);
506 QSignalSpy clickSpy(m_series, SIGNAL(clicked(QPieSlice*)));
506 QSignalSpy clickSpy(m_series, SIGNAL(clicked(QPieSlice*)));
507
507
508 // add series to the chart
508 // add series to the chart
509 m_view->chart()->legend()->setVisible(false);
509 m_view->chart()->legend()->setVisible(false);
510 m_view->chart()->addSeries(m_series);
510 m_view->chart()->addSeries(m_series);
511 m_view->show();
511 m_view->show();
512 QTest::qWaitForWindowShown(m_view);
512 QTest::qWaitForWindowShown(m_view);
513
513
514 // test maximum size
514 // test maximum size
515 m_series->setPieSize(1.0);
515 m_series->setPieSize(1.0);
516 QRectF pieRect = m_view->chart()->plotArea();
516 QRectF pieRect = m_view->chart()->plotArea();
517 QList<QPoint> points = slicePoints(pieRect);
517 QList<QPoint> points = slicePoints(pieRect);
518 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(0));
518 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(0));
519 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(1));
519 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(1));
520 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(2));
520 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(2));
521 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(3));
521 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(3));
522 TRY_COMPARE(clickSpy.count(), 4);
522 TRY_COMPARE(clickSpy.count(), 4);
523 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(0).at(0)), s1);
523 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(0).at(0)), s1);
524 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(1).at(0)), s2);
524 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(1).at(0)), s2);
525 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(2).at(0)), s3);
525 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(2).at(0)), s3);
526 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(3).at(0)), s4);
526 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(3).at(0)), s4);
527 clickSpy.clear();
527 clickSpy.clear();
528
528
529 // test half size
529 // test half size
530 m_series->setPieSize(0.5);
530 m_series->setPieSize(0.5);
531 m_series->setVerticalPosition(0.25);
531 m_series->setVerticalPosition(0.25);
532 m_series->setHorizontalPosition(0.25);
532 m_series->setHorizontalPosition(0.25);
533 pieRect = QRectF(m_view->chart()->plotArea().topLeft(), m_view->chart()->plotArea().center());
533 pieRect = QRectF(m_view->chart()->plotArea().topLeft(), m_view->chart()->plotArea().center());
534 points = slicePoints(pieRect);
534 points = slicePoints(pieRect);
535 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(0));
535 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(0));
536 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(1));
536 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(1));
537 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(2));
537 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(2));
538 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(3));
538 QTest::mouseClick(m_view->viewport(), Qt::LeftButton, 0, points.at(3));
539 TRY_COMPARE(clickSpy.count(), 4);
539 TRY_COMPARE(clickSpy.count(), 4);
540 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(0).at(0)), s1);
540 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(0).at(0)), s1);
541 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(1).at(0)), s2);
541 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(1).at(0)), s2);
542 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(2).at(0)), s3);
542 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(2).at(0)), s3);
543 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(3).at(0)), s4);
543 QCOMPARE(qvariant_cast<QPieSlice*>(clickSpy.at(3).at(0)), s4);
544 }
544 }
545
545
546 void tst_qpieseries::hoverSignal()
546 void tst_qpieseries::hoverSignal()
547 {
547 {
548 // NOTE:
548 // NOTE:
549 // This test is the same as tst_qpieslice::hoverSignal()
549 // This test is the same as tst_qpieslice::hoverSignal()
550 // Just for different signals.
550 // Just for different signals.
551
551
552 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
552 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
553
553
554 // add some slices
554 // add some slices
555 m_series->append("slice 1", 1);
555 m_series->append("slice 1", 1);
556 m_series->append("slice 2", 1);
556 m_series->append("slice 2", 1);
557 m_series->append("slice 3", 1);
557 m_series->append("slice 3", 1);
558 m_series->append("slice 4", 1);
558 m_series->append("slice 4", 1);
559
559
560 // add series to the chart
560 // add series to the chart
561 m_view->chart()->legend()->setVisible(false);
561 m_view->chart()->legend()->setVisible(false);
562 m_view->chart()->addSeries(m_series);
562 m_view->chart()->addSeries(m_series);
563 m_view->show();
563 m_view->show();
564 QTest::qWaitForWindowShown(m_view);
564 QTest::qWaitForWindowShown(m_view);
565
565
566 // try to ensure focus
567 QApplication::setActiveWindow(m_view);
568 m_view->setFocus();
569 QApplication::processEvents();
570 QVERIFY(m_view->isActiveWindow());
571 QVERIFY(m_view->hasFocus());
572
566 // move inside the slices
573 // move inside the slices
567 m_series->setPieSize(1.0);
574 m_series->setPieSize(1.0);
568 QRectF pieRect = m_view->chart()->plotArea();
575 QRectF pieRect = m_view->chart()->plotArea();
569 QList<QPoint> points = slicePoints(pieRect);
576 QList<QPoint> points = slicePoints(pieRect);
570 QTest::mouseMove(m_view->viewport(), pieRect.topRight().toPoint(), 100);
577 QTest::mouseMove(m_view->viewport(), pieRect.topRight().toPoint(), 100);
571 QSignalSpy hoverSpy(m_series, SIGNAL(hovered(QPieSlice*,bool)));
578 QSignalSpy hoverSpy(m_series, SIGNAL(hovered(QPieSlice*,bool)));
572 QTest::mouseMove(m_view->viewport(), points.at(0), 100);
579 QTest::mouseMove(m_view->viewport(), points.at(0), 100);
573 QTest::mouseMove(m_view->viewport(), points.at(1), 100);
580 QTest::mouseMove(m_view->viewport(), points.at(1), 100);
574 QTest::mouseMove(m_view->viewport(), points.at(2), 100);
581 QTest::mouseMove(m_view->viewport(), points.at(2), 100);
575 QTest::mouseMove(m_view->viewport(), points.at(3), 100);
582 QTest::mouseMove(m_view->viewport(), points.at(3), 100);
576 QTest::mouseMove(m_view->viewport(), pieRect.topLeft().toPoint(), 100);
583 QTest::mouseMove(m_view->viewport(), pieRect.topLeft().toPoint(), 100);
577 QApplication::processEvents();
584 QApplication::processEvents();
578
585
579 // check
586 // check
580 QCOMPARE(hoverSpy.count(), 8);
587 QCOMPARE(hoverSpy.count(), 8);
581 int i = 0;
588 int i = 0;
582 foreach (QPieSlice *s, m_series->slices()) {
589 foreach (QPieSlice *s, m_series->slices()) {
583 QCOMPARE(qvariant_cast<QPieSlice*>(hoverSpy.at(i).at(0)), s);
590 QCOMPARE(qvariant_cast<QPieSlice*>(hoverSpy.at(i).at(0)), s);
584 QCOMPARE(qvariant_cast<bool>(hoverSpy.at(i).at(1)), true);
591 QCOMPARE(qvariant_cast<bool>(hoverSpy.at(i).at(1)), true);
585 i++;
592 i++;
586 QCOMPARE(qvariant_cast<QPieSlice*>(hoverSpy.at(i).at(0)), s);
593 QCOMPARE(qvariant_cast<QPieSlice*>(hoverSpy.at(i).at(0)), s);
587 QCOMPARE(qvariant_cast<bool>(hoverSpy.at(i).at(1)), false);
594 QCOMPARE(qvariant_cast<bool>(hoverSpy.at(i).at(1)), false);
588 i++;
595 i++;
589 }
596 }
590 }
597 }
591
598
592 void tst_qpieseries::sliceSeries()
599 void tst_qpieseries::sliceSeries()
593 {
600 {
594 QPieSlice *slice = new QPieSlice();
601 QPieSlice *slice = new QPieSlice();
595 QVERIFY(!slice->series());
602 QVERIFY(!slice->series());
596 delete slice;
603 delete slice;
597
604
598 slice = new QPieSlice(m_series);
605 slice = new QPieSlice(m_series);
599 QVERIFY(!slice->series());
606 QVERIFY(!slice->series());
600
607
601 m_series->append(slice);
608 m_series->append(slice);
602 QCOMPARE(slice->series(), m_series);
609 QCOMPARE(slice->series(), m_series);
603
610
604 slice = new QPieSlice();
611 slice = new QPieSlice();
605 m_series->insert(0, slice);
612 m_series->insert(0, slice);
606 QCOMPARE(slice->series(), m_series);
613 QCOMPARE(slice->series(), m_series);
607
614
608 m_series->take(slice);
615 m_series->take(slice);
609 QCOMPARE(slice->series(), (QPieSeries*) 0);
616 QCOMPARE(slice->series(), (QPieSeries*) 0);
610 }
617 }
611
618
612 void tst_qpieseries::destruction()
619 void tst_qpieseries::destruction()
613 {
620 {
614 // add some slices
621 // add some slices
615 QPieSlice *slice1 = m_series->append("slice 1", 1);
622 QPieSlice *slice1 = m_series->append("slice 1", 1);
616 QPieSlice *slice2 = m_series->append("slice 2", 2);
623 QPieSlice *slice2 = m_series->append("slice 2", 2);
617 QPieSlice *slice3 = m_series->append("slice 3", 3);
624 QPieSlice *slice3 = m_series->append("slice 3", 3);
618 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
625 QSignalSpy spy1(slice1, SIGNAL(destroyed()));
619 QSignalSpy spy2(slice2, SIGNAL(destroyed()));
626 QSignalSpy spy2(slice2, SIGNAL(destroyed()));
620 QSignalSpy spy3(slice3, SIGNAL(destroyed()));
627 QSignalSpy spy3(slice3, SIGNAL(destroyed()));
621
628
622 // destroy series
629 // destroy series
623 delete m_series;
630 delete m_series;
624 m_series = 0;
631 m_series = 0;
625
632
626 // check that series has destroyed its slices
633 // check that series has destroyed its slices
627 QCOMPARE(spy1.count(), 1);
634 QCOMPARE(spy1.count(), 1);
628 QCOMPARE(spy2.count(), 1);
635 QCOMPARE(spy2.count(), 1);
629 QCOMPARE(spy3.count(), 1);
636 QCOMPARE(spy3.count(), 1);
630 }
637 }
631
638
632 QList<QPoint> tst_qpieseries::slicePoints(QRectF rect)
639 QList<QPoint> tst_qpieseries::slicePoints(QRectF rect)
633 {
640 {
634 qreal x1 = rect.topLeft().x() + (rect.width() / 4);
641 qreal x1 = rect.topLeft().x() + (rect.width() / 4);
635 qreal x2 = rect.topLeft().x() + (rect.width() / 4) * 3;
642 qreal x2 = rect.topLeft().x() + (rect.width() / 4) * 3;
636 qreal y1 = rect.topLeft().y() + (rect.height() / 4);
643 qreal y1 = rect.topLeft().y() + (rect.height() / 4);
637 qreal y2 = rect.topLeft().y() + (rect.height() / 4) * 3;
644 qreal y2 = rect.topLeft().y() + (rect.height() / 4) * 3;
638 QList<QPoint> points;
645 QList<QPoint> points;
639 points << QPoint(x2, y1);
646 points << QPoint(x2, y1);
640 points << QPoint(x2, y2);
647 points << QPoint(x2, y2);
641 points << QPoint(x1, y2);
648 points << QPoint(x1, y2);
642 points << QPoint(x1, y1);
649 points << QPoint(x1, y1);
643 return points;
650 return points;
644 }
651 }
645
652
646 QTEST_MAIN(tst_qpieseries)
653 QTEST_MAIN(tst_qpieseries)
647
654
648 #include "tst_qpieseries.moc"
655 #include "tst_qpieseries.moc"
649
656
@@ -1,332 +1,339
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 <QtTest/QtTest>
21 #include <QtTest/QtTest>
22 #include <tst_definitions.h>
22 #include <tst_definitions.h>
23 #include <qchartview.h>
23 #include <qchartview.h>
24 #include <qchart.h>
24 #include <qchart.h>
25 #include <qpieslice.h>
25 #include <qpieslice.h>
26 #include <qpieseries.h>
26 #include <qpieseries.h>
27
27
28 QTCOMMERCIALCHART_USE_NAMESPACE
28 QTCOMMERCIALCHART_USE_NAMESPACE
29
29
30 class tst_qpieslice : public QObject
30 class tst_qpieslice : public QObject
31 {
31 {
32 Q_OBJECT
32 Q_OBJECT
33
33
34 public slots:
34 public slots:
35 void initTestCase();
35 void initTestCase();
36 void cleanupTestCase();
36 void cleanupTestCase();
37 void init();
37 void init();
38 void cleanup();
38 void cleanup();
39
39
40 private slots:
40 private slots:
41 void construction();
41 void construction();
42 void changedSignals();
42 void changedSignals();
43 void customize();
43 void customize();
44 void clickedSignal();
44 void clickedSignal();
45 void hoverSignal();
45 void hoverSignal();
46
46
47 private:
47 private:
48 QList<QPoint> slicePoints(QRectF rect);
48 QList<QPoint> slicePoints(QRectF rect);
49
49
50 private:
50 private:
51
51
52 };
52 };
53
53
54 void tst_qpieslice::initTestCase()
54 void tst_qpieslice::initTestCase()
55 {
55 {
56 }
56 }
57
57
58 void tst_qpieslice::cleanupTestCase()
58 void tst_qpieslice::cleanupTestCase()
59 {
59 {
60 }
60 }
61
61
62 void tst_qpieslice::init()
62 void tst_qpieslice::init()
63 {
63 {
64
64
65 }
65 }
66
66
67 void tst_qpieslice::cleanup()
67 void tst_qpieslice::cleanup()
68 {
68 {
69
69
70 }
70 }
71
71
72 void tst_qpieslice::construction()
72 void tst_qpieslice::construction()
73 {
73 {
74 // no params
74 // no params
75 QPieSlice slice1;
75 QPieSlice slice1;
76 QCOMPARE(slice1.value(), 0.0);
76 QCOMPARE(slice1.value(), 0.0);
77 QVERIFY(slice1.label().isEmpty());
77 QVERIFY(slice1.label().isEmpty());
78 QVERIFY(!slice1.isLabelVisible());
78 QVERIFY(!slice1.isLabelVisible());
79 QVERIFY(!slice1.isExploded());
79 QVERIFY(!slice1.isExploded());
80 QCOMPARE(slice1.pen(), QPen());
80 QCOMPARE(slice1.pen(), QPen());
81 QCOMPARE(slice1.brush(), QBrush());
81 QCOMPARE(slice1.brush(), QBrush());
82 QCOMPARE(slice1.labelBrush(), QBrush());
82 QCOMPARE(slice1.labelBrush(), QBrush());
83 QCOMPARE(slice1.labelFont(), QFont());
83 QCOMPARE(slice1.labelFont(), QFont());
84 QCOMPARE(slice1.labelArmLengthFactor(), 0.15); // default value
84 QCOMPARE(slice1.labelArmLengthFactor(), 0.15); // default value
85 QCOMPARE(slice1.explodeDistanceFactor(), 0.15); // default value
85 QCOMPARE(slice1.explodeDistanceFactor(), 0.15); // default value
86 QCOMPARE(slice1.percentage(), 0.0);
86 QCOMPARE(slice1.percentage(), 0.0);
87 QCOMPARE(slice1.startAngle(), 0.0);
87 QCOMPARE(slice1.startAngle(), 0.0);
88 QCOMPARE(slice1.angleSpan(), 0.0);
88 QCOMPARE(slice1.angleSpan(), 0.0);
89
89
90 // value and label params
90 // value and label params
91 QPieSlice slice2("foobar", 1.0);
91 QPieSlice slice2("foobar", 1.0);
92 QCOMPARE(slice2.value(), 1.0);
92 QCOMPARE(slice2.value(), 1.0);
93 QCOMPARE(slice2.label(), QString("foobar"));
93 QCOMPARE(slice2.label(), QString("foobar"));
94 QVERIFY(!slice2.isLabelVisible());
94 QVERIFY(!slice2.isLabelVisible());
95 QVERIFY(!slice2.isExploded());
95 QVERIFY(!slice2.isExploded());
96 QCOMPARE(slice2.pen(), QPen());
96 QCOMPARE(slice2.pen(), QPen());
97 QCOMPARE(slice2.brush(), QBrush());
97 QCOMPARE(slice2.brush(), QBrush());
98 QCOMPARE(slice2.labelBrush(), QBrush());
98 QCOMPARE(slice2.labelBrush(), QBrush());
99 QCOMPARE(slice2.labelFont(), QFont());
99 QCOMPARE(slice2.labelFont(), QFont());
100 QCOMPARE(slice2.labelArmLengthFactor(), 0.15); // default value
100 QCOMPARE(slice2.labelArmLengthFactor(), 0.15); // default value
101 QCOMPARE(slice2.explodeDistanceFactor(), 0.15); // default value
101 QCOMPARE(slice2.explodeDistanceFactor(), 0.15); // default value
102 QCOMPARE(slice2.percentage(), 0.0);
102 QCOMPARE(slice2.percentage(), 0.0);
103 QCOMPARE(slice2.startAngle(), 0.0);
103 QCOMPARE(slice2.startAngle(), 0.0);
104 QCOMPARE(slice2.angleSpan(), 0.0);
104 QCOMPARE(slice2.angleSpan(), 0.0);
105 }
105 }
106
106
107 void tst_qpieslice::changedSignals()
107 void tst_qpieslice::changedSignals()
108 {
108 {
109 QPieSlice slice;
109 QPieSlice slice;
110
110
111 QSignalSpy valueSpy(&slice, SIGNAL(valueChanged()));
111 QSignalSpy valueSpy(&slice, SIGNAL(valueChanged()));
112 QSignalSpy labelSpy(&slice, SIGNAL(labelChanged()));
112 QSignalSpy labelSpy(&slice, SIGNAL(labelChanged()));
113 QSignalSpy penSpy(&slice, SIGNAL(penChanged()));
113 QSignalSpy penSpy(&slice, SIGNAL(penChanged()));
114 QSignalSpy brushSpy(&slice, SIGNAL(brushChanged()));
114 QSignalSpy brushSpy(&slice, SIGNAL(brushChanged()));
115 QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged()));
115 QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged()));
116 QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged()));
116 QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged()));
117 QSignalSpy colorSpy(&slice, SIGNAL(colorChanged()));
117 QSignalSpy colorSpy(&slice, SIGNAL(colorChanged()));
118 QSignalSpy borderColorSpy(&slice, SIGNAL(borderColorChanged()));
118 QSignalSpy borderColorSpy(&slice, SIGNAL(borderColorChanged()));
119 QSignalSpy borderWidthSpy(&slice, SIGNAL(borderWidthChanged()));
119 QSignalSpy borderWidthSpy(&slice, SIGNAL(borderWidthChanged()));
120 QSignalSpy labelColorSpy(&slice, SIGNAL(labelColorChanged()));
120 QSignalSpy labelColorSpy(&slice, SIGNAL(labelColorChanged()));
121
121
122 // percentageChanged(), startAngleChanged() and angleSpanChanged() signals tested at tst_qpieseries::calculatedValues()
122 // percentageChanged(), startAngleChanged() and angleSpanChanged() signals tested at tst_qpieseries::calculatedValues()
123
123
124 // set everything twice to see we do not get unnecessary signals
124 // set everything twice to see we do not get unnecessary signals
125 slice.setValue(1.0);
125 slice.setValue(1.0);
126 slice.setValue(-1.0);
126 slice.setValue(-1.0);
127 QCOMPARE(slice.value(), 1.0);
127 QCOMPARE(slice.value(), 1.0);
128 slice.setLabel("foobar");
128 slice.setLabel("foobar");
129 slice.setLabel("foobar");
129 slice.setLabel("foobar");
130 slice.setLabelVisible();
130 slice.setLabelVisible();
131 slice.setLabelVisible();
131 slice.setLabelVisible();
132 slice.setExploded();
132 slice.setExploded();
133 slice.setExploded();
133 slice.setExploded();
134 slice.setPen(QPen(Qt::red));
134 slice.setPen(QPen(Qt::red));
135 slice.setPen(QPen(QBrush(Qt::red), 3));
135 slice.setPen(QPen(QBrush(Qt::red), 3));
136 slice.setBrush(QBrush(Qt::red));
136 slice.setBrush(QBrush(Qt::red));
137 slice.setBrush(QBrush(Qt::red));
137 slice.setBrush(QBrush(Qt::red));
138 slice.setLabelBrush(QBrush(Qt::green));
138 slice.setLabelBrush(QBrush(Qt::green));
139 slice.setLabelBrush(QBrush(Qt::green));
139 slice.setLabelBrush(QBrush(Qt::green));
140 slice.setLabelFont(QFont("Tahoma"));
140 slice.setLabelFont(QFont("Tahoma"));
141 slice.setLabelFont(QFont("Tahoma"));
141 slice.setLabelFont(QFont("Tahoma"));
142 slice.setLabelPosition(QPieSlice::LabelInsideHorizontal);
142 slice.setLabelPosition(QPieSlice::LabelInsideHorizontal);
143 slice.setLabelPosition(QPieSlice::LabelInsideHorizontal);
143 slice.setLabelPosition(QPieSlice::LabelInsideHorizontal);
144 slice.setLabelArmLengthFactor(0.1);
144 slice.setLabelArmLengthFactor(0.1);
145 slice.setLabelArmLengthFactor(0.1);
145 slice.setLabelArmLengthFactor(0.1);
146 slice.setExplodeDistanceFactor(0.1);
146 slice.setExplodeDistanceFactor(0.1);
147 slice.setExplodeDistanceFactor(0.1);
147 slice.setExplodeDistanceFactor(0.1);
148
148
149 TRY_COMPARE(valueSpy.count(), 1);
149 TRY_COMPARE(valueSpy.count(), 1);
150 TRY_COMPARE(labelSpy.count(), 1);
150 TRY_COMPARE(labelSpy.count(), 1);
151 TRY_COMPARE(penSpy.count(), 2);
151 TRY_COMPARE(penSpy.count(), 2);
152 TRY_COMPARE(brushSpy.count(), 1);
152 TRY_COMPARE(brushSpy.count(), 1);
153 TRY_COMPARE(labelBrushSpy.count(), 1);
153 TRY_COMPARE(labelBrushSpy.count(), 1);
154 TRY_COMPARE(labelFontSpy.count(), 1);
154 TRY_COMPARE(labelFontSpy.count(), 1);
155 TRY_COMPARE(colorSpy.count(), 1);
155 TRY_COMPARE(colorSpy.count(), 1);
156 TRY_COMPARE(borderColorSpy.count(), 1);
156 TRY_COMPARE(borderColorSpy.count(), 1);
157 TRY_COMPARE(borderWidthSpy.count(), 1);
157 TRY_COMPARE(borderWidthSpy.count(), 1);
158 TRY_COMPARE(labelColorSpy.count(), 1);
158 TRY_COMPARE(labelColorSpy.count(), 1);
159 }
159 }
160
160
161 void tst_qpieslice::customize()
161 void tst_qpieslice::customize()
162 {
162 {
163 // create a pie series
163 // create a pie series
164 QPieSeries *series = new QPieSeries();
164 QPieSeries *series = new QPieSeries();
165 QPieSlice *s1 = series->append("slice 1", 1);
165 QPieSlice *s1 = series->append("slice 1", 1);
166 QPieSlice *s2 = series->append("slice 2", 2);
166 QPieSlice *s2 = series->append("slice 2", 2);
167 series->append("slice 3", 3);
167 series->append("slice 3", 3);
168
168
169 // customize a slice
169 // customize a slice
170 QPen p1(Qt::red);
170 QPen p1(Qt::red);
171 s1->setPen(p1);
171 s1->setPen(p1);
172 QBrush b1(Qt::red);
172 QBrush b1(Qt::red);
173 s1->setBrush(b1);
173 s1->setBrush(b1);
174 s1->setLabelBrush(b1);
174 s1->setLabelBrush(b1);
175 QFont f1("Consolas");
175 QFont f1("Consolas");
176 s1->setLabelFont(f1);
176 s1->setLabelFont(f1);
177
177
178 // add series to the chart
178 // add series to the chart
179 QChartView view(new QChart());
179 QChartView view(new QChart());
180 view.resize(200, 200);
180 view.resize(200, 200);
181 view.chart()->addSeries(series);
181 view.chart()->addSeries(series);
182 view.show();
182 view.show();
183 QTest::qWaitForWindowShown(&view);
183 QTest::qWaitForWindowShown(&view);
184 //QTest::qWait(1000);
184 //QTest::qWait(1000);
185
185
186 // check that customizations persist
186 // check that customizations persist
187 QCOMPARE(s1->pen(), p1);
187 QCOMPARE(s1->pen(), p1);
188 QCOMPARE(s1->brush(), b1);
188 QCOMPARE(s1->brush(), b1);
189 QCOMPARE(s1->labelBrush(), b1);
189 QCOMPARE(s1->labelBrush(), b1);
190 QCOMPARE(s1->labelFont(), f1);
190 QCOMPARE(s1->labelFont(), f1);
191
191
192 // remove a slice
192 // remove a slice
193 series->remove(s2);
193 series->remove(s2);
194 QCOMPARE(s1->pen(), p1);
194 QCOMPARE(s1->pen(), p1);
195 QCOMPARE(s1->brush(), b1);
195 QCOMPARE(s1->brush(), b1);
196 QCOMPARE(s1->labelBrush(), b1);
196 QCOMPARE(s1->labelBrush(), b1);
197 QCOMPARE(s1->labelFont(), f1);
197 QCOMPARE(s1->labelFont(), f1);
198
198
199 // add a slice
199 // add a slice
200 series->append("slice 4", 4);
200 series->append("slice 4", 4);
201 QCOMPARE(s1->pen(), p1);
201 QCOMPARE(s1->pen(), p1);
202 QCOMPARE(s1->brush(), b1);
202 QCOMPARE(s1->brush(), b1);
203 QCOMPARE(s1->labelBrush(), b1);
203 QCOMPARE(s1->labelBrush(), b1);
204 QCOMPARE(s1->labelFont(), f1);
204 QCOMPARE(s1->labelFont(), f1);
205
205
206 // insert a slice
206 // insert a slice
207 series->insert(0, new QPieSlice("slice 5", 5));
207 series->insert(0, new QPieSlice("slice 5", 5));
208 QCOMPARE(s1->pen(), p1);
208 QCOMPARE(s1->pen(), p1);
209 QCOMPARE(s1->brush(), b1);
209 QCOMPARE(s1->brush(), b1);
210 QCOMPARE(s1->labelBrush(), b1);
210 QCOMPARE(s1->labelBrush(), b1);
211 QCOMPARE(s1->labelFont(), f1);
211 QCOMPARE(s1->labelFont(), f1);
212
212
213 // change theme
213 // change theme
214 // theme will overwrite customizations
214 // theme will overwrite customizations
215 view.chart()->setTheme(QChart::ChartThemeHighContrast);
215 view.chart()->setTheme(QChart::ChartThemeHighContrast);
216 QVERIFY(s1->pen() != p1);
216 QVERIFY(s1->pen() != p1);
217 QVERIFY(s1->brush() != b1);
217 QVERIFY(s1->brush() != b1);
218 QVERIFY(s1->labelBrush() != b1);
218 QVERIFY(s1->labelBrush() != b1);
219 QVERIFY(s1->labelFont() != f1);
219 QVERIFY(s1->labelFont() != f1);
220 }
220 }
221
221
222 void tst_qpieslice::clickedSignal()
222 void tst_qpieslice::clickedSignal()
223 {
223 {
224 // NOTE:
224 // NOTE:
225 // This test is the same as tst_qpieseries::clickedSignal()
225 // This test is the same as tst_qpieseries::clickedSignal()
226 // Just for different signals.
226 // Just for different signals.
227
227
228 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
228 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
229
229
230 // create a pie series
230 // create a pie series
231 QPieSeries *series = new QPieSeries();
231 QPieSeries *series = new QPieSeries();
232 QPieSlice *s1 = series->append("slice 1", 1);
232 QPieSlice *s1 = series->append("slice 1", 1);
233 QPieSlice *s2 = series->append("slice 2", 1);
233 QPieSlice *s2 = series->append("slice 2", 1);
234 QPieSlice *s3 = series->append("slice 3", 1);
234 QPieSlice *s3 = series->append("slice 3", 1);
235 QPieSlice *s4 = series->append("slice 4", 1);
235 QPieSlice *s4 = series->append("slice 4", 1);
236 QSignalSpy clickSpy1(s1, SIGNAL(clicked()));
236 QSignalSpy clickSpy1(s1, SIGNAL(clicked()));
237 QSignalSpy clickSpy2(s2, SIGNAL(clicked()));
237 QSignalSpy clickSpy2(s2, SIGNAL(clicked()));
238 QSignalSpy clickSpy3(s3, SIGNAL(clicked()));
238 QSignalSpy clickSpy3(s3, SIGNAL(clicked()));
239 QSignalSpy clickSpy4(s4, SIGNAL(clicked()));
239 QSignalSpy clickSpy4(s4, SIGNAL(clicked()));
240
240
241 // add series to the chart
241 // add series to the chart
242 QChartView view;
242 QChartView view;
243 view.chart()->legend()->setVisible(false);
243 view.chart()->legend()->setVisible(false);
244 view.chart()->addSeries(series);
244 view.chart()->addSeries(series);
245 view.show();
245 view.show();
246 QTest::qWaitForWindowShown(&view);
246 QTest::qWaitForWindowShown(&view);
247
247
248 // simulate clicks
248 // simulate clicks
249 series->setPieSize(1.0);
249 series->setPieSize(1.0);
250 QRectF pieRect = view.chart()->plotArea();
250 QRectF pieRect = view.chart()->plotArea();
251 QList<QPoint> points = slicePoints(pieRect);
251 QList<QPoint> points = slicePoints(pieRect);
252 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, points.at(0));
252 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, points.at(0));
253 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, points.at(1));
253 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, points.at(1));
254 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, points.at(2));
254 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, points.at(2));
255 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, points.at(3));
255 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, points.at(3));
256 QCOMPARE(clickSpy1.count(), 1);
256 QCOMPARE(clickSpy1.count(), 1);
257 QCOMPARE(clickSpy2.count(), 1);
257 QCOMPARE(clickSpy2.count(), 1);
258 QCOMPARE(clickSpy3.count(), 1);
258 QCOMPARE(clickSpy3.count(), 1);
259 QCOMPARE(clickSpy4.count(), 1);
259 QCOMPARE(clickSpy4.count(), 1);
260 }
260 }
261
261
262 void tst_qpieslice::hoverSignal()
262 void tst_qpieslice::hoverSignal()
263 {
263 {
264 // NOTE:
264 // NOTE:
265 // This test is the same as tst_qpieseries::hoverSignal()
265 // This test is the same as tst_qpieseries::hoverSignal()
266 // Just for different signals.
266 // Just for different signals.
267
267
268 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
268 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
269
269
270 // add some slices
270 // add some slices
271 QPieSeries *series = new QPieSeries();
271 QPieSeries *series = new QPieSeries();
272 QPieSlice *s1 = series->append("slice 1", 1);
272 QPieSlice *s1 = series->append("slice 1", 1);
273 QPieSlice *s2 = series->append("slice 2", 1);
273 QPieSlice *s2 = series->append("slice 2", 1);
274 QPieSlice *s3 = series->append("slice 3", 1);
274 QPieSlice *s3 = series->append("slice 3", 1);
275 QPieSlice *s4 = series->append("slice 4", 1);
275 QPieSlice *s4 = series->append("slice 4", 1);
276
276
277 // add series to the chart
277 // add series to the chart
278 QChartView view;
278 QChartView view;
279 view.chart()->legend()->setVisible(false);
279 view.chart()->legend()->setVisible(false);
280 view.chart()->addSeries(series);
280 view.chart()->addSeries(series);
281 view.show();
281 view.show();
282 QTest::qWaitForWindowShown(&view);
282 QTest::qWaitForWindowShown(&view);
283
283
284 // try to ensure focus
285 QApplication::setActiveWindow(&view);
286 view.setFocus();
287 QApplication::processEvents();
288 QVERIFY(view.isActiveWindow());
289 QVERIFY(view.hasFocus());
290
284 // move inside the slices
291 // move inside the slices
285 series->setPieSize(1.0);
292 series->setPieSize(1.0);
286 QRectF pieRect = view.chart()->plotArea();
293 QRectF pieRect = view.chart()->plotArea();
287 QList<QPoint> points = slicePoints(pieRect);
294 QList<QPoint> points = slicePoints(pieRect);
288 QTest::mouseMove(view.viewport(), pieRect.topRight().toPoint(), 100);
295 QTest::mouseMove(view.viewport(), pieRect.topRight().toPoint(), 100);
289 QSignalSpy hoverSpy1(s1, SIGNAL(hovered(bool)));
296 QSignalSpy hoverSpy1(s1, SIGNAL(hovered(bool)));
290 QSignalSpy hoverSpy2(s2, SIGNAL(hovered(bool)));
297 QSignalSpy hoverSpy2(s2, SIGNAL(hovered(bool)));
291 QSignalSpy hoverSpy3(s3, SIGNAL(hovered(bool)));
298 QSignalSpy hoverSpy3(s3, SIGNAL(hovered(bool)));
292 QSignalSpy hoverSpy4(s4, SIGNAL(hovered(bool)));
299 QSignalSpy hoverSpy4(s4, SIGNAL(hovered(bool)));
293 QTest::mouseMove(view.viewport(), points.at(0), 100);
300 QTest::mouseMove(view.viewport(), points.at(0), 100);
294 QTest::mouseMove(view.viewport(), points.at(1), 100);
301 QTest::mouseMove(view.viewport(), points.at(1), 100);
295 QTest::mouseMove(view.viewport(), points.at(2), 100);
302 QTest::mouseMove(view.viewport(), points.at(2), 100);
296 QTest::mouseMove(view.viewport(), points.at(3), 100);
303 QTest::mouseMove(view.viewport(), points.at(3), 100);
297 QTest::mouseMove(view.viewport(), pieRect.topLeft().toPoint(), 100);
304 QTest::mouseMove(view.viewport(), pieRect.topLeft().toPoint(), 100);
298 QApplication::processEvents();
305 QApplication::processEvents();
299
306
300 // check
307 // check
301 QCOMPARE(hoverSpy1.count(), 2);
308 QCOMPARE(hoverSpy1.count(), 2);
302 QCOMPARE(qvariant_cast<bool>(hoverSpy1.at(0).at(0)), true);
309 QCOMPARE(qvariant_cast<bool>(hoverSpy1.at(0).at(0)), true);
303 QCOMPARE(qvariant_cast<bool>(hoverSpy1.at(1).at(0)), false);
310 QCOMPARE(qvariant_cast<bool>(hoverSpy1.at(1).at(0)), false);
304 QCOMPARE(hoverSpy2.count(), 2);
311 QCOMPARE(hoverSpy2.count(), 2);
305 QCOMPARE(qvariant_cast<bool>(hoverSpy2.at(0).at(0)), true);
312 QCOMPARE(qvariant_cast<bool>(hoverSpy2.at(0).at(0)), true);
306 QCOMPARE(qvariant_cast<bool>(hoverSpy2.at(1).at(0)), false);
313 QCOMPARE(qvariant_cast<bool>(hoverSpy2.at(1).at(0)), false);
307 QCOMPARE(hoverSpy3.count(), 2);
314 QCOMPARE(hoverSpy3.count(), 2);
308 QCOMPARE(qvariant_cast<bool>(hoverSpy3.at(0).at(0)), true);
315 QCOMPARE(qvariant_cast<bool>(hoverSpy3.at(0).at(0)), true);
309 QCOMPARE(qvariant_cast<bool>(hoverSpy3.at(1).at(0)), false);
316 QCOMPARE(qvariant_cast<bool>(hoverSpy3.at(1).at(0)), false);
310 QCOMPARE(hoverSpy4.count(), 2);
317 QCOMPARE(hoverSpy4.count(), 2);
311 QCOMPARE(qvariant_cast<bool>(hoverSpy4.at(0).at(0)), true);
318 QCOMPARE(qvariant_cast<bool>(hoverSpy4.at(0).at(0)), true);
312 QCOMPARE(qvariant_cast<bool>(hoverSpy4.at(1).at(0)), false);
319 QCOMPARE(qvariant_cast<bool>(hoverSpy4.at(1).at(0)), false);
313 }
320 }
314
321
315 QList<QPoint> tst_qpieslice::slicePoints(QRectF rect)
322 QList<QPoint> tst_qpieslice::slicePoints(QRectF rect)
316 {
323 {
317 qreal x1 = rect.topLeft().x() + (rect.width() / 4);
324 qreal x1 = rect.topLeft().x() + (rect.width() / 4);
318 qreal x2 = rect.topLeft().x() + (rect.width() / 4) * 3;
325 qreal x2 = rect.topLeft().x() + (rect.width() / 4) * 3;
319 qreal y1 = rect.topLeft().y() + (rect.height() / 4);
326 qreal y1 = rect.topLeft().y() + (rect.height() / 4);
320 qreal y2 = rect.topLeft().y() + (rect.height() / 4) * 3;
327 qreal y2 = rect.topLeft().y() + (rect.height() / 4) * 3;
321 QList<QPoint> points;
328 QList<QPoint> points;
322 points << QPoint(x2, y1);
329 points << QPoint(x2, y1);
323 points << QPoint(x2, y2);
330 points << QPoint(x2, y2);
324 points << QPoint(x1, y2);
331 points << QPoint(x1, y2);
325 points << QPoint(x1, y1);
332 points << QPoint(x1, y1);
326 return points;
333 return points;
327 }
334 }
328
335
329 QTEST_MAIN(tst_qpieslice)
336 QTEST_MAIN(tst_qpieslice)
330
337
331 #include "tst_qpieslice.moc"
338 #include "tst_qpieslice.moc"
332
339
General Comments 0
You need to be logged in to leave comments. Login now