2 * Copyright © 2014 Collabora, Ltd.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 #include "weston-test-client-helper.h"
31 static struct wl_subcompositor *
32 get_subcompositor(struct client *client)
35 struct global *global_sub = NULL;
36 struct wl_subcompositor *sub;
38 wl_list_for_each(g, &client->global_list, link) {
39 if (strcmp(g->interface, "wl_subcompositor"))
43 assert(0 && "multiple wl_subcompositor objects");
48 assert(global_sub && "no wl_subcompositor found");
50 assert(global_sub->version == 1);
52 sub = wl_registry_bind(client->wl_registry, global_sub->name,
53 &wl_subcompositor_interface, 1);
59 static struct wl_shell *
60 get_wl_shell(struct client *client)
63 struct global *global = NULL;
64 struct wl_shell *shell;
66 wl_list_for_each(g, &client->global_list, link) {
67 if (strcmp(g->interface, "wl_shell"))
71 assert(0 && "multiple wl_shell objects");
76 assert(global && "no wl_shell found");
78 shell = wl_registry_bind(client->wl_registry, global->name,
79 &wl_shell_interface, 1);
85 TEST(test_role_conflict_sub_wlshell)
87 struct client *client;
88 struct wl_subcompositor *subco;
89 struct wl_surface *child;
90 struct wl_subsurface *sub;
91 struct wl_shell *shell;
92 struct wl_shell_surface *shsurf;
94 client = client_create(100, 50, 123, 77);
97 subco = get_subcompositor(client);
98 shell = get_wl_shell(client);
100 child = wl_compositor_create_surface(client->wl_compositor);
102 sub = wl_subcompositor_get_subsurface(subco, child,
103 client->surface->wl_surface);
106 shsurf = wl_shell_get_shell_surface(shell, child);
109 expect_protocol_error(client, &wl_shell_interface,
110 WL_SHELL_ERROR_ROLE);
113 TEST(test_role_conflict_wlshell_sub)
115 struct client *client;
116 struct wl_subcompositor *subco;
117 struct wl_surface *child;
118 struct wl_subsurface *sub;
119 struct wl_shell *shell;
120 struct wl_shell_surface *shsurf;
122 client = client_create(100, 50, 123, 77);
125 subco = get_subcompositor(client);
126 shell = get_wl_shell(client);
128 child = wl_compositor_create_surface(client->wl_compositor);
130 shsurf = wl_shell_get_shell_surface(shell, child);
133 sub = wl_subcompositor_get_subsurface(subco, child,
134 client->surface->wl_surface);
137 expect_protocol_error(client, &wl_subcompositor_interface,
138 WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE);