1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/platform/wayland/test/test_subcompositor.h"
#include <wayland-server-core.h>
#include "base/logging.h"
#include "ui/ozone/platform/wayland/test/mock_surface.h"
#include "ui/ozone/platform/wayland/test/server_object.h"
#include "ui/ozone/platform/wayland/test/test_subsurface.h"
namespace wl {
namespace {
constexpr uint32_t kSubCompositorVersion = 1;
void GetSubsurface(struct wl_client* client,
struct wl_resource* resource,
uint32_t id,
struct wl_resource* surface,
struct wl_resource* parent) {
auto* mock_surface = GetUserDataAs<MockSurface>(surface);
auto* parent_surface = GetUserDataAs<MockSurface>(parent);
if (mock_surface->has_role() || !parent_surface) {
wl_resource_post_error(resource, WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE,
"invalid surface");
return;
}
wl_resource* subsurface_resource =
CreateResourceWithImpl<::testing::NiceMock<TestSubSurface>>(
client, &wl_subsurface_interface, wl_resource_get_version(resource),
&kTestSubSurfaceImpl, id, surface, parent);
DCHECK(subsurface_resource);
mock_surface->set_sub_surface(
GetUserDataAs<TestSubSurface>(subsurface_resource));
}
} // namespace
const struct wl_subcompositor_interface kTestSubCompositorImpl = {
DestroyResource,
GetSubsurface,
};
TestSubCompositor::TestSubCompositor()
: GlobalObject(&wl_subcompositor_interface,
&kTestSubCompositorImpl,
kSubCompositorVersion) {}
TestSubCompositor::~TestSubCompositor() {}
} // namespace wl
|