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

Method TestSetCoordinateSystem

tests/backend/Axis/AxisTest.cpp:371–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369}
370
371void AxisTest::TestSetCoordinateSystem() {
372 // Test if the range stored in the Axis gets updated when a new coordinatesystemindex is set
373 Project project;
374 auto* ws = new Worksheet(QStringLiteral("worksheet"));
375 QVERIFY(ws != nullptr);
376 project.addChild(ws);
377
378 auto* p = new CartesianPlot(QStringLiteral("plot"));
379 QVERIFY(p != nullptr);
380 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axes are created
381 ws->addChild(p);
382
383 auto axes = p->children<Axis>();
384 QCOMPARE(axes.count(), 2);
385 auto yAxis = axes.at(1);
386 QCOMPARE(yAxis->name(), QStringLiteral("y"));
387 {
388 auto range = yAxis->range();
389 QCOMPARE(range.start(), 0);
390 QCOMPARE(range.end(), 1);
391 }
392
393 // Add new coordinatesystem to the plot
394 p->addYRange(Range<double>(5, 100));
395 QCOMPARE(p->rangeCount(Dimension::X), 1);
396 QCOMPARE(p->rangeCount(Dimension::Y), 2);
397 p->addCoordinateSystem();
398 QCOMPARE(p->coordinateSystemCount(), 2);
399 auto cSystem = p->coordinateSystem(1);
400 cSystem->setIndex(Dimension::X, 0);
401 cSystem->setIndex(Dimension::Y, 1);
402
403 // Change CoordinatesystemIndex of the axis
404 yAxis->setCoordinateSystemIndex(1);
405
406 {
407 auto range = yAxis->range();
408 QCOMPARE(range.start(), 5);
409 QCOMPARE(range.end(), 100);
410 }
411}
412
413void AxisTest::TestSetRange() {
414 Project project;

Callers

nothing calls this directly

Calls 14

rangeMethod · 0.80
addCoordinateSystemMethod · 0.80
addChildMethod · 0.45
setTypeMethod · 0.45
countMethod · 0.45
nameMethod · 0.45
startMethod · 0.45
endMethod · 0.45
addYRangeMethod · 0.45
rangeCountMethod · 0.45
coordinateSystemCountMethod · 0.45

Tested by

no test coverage detected