! * \brief AxisTest2::columnLabelValuesMoreTicksThanLabels * Draw all ticks regardsless of their position, because we have only a few */
| 427 | * Draw all ticks regardsless of their position, because we have only a few |
| 428 | */ |
| 429 | void AxisTest2::columnLabelValuesMoreTicksThanLabels() { |
| 430 | QLocale::setDefault(QLocale::C); // . as decimal separator |
| 431 | Project project; |
| 432 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 433 | QVERIFY(ws != nullptr); |
| 434 | project.addChild(ws); |
| 435 | |
| 436 | Spreadsheet* spreadsheet = new Spreadsheet(QStringLiteral("test"), false); |
| 437 | spreadsheet->setColumnCount(2); |
| 438 | spreadsheet->setRowCount(3); |
| 439 | project.addChild(spreadsheet); |
| 440 | |
| 441 | auto* xCol = spreadsheet->column(0); |
| 442 | xCol->replaceValues(0, QVector<double>({1, 2, 3})); |
| 443 | |
| 444 | auto* yCol = spreadsheet->column(1); |
| 445 | yCol->replaceValues(0, QVector<double>({3, 5, 10})); |
| 446 | |
| 447 | QCOMPARE(spreadsheet->rowCount(), 3); |
| 448 | QCOMPARE(spreadsheet->columnCount(), 2); |
| 449 | |
| 450 | yCol->addValueLabel(0, QStringLiteral("Status 1")); |
| 451 | yCol->addValueLabel(1, QStringLiteral("Status 2")); |
| 452 | yCol->addValueLabel(2, QStringLiteral("Status 3")); |
| 453 | yCol->addValueLabel(3, QStringLiteral("Status 4")); |
| 454 | yCol->addValueLabel(4, QStringLiteral("Status 5")); |
| 455 | // yCol->addValueLabel(5, QStringLiteral("Status 6")); Gap |
| 456 | // yCol->addValueLabel(6, QStringLiteral("Status 7")); Gap |
| 457 | yCol->addValueLabel(7, QStringLiteral("Status 8")); |
| 458 | yCol->addValueLabel(8, QStringLiteral("Status 9")); |
| 459 | yCol->addValueLabel(9, QStringLiteral("Status 10")); |
| 460 | yCol->addValueLabel(10, QStringLiteral("Status 11")); |
| 461 | |
| 462 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 463 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 464 | QVERIFY(p != nullptr); |
| 465 | ws->addChild(p); |
| 466 | |
| 467 | auto* curve = new XYCurve(QStringLiteral("xy-curve")); |
| 468 | curve->setXColumn(xCol); |
| 469 | curve->setYColumn(yCol); |
| 470 | p->addChild(curve); |
| 471 | |
| 472 | auto axes = p->children<Axis>(); |
| 473 | QCOMPARE(axes.count(), 2); |
| 474 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 475 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 476 | auto* yAxis = static_cast<Axis*>(axes.at(1)); |
| 477 | |
| 478 | { |
| 479 | yAxis->setMajorTicksType(Axis::TicksType::ColumnLabels); |
| 480 | yAxis->setMajorTicksColumn(yCol); |
| 481 | |
| 482 | QStringList expectedStrings{ |
| 483 | QStringLiteral("Status 4"), |
| 484 | QStringLiteral("Status 5"), |
| 485 | // QStringLiteral("Status 6"), |
| 486 | // QStringLiteral("Status 7"), |
nothing calls this directly
no test coverage detected