compositor: move tests quirks initialization to weston_compositor_create()

Until now we had the test quirks initialization in wet_main(),
just after calling weston_compositor_create(). But there are
some cases that require the quirks during struct weston_compositor
creation time.

Move test quirks initialization to weston_compositor_create()
in order to cover more use cases for the test quirks mechanism.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
dev
Leandro Ribeiro 4 years ago committed by Pekka Paalanen
parent bb7ed37a89
commit cdb7218daf
  1. 5
      compositor/main.c
  2. 14
      include/libweston/libweston.h
  3. 38
      libweston/compositor.c

@ -3283,15 +3283,12 @@ wet_main(int argc, char *argv[], const struct weston_testsuite_data *test_data)
backend = weston_choose_default_backend();
}
wet.compositor = weston_compositor_create(display, log_ctx, &wet);
wet.compositor = weston_compositor_create(display, log_ctx, &wet, test_data);
if (wet.compositor == NULL) {
weston_log("fatal: failed to create compositor\n");
goto out;
}
if (test_data)
weston_compositor_test_data_init(wet.compositor, test_data);
protocol_scope =
weston_log_ctx_add_log_scope(log_ctx, "proto",
"Wayland protocol dump for all clients.\n",

@ -197,6 +197,14 @@ struct weston_testsuite_quirks {
};
/** Weston test suite data that is given to compositor
*
* It contains two members:
*
* 1. The struct weston_testsuite_quirks, which can be used by the tests to
* change certain behavior of Weston when running these tests.
* 2. The void *test_private_data member which can be used by the testsuite of
* projects that uses libweston in order to give arbitrary test data to the
* compositor. Its type should be defined by the testsuite of the project.
*
* \sa compositor_setup
* \ingroup testharness
@ -1798,11 +1806,9 @@ weston_compositor_destroy(struct weston_compositor *ec);
struct weston_compositor *
weston_compositor_create(struct wl_display *display,
struct weston_log_context *log_ctx, void *user_data);
struct weston_log_context *log_ctx, void *user_data,
const struct weston_testsuite_data *test_data);
void
weston_compositor_test_data_init(struct weston_compositor *ec,
const struct weston_testsuite_data *test_data);
void *
weston_compositor_get_test_data(struct weston_compositor *ec);

@ -7327,36 +7327,6 @@ debug_scene_graph_cb(struct weston_log_subscription *sub, void *data)
weston_log_subscription_complete(sub);
}
/** Init the compositor testsuite data
*
* The struct weston_testsuite_data contains two members:
*
* 1. The struct weston_testsuite_quirks, which can be used by the tests to
* change certain behavior of Weston when running these tests.
*
* 2. The void *test_private_data member which can be used by the test suite
* of projects that uses libweston in order to give arbitrary test data to the
* compositor. Its type should be defined by the test suite of the project.
*
* This function can be called at most once per compositor instance, just after
* creating the weston_compositor object and never again. This happens because
* changing the quirks after e.g. loading the backend is not going to work,
* there are certain behaviors that need to be set up before this point.
*
* \param ec The weston compositor.
* \param test_data The testsuite data.
*
* \ingroup compositor
* \sa weston_compositor_get_test_data
*/
WL_EXPORT void
weston_compositor_test_data_init(struct weston_compositor *ec,
const struct weston_testsuite_data *test_data)
{
assert(ec->backend == NULL);
ec->test_data = *test_data;
}
/** Retrieve testsuite data from compositor
*
* The testsuite data can be defined by the test suite of projects that uses
@ -7383,6 +7353,7 @@ weston_compositor_get_test_data(struct weston_compositor *ec)
* \param display The Wayland display to be used.
* \param user_data A pointer to an object that can later be retrieved
* \param log_ctx A pointer to weston_debug_compositor
* \param test_data Optional testsuite data, or NULL.
* using the \ref weston_compositor_get_user_data function.
* \return The compositor instance on success or NULL on failure.
*
@ -7390,8 +7361,8 @@ weston_compositor_get_test_data(struct weston_compositor *ec)
*/
WL_EXPORT struct weston_compositor *
weston_compositor_create(struct wl_display *display,
struct weston_log_context *log_ctx,
void *user_data)
struct weston_log_context *log_ctx, void *user_data,
const struct weston_testsuite_data *test_data)
{
struct weston_compositor *ec;
struct wl_event_loop *loop;
@ -7403,6 +7374,9 @@ weston_compositor_create(struct wl_display *display,
if (!ec)
return NULL;
if (test_data)
ec->test_data = *test_data;
ec->weston_log_ctx = log_ctx;
ec->wl_display = display;
ec->user_data = user_data;

Loading…
Cancel
Save