1/* gtktestatcontext.h: Test AT context
2 *
3 * Copyright 2020 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 Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
24#error "Only <gtk/gtk.h> can be included directly."
25#endif
26
27#include <gtk/gtkatcontext.h>
28
29G_BEGIN_DECLS
30
31/**
32 * gtk_test_accessible_assert_role:
33 * @accessible: a `GtkAccessible`
34 * @role: a `GtkAccessibleRole`
35 *
36 * Checks whether a `GtkAccessible` implementation has the given @role,
37 * and raises an assertion if the condition is failed.
38 */
39#define gtk_test_accessible_assert_role(accessible,role) \
40G_STMT_START { \
41 GtkAccessible *__a = GTK_ACCESSIBLE (accessible); \
42 GtkAccessibleRole __r1 = (role); \
43 GtkAccessibleRole __r2 = gtk_accessible_get_accessible_role (__a); \
44 if (__r1 == __r2) ; else { \
45 gtk_test_accessible_assertion_message_role (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
46 #accessible ".accessible-role == " #role, \
47 __a, __r1, __r2); \
48 } \
49} G_STMT_END
50
51/**
52 * gtk_test_accessible_assert_property:
53 * @accessible: a `GtkAccessible`
54 * @property: a `GtkAccessibleProperty`
55 * @...: the value of @property
56 *
57 * Checks whether a `GtkAccessible` implementation has its accessible
58 * property set to the expected value, and raises an assertion if the
59 * condition is not satisfied.
60 */
61#define gtk_test_accessible_assert_property(accessible,property,...) \
62G_STMT_START { \
63 GtkAccessible *__a = GTK_ACCESSIBLE (accessible); \
64 GtkAccessibleProperty __p = (property); \
65 char *value__ = gtk_test_accessible_check_property (__a, __p, __VA_ARGS__); \
66 if (value__ == NULL) ; else { \
67 char *msg__ = g_strdup_printf ("assertion failed: (" #accessible ".accessible-property(" #property ") == " # __VA_ARGS__ "): value = '%s'", value__); \
68 g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg__); \
69 g_free (msg__); \
70 } \
71} G_STMT_END
72
73/**
74 * gtk_test_accessible_assert_relation:
75 * @accessible: a `GtkAccessible`
76 * @relation: a `GtkAccessibleRelation`
77 * @...: the expected value of @relation
78 *
79 * Checks whether a `GtkAccessible` implementation has its accessible
80 * relation set to the expected value, and raises an assertion if the
81 * condition is not satisfied.
82 */
83#define gtk_test_accessible_assert_relation(accessible,relation,...) \
84G_STMT_START { \
85 GtkAccessible *__a = GTK_ACCESSIBLE (accessible); \
86 GtkAccessibleRelation __r = (relation); \
87 char *value__ = gtk_test_accessible_check_relation (__a, __r, __VA_ARGS__); \
88 if (value__ == NULL); else { \
89 char *msg__ = g_strdup_printf ("assertion failed: (" #accessible ".accessible-relation(" #relation ") == " # __VA_ARGS__ "): value = '%s'", value__); \
90 g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg__); \
91 g_free (msg__); \
92 } \
93} G_STMT_END
94
95/**
96 * gtk_test_accessible_assert_state:
97 * @accessible: a `GtkAccessible`
98 * @state: a `GtkAccessibleRelation`
99 * @...: the expected value of @state
100 *
101 * Checks whether a `GtkAccessible` implementation has its accessible
102 * state set to the expected value, and raises an assertion if the
103 * condition is not satisfied.
104 */
105#define gtk_test_accessible_assert_state(accessible,state,...) \
106G_STMT_START { \
107 GtkAccessible *__a = GTK_ACCESSIBLE (accessible); \
108 GtkAccessibleState __s = (state); \
109 char *value__ = gtk_test_accessible_check_state (__a, __s, __VA_ARGS__); \
110 if (value__ == NULL); else { \
111 char *msg__ = g_strdup_printf ("assertion failed: (" #accessible ".accessible-state(" #state ") == " # __VA_ARGS__ "): value = '%s'", value__); \
112 g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg__); \
113 g_free (msg__); \
114 } \
115} G_STMT_END
116
117GDK_AVAILABLE_IN_ALL
118gboolean gtk_test_accessible_has_role (GtkAccessible *accessible,
119 GtkAccessibleRole role);
120GDK_AVAILABLE_IN_ALL
121gboolean gtk_test_accessible_has_property (GtkAccessible *accessible,
122 GtkAccessibleProperty property);
123GDK_AVAILABLE_IN_ALL
124gboolean gtk_test_accessible_has_relation (GtkAccessible *accessible,
125 GtkAccessibleRelation relation);
126GDK_AVAILABLE_IN_ALL
127gboolean gtk_test_accessible_has_state (GtkAccessible *accessible,
128 GtkAccessibleState state);
129
130GDK_AVAILABLE_IN_ALL
131char * gtk_test_accessible_check_property (GtkAccessible *accessible,
132 GtkAccessibleProperty property,
133 ...);
134GDK_AVAILABLE_IN_ALL
135char * gtk_test_accessible_check_relation (GtkAccessible *accessible,
136 GtkAccessibleRelation relation,
137 ...);
138GDK_AVAILABLE_IN_ALL
139char * gtk_test_accessible_check_state (GtkAccessible *accessible,
140 GtkAccessibleState state,
141 ...);
142
143GDK_AVAILABLE_IN_ALL
144void gtk_test_accessible_assertion_message_role (const char *domain,
145 const char *file,
146 int line,
147 const char *func,
148 const char *expr,
149 GtkAccessible *accessible,
150 GtkAccessibleRole expected_role,
151 GtkAccessibleRole actual_role);
152
153G_END_DECLS
154

source code of gtk/gtk/gtktestatcontext.h