| 86 | } |
| 87 | |
| 88 | void InfoElementTest::removeCurve() { |
| 89 | Project project; |
| 90 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 91 | QVERIFY(ws != nullptr); |
| 92 | project.addChild(ws); |
| 93 | |
| 94 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 95 | QVERIFY(p != nullptr); |
| 96 | ws->addChild(p); |
| 97 | |
| 98 | auto* curve{new XYEquationCurve(QStringLiteral("f(x)"))}; |
| 99 | curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 100 | p->addChild(curve); |
| 101 | |
| 102 | XYEquationCurve::EquationData data; |
| 103 | data.min = QStringLiteral("0"); |
| 104 | data.max = QStringLiteral("10"); |
| 105 | data.count = 11; |
| 106 | data.expression1 = QStringLiteral("x"); |
| 107 | curve->setEquationData(data); |
| 108 | curve->recalculate(); |
| 109 | |
| 110 | auto* curve2{new XYEquationCurve(QStringLiteral("f(x^2)"))}; |
| 111 | curve2->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 112 | p->addChild(curve2); |
| 113 | |
| 114 | data.min = QStringLiteral("0"); |
| 115 | data.max = QStringLiteral("10"); |
| 116 | data.count = 11; |
| 117 | data.expression1 = QStringLiteral("x^2"); |
| 118 | curve2->setEquationData(data); |
| 119 | curve2->recalculate(); |
| 120 | |
| 121 | CHECK_RANGE(p, curve, Dimension::X, 0., 10.); |
| 122 | CHECK_RANGE(p, curve, Dimension::Y, 0., 100.); |
| 123 | |
| 124 | auto* ie = new InfoElement(QStringLiteral("InfoElement"), p, curve, 4.9); |
| 125 | QVERIFY(ie != nullptr); |
| 126 | p->addChild(ie); |
| 127 | |
| 128 | { |
| 129 | const auto points = ie->children<CustomPoint>(); |
| 130 | QCOMPARE(ie->markerPointsCount(), 1); |
| 131 | QCOMPARE(ie->markerPointAt(0).curve, curve); |
| 132 | QCOMPARE(points.count(), 1); |
| 133 | QCOMPARE(ie->markerPointAt(0).customPoint, points.at(0)); |
| 134 | QCOMPARE(points.at(0)->positionLogical(), QPointF(5, 5)); |
| 135 | } |
| 136 | QCOMPARE(ie->connectionLineCurveName(), curve->name()); |
| 137 | |
| 138 | ie->addCurve(curve2); |
| 139 | |
| 140 | QCOMPARE(ie->connectionLineCurveName(), curve->name()); // No change here |
| 141 | |
| 142 | { |
| 143 | const auto points = ie->children<CustomPoint>(); |
| 144 | QCOMPARE(points.count(), 2); |
| 145 |
nothing calls this directly
no test coverage detected