| 339 | } |
| 340 | |
| 341 | void InfoElementTest::columnValueChanged() { |
| 342 | Project project; |
| 343 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 344 | QVERIFY(ws != nullptr); |
| 345 | project.addChild(ws); |
| 346 | |
| 347 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 348 | QVERIFY(p != nullptr); |
| 349 | ws->addChild(p); |
| 350 | |
| 351 | auto* curve{new XYCurve(QStringLiteral("f(x)"))}; |
| 352 | curve->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 353 | |
| 354 | auto* spreadsheet = new Spreadsheet(QStringLiteral("spreadsheet")); |
| 355 | spreadsheet->setColumnCount(2); |
| 356 | spreadsheet->setRowCount(11); |
| 357 | project.addChild(spreadsheet); |
| 358 | const auto& columns = spreadsheet->children<Column>(); |
| 359 | QCOMPARE(columns.count(), 2); |
| 360 | QCOMPARE(spreadsheet->rowCount(), 11); |
| 361 | |
| 362 | auto* xColumn = columns.at(0); |
| 363 | auto* yColumn = columns.at(1); |
| 364 | |
| 365 | for (int i = 0; i < spreadsheet->rowCount(); i++) { |
| 366 | xColumn->setValueAt(i, i); |
| 367 | yColumn->setValueAt(i, i); |
| 368 | } |
| 369 | |
| 370 | curve->setXColumn(xColumn); |
| 371 | curve->setYColumn(yColumn); |
| 372 | p->addChild(curve); |
| 373 | |
| 374 | CHECK_RANGE(p, curve, Dimension::X, 0., 10.); |
| 375 | CHECK_RANGE(p, curve, Dimension::Y, 0., 10.); |
| 376 | |
| 377 | auto* ie = new InfoElement(QStringLiteral("InfoElement"), p, curve, 4.9); |
| 378 | QVERIFY(ie != nullptr); |
| 379 | p->addChild(ie); |
| 380 | |
| 381 | { |
| 382 | const auto points = ie->children<CustomPoint>(); |
| 383 | QCOMPARE(ie->markerPointsCount(), 1); |
| 384 | QCOMPARE(ie->markerPointAt(0).curve, curve); |
| 385 | QCOMPARE(points.count(), 1); |
| 386 | QCOMPARE(ie->markerPointAt(0).customPoint, points.at(0)); |
| 387 | QCOMPARE(points.at(0)->positionLogical(), QPointF(5, 5)); |
| 388 | } |
| 389 | QCOMPARE(ie->connectionLineCurveName(), curve->name()); |
| 390 | |
| 391 | // InfoElement is invalid |
| 392 | const auto& labels = ie->children<TextLabel>(AbstractAspect::ChildIndexFlag::IncludeHidden); |
| 393 | const auto& points = ie->children<CustomPoint>(); |
| 394 | QCOMPARE(labels.count(), 1); |
| 395 | QCOMPARE(points.count(), 1); |
| 396 | |
| 397 | QCOMPARE(ie->isValid(), true); |
| 398 | QCOMPARE(labels.at(0)->isVisible(), true); |
nothing calls this directly
no test coverage detected