MCPcopy Create free account
hub / github.com/KDE/labplot / tickSpacingUpdateDockMajorTicks

Method tickSpacingUpdateDockMajorTicks

tests/backend/Axis/AxisTest.cpp:911–936  ·  view source on GitHub ↗

! * checks the spacing of the ticks that is automatically calculated and set * after the switch from "number" to "spacing" ticks type in the dock widget. */

Source from the content-addressed store, hash-verified

909 * after the switch from "number" to "spacing" ticks type in the dock widget.
910 */
911void AxisTest::tickSpacingUpdateDockMajorTicks() {
912 Project project;
913 auto* ws = new Worksheet(QStringLiteral("worksheet"));
914 QVERIFY(ws != nullptr);
915 project.addChild(ws);
916
917 auto* p = new CartesianPlot(QStringLiteral("plot"));
918 QVERIFY(p != nullptr);
919 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
920 ws->addChild(p);
921
922 auto axes = p->children<Axis>();
923 auto* xAxis = static_cast<Axis*>(axes.at(0));
924
925 AxisDock dock(nullptr);
926 dock.setAxes({xAxis});
927 dock.ui.cbMajorTicksType->setCurrentIndex(dock.ui.cbMajorTicksType->findData((int)Axis::TicksType::Spacing));
928 dock.ui.cbMinorTicksType->setCurrentIndex(dock.ui.cbMinorTicksType->findData((int)Axis::TicksType::Spacing));
929
930 // initially, the spacing is not set (equal to zero) and after the switch to "spacing"
931 // it's adjusted to the current spacing determined by the total number of the ticks:
932 // * for major ticks, for the range 0-1 and the initial number of ticks is 6 and it corresponds to spacing = 0.2
933 // * for minor ticks, the spacing between the major ticks is 0.2 and the number of minor ticks is 1 which corresponds to spacing = 0.1
934 QCOMPARE(xAxis->majorTicksSpacing(), 0.2);
935 QCOMPARE(xAxis->minorTicksSpacing(), 0.1);
936}
937
938QTEST_MAIN(AxisTest)

Callers

nothing calls this directly

Calls 4

addChildMethod · 0.45
setTypeMethod · 0.45
setAxesMethod · 0.45
setCurrentIndexMethod · 0.45

Tested by

no test coverage detected