| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#include <QtTest/QtTest> |
| 5 |
#include <tst_definitions.h> |
| 6 |
#include <QtCharts/QChartView> |
| 7 |
#include <QtCharts/QChart> |
| 8 |
#include <QtCharts/QLegend> |
| 9 |
#include <QtCharts/QLegendMarker> |
| 10 |
#include <QtCharts/QPieSlice> |
| 11 |
#include <QtCharts/QPieSeries> |
| 12 |
|
| 13 |
QT_USE_NAMESPACE |
| 14 |
|
| 15 |
class tst_qpieslice : public QObject |
| 16 |
{ |
| 17 |
Q_OBJECT |
| 18 |
|
| 19 |
public slots: |
| 20 |
void initTestCase(); |
| 21 |
void cleanupTestCase(); |
| 22 |
void init(); |
| 23 |
void cleanup(); |
| 24 |
|
| 25 |
private slots: |
| 26 |
void construction(); |
| 27 |
void changedSignals(); |
| 28 |
void customize(); |
| 29 |
void clickedSignal(); |
| 30 |
void hoverSignal(); |
| 31 |
void pressedSignal(); |
| 32 |
void releasedSignal(); |
| 33 |
void doubleClickedSignal(); |
| 34 |
|
| 35 |
private: |
| 36 |
QList<QPoint> slicePoints(QRectF rect); |
| 37 |
|
| 38 |
private: |
| 39 |
|
| 40 |
}; |
| 41 |
|
| 42 |
void tst_qpieslice::initTestCase() |
| 43 |
{ |
| 44 |
} |
| 45 |
|
| 46 |
void tst_qpieslice::cleanupTestCase() |
| 47 |
{ |
| 48 |
QTest::qWait(1); // Allow final deleteLaters to run |
| 49 |
} |
| 50 |
|
| 51 |
void tst_qpieslice::init() |
| 52 |
{ |
| 53 |
|
| 54 |
} |
| 55 |
|
| 56 |
void tst_qpieslice::cleanup() |
| 57 |
{ |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
void tst_qpieslice::construction() |
| 62 |
{ |
| 63 |
// no params |
| 64 |
QPieSlice slice1; |
| 65 |
QCOMPARE(slice1.value(), 0.0); |
| 66 |
QVERIFY(slice1.label().isEmpty()); |
| 67 |
QVERIFY(!slice1.isLabelVisible()); |
| 68 |
QVERIFY(!slice1.isExploded()); |
| 69 |
QCOMPARE(slice1.pen(), QPen()); |
| 70 |
QCOMPARE(slice1.brush(), QBrush()); |
| 71 |
QCOMPARE(slice1.labelBrush(), QBrush()); |
| 72 |
QCOMPARE(slice1.labelFont(), QFont()); |
| 73 |
QCOMPARE(slice1.labelArmLengthFactor(), 0.15); // default value |
| 74 |
QCOMPARE(slice1.explodeDistanceFactor(), 0.15); // default value |
| 75 |
QCOMPARE(slice1.percentage(), 0.0); |
| 76 |
QCOMPARE(slice1.startAngle(), 0.0); |
| 77 |
QCOMPARE(slice1.angleSpan(), 0.0); |
| 78 |
|
| 79 |
// value and label params |
| 80 |
QPieSlice slice2("foobar", 1.0); |
| 81 |
QCOMPARE(slice2.value(), 1.0); |
| 82 |
QCOMPARE(slice2.label(), QString("foobar")); |
| 83 |
QVERIFY(!slice2.isLabelVisible()); |
| 84 |
QVERIFY(!slice2.isExploded()); |
| 85 |
QCOMPARE(slice2.pen(), QPen()); |
| 86 |
QCOMPARE(slice2.brush(), QBrush()); |
| 87 |
QCOMPARE(slice2.labelBrush(), QBrush()); |
| 88 |
QCOMPARE(slice2.labelFont(), QFont()); |
| 89 |
QCOMPARE(slice2.labelArmLengthFactor(), 0.15); // default value |
| 90 |
QCOMPARE(slice2.explodeDistanceFactor(), 0.15); // default value |
| 91 |
QCOMPARE(slice2.percentage(), 0.0); |
| 92 |
QCOMPARE(slice2.startAngle(), 0.0); |
| 93 |
QCOMPARE(slice2.angleSpan(), 0.0); |
| 94 |
} |
| 95 |
|
| 96 |
void tst_qpieslice::changedSignals() |
| 97 |
{ |
| 98 |
QPieSlice slice; |
| 99 |
|
| 100 |
QSignalSpy valueSpy(&slice, SIGNAL(valueChanged())); |
| 101 |
QSignalSpy labelSpy(&slice, SIGNAL(labelChanged())); |
| 102 |
QSignalSpy penSpy(&slice, SIGNAL(penChanged())); |
| 103 |
QSignalSpy brushSpy(&slice, SIGNAL(brushChanged())); |
| 104 |
QSignalSpy labelBrushSpy(&slice, SIGNAL(labelBrushChanged())); |
| 105 |
QSignalSpy labelFontSpy(&slice, SIGNAL(labelFontChanged())); |
| 106 |
QSignalSpy colorSpy(&slice, SIGNAL(colorChanged())); |
| 107 |
QSignalSpy borderColorSpy(&slice, SIGNAL(borderColorChanged())); |
| 108 |
QSignalSpy borderWidthSpy(&slice, SIGNAL(borderWidthChanged())); |
| 109 |
QSignalSpy labelColorSpy(&slice, SIGNAL(labelColorChanged())); |
| 110 |
|
| 111 |
// percentageChanged(), startAngleChanged() and angleSpanChanged() signals tested at tst_qpieseries::calculatedValues() |
| 112 |
|
| 113 |
// set everything twice to see we do not get unnecessary signals |
| 114 |
slice.setValue(1.0); |
| 115 |
slice.setValue(-1.0); |
| 116 |
QCOMPARE(slice.value(), 1.0); |
| 117 |
slice.setLabel("foobar"); |
| 118 |
slice.setLabel("foobar"); |
| 119 |
slice.setLabelVisible(); |
| 120 |
slice.setLabelVisible(); |
| 121 |
slice.setExploded(); |
| 122 |
slice.setExploded(); |
| 123 |
slice.setPen(QPen(Qt::red)); |
| 124 |
slice.setPen(QPen(QBrush(Qt::red), 3)); |
| 125 |
slice.setBrush(QBrush(Qt::red)); |
| 126 |
slice.setBrush(QBrush(Qt::red)); |
| 127 |
slice.setLabelBrush(QBrush(Qt::green)); |
| 128 |
slice.setLabelBrush(QBrush(Qt::green)); |
| 129 |
slice.setLabelFont(QFont("Tahoma")); |
| 130 |
slice.setLabelFont(QFont("Tahoma")); |
| 131 |
slice.setLabelPosition(QPieSlice::LabelInsideHorizontal); |
| 132 |
slice.setLabelPosition(QPieSlice::LabelInsideHorizontal); |
| 133 |
slice.setLabelArmLengthFactor(0.1); |
| 134 |
slice.setLabelArmLengthFactor(0.1); |
| 135 |
slice.setExplodeDistanceFactor(0.1); |
| 136 |
slice.setExplodeDistanceFactor(0.1); |
| 137 |
|
| 138 |
TRY_COMPARE(valueSpy.size(), 1); |
| 139 |
TRY_COMPARE(labelSpy.size(), 1); |
| 140 |
TRY_COMPARE(penSpy.size(), 2); |
| 141 |
TRY_COMPARE(brushSpy.size(), 1); |
| 142 |
TRY_COMPARE(labelBrushSpy.size(), 1); |
| 143 |
TRY_COMPARE(labelFontSpy.size(), 1); |
| 144 |
TRY_COMPARE(colorSpy.size(), 1); |
| 145 |
TRY_COMPARE(borderColorSpy.size(), 1); |
| 146 |
TRY_COMPARE(borderWidthSpy.size(), 1); |
| 147 |
TRY_COMPARE(labelColorSpy.size(), 1); |
| 148 |
} |
| 149 |
|
| 150 |
void tst_qpieslice::customize() |
| 151 |
{ |
| 152 |
// create a pie series |
| 153 |
QPieSeries *series = new QPieSeries(); |
| 154 |
QPieSlice *s1 = series->append("slice 1", 1); |
| 155 |
QPieSlice *s2 = series->append("slice 2", 2); |
| 156 |
series->append("slice 3", 3); |
| 157 |
|
| 158 |
// customize a slice |
| 159 |
QPen p1(Qt::red); |
| 160 |
s1->setPen(p1); |
| 161 |
QBrush b1(Qt::red); |
| 162 |
s1->setBrush(b1); |
| 163 |
s1->setLabelBrush(b1); |
| 164 |
QFont f1("Consolas"); |
| 165 |
s1->setLabelFont(f1); |
| 166 |
|
| 167 |
// add series to the chart |
| 168 |
QChartView view(new QChart()); |
| 169 |
view.resize(200, 200); |
| 170 |
view.chart()->addSeries(series); |
| 171 |
view.show(); |
| 172 |
QVERIFY(QTest::qWaitForWindowExposed(&view)); |
| 173 |
//QTest::qWait(1000); |
| 174 |
|
| 175 |
// check that customizations persist |
| 176 |
QCOMPARE(s1->pen(), p1); |
| 177 |
QCOMPARE(s1->brush(), b1); |
| 178 |
QCOMPARE(s1->labelBrush(), b1); |
| 179 |
QCOMPARE(s1->labelFont(), f1); |
| 180 |
|
| 181 |
// remove a slice |
| 182 |
series->remove(s2); |
| 183 |
QCOMPARE(s1->pen(), p1); |
| 184 |
QCOMPARE(s1->brush(), b1); |
| 185 |
QCOMPARE(s1->labelBrush(), b1); |
| 186 |
QCOMPARE(s1->labelFont(), f1); |
| 187 |
|
| 188 |
// add a slice |
| 189 |
series->append("slice 4", 4); |
| 190 |
QCOMPARE(s1->pen(), p1); |
| 191 |
QCOMPARE(s1->brush(), b1); |
| 192 |
QCOMPARE(s1->labelBrush(), b1); |
| 193 |
QCOMPARE(s1->labelFont(), f1); |
| 194 |
|
| 195 |
// insert a slice |
| 196 |
series->insert(0, new QPieSlice("slice 0", 5)); |
| 197 |
QCOMPARE(s1->pen(), p1); |
| 198 |
QCOMPARE(s1->brush(), b1); |
| 199 |
QCOMPARE(s1->labelBrush(), b1); |
| 200 |
QCOMPARE(s1->labelFont(), f1); |
| 201 |
|
| 202 |
// QTBUG-62082, verify correct insertion at 0. |
| 203 |
const QStringList expectedLabels{"slice 0", "slice 1", "slice 3", "slice 4"}; |
| 204 |
const auto legendMarkers = view.chart()->legend()->markers(); |
| 205 |
const int legendMarkersSize = legendMarkers.size(); |
| 206 |
QCOMPARE(legendMarkersSize, expectedLabels.size()); |
| 207 |
for (int m = 0; m < legendMarkersSize; ++m) |
| 208 |
QCOMPARE(legendMarkers.at(m)->label(), expectedLabels.at(m)); |
| 209 |
|
| 210 |
// change theme |
| 211 |
// theme will overwrite customizations |
| 212 |
view.chart()->setTheme(QChart::ChartThemeHighContrast); |
| 213 |
QVERIFY(s1->pen() != p1); |
| 214 |
QVERIFY(s1->brush() != b1); |
| 215 |
QVERIFY(s1->labelBrush() != b1); |
| 216 |
QVERIFY(s1->labelFont() != f1); |
| 217 |
} |
| 218 |
|
| 219 |
void tst_qpieslice::clickedSignal() |
| 220 |
{ |
| 221 |
// NOTE: |
| 222 |
// This test is the same as tst_qpieseries::clickedSignal() |
| 223 |
// Just for different signals. |
| 224 |
|
| 225 |
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS(); |
| 226 |
|
| 227 |
// create a pie series |
| 228 |
QPieSeries *series = new QPieSeries(); |
| 229 |
QPieSlice *s1 = series->append("slice 1", 1); |
| 230 |
QPieSlice *s2 = series->append("slice 2", 1); |
| 231 |
QPieSlice *s3 = series->append("slice 3", 1); |
| 232 |
QPieSlice *s4 = series->append("slice 4", 1); |
| 233 |
QSignalSpy clickSpy1(s1, SIGNAL(clicked())); |
| 234 |
QSignalSpy clickSpy2(s2, SIGNAL(clicked())); |
| 235 |
QSignalSpy clickSpy3(s3, SIGNAL(clicked())); |
| 236 |
QSignalSpy clickSpy4(s4, SIGNAL(clicked())); |
| 237 |
|
| 238 |
// add series to the chart |
| 239 |
QChartView view; |
| 240 |
view.resize(200, 200); |
| 241 |
view.chart()->legend()->setVisible(false); |
| 242 |
view.chart()->addSeries(series); |
| 243 |
view.show(); |
| 244 |
QVERIFY(QTest::qWaitForWindowExposed(&view)); |
| 245 |
|
| 246 |
// simulate clicks |
| 247 |
series->setPieSize(1.0); |
| 248 |
QRectF pieRect = view.chart()->plotArea(); |
| 249 |
QList<QPoint> points = slicePoints(pieRect); |
| 250 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(0)); |
| 251 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(1)); |
| 252 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(2)); |
| 253 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(3)); |
| 254 |
QCOMPARE(clickSpy1.size(), 1); |
| 255 |
QCOMPARE(clickSpy2.size(), 1); |
| 256 |
QCOMPARE(clickSpy3.size(), 1); |
| 257 |
QCOMPARE(clickSpy4.size(), 1); |
| 258 |
} |
| 259 |
|
| 260 |
void tst_qpieslice::hoverSignal() |
| 261 |
{ |
| 262 |
// NOTE: |
| 263 |
// This test is the same as tst_qpieseries::hoverSignal() |
| 264 |
// Just for different signals. |
| 265 |
|
| 266 |
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS(); |
| 267 |
SKIP_IF_FLAKY_MOUSE_MOVE(); |
| 268 |
|
| 269 |
// add some slices |
| 270 |
QPieSeries *series = new QPieSeries(); |
| 271 |
QPieSlice *s1 = series->append("slice 1", 1); |
| 272 |
QPieSlice *s2 = series->append("slice 2", 1); |
| 273 |
QPieSlice *s3 = series->append("slice 3", 1); |
| 274 |
QPieSlice *s4 = series->append("slice 4", 1); |
| 275 |
|
| 276 |
// add series to the chart |
| 277 |
QChartView view; |
| 278 |
view.resize(200, 200); |
| 279 |
view.chart()->legend()->setVisible(false); |
| 280 |
view.chart()->addSeries(series); |
| 281 |
view.show(); |
| 282 |
QVERIFY(QTest::qWaitForWindowExposed(&view)); |
| 283 |
|
| 284 |
// try to ensure focus |
| 285 |
view.activateWindow(); |
| 286 |
QVERIFY(QTest::qWaitForWindowActive(&view)); |
| 287 |
view.setFocus(); |
| 288 |
QApplication::processEvents(); |
| 289 |
QVERIFY(view.isActiveWindow()); |
| 290 |
QVERIFY(view.hasFocus()); |
| 291 |
|
| 292 |
// move inside the slices |
| 293 |
series->setPieSize(1.0); |
| 294 |
QRectF pieRect = view.chart()->plotArea(); |
| 295 |
QList<QPoint> points = slicePoints(pieRect); |
| 296 |
QTest::mouseMove(view.viewport(), pieRect.topRight().toPoint(), 100); |
| 297 |
QSignalSpy hoverSpy1(s1, SIGNAL(hovered(bool))); |
| 298 |
QSignalSpy hoverSpy2(s2, SIGNAL(hovered(bool))); |
| 299 |
QSignalSpy hoverSpy3(s3, SIGNAL(hovered(bool))); |
| 300 |
QSignalSpy hoverSpy4(s4, SIGNAL(hovered(bool))); |
| 301 |
QTest::mouseMove(view.viewport(), points.at(0), 100); |
| 302 |
QTest::mouseMove(view.viewport(), points.at(1), 100); |
| 303 |
QTest::mouseMove(view.viewport(), points.at(2), 100); |
| 304 |
QTest::mouseMove(view.viewport(), points.at(3), 100); |
| 305 |
QTest::mouseMove(view.viewport(), pieRect.topLeft().toPoint(), 100); |
| 306 |
// Final hoverevent can take few milliseconds to appear in some environments, so wait a bit |
| 307 |
QTest::qWait(100); |
| 308 |
|
| 309 |
// check |
| 310 |
QCOMPARE(hoverSpy1.size(), 2); |
| 311 |
QCOMPARE(qvariant_cast<bool>(hoverSpy1.at(0).at(0)), true); |
| 312 |
QCOMPARE(qvariant_cast<bool>(hoverSpy1.at(1).at(0)), false); |
| 313 |
QCOMPARE(hoverSpy2.size(), 2); |
| 314 |
QCOMPARE(qvariant_cast<bool>(hoverSpy2.at(0).at(0)), true); |
| 315 |
QCOMPARE(qvariant_cast<bool>(hoverSpy2.at(1).at(0)), false); |
| 316 |
QCOMPARE(hoverSpy3.size(), 2); |
| 317 |
QCOMPARE(qvariant_cast<bool>(hoverSpy3.at(0).at(0)), true); |
| 318 |
QCOMPARE(qvariant_cast<bool>(hoverSpy3.at(1).at(0)), false); |
| 319 |
QCOMPARE(hoverSpy4.size(), 2); |
| 320 |
QCOMPARE(qvariant_cast<bool>(hoverSpy4.at(0).at(0)), true); |
| 321 |
QCOMPARE(qvariant_cast<bool>(hoverSpy4.at(1).at(0)), false); |
| 322 |
} |
| 323 |
|
| 324 |
QList<QPoint> tst_qpieslice::slicePoints(QRectF rect) |
| 325 |
{ |
| 326 |
qreal x1 = rect.topLeft().x() + (rect.width() / 4); |
| 327 |
qreal x2 = rect.topLeft().x() + (rect.width() / 4) * 3; |
| 328 |
qreal y1 = rect.topLeft().y() + (rect.height() / 4); |
| 329 |
qreal y2 = rect.topLeft().y() + (rect.height() / 4) * 3; |
| 330 |
QList<QPoint> points; |
| 331 |
points << QPoint(x2, y1); |
| 332 |
points << QPoint(x2, y2); |
| 333 |
points << QPoint(x1, y2); |
| 334 |
points << QPoint(x1, y1); |
| 335 |
return points; |
| 336 |
} |
| 337 |
|
| 338 |
void tst_qpieslice::pressedSignal() |
| 339 |
{ |
| 340 |
// NOTE: |
| 341 |
// This test is the same as tst_qpieseries::pressedSignal() |
| 342 |
// Just for different signals. |
| 343 |
|
| 344 |
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS(); |
| 345 |
|
| 346 |
// create a pie series |
| 347 |
QPieSeries *series = new QPieSeries(); |
| 348 |
QPieSlice *s1 = series->append("slice 1", 1); |
| 349 |
QPieSlice *s2 = series->append("slice 2", 1); |
| 350 |
QPieSlice *s3 = series->append("slice 3", 1); |
| 351 |
QPieSlice *s4 = series->append("slice 4", 1); |
| 352 |
QSignalSpy clickSpy1(s1, SIGNAL(pressed())); |
| 353 |
QSignalSpy clickSpy2(s2, SIGNAL(pressed())); |
| 354 |
QSignalSpy clickSpy3(s3, SIGNAL(pressed())); |
| 355 |
QSignalSpy clickSpy4(s4, SIGNAL(pressed())); |
| 356 |
|
| 357 |
// add series to the chart |
| 358 |
QChartView view; |
| 359 |
view.resize(200, 200); |
| 360 |
view.chart()->legend()->setVisible(false); |
| 361 |
view.chart()->addSeries(series); |
| 362 |
view.show(); |
| 363 |
QVERIFY(QTest::qWaitForWindowExposed(&view)); |
| 364 |
|
| 365 |
// simulate clicks |
| 366 |
series->setPieSize(1.0); |
| 367 |
QRectF pieRect = view.chart()->plotArea(); |
| 368 |
QList<QPoint> points = slicePoints(pieRect); |
| 369 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(0)); |
| 370 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(1)); |
| 371 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(2)); |
| 372 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(3)); |
| 373 |
QCOMPARE(clickSpy1.size(), 1); |
| 374 |
QCOMPARE(clickSpy2.size(), 1); |
| 375 |
QCOMPARE(clickSpy3.size(), 1); |
| 376 |
QCOMPARE(clickSpy4.size(), 1); |
| 377 |
} |
| 378 |
|
| 379 |
void tst_qpieslice::releasedSignal() |
| 380 |
{ |
| 381 |
// NOTE: |
| 382 |
// This test is the same as tst_qpieseries::releasedSignal() |
| 383 |
// Just for different signals. |
| 384 |
|
| 385 |
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS(); |
| 386 |
|
| 387 |
// create a pie series |
| 388 |
QPieSeries *series = new QPieSeries(); |
| 389 |
QPieSlice *s1 = series->append("slice 1", 1); |
| 390 |
QPieSlice *s2 = series->append("slice 2", 1); |
| 391 |
QPieSlice *s3 = series->append("slice 3", 1); |
| 392 |
QPieSlice *s4 = series->append("slice 4", 1); |
| 393 |
QSignalSpy clickSpy1(s1, SIGNAL(released())); |
| 394 |
QSignalSpy clickSpy2(s2, SIGNAL(released())); |
| 395 |
QSignalSpy clickSpy3(s3, SIGNAL(released())); |
| 396 |
QSignalSpy clickSpy4(s4, SIGNAL(released())); |
| 397 |
|
| 398 |
// add series to the chart |
| 399 |
QChartView view; |
| 400 |
view.resize(200, 200); |
| 401 |
view.chart()->legend()->setVisible(false); |
| 402 |
view.chart()->addSeries(series); |
| 403 |
view.show(); |
| 404 |
QVERIFY(QTest::qWaitForWindowExposed(&view)); |
| 405 |
|
| 406 |
// simulate clicks |
| 407 |
series->setPieSize(1.0); |
| 408 |
QRectF pieRect = view.chart()->plotArea(); |
| 409 |
QList<QPoint> points = slicePoints(pieRect); |
| 410 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(0)); |
| 411 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(1)); |
| 412 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(2)); |
| 413 |
QTest::mouseClick(view.viewport(), Qt::LeftButton, {}, points.at(3)); |
| 414 |
QCOMPARE(clickSpy1.size(), 1); |
| 415 |
QCOMPARE(clickSpy2.size(), 1); |
| 416 |
QCOMPARE(clickSpy3.size(), 1); |
| 417 |
QCOMPARE(clickSpy4.size(), 1); |
| 418 |
} |
| 419 |
|
| 420 |
void tst_qpieslice::doubleClickedSignal() |
| 421 |
{ |
| 422 |
// NOTE: |
| 423 |
// This test is the same as tst_qpieseries::doubleClickedSignal() |
| 424 |
// Just for different signals. |
| 425 |
|
| 426 |
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS(); |
| 427 |
|
| 428 |
// create a pie series |
| 429 |
QPieSeries *series = new QPieSeries(); |
| 430 |
QPieSlice *s1 = series->append("slice 1", 1); |
| 431 |
QSignalSpy clickSpy1(s1, SIGNAL(doubleClicked())); |
| 432 |
|
| 433 |
// add series to the chart |
| 434 |
QChartView view; |
| 435 |
view.resize(200, 200); |
| 436 |
view.chart()->legend()->setVisible(false); |
| 437 |
view.chart()->addSeries(series); |
| 438 |
view.show(); |
| 439 |
QVERIFY(QTest::qWaitForWindowExposed(&view)); |
| 440 |
|
| 441 |
// simulate clicks |
| 442 |
series->setPieSize(1.0); |
| 443 |
QRectF pieRect = view.chart()->plotArea(); |
| 444 |
QList<QPoint> points = slicePoints(pieRect); |
| 445 |
QTest::mouseDClick(view.viewport(), Qt::LeftButton, {}, points.at(0)); |
| 446 |
QCOMPARE(clickSpy1.size(), 1); |
| 447 |
} |
| 448 |
|
| 449 |
QTEST_MAIN(tst_qpieslice) |
| 450 |
|
| 451 |
#include "tst_qpieslice.moc" |
| 452 |
|