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.
| 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. |
| 98 | TEST(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 == |
nothing calls this directly
no test coverage detected