| 396 | } |
| 397 | |
| 398 | void WorksheetElementTest::referenceRangeSaveLoad() { |
| 399 | QString savePath; |
| 400 | { |
| 401 | SETUP_PROJECT |
| 402 | |
| 403 | auto* referenceRange = new ReferenceRange(p, QStringLiteral("range")); |
| 404 | referenceRange->setOrientation(ReferenceRange::Orientation::Horizontal); |
| 405 | p->addChild(referenceRange); |
| 406 | referenceRange->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 407 | auto pp = referenceRange->position(); |
| 408 | pp.point = QPointF(0, 0); |
| 409 | referenceRange->setPosition(pp); |
| 410 | referenceRange->setCoordinateBindingEnabled(true); |
| 411 | SAVE_PROJECT("testReferenceRangeSaveLoad"); |
| 412 | } |
| 413 | |
| 414 | { |
| 415 | Project project; |
| 416 | QCOMPARE(project.load(savePath), true); // shall not crash |
| 417 | |
| 418 | const auto* ws = project.child<Worksheet>(0); |
| 419 | QVERIFY(ws); |
| 420 | const auto* p = ws->child<CartesianPlot>(0); |
| 421 | QVERIFY(p); |
| 422 | const auto* referenceRange = p->child<ReferenceRange>(0); |
| 423 | QVERIFY(referenceRange); |
| 424 | |
| 425 | QCOMPARE(referenceRange->positionLogical().x(), 0.5); |
| 426 | QCOMPARE(referenceRange->positionLogical().y(), 0.5); |
| 427 | QCOMPARE(referenceRange->positionLogicalStart().y(), 0.45); |
| 428 | QCOMPARE(referenceRange->positionLogicalEnd().y(), 0.55); |
| 429 | CHECK_REFERENCERANGE_RECT(referenceRange, 0., 0.55, 1., 0.45); |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | /*! |
| 434 | * \brief create and add a new ReferenceLine, undo and redo this step |
nothing calls this directly
no test coverage detected