xref: /aosp_15_r20/external/libxkbcommon/test/test.h (revision 2b949d0487e80d67f1fda82db69e101e761f8064)
1*2b949d04SAndroid Build Coastguard Worker /*
2*2b949d04SAndroid Build Coastguard Worker  * Copyright © 2012 Intel Corporation
3*2b949d04SAndroid Build Coastguard Worker  *
4*2b949d04SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a
5*2b949d04SAndroid Build Coastguard Worker  * copy of this software and associated documentation files (the "Software"),
6*2b949d04SAndroid Build Coastguard Worker  * to deal in the Software without restriction, including without limitation
7*2b949d04SAndroid Build Coastguard Worker  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*2b949d04SAndroid Build Coastguard Worker  * and/or sell copies of the Software, and to permit persons to whom the
9*2b949d04SAndroid Build Coastguard Worker  * Software is furnished to do so, subject to the following conditions:
10*2b949d04SAndroid Build Coastguard Worker  *
11*2b949d04SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice (including the next
12*2b949d04SAndroid Build Coastguard Worker  * paragraph) shall be included in all copies or substantial portions of the
13*2b949d04SAndroid Build Coastguard Worker  * Software.
14*2b949d04SAndroid Build Coastguard Worker  *
15*2b949d04SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*2b949d04SAndroid Build Coastguard Worker  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*2b949d04SAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*2b949d04SAndroid Build Coastguard Worker  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*2b949d04SAndroid Build Coastguard Worker  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*2b949d04SAndroid Build Coastguard Worker  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21*2b949d04SAndroid Build Coastguard Worker  * DEALINGS IN THE SOFTWARE.
22*2b949d04SAndroid Build Coastguard Worker  *
23*2b949d04SAndroid Build Coastguard Worker  * Author: Daniel Stone <[email protected]>
24*2b949d04SAndroid Build Coastguard Worker  */
25*2b949d04SAndroid Build Coastguard Worker 
26*2b949d04SAndroid Build Coastguard Worker #include <assert.h>
27*2b949d04SAndroid Build Coastguard Worker 
28*2b949d04SAndroid Build Coastguard Worker /* Don't use compat names in internal code. */
29*2b949d04SAndroid Build Coastguard Worker #define _XKBCOMMON_COMPAT_H
30*2b949d04SAndroid Build Coastguard Worker #include "xkbcommon/xkbcommon.h"
31*2b949d04SAndroid Build Coastguard Worker #include "xkbcommon/xkbcommon-compose.h"
32*2b949d04SAndroid Build Coastguard Worker #include "utils.h"
33*2b949d04SAndroid Build Coastguard Worker 
34*2b949d04SAndroid Build Coastguard Worker /* Automake test exit code to signify SKIP (à la PASS, FAIL, etc). */
35*2b949d04SAndroid Build Coastguard Worker #define SKIP_TEST 77
36*2b949d04SAndroid Build Coastguard Worker 
37*2b949d04SAndroid Build Coastguard Worker /* The offset between KEY_* numbering, and keycodes in the XKB evdev
38*2b949d04SAndroid Build Coastguard Worker  * dataset. */
39*2b949d04SAndroid Build Coastguard Worker #define EVDEV_OFFSET 8
40*2b949d04SAndroid Build Coastguard Worker 
41*2b949d04SAndroid Build Coastguard Worker enum key_seq_state {
42*2b949d04SAndroid Build Coastguard Worker     DOWN,
43*2b949d04SAndroid Build Coastguard Worker     REPEAT,
44*2b949d04SAndroid Build Coastguard Worker     UP,
45*2b949d04SAndroid Build Coastguard Worker     BOTH,
46*2b949d04SAndroid Build Coastguard Worker     NEXT,
47*2b949d04SAndroid Build Coastguard Worker     FINISH,
48*2b949d04SAndroid Build Coastguard Worker };
49*2b949d04SAndroid Build Coastguard Worker 
50*2b949d04SAndroid Build Coastguard Worker int
51*2b949d04SAndroid Build Coastguard Worker test_key_seq(struct xkb_keymap *keymap, ...);
52*2b949d04SAndroid Build Coastguard Worker 
53*2b949d04SAndroid Build Coastguard Worker int
54*2b949d04SAndroid Build Coastguard Worker test_key_seq_va(struct xkb_keymap *keymap, va_list args);
55*2b949d04SAndroid Build Coastguard Worker 
56*2b949d04SAndroid Build Coastguard Worker char *
57*2b949d04SAndroid Build Coastguard Worker test_get_path(const char *path_rel);
58*2b949d04SAndroid Build Coastguard Worker 
59*2b949d04SAndroid Build Coastguard Worker char *
60*2b949d04SAndroid Build Coastguard Worker test_read_file(const char *path_rel);
61*2b949d04SAndroid Build Coastguard Worker 
62*2b949d04SAndroid Build Coastguard Worker enum test_context_flags {
63*2b949d04SAndroid Build Coastguard Worker     CONTEXT_NO_FLAG = 0,
64*2b949d04SAndroid Build Coastguard Worker     CONTEXT_ALLOW_ENVIRONMENT_NAMES = (1 << 0),
65*2b949d04SAndroid Build Coastguard Worker };
66*2b949d04SAndroid Build Coastguard Worker 
67*2b949d04SAndroid Build Coastguard Worker struct xkb_context *
68*2b949d04SAndroid Build Coastguard Worker test_get_context(enum test_context_flags flags);
69*2b949d04SAndroid Build Coastguard Worker 
70*2b949d04SAndroid Build Coastguard Worker struct xkb_keymap *
71*2b949d04SAndroid Build Coastguard Worker test_compile_file(struct xkb_context *context, const char *path_rel);
72*2b949d04SAndroid Build Coastguard Worker 
73*2b949d04SAndroid Build Coastguard Worker struct xkb_keymap *
74*2b949d04SAndroid Build Coastguard Worker test_compile_string(struct xkb_context *context, const char *string);
75*2b949d04SAndroid Build Coastguard Worker 
76*2b949d04SAndroid Build Coastguard Worker struct xkb_keymap *
77*2b949d04SAndroid Build Coastguard Worker test_compile_buffer(struct xkb_context *context, const char *buf, size_t len);
78*2b949d04SAndroid Build Coastguard Worker 
79*2b949d04SAndroid Build Coastguard Worker struct xkb_keymap *
80*2b949d04SAndroid Build Coastguard Worker test_compile_rules(struct xkb_context *context, const char *rules,
81*2b949d04SAndroid Build Coastguard Worker                    const char *model, const char *layout, const char *variant,
82*2b949d04SAndroid Build Coastguard Worker                    const char *options);
83*2b949d04SAndroid Build Coastguard Worker 
84*2b949d04SAndroid Build Coastguard Worker 
85*2b949d04SAndroid Build Coastguard Worker #ifdef _MSC_VER
86*2b949d04SAndroid Build Coastguard Worker #define setenv(varname, value, overwrite) _putenv_s((varname), (value))
87*2b949d04SAndroid Build Coastguard Worker #define unsetenv(varname) _putenv_s(varname, "")
88*2b949d04SAndroid Build Coastguard Worker #endif
89