| 259 | } |
| 260 | |
| 261 | void InfoElementTest::changeColumn() { |
| 262 | Project project; |
| 263 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 264 | QVERIFY(ws != nullptr); |
| 265 | project.addChild(ws); |
| 266 | |
| 267 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 268 | QVERIFY(p != nullptr); |
| 269 | ws->addChild(p); |
| 270 | |
| 271 | auto* curve{new XYCurve(QStringLiteral("f(x)"))}; |
| 272 | curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 273 | |
| 274 | auto* spreadsheet = new Spreadsheet(QStringLiteral("spreadsheet")); |
| 275 | spreadsheet->setColumnCount(3); |
| 276 | spreadsheet->setRowCount(11); |
| 277 | project.addChild(spreadsheet); |
| 278 | const auto& columns = spreadsheet->children<Column>(); |
| 279 | QCOMPARE(columns.count(), 3); |
| 280 | QCOMPARE(spreadsheet->rowCount(), 11); |
| 281 | |
| 282 | auto* xColumn = columns.at(0); |
| 283 | auto* yColumn = columns.at(1); |
| 284 | auto* y2Column = columns.at(2); |
| 285 | |
| 286 | for (int i = 0; i < spreadsheet->rowCount(); i++) { |
| 287 | xColumn->setValueAt(i, i); |
| 288 | yColumn->setValueAt(i, i); |
| 289 | y2Column->setValueAt(i, i + 1); |
| 290 | } |
| 291 | |
| 292 | curve->setXColumn(xColumn); |
| 293 | curve->setYColumn(yColumn); |
| 294 | p->addChild(curve); |
| 295 | |
| 296 | CHECK_RANGE(p, curve, Dimension::X, 0., 10.); |
| 297 | CHECK_RANGE(p, curve, Dimension::Y, 0., 10.); |
| 298 | |
| 299 | auto* ie = new InfoElement(QStringLiteral("InfoElement"), p, curve, 4.9); |
| 300 | QVERIFY(ie != nullptr); |
| 301 | p->addChild(ie); |
| 302 | |
| 303 | { |
| 304 | const auto points = ie->children<CustomPoint>(); |
| 305 | QCOMPARE(ie->markerPointsCount(), 1); |
| 306 | QCOMPARE(ie->markerPointAt(0).curve, curve); |
| 307 | QCOMPARE(points.count(), 1); |
| 308 | QCOMPARE(ie->markerPointAt(0).customPoint, points.at(0)); |
| 309 | QCOMPARE(points.at(0)->positionLogical(), QPointF(5, 5)); |
| 310 | } |
| 311 | QCOMPARE(ie->connectionLineCurveName(), curve->name()); |
| 312 | |
| 313 | // InfoElement is invalid |
| 314 | const auto& labels = ie->children<TextLabel>(AbstractAspect::ChildIndexFlag::IncludeHidden); |
| 315 | const auto& points = ie->children<CustomPoint>(); |
| 316 | QCOMPARE(labels.count(), 1); |
| 317 | QCOMPARE(points.count(), 1); |
| 318 |
nothing calls this directly
no test coverage detected