| 694 | } |
| 695 | |
| 696 | void InfoElementTest::addRemoveRenameColumn() { |
| 697 | Project project; |
| 698 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 699 | QVERIFY(ws != nullptr); |
| 700 | project.addChild(ws); |
| 701 | |
| 702 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 703 | QVERIFY(p != nullptr); |
| 704 | ws->addChild(p); |
| 705 | |
| 706 | auto* curve{new XYCurve(QStringLiteral("f(x)"))}; |
| 707 | curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 708 | |
| 709 | auto* spreadsheet = new Spreadsheet(QStringLiteral("spreadsheet")); |
| 710 | spreadsheet->setRowCount(11); |
| 711 | project.addChild(spreadsheet); |
| 712 | const auto& columns = spreadsheet->children<Column>(); |
| 713 | QCOMPARE(columns.count(), 2); |
| 714 | |
| 715 | auto* xColumn = columns.at(0); |
| 716 | auto* yColumn = columns.at(1); |
| 717 | |
| 718 | for (int i = 0; i < spreadsheet->rowCount(); i++) { |
| 719 | const double value = i; |
| 720 | xColumn->setValueAt(i, value); |
| 721 | yColumn->setValueAt(i, value); |
| 722 | } |
| 723 | |
| 724 | curve->setXColumn(xColumn); |
| 725 | curve->setYColumn(yColumn); |
| 726 | p->addChild(curve); |
| 727 | |
| 728 | CHECK_RANGE(p, curve, Dimension::X, 0., 10.); |
| 729 | CHECK_RANGE(p, curve, Dimension::Y, 0., 10.); |
| 730 | |
| 731 | auto* ie = new InfoElement(QStringLiteral("InfoElement"), p, curve, 4.9); |
| 732 | QVERIFY(ie != nullptr); |
| 733 | p->addChild(ie); |
| 734 | |
| 735 | { |
| 736 | const auto points = ie->children<CustomPoint>(); |
| 737 | QCOMPARE(ie->markerPointsCount(), 1); |
| 738 | QCOMPARE(ie->markerPointAt(0).curve, curve); |
| 739 | QCOMPARE(points.count(), 1); |
| 740 | QCOMPARE(ie->markerPointAt(0).customPoint, points.at(0)); |
| 741 | QCOMPARE(points.at(0)->positionLogical(), QPointF(5, 5)); |
| 742 | } |
| 743 | QCOMPARE(ie->connectionLineCurveName(), curve->name()); |
| 744 | |
| 745 | spreadsheet->removeChild(yColumn); |
| 746 | |
| 747 | // InfoElement is invalid |
| 748 | const auto& labels = ie->children<TextLabel>(AbstractAspect::ChildIndexFlag::IncludeHidden); |
| 749 | const auto& points = ie->children<CustomPoint>(); |
| 750 | QCOMPARE(labels.count(), 1); |
| 751 | QCOMPARE(points.count(), 1); |
| 752 | |
| 753 | QCOMPARE(ie->isValid(), false); |
nothing calls this directly
no test coverage detected