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

Method majorTicksStartValue

tests/backend/Axis/AxisTest.cpp:299–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299void AxisTest::majorTicksStartValue() {
300 Project project;
301 auto* ws = new Worksheet(QStringLiteral("worksheet"));
302 QVERIFY(ws != nullptr);
303 project.addChild(ws);
304
305 auto* p = new CartesianPlot(QStringLiteral("plot"));
306 QVERIFY(p != nullptr);
307 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created
308 ws->addChild(p);
309
310 auto axes = p->children<Axis>();
311 QCOMPARE(axes.count(), 2);
312 QCOMPARE(axes.at(0)->name(), QStringLiteral("x"));
313 QCOMPARE(axes.at(1)->name(), QStringLiteral("y"));
314
315 AxisDock axisDock(nullptr);
316
317 auto* xAxis = axes.at(0);
318
319 {
320 QVector<double> expectedTickValues = {0, 0.2, 0.4, 0.6, 0.8, 1.0};
321 CHECK_AXIS_LABELS(xAxis->tickLabelValues(), expectedTickValues);
322 }
323
324 // To check also if the dock shows the correct values
325 axisDock.setAxes({xAxis});
326
327 QCOMPARE(axisDock.ui.cbMajorTicksStartType->currentIndex(), 1); // by default offset is used
328
329 QCOMPARE(xAxis->majorTicksStartType(), Axis::TicksStartType::Offset);
330
331 xAxis->setMajorTickStartValue(0.1); // does not affect anything, but just that the ticklabels are different to the offset when setting
332
333 xAxis->setMajorTicksStartType(Axis::TicksStartType::Absolute);
334
335 QCOMPARE(axisDock.ui.cbMajorTicksStartType->currentIndex(), 0);
336
337 QCOMPARE(xAxis->majorTicksStartType(), Axis::TicksStartType::Absolute);
338 {
339 QVector<double> expectedTickValues = {0.1, 0.4, 0.7, 1.0}; // starting now from 0.1
340 CHECK_AXIS_LABELS(xAxis->tickLabelValues(), expectedTickValues);
341 }
342
343 xAxis->setMajorTickStartValue(0.2);
344 QCOMPARE(axisDock.ui.sbMajorTickStartValue->value(), 0.2);
345
346 {
347 QVector<double> expectedTickValues = {0.2, 0.4, 0.6, 0.8, 1.0}; // starting now from 0.2
348 CHECK_AXIS_LABELS(xAxis->tickLabelValues(), expectedTickValues);
349 }
350
351 project.undoStack()->undo();
352
353 QCOMPARE(xAxis->majorTicksStartType(), Axis::TicksStartType::Absolute);
354
355 {
356 QVector<double> expectedTickValues = {0.1, 0.4, 0.7, 1.0}; // starting now from 0.1

Callers

nothing calls this directly

Calls 12

tickLabelValuesMethod · 0.80
addChildMethod · 0.45
setTypeMethod · 0.45
countMethod · 0.45
nameMethod · 0.45
setAxesMethod · 0.45
currentIndexMethod · 0.45
valueMethod · 0.45
undoMethod · 0.45
undoStackMethod · 0.45

Tested by

no test coverage detected