#include "Qt/plot/Latency_Eager_Plot.h" #include #include #include #include #include namespace renderive { namespace { TEST(Renderive_Qt, WidgetLifecycleDrivesAndStopsKernelScene) { auto* application = qobject_cast(QCoreApplication::instance()); ASSERT_NE(application, nullptr); Latency_Eager_Plot plot; plot.resize(240, 120); renderive_Owner x_axis; renderive_Owner y_axis; renderive_Owner spectrum; x_axis = Frequency_Axis::Builder{} .set<&Frequency_Axis::Properties::orientation>(Orientation::Horizontal) .set<&Frequency_Axis::Properties::x>(20) .set<&Frequency_Axis::Properties::y>(100) .set<&Frequency_Axis::Properties::pixel_length>(200) .set<&Frequency_Axis::Properties::coordinates>(Range{0.0, 10.0}) .set_object_name("X Axis") .build(); plot.add_renderable(x_axis); y_axis = Axis::Builder{} .set<&Axis::Properties::orientation>(Orientation::Vertical) .set<&Axis::Properties::x>(20) .set<&Axis::Properties::y>(10) .set<&Axis::Properties::pixel_length>(90) .set<&Axis::Properties::coordinates>(Range{1.0, 0.0}) .set_object_name("Y Axis") .build(); plot.add_renderable(y_axis); spectrum = Spectrum::Builder{} .set<&Spectrum::Properties::frequency_range>(Range{0.0, 10.0}) .set<&Spectrum::Properties::frequency_point_size>(8) .set_object_name("Spectrum") .build(x_axis, y_axis); plot.add_renderable(spectrum); plot.init(); spectrum->update_samples(std::vector{0.1, 0.3, 0.8, 0.5, 0.9, 0.4, 0.2, 0.7}); plot.show(); QTimer::singleShot(150, application, &QCoreApplication::quit); EXPECT_EQ(application->exec(), 0); EXPECT_GT(plot.diagnostics().refresh.frame_count, 0u); plot.pause(); plot.hide(); application->processEvents(); EXPECT_FALSE(plot.running()); } } } int main(int argc, char** argv) { qputenv("QT_QPA_PLATFORM", "offscreen"); QApplication application(argc, argv); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }