blob: 89869bba94ada3bb2f3102a467aa7f81c95c9ab8 [file] [log] [blame]
Pekka Paalanenbabb3b32019-11-01 14:02:15 +02001/*
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
Pekka Paalanen0ce5a192020-01-22 11:53:12 +020029#include <wayland-client-protocol.h>
Pekka Paalanenbabb3b32019-11-01 14:02:15 +020030#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 */
39enum 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 */
53enum 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 */
73struct compositor_setup {
Leandro Ribeiro32a5acd2020-10-19 16:06:22 -030074 /** The test suite quirks. */
75 struct weston_testsuite_quirks test_quirks;
Pekka Paalanenbabb3b32019-11-01 14:02:15 +020076 /** 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;
Pekka Paalanen0ce5a192020-01-22 11:53:12 +020088 /** Default output scale. */
89 int scale;
90 /** Default output transform, one of WL_OUTPUT_TRANSFORM_*. */
91 enum wl_output_transform transform;
Pekka Paalanenbabb3b32019-11-01 14:02:15 +020092 /** The absolute path to \c weston.ini to use,
Igor Matheus Andrade Torrentead41a882020-08-15 21:19:13 -030093 * or NULL for \c --no-config .
94 * To properly fill this entry use weston_ini_setup() */
95 char *config_file;
Pekka Paalanenbabb3b32019-11-01 14:02:15 +020096 /** Full path to an extra plugin to load, or NULL for none. */
97 const char *extra_module;
98 /** Debug scopes for the compositor log,
99 * or NULL for compositor defaults. */
100 const char *logging_scopes;
101 /** The name of this test program, used as a unique identifier. */
102 const char *testset_name;
103};
104
105void
106compositor_setup_defaults_(struct compositor_setup *setup,
107 const char *testset_name);
108
109/** Initialize compositor setup to defaults
110 *
111 * \param s The variable to initialize.
112 *
113 * The defaults are:
114 * - backend: headless
115 * - renderer: noop
116 * - shell: desktop shell
117 * - xwayland: no
118 * - width: 320
119 * - height: 240
Pekka Paalanen0ce5a192020-01-22 11:53:12 +0200120 * - scale: 1
121 * - transform: WL_OUTPUT_TRANSFORM_NORMAL
Pekka Paalanenbabb3b32019-11-01 14:02:15 +0200122 * - config_file: none
123 * - extra_module: none
124 * - logging_scopes: compositor defaults
125 * - testset_name: the test name from meson.build
126 *
127 * \ingroup testharness
128 */
129#define compositor_setup_defaults(s) do {\
130 compositor_setup_defaults_(s, THIS_TEST_NAME); \
131} while (0)
132
133int
134execute_compositor(const struct compositor_setup *setup,
135 struct wet_testsuite_data *data);
136
Igor Matheus Andrade Torrentead41a882020-08-15 21:19:13 -0300137/* This function creates and fills a Weston.ini file
138 *
139 * \param setup a compositor_setup
140 * \param ... Variadic number of strings that will be used to compose
141 * the Weston.ini
142 *
143 * This function receives a compositor_setup and a variable number of
144 * strings that will compose the weston.ini. And will create a
145 * <test-name>.ini and fill it with the entries.
146 * This function will assert if anything goes wrong, then it will not
147 * have a return value to indicate success or failure.
148 *
149 * \ingroup testharness
150 */
151#define weston_ini_setup(setup, ...) \
152 weston_ini_setup_(setup, __VA_ARGS__, NULL)
153
154void
155weston_ini_setup_(struct compositor_setup *setup, ...);
156
157char *
158cfgln(const char *fmt, ...);
159
Pekka Paalanenbabb3b32019-11-01 14:02:15 +0200160#endif /* WESTON_TEST_FIXTURE_COMPOSITOR_H */