Branch data Line data Source code
1 : : /* GLib testing framework examples and tests 2 : : * 3 : : * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/> 4 : : * 5 : : * SPDX-License-Identifier: LGPL-2.1-or-later 6 : : * 7 : : * This library is free software; you can redistribute it and/or 8 : : * modify it under the terms of the GNU Lesser General Public 9 : : * License as published by the Free Software Foundation; either 10 : : * version 2.1 of the License, or (at your option) any later version. 11 : : * 12 : : * This library is distributed in the hope that it will be useful, 13 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 : : * Lesser General Public License for more details. 16 : : * 17 : : * You should have received a copy of the GNU Lesser General 18 : : * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. 19 : : * 20 : : * Author: Xavier Claessens <xavier.claessens@collabora.co.uk> 21 : : */ 22 : : 23 : : #include "gdbus-sessionbus.h" 24 : : 25 : : static GTestDBus *singleton = NULL; 26 : : 27 : : void 28 : 42 : session_bus_up (void) 29 : : { 30 : : gchar *relative, *servicesdir; 31 : 42 : g_assert (singleton == NULL); 32 : 42 : singleton = g_test_dbus_new (G_TEST_DBUS_NONE); 33 : : 34 : : /* We ignore deprecations here so that gdbus-test-codegen-old can 35 : : * build successfully despite these two functions not being 36 : : * available in GLib 2.36 */ 37 : : G_GNUC_BEGIN_IGNORE_DEPRECATIONS 38 : 42 : relative = g_test_build_filename (G_TEST_BUILT, "services", NULL); 39 : 42 : servicesdir = g_canonicalize_filename (relative, NULL); 40 : : G_GNUC_END_IGNORE_DEPRECATIONS 41 : 42 : g_free (relative); 42 : : 43 : 42 : g_test_dbus_add_service_dir (singleton, servicesdir); 44 : 42 : g_free (servicesdir); 45 : 42 : g_test_dbus_up (singleton); 46 : 42 : } 47 : : 48 : : void 49 : 13 : session_bus_stop (void) 50 : : { 51 : 13 : g_assert (singleton != NULL); 52 : 13 : g_test_dbus_stop (singleton); 53 : 13 : } 54 : : 55 : : void 56 : 40 : session_bus_down (void) 57 : : { 58 : 40 : g_assert (singleton != NULL); 59 : 40 : g_test_dbus_down (singleton); 60 : 40 : g_clear_object (&singleton); 61 : 40 : } 62 : : 63 : : gint 64 : 8 : session_bus_run (void) 65 : : { 66 : : gint ret; 67 : : 68 : 8 : session_bus_up (); 69 : 8 : ret = g_test_run (); 70 : 8 : session_bus_down (); 71 : : 72 : 8 : return ret; 73 : : }