From f320760f20b282e9b2695477ab602d4041a3ada8 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 27 Jan 2014 01:26:52 -0600 Subject: add test coverage for Exporter's name_lost signal --- tests/test-exporter.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'tests/test-exporter.cpp') diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp index aa9e89d..104fb4b 100644 --- a/tests/test-exporter.cpp +++ b/tests/test-exporter.cpp @@ -36,17 +36,6 @@ private: typedef GlibFixture super; - static void on_bus_closed(GObject * object, - GAsyncResult * res, - gpointer gself) - { - auto self = static_cast(gself); - GError* err = nullptr; - g_dbus_connection_close_finish(G_DBUS_CONNECTION(object), res, &err); - g_assert_no_error(err); - g_main_loop_quit(self->loop); - } - protected: GTestDBus* bus = nullptr; @@ -65,9 +54,11 @@ protected: void TearDown() { - GDBusConnection* connection = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, nullptr); - g_dbus_connection_close(connection, nullptr, on_bus_closed, this); - g_main_loop_run(loop); + GError * error = nullptr; + GDBusConnection* connection = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error); + if(!g_dbus_connection_is_closed(connection)) + g_dbus_connection_close_sync(connection, nullptr, &error); + g_assert_no_error(error); g_clear_object(&connection); g_test_dbus_down(bus); g_clear_object(&bus); @@ -87,6 +78,10 @@ TEST_F(ExporterFixture, Publish) std::shared_ptr actions(new MockActions(state)); std::vector> menus; + MenuFactory menu_factory (actions, state); + for(int i=0; i