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.
| 47 | // the filtered output REPLACE the source (not add alongside) and INHERIT the |
| 48 | // source's colour. |
| 49 | TEST(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). |
| 83 | TEST(PlotWidgetReplaceCurve, AbsentSourceJustAddsOutput) { |
nothing calls this directly
no test coverage detected