| 773 | } |
| 774 | |
| 775 | void InfoElementTest::moveDuringMissingCurve() { |
| 776 | Project project; |
| 777 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 778 | QVERIFY(ws != nullptr); |
| 779 | project.addChild(ws); |
| 780 | |
| 781 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 782 | QVERIFY(p != nullptr); |
| 783 | ws->addChild(p); |
| 784 | |
| 785 | auto* curve{new XYEquationCurve(QStringLiteral("f(x)"))}; |
| 786 | curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 787 | p->addChild(curve); |
| 788 | |
| 789 | XYEquationCurve::EquationData data; |
| 790 | data.min = QStringLiteral("0"); |
| 791 | data.max = QStringLiteral("10"); |
| 792 | data.count = 11; |
| 793 | data.expression1 = QStringLiteral("x"); |
| 794 | curve->setEquationData(data); |
| 795 | curve->recalculate(); |
| 796 | |
| 797 | auto* curve3{new XYEquationCurve(QStringLiteral("New curve"))}; |
| 798 | curve3->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 799 | p->addChild(curve3); |
| 800 | data.min = QStringLiteral("0"); |
| 801 | data.max = QStringLiteral("10"); |
| 802 | data.count = 11; |
| 803 | data.expression1 = QStringLiteral("x^2"); |
| 804 | curve3->setEquationData(data); |
| 805 | curve3->recalculate(); |
| 806 | |
| 807 | CHECK_RANGE(p, curve, Dimension::X, 0., 10.); |
| 808 | CHECK_RANGE(p, curve, Dimension::Y, 0., 100.); |
| 809 | |
| 810 | auto* ie = new InfoElement(QStringLiteral("InfoElement"), p, curve, 4.9); |
| 811 | QVERIFY(ie != nullptr); |
| 812 | p->addChild(ie); |
| 813 | |
| 814 | { |
| 815 | const auto points = ie->children<CustomPoint>(); |
| 816 | QCOMPARE(ie->markerPointsCount(), 1); |
| 817 | QCOMPARE(ie->markerPointAt(0).curve, curve); |
| 818 | QCOMPARE(points.count(), 1); |
| 819 | QCOMPARE(ie->markerPointAt(0).customPoint, points.at(0)); |
| 820 | QCOMPARE(points.at(0)->positionLogical(), QPointF(5, 5)); |
| 821 | } |
| 822 | QCOMPARE(ie->connectionLineCurveName(), curve->name()); |
| 823 | |
| 824 | p->removeChild(curve); |
| 825 | |
| 826 | QCOMPARE(ie->isValid(), false); |
| 827 | ie->setPositionLogical(7); // No crash! |
| 828 | |
| 829 | { |
| 830 | const auto points = ie->children<CustomPoint>(); |
| 831 | QCOMPARE(points.count(), 1); |
| 832 |
nothing calls this directly
no test coverage detected