2 * Copyright © 2014 Collabora, Ltd.
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:
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.
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
32 #include "weston-test-client-helper.h"
34 static struct wl_subcompositor *
35 get_subcompositor(struct client *client)
38 struct global *global_sub = NULL;
39 struct wl_subcompositor *sub;
41 wl_list_for_each(g, &client->global_list, link) {
42 if (strcmp(g->interface, "wl_subcompositor"))
46 assert(0 && "multiple wl_subcompositor objects");
51 assert(global_sub && "no wl_subcompositor found");
53 assert(global_sub->version == 1);
55 sub = wl_registry_bind(client->wl_registry, global_sub->name,
56 &wl_subcompositor_interface, 1);
62 static struct wl_shell *
63 get_wl_shell(struct client *client)
66 struct global *global = NULL;
67 struct wl_shell *shell;
69 wl_list_for_each(g, &client->global_list, link) {
70 if (strcmp(g->interface, "wl_shell"))
74 assert(0 && "multiple wl_shell objects");
79 assert(global && "no wl_shell found");
81 shell = wl_registry_bind(client->wl_registry, global->name,
82 &wl_shell_interface, 1);
88 TEST(test_role_conflict_sub_wlshell)
90 struct client *client;
91 struct wl_subcompositor *subco;
92 struct wl_surface *child;
93 struct wl_subsurface *sub;
94 struct wl_shell *shell;
95 struct wl_shell_surface *shsurf;
97 client = create_client_and_test_surface(100, 50, 123, 77);
100 subco = get_subcompositor(client);
101 shell = get_wl_shell(client);
103 child = wl_compositor_create_surface(client->wl_compositor);
105 sub = wl_subcompositor_get_subsurface(subco, child,
106 client->surface->wl_surface);
109 shsurf = wl_shell_get_shell_surface(shell, child);
112 expect_protocol_error(client, &wl_shell_interface,
113 WL_SHELL_ERROR_ROLE);
116 TEST(test_role_conflict_wlshell_sub)
118 struct client *client;
119 struct wl_subcompositor *subco;
120 struct wl_surface *child;
121 struct wl_subsurface *sub;
122 struct wl_shell *shell;
123 struct wl_shell_surface *shsurf;
125 client = create_client_and_test_surface(100, 50, 123, 77);
128 subco = get_subcompositor(client);
129 shell = get_wl_shell(client);
131 child = wl_compositor_create_surface(client->wl_compositor);
133 shsurf = wl_shell_get_shell_surface(shell, child);
136 sub = wl_subcompositor_get_subsurface(subco, child,
137 client->surface->wl_surface);
140 expect_protocol_error(client, &wl_subcompositor_interface,
141 WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE);