From ee369babc9185bac7c7910a68a1e58bab7efa64c Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 15 Mar 2016 16:12:05 -0500 Subject: oops, last commit's diagnosis was incorrect. The timing test issue came from async dbus handling interfering with fast setup/teardown of automated tests. Revert the last change and fix by setting up the dbus signal subscription immediately upon getting the dbus connection. --- src/usb-snap.cpp | 22 +++++++++++----------- tests/unit/usb-snap-test.cpp | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/usb-snap.cpp b/src/usb-snap.cpp index 87f4673..c42f9f0 100644 --- a/src/usb-snap.cpp +++ b/src/usb-snap.cpp @@ -92,6 +92,17 @@ private: { m_bus = G_DBUS_CONNECTION(g_object_ref(G_OBJECT(bus))); + m_subscription_id = g_dbus_connection_signal_subscribe(m_bus, + BUS_NAME, + IFACE_NAME, + nullptr, + OBJECT_PATH, + nullptr, + G_DBUS_SIGNAL_FLAGS_NONE, + on_notification_signal_static, + this, + nullptr); + auto body = g_strdup_printf(_("The computer's RSA key fingerprint is: %s"), m_fingerprint.c_str()); GVariantBuilder actions_builder; @@ -151,17 +162,6 @@ private: void on_notify_reply(uint32_t id) { m_notification_id = id; - - m_subscription_id = g_dbus_connection_signal_subscribe(m_bus, - BUS_NAME, - IFACE_NAME, - nullptr, - OBJECT_PATH, - nullptr, - G_DBUS_SIGNAL_FLAGS_NONE, - on_notification_signal_static, - this, - nullptr); } static void on_notification_signal_static(GDBusConnection* /*connection*/, diff --git a/tests/unit/usb-snap-test.cpp b/tests/unit/usb-snap-test.cpp index 4300c47..84555cc 100644 --- a/tests/unit/usb-snap-test.cpp +++ b/tests/unit/usb-snap-test.cpp @@ -163,7 +163,7 @@ TEST_F(UsbSnapFixture, TestRoundTrip) QVariantList() << id << test.action_to_invoke); // test that UsbSnap emits on_user_response() as a result - wait_for([&user_response_set](){return user_response_set;}, 2000); + wait_for([&user_response_set](){return user_response_set;}); EXPECT_TRUE(user_response_set); ASSERT_EQ(test.expected_response, user_response); -- cgit v1.2.3