| 863 | } |
| 864 | |
| 865 | void AxisTest::automaticTicNumberUpdateDockMinorTicks() { |
| 866 | Project project; |
| 867 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 868 | QVERIFY(ws != nullptr); |
| 869 | project.addChild(ws); |
| 870 | |
| 871 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 872 | QVERIFY(p != nullptr); |
| 873 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 874 | ws->addChild(p); |
| 875 | |
| 876 | auto axes = p->children<Axis>(); |
| 877 | QCOMPARE(axes.count(), 2); |
| 878 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 879 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 880 | auto* yAxis = static_cast<Axis*>(axes.at(1)); |
| 881 | auto* xAxis = static_cast<Axis*>(axes.at(0)); |
| 882 | |
| 883 | AxisDock dock(nullptr); |
| 884 | dock.setAxes({xAxis, yAxis}); |
| 885 | dock.ui.cbMinorTicksAutoNumber->setChecked(false); |
| 886 | dock.ui.sbMinorTicksNumber->setValue(10); |
| 887 | |
| 888 | // Check minorticks numbers of the axes |
| 889 | QCOMPARE(xAxis->minorTicksNumber(), 10); |
| 890 | QCOMPARE(xAxis->minorTicksAutoNumber(), false); |
| 891 | QCOMPARE(yAxis->minorTicksNumber(), 10); |
| 892 | QCOMPARE(xAxis->minorTicksAutoNumber(), false); |
| 893 | QCOMPARE(dock.ui.cbMinorTicksAutoNumber->isChecked(), false); |
| 894 | |
| 895 | dock.setAxes({xAxis, yAxis}); // Another time |
| 896 | QCOMPARE(dock.ui.cbMinorTicksAutoNumber->isChecked(), false); |
| 897 | dock.ui.cbMinorTicksAutoNumber->setChecked(true); |
| 898 | |
| 899 | // 1 is the default value for automatic |
| 900 | QCOMPARE(xAxis->minorTicksNumber(), 1); |
| 901 | QCOMPARE(xAxis->minorTicksAutoNumber(), true); |
| 902 | QCOMPARE(yAxis->minorTicksNumber(), 1); |
| 903 | QCOMPARE(xAxis->minorTicksAutoNumber(), true); |
| 904 | QCOMPARE(dock.ui.sbMinorTicksNumber->value(), 1); |
| 905 | } |
| 906 | |
| 907 | /*! |
| 908 | * checks the spacing of the ticks that is automatically calculated and set |