tests: remove static data from presentation

While get_presentation() will only ever be called once (making the caching of
the return value moot), it is good to stop using the static variable as it
would cause surprising problems if anyone adds more tests here and runs it
under the new test harness.

It was leaked before and continues to be so.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 5 years ago committed by Daniel Stone
parent f8086fb839
commit f38d4458f7
  1. 15
      tests/presentation-test.c

@ -43,10 +43,7 @@ get_presentation(struct client *client)
{
struct global *g;
struct global *global_pres = NULL;
static struct wp_presentation *pres;
if (pres)
return pres;
struct wp_presentation *pres;
wl_list_for_each(g, &client->global_list, link) {
if (strcmp(g->interface, wp_presentation_interface.name))
@ -137,13 +134,15 @@ static const struct wp_presentation_feedback_listener feedback_listener = {
};
static struct feedback *
feedback_create(struct client *client, struct wl_surface *surface)
feedback_create(struct client *client,
struct wl_surface *surface,
struct wp_presentation *pres)
{
struct feedback *fb;
fb = xzalloc(sizeof *fb);
fb->client = client;
fb->obj = wp_presentation_feedback(get_presentation(client), surface);
fb->obj = wp_presentation_feedback(pres, surface);
wp_presentation_feedback_add_listener(fb->obj, &feedback_listener, fb);
return fb;
@ -215,13 +214,15 @@ TEST(test_presentation_feedback_simple)
{
struct client *client;
struct feedback *fb;
struct wp_presentation *pres;
client = create_client_and_test_surface(100, 50, 123, 77);
assert(client);
pres = get_presentation(client);
wl_surface_attach(client->surface->wl_surface,
client->surface->buffer->proxy, 0, 0);
fb = feedback_create(client, client->surface->wl_surface);
fb = feedback_create(client, client->surface->wl_surface, pres);
wl_surface_damage(client->surface->wl_surface, 0, 0, 100, 100);
wl_surface_commit(client->surface->wl_surface);

Loading…
Cancel
Save