#include #include "../../src/core/eventbus.h" #include "../../src/core/events.h" class TestEventBus : public QObject { Q_OBJECT private slots: void testPublishAndSubscribe(); }; void TestEventBus::testPublishAndSubscribe() { bool received = false; int value = 0; // Subscribe to an event of type int auto subscription = EventBus::instance().subscribe([&](int data) { received = true; value = data; }); // Publish an event EventBus::instance().publish(42); // Check that we received the event QVERIFY(received); QCOMPARE(value, 42); // Unsubscribe (optional, subscription goes out of scope) } QTEST_MAIN(TestEventBus) #include "test_eventbus.moc"