| 923 | } |
| 924 | |
| 925 | void InfoElementTest::saveLoad() { |
| 926 | QString savePath; |
| 927 | { |
| 928 | Project project; |
| 929 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 930 | QVERIFY(ws != nullptr); |
| 931 | project.addChild(ws); |
| 932 | |
| 933 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 934 | QVERIFY(p != nullptr); |
| 935 | ws->addChild(p); |
| 936 | |
| 937 | auto* curve{new XYEquationCurve(QStringLiteral("f(x)"))}; |
| 938 | curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 939 | p->addChild(curve); |
| 940 | |
| 941 | XYEquationCurve::EquationData data; |
| 942 | data.min = QStringLiteral("0"); |
| 943 | data.max = QStringLiteral("10"); |
| 944 | data.count = 11; |
| 945 | data.expression1 = QStringLiteral("x"); |
| 946 | curve->setEquationData(data); |
| 947 | curve->recalculate(); |
| 948 | |
| 949 | auto* curve2{new XYEquationCurve(QStringLiteral("f(x^2)"))}; |
| 950 | curve2->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 951 | p->addChild(curve2); |
| 952 | |
| 953 | data.min = QStringLiteral("0"); |
| 954 | data.max = QStringLiteral("10"); |
| 955 | data.count = 11; |
| 956 | data.expression1 = QStringLiteral("x^2"); |
| 957 | curve2->setEquationData(data); |
| 958 | curve2->recalculate(); |
| 959 | |
| 960 | CHECK_RANGE(p, curve, Dimension::X, 0., 10.); |
| 961 | CHECK_RANGE(p, curve, Dimension::Y, 0., 100.); |
| 962 | |
| 963 | auto* ie = new InfoElement(QStringLiteral("InfoElement"), p, curve, 4.9); |
| 964 | QVERIFY(ie != nullptr); |
| 965 | p->addChild(ie); |
| 966 | ie->addCurve(curve2); |
| 967 | { |
| 968 | const auto points = ie->children<CustomPoint>(); |
| 969 | QCOMPARE(ie->markerPointsCount(), 2); |
| 970 | QCOMPARE(points.count(), 2); |
| 971 | QCOMPARE(ie->markerPointAt(0).curve, curve); |
| 972 | QCOMPARE(ie->markerPointAt(0).customPoint, points.at(0)); |
| 973 | QCOMPARE(points.at(0)->positionLogical(), QPointF(5, 5)); |
| 974 | QCOMPARE(points.at(0)->isVisible(), true); |
| 975 | |
| 976 | QCOMPARE(ie->markerPointAt(1).curve, curve2); |
| 977 | QCOMPARE(ie->markerPointAt(1).customPoint, points.at(1)); |
| 978 | QCOMPARE(points.at(1)->positionLogical(), QPointF(5, 25)); |
| 979 | QCOMPARE(points.at(1)->isVisible(), true); |
| 980 | } |
| 981 | |
| 982 | QCOMPARE(ie->connectionLineCurveName(), curve->name()); |
nothing calls this directly
no test coverage detected