Branch data Line data Source code
1 : : /* 2 : : * Copyright 2024 Philip Chimento <philip.chimento@gmail.com> 3 : : * Copyright 2024 GNOME Foundation 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 : : 21 : : #include "config.h" 22 : : 23 : : #include "girepository.h" 24 : : #include "test-common.h" 25 : : 26 : : static void 27 : 1 : test_object_info_find_method_using_interfaces (RepositoryFixture *fx, 28 : : const void *unused) 29 : : { 30 : 1 : GIObjectInfo *class_info = NULL; 31 : 1 : GIFunctionInfo *method_info = NULL; 32 : 1 : GIBaseInfo *declarer_info = NULL; 33 : : 34 : 1 : class_info = GI_OBJECT_INFO (gi_repository_find_by_name (fx->repository, "Gio", "DBusProxy")); 35 : 1 : g_assert_nonnull (class_info); 36 : : 37 : 1 : method_info = gi_object_info_find_method_using_interfaces (class_info, "init", &declarer_info); 38 : : 39 : 1 : g_assert_nonnull (declarer_info); 40 : 1 : g_assert_cmpstr (gi_base_info_get_namespace (declarer_info), ==, "Gio"); 41 : 1 : g_assert_cmpstr (gi_base_info_get_name (declarer_info), ==, "Initable"); 42 : 1 : g_assert_true (GI_IS_INTERFACE_INFO (declarer_info)); 43 : : 44 : 1 : g_clear_pointer (&class_info, gi_base_info_unref); 45 : 1 : g_clear_pointer (&method_info, gi_base_info_unref); 46 : 1 : g_clear_pointer (&declarer_info, gi_base_info_unref); 47 : 1 : } 48 : : 49 : : static void 50 : 1 : test_object_info_find_vfunc_using_interfaces (RepositoryFixture *fx, 51 : : const void *unused) 52 : : { 53 : 1 : GIObjectInfo *class_info = NULL; 54 : 1 : GIVFuncInfo *vfunc_info = NULL; 55 : 1 : GIBaseInfo *declarer_info = NULL; 56 : : 57 : 1 : class_info = GI_OBJECT_INFO (gi_repository_find_by_name (fx->repository, "Gio", "Application")); 58 : 1 : g_assert_nonnull (class_info); 59 : : 60 : 1 : vfunc_info = gi_object_info_find_vfunc_using_interfaces (class_info, "after_emit", &declarer_info); 61 : : 62 : 1 : g_assert_nonnull (declarer_info); 63 : 1 : g_assert_cmpstr (gi_base_info_get_namespace (declarer_info), ==, "Gio"); 64 : 1 : g_assert_cmpstr (gi_base_info_get_name (declarer_info), ==, "Application"); 65 : 1 : g_assert_true (GI_IS_OBJECT_INFO (declarer_info)); 66 : : 67 : 1 : g_clear_pointer (&class_info, gi_base_info_unref); 68 : 1 : g_clear_pointer (&vfunc_info, gi_base_info_unref); 69 : 1 : g_clear_pointer (&declarer_info, gi_base_info_unref); 70 : 1 : } 71 : : 72 : : int 73 : 1 : main (int argc, 74 : : char *argv[]) 75 : : { 76 : 1 : repository_init (&argc, &argv); 77 : : 78 : 1 : ADD_REPOSITORY_TEST ("/object-info/find-method-using-interfaces", test_object_info_find_method_using_interfaces, &typelib_load_spec_gio); 79 : 1 : ADD_REPOSITORY_TEST ("/object-info/find-vfunc-using-interfaces", test_object_info_find_vfunc_using_interfaces, &typelib_load_spec_gio); 80 : : 81 : 1 : return g_test_run (); 82 : : }