MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / TEST

Function TEST

pj_plotting/tests/plot_widget_range_offset_test.cpp:98–111  ·  view source on GitHub ↗

With "Use time offset" ON, the axis frames display window [0, 1] s. Saving must record the ABSOLUTE window [1.6e9, 1.6e9 + 1] s. The layout always stores a time axis absolute (the offset is a visualization concern), so NO x_absolute marker is written — the plot mode distinguishes time-series from XY on load.

Source from the content-addressed store, hash-verified

96// axis absolute (the offset is a visualization concern), so NO x_absolute marker is
97// written — the plot mode distinguishes time-series from XY on load.
98TEST(PlotWidgetRangeOffset, SavesAbsoluteTimeRange) {
99 PlotFixture fixture;
100 fixture.session.setUseTimeOffset(true); // display offset = dataset min = kT0Ns
101 fixture.plot.setZoomRectangle(QRectF(0.0, -5.0, 1.0, 10.0), /*emit_signal=*/false);
102
103 QDomDocument doc;
104 const QDomElement plot_element = fixture.plot.xmlSaveState(doc);
105 const QDomElement range = plot_element.firstChildElement(QStringLiteral("range"));
106 ASSERT_FALSE(range.isNull());
107
108 EXPECT_FALSE(range.hasAttribute(QStringLiteral("x_absolute"))) << "the obsolete marker must not be written";
109 EXPECT_NEAR(range.attribute(QStringLiteral("left")).toDouble(), kT0Sec, 1e-3);
110 EXPECT_NEAR(range.attribute(QStringLiteral("right")).toDouble(), kT0Sec + 1.0, 1e-3);
111}
112
113// The core bug: save with the offset ON, load with it OFF. The restored axis
114// must still frame the same ABSOLUTE instant. With the offset now 0, display ==

Callers

nothing calls this directly

Calls 10

rebindCurveNamesFunction · 0.85
setUseTimeOffsetMethod · 0.80
setZoomRectangleMethod · 0.80
toDoubleMethod · 0.80
currentBoundingRectMethod · 0.80
QRectFClass · 0.50
xmlSaveStateMethod · 0.45
isNullMethod · 0.45
xmlLoadStateMethod · 0.45
setAttributeMethod · 0.45

Tested by

no test coverage detected