From b1be45c3b8cef5fede101985a26363319f3a9645 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 4 Mar 2016 12:40:23 -0600 Subject: update glib/dbus test fixtures from indicator-datetime/15.10 branch --- tests/gtestdbus-fixture.h | 108 ---------------------------------------------- 1 file changed, 108 deletions(-) delete mode 100644 tests/gtestdbus-fixture.h (limited to 'tests/gtestdbus-fixture.h') diff --git a/tests/gtestdbus-fixture.h b/tests/gtestdbus-fixture.h deleted file mode 100644 index c592033..0000000 --- a/tests/gtestdbus-fixture.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2013 Canonical Ltd. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - * Authors: - * Charles Kerr - */ - -#ifndef INDICATOR_TESTS_GTESTDBUS_FIXTURE_H -#define INDICATOR_TESTS_GTESTDBUS_FIXTURE_H - -#include "glib-fixture.h" - -/*** -**** -***/ - -class GTestDBusFixture: public GlibFixture -{ - public: - - GTestDBusFixture() =default; - virtual ~GTestDBusFixture() =default; - - explicit GTestDBusFixture(const std::vector& service_dirs_in): service_dirs(service_dirs_in) {} - - private: - - typedef GlibFixture super; - - static void - on_bus_opened (GObject* /*object*/, GAsyncResult * res, gpointer gself) - { - auto self = static_cast(gself); - - GError * err = 0; - self->bus = g_bus_get_finish (res, &err); - g_assert_no_error (err); - - g_main_loop_quit (self->loop); - } - - static void - on_bus_closed (GObject* /*object*/, GAsyncResult * res, gpointer gself) - { - auto self = static_cast(gself); - - GError * err = 0; - g_dbus_connection_close_finish (self->bus, res, &err); - g_assert_no_error (err); - - g_main_loop_quit (self->loop); - } - - protected: - - GTestDBus * test_dbus = nullptr; - GDBusConnection * bus = nullptr; - const std::vector service_dirs; - - virtual void SetUp () - { - super::SetUp (); - - // pull up a test dbus - test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); - for (const auto& dir : service_dirs) - g_test_dbus_add_service_dir (test_dbus, dir.c_str()); - g_test_dbus_up (test_dbus); - const char * address = g_test_dbus_get_bus_address (test_dbus); - g_setenv ("DBUS_SYSTEM_BUS_ADDRESS", address, true); - g_setenv ("DBUS_SESSION_BUS_ADDRESS", address, true); - g_debug ("test_dbus's address is %s", address); - - // wait for the GDBusConnection before returning - g_bus_get (G_BUS_TYPE_SYSTEM, nullptr, on_bus_opened, this); - g_main_loop_run (loop); - } - - virtual void TearDown () - { - wait_msec(); - - // close the system bus - g_dbus_connection_close(bus, nullptr, on_bus_closed, this); - g_main_loop_run(loop); - g_clear_object(&bus); - - // tear down the test dbus - g_test_dbus_down(test_dbus); - g_clear_object(&test_dbus); - - super::TearDown(); - } -}; - -#endif /* INDICATOR_TESTS_GTESTDBUS_FIXTURE_H */ -- cgit v1.2.3