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

Function TEST

pj_plotting/tests/plot_widget_replace_curve_test.cpp:49–80  ·  view source on GitHub ↗

The Filter Editor's core behavior: applying a filter to a plotted curve makes the filtered output REPLACE the source (not add alongside) and INHERIT the source's colour.

Source from the content-addressed store, hash-verified

47// the filtered output REPLACE the source (not add alongside) and INHERIT the
48// source's colour.
49TEST(PlotWidgetReplaceCurve, OutputInheritsSourceColourAndReplacesSource) {
50 PJ::SessionManager session;
51 PJ::CatalogModel catalog(&session);
52 auto dataset = session.dataEngine().createDataset(PJ::DatasetDescriptor{.source_name = "drive.mcap"});
53 ASSERT_TRUE(dataset.has_value()) << dataset.error();
54
55 const PJ::TopicId src = addScalarTopic(session, *dataset, "/imu/accel");
56 const PJ::TopicId out = addScalarTopic(session, *dataset, "/imu/accel[Filtered]");
57 ASSERT_NE(src, 0U);
58 ASSERT_NE(out, 0U);
59
60 const QString src_key = keyForTopic(catalog, src);
61 const QString out_key = keyForTopic(catalog, out);
62 ASSERT_FALSE(src_key.isEmpty());
63 ASSERT_FALSE(out_key.isEmpty());
64
65 PJ::PlotWidget plot(&session, &catalog);
66 ASSERT_NE(plot.addCurve(src_key), nullptr);
67
68 const QColor chosen(Qt::red);
69 plot.onChangeCurveColor(src_key, chosen);
70 ASSERT_EQ(plot.curveList().size(), 1U);
71
72 plot.replaceCurve(src_key, out_key);
73
74 // Source gone, output present, count unchanged (replaced, not added).
75 ASSERT_EQ(plot.curveList().size(), 1U);
76 const auto& only = plot.curveList().front();
77 EXPECT_EQ(only.source_name, out_key);
78 ASSERT_NE(only.curve, nullptr);
79 EXPECT_EQ(only.curve->pen().color(), chosen);
80}
81
82// A source not currently plotted is just added (no spurious removal/crash).
83TEST(PlotWidgetReplaceCurve, AbsentSourceJustAddsOutput) {

Callers

nothing calls this directly

Calls 10

createDatasetMethod · 0.80
onChangeCurveColorMethod · 0.80
replaceCurveMethod · 0.80
addScalarTopicFunction · 0.70
keyForTopicFunction · 0.70
isEmptyMethod · 0.45
addCurveMethod · 0.45
sizeMethod · 0.45
colorMethod · 0.45
penMethod · 0.45

Tested by

no test coverage detected