| 563 | } |
| 564 | |
| 565 | void AxisTest::tickLabelRepresentationManual() { |
| 566 | QLocale::setDefault(QLocale::English); // . as decimal separator |
| 567 | Project project; |
| 568 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 569 | QVERIFY(ws != nullptr); |
| 570 | project.addChild(ws); |
| 571 | |
| 572 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 573 | QVERIFY(p != nullptr); |
| 574 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 575 | ws->addChild(p); |
| 576 | |
| 577 | auto axes = p->children<Axis>(); |
| 578 | QCOMPARE(axes.count(), 2); |
| 579 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 580 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 581 | auto* yAxis = static_cast<Axis*>(axes.at(1)); |
| 582 | |
| 583 | AxisDock dock(nullptr); |
| 584 | dock.setAxes({yAxis}); |
| 585 | |
| 586 | QCOMPARE(dock.ui.chkLabelsFormatAuto->isChecked(), true); |
| 587 | QCOMPARE(dock.ui.cbLabelsFormat->isEnabled(), false); |
| 588 | |
| 589 | yAxis->setLabelsFormatAuto(false); |
| 590 | |
| 591 | QCOMPARE(dock.ui.chkLabelsFormatAuto->isChecked(), false); |
| 592 | QCOMPARE(dock.ui.cbLabelsFormat->isEnabled(), true); |
| 593 | |
| 594 | { |
| 595 | // Check if applied also when settings |
| 596 | AxisDock dock2(nullptr); |
| 597 | dock2.setAxes({yAxis}); |
| 598 | QCOMPARE(dock2.ui.chkLabelsFormatAuto->isChecked(), false); |
| 599 | QCOMPARE(dock2.ui.cbLabelsFormat->isEnabled(), true); |
| 600 | } |
| 601 | |
| 602 | { |
| 603 | QCOMPARE(yAxis->labelsFormat(), Axis::LabelsFormat::Decimal); |
| 604 | QStringList expectedStrings{QStringLiteral("0.0"), |
| 605 | QStringLiteral("0.2"), |
| 606 | QStringLiteral("0.4"), |
| 607 | QStringLiteral("0.6"), |
| 608 | QStringLiteral("0.8"), |
| 609 | QStringLiteral("1.0")}; |
| 610 | COMPARE_STRING_VECTORS(yAxis->tickLabelStrings(), expectedStrings); |
| 611 | } |
| 612 | |
| 613 | p->setRangeDefault(Dimension::Y, Range<double>(0, 1e6)); |
| 614 | |
| 615 | { |
| 616 | QCOMPARE(yAxis->labelsFormat(), Axis::LabelsFormat::Decimal); |
| 617 | QStringList expectedStrings{QStringLiteral("0"), |
| 618 | QStringLiteral("200,000"), |
| 619 | QStringLiteral("400,000"), |
| 620 | QStringLiteral("600,000"), |
| 621 | QStringLiteral("800,000"), |
| 622 | QStringLiteral("1,000,000")}; |
nothing calls this directly
no test coverage detected