#include #include #include #include #include #include "MainWindow.hpp" // QWidget-based tests need a full QApplication (not QCoreApplication). // Use offscreen platform so tests run headless in containers. static int argc_ = 0; static char* argv_[] = {nullptr}; static struct SetupOffscreen { SetupOffscreen() { qputenv("QT_QPA_PLATFORM", "offscreen"); } } setup_offscreen_; static QApplication app_(argc_, argv_); TEST(MainWindowTest, LabelUpdatesOnValueReceived) { MainWindow window; // Simulate receiving a value from ConsumerThread window.onValueReceived(42); // The label should display the received value EXPECT_NE(window.lastDisplayedText().toStdString().find("42"), std::string::npos); } TEST(MainWindowTest, LabelUpdatesMultipleTimes) { MainWindow window; window.onValueReceived(10); window.onValueReceived(20); window.onValueReceived(30); // Label should show the most recent value EXPECT_NE(window.lastDisplayedText().toStdString().find("30"), std::string::npos); } TEST(MainWindowTest, WindowTitleIsSet) { MainWindow window; EXPECT_FALSE(window.windowTitle().isEmpty()); }