MCPcopy Create free account
hub / github.com/KDE/labplot / moveDuringMissingCurve

Method moveDuringMissingCurve

tests/backend/InfoElement/InfoElementTest.cpp:775–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

773}
774
775void 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

Callers

nothing calls this directly

Calls 13

setEquationDataMethod · 0.80
markerPointsCountMethod · 0.80
markerPointAtMethod · 0.80
QPointFClass · 0.50
addChildMethod · 0.45
recalculateMethod · 0.45
countMethod · 0.45
nameMethod · 0.45
removeChildMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected