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

Method addRemoveRenameColumn

tests/backend/InfoElement/InfoElementTest.cpp:696–773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

694}
695
696void 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);

Callers

nothing calls this directly

Calls 15

setYColumnMethod · 0.80
markerPointsCountMethod · 0.80
markerPointAtMethod · 0.80
QPointFClass · 0.50
addChildMethod · 0.45
setRowCountMethod · 0.45
countMethod · 0.45
rowCountMethod · 0.45
setValueAtMethod · 0.45
setXColumnMethod · 0.45

Tested by

no test coverage detected