Initial import of the Weston testing framework.
[src/agl-compositor.git] / tests / weston-test-fixture-compositor.h
1 /*
2  * Copyright 2019 Collabora, Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial
14  * portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  */
25
26 #ifndef WESTON_TEST_FIXTURE_COMPOSITOR_H
27 #define WESTON_TEST_FIXTURE_COMPOSITOR_H
28
29 #include <wayland-client-protocol.h>
30 #include <libweston/libweston.h>
31
32 #include "weston-testsuite-data.h"
33
34 /** Weston renderer type
35  *
36  * \sa compositor_setup
37  * \ingroup testharness
38  */
39 enum renderer_type {
40         /** Dummy renderer that does nothing. */
41         RENDERER_NOOP = 0,
42         /** Pixman-renderer */
43         RENDERER_PIXMAN,
44         /** GL-renderer */
45         RENDERER_GL
46 };
47
48 /** Weston shell plugin
49  *
50  * \sa compositor_setup
51  * \ingroup testharness
52  */
53 enum shell_type {
54         /** Desktop test-shell with predictable window placement and
55          * no helper clients */
56         SHELL_TEST_DESKTOP = 0,
57         /** The full desktop shell. */
58         SHELL_DESKTOP,
59         /** The ivi-shell. */
60         SHELL_IVI,
61         /** The fullscreen-shell. */
62         SHELL_FULLSCREEN
63 };
64
65 /** Weston compositor configuration
66  *
67  * This structure determines the Weston compositor command line arguments.
68  * You should always use compositor_setup_defaults() to initialize this, then
69  * override any members you need with assignments.
70  *
71  * \ingroup testharness
72  */
73 struct compositor_setup {
74         /** The test suite quirks. */
75         struct weston_testsuite_quirks test_quirks;
76         /** The backend to use. */
77         enum weston_compositor_backend backend;
78         /** The renderer to use. */
79         enum renderer_type renderer;
80         /** The shell plugin to use. */
81         enum shell_type shell;
82         /** Whether to enable xwayland support. */
83         bool xwayland;
84         /** Default output width. */
85         unsigned width;
86         /** Default output height. */
87         unsigned height;
88         /** Default output scale. */
89         int scale;
90         /** Default output transform, one of WL_OUTPUT_TRANSFORM_*. */
91         enum wl_output_transform transform;
92         /** The absolute path to \c weston.ini to use,
93          * or NULL for \c --no-config . */
94         const char *config_file;
95         /** Full path to an extra plugin to load, or NULL for none. */
96         const char *extra_module;
97         /** Debug scopes for the compositor log,
98          * or NULL for compositor defaults. */
99         const char *logging_scopes;
100         /** The name of this test program, used as a unique identifier. */
101         const char *testset_name;
102 };
103
104 void
105 compositor_setup_defaults_(struct compositor_setup *setup,
106                            const char *testset_name);
107
108 /** Initialize compositor setup to defaults
109  *
110  * \param s The variable to initialize.
111  *
112  * The defaults are:
113  * - backend: headless
114  * - renderer: noop
115  * - shell: desktop shell
116  * - xwayland: no
117  * - width: 320
118  * - height: 240
119  * - scale: 1
120  * - transform: WL_OUTPUT_TRANSFORM_NORMAL
121  * - config_file: none
122  * - extra_module: none
123  * - logging_scopes: compositor defaults
124  * - testset_name: the test name from meson.build
125  *
126  * \ingroup testharness
127  */
128 #define compositor_setup_defaults(s) do {\
129         compositor_setup_defaults_(s, THIS_TEST_NAME); \
130 } while (0)
131
132 int
133 execute_compositor(const struct compositor_setup *setup,
134                    struct wet_testsuite_data *data);
135
136 #endif /* WESTON_TEST_FIXTURE_COMPOSITOR_H */