Commit 0bfea385 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

ozone: fix some minor style issues

BUG=none
TEST=none

Change-Id: I387c43f58eaf7bf3a1f2dd01c40c9fd6974b3413
Reviewed-on: https://chromium-review.googlesource.com/1002953Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549212}
parent 2a20aba0
...@@ -139,7 +139,7 @@ void GetPointer(wl_client* client, wl_resource* resource, uint32_t id) { ...@@ -139,7 +139,7 @@ void GetPointer(wl_client* client, wl_resource* resource, uint32_t id) {
return; return;
} }
auto* seat = GetUserDataAs<MockSeat>(resource); auto* seat = GetUserDataAs<MockSeat>(resource);
seat->pointer_.reset(new MockPointer(pointer_resource)); seat->set_pointer(std::make_unique<MockPointer>(pointer_resource));
} }
void GetKeyboard(wl_client* client, wl_resource* resource, uint32_t id) { void GetKeyboard(wl_client* client, wl_resource* resource, uint32_t id) {
...@@ -150,7 +150,7 @@ void GetKeyboard(wl_client* client, wl_resource* resource, uint32_t id) { ...@@ -150,7 +150,7 @@ void GetKeyboard(wl_client* client, wl_resource* resource, uint32_t id) {
return; return;
} }
auto* seat = GetUserDataAs<MockSeat>(resource); auto* seat = GetUserDataAs<MockSeat>(resource);
seat->keyboard_.reset(new MockKeyboard(keyboard_resource)); seat->set_keyboard(std::make_unique<MockKeyboard>(keyboard_resource));
} }
void GetTouch(wl_client* client, wl_resource* resource, uint32_t id) { void GetTouch(wl_client* client, wl_resource* resource, uint32_t id) {
...@@ -161,7 +161,7 @@ void GetTouch(wl_client* client, wl_resource* resource, uint32_t id) { ...@@ -161,7 +161,7 @@ void GetTouch(wl_client* client, wl_resource* resource, uint32_t id) {
return; return;
} }
auto* seat = GetUserDataAs<MockSeat>(resource); auto* seat = GetUserDataAs<MockSeat>(resource);
seat->touch_.reset(new MockTouch(touch_resource)); seat->set_touch(std::make_unique<MockTouch>(touch_resource));
} }
const struct wl_seat_interface seat_impl = { const struct wl_seat_interface seat_impl = {
...@@ -257,7 +257,7 @@ const struct xdg_surface_interface xdg_surface_impl = { ...@@ -257,7 +257,7 @@ const struct xdg_surface_interface xdg_surface_impl = {
void GetTopLevel(wl_client* client, wl_resource* resource, uint32_t id) { void GetTopLevel(wl_client* client, wl_resource* resource, uint32_t id) {
auto* surface = GetUserDataAs<MockXdgSurface>(resource); auto* surface = GetUserDataAs<MockXdgSurface>(resource);
if (surface->xdg_toplevel) { if (surface->xdg_toplevel()) {
wl_resource_post_error(resource, ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED, wl_resource_post_error(resource, ZXDG_SURFACE_V6_ERROR_ALREADY_CONSTRUCTED,
"surface has already been constructed"); "surface has already been constructed");
return; return;
...@@ -268,7 +268,8 @@ void GetTopLevel(wl_client* client, wl_resource* resource, uint32_t id) { ...@@ -268,7 +268,8 @@ void GetTopLevel(wl_client* client, wl_resource* resource, uint32_t id) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
} }
surface->xdg_toplevel.reset(new MockXdgTopLevel(xdg_toplevel_resource)); surface->set_xdg_toplevel(
std::make_unique<MockXdgTopLevel>(xdg_toplevel_resource));
} }
const struct zxdg_surface_v6_interface zxdg_surface_v6_impl = { const struct zxdg_surface_v6_interface zxdg_surface_v6_impl = {
...@@ -303,7 +304,7 @@ void GetXdgSurfaceImpl(wl_client* client, ...@@ -303,7 +304,7 @@ void GetXdgSurfaceImpl(wl_client* client,
const struct wl_interface* interface, const struct wl_interface* interface,
const void* implementation) { const void* implementation) {
auto* surface = GetUserDataAs<MockSurface>(surface_resource); auto* surface = GetUserDataAs<MockSurface>(surface_resource);
if (surface->xdg_surface) { if (surface->xdg_surface()) {
uint32_t xdg_error = implementation == &xdg_surface_impl uint32_t xdg_error = implementation == &xdg_surface_impl
? XDG_SHELL_ERROR_ROLE ? XDG_SHELL_ERROR_ROLE
: ZXDG_SHELL_V6_ERROR_ROLE; : ZXDG_SHELL_V6_ERROR_ROLE;
...@@ -317,8 +318,8 @@ void GetXdgSurfaceImpl(wl_client* client, ...@@ -317,8 +318,8 @@ void GetXdgSurfaceImpl(wl_client* client,
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
} }
surface->xdg_surface.reset( surface->set_xdg_surface(
new MockXdgSurface(xdg_surface_resource, implementation)); std::make_unique<MockXdgSurface>(xdg_surface_resource, implementation));
} }
// xdg_shell // xdg_shell
...@@ -384,8 +385,8 @@ MockSurface::MockSurface(wl_resource* resource) : ServerObject(resource) { ...@@ -384,8 +385,8 @@ MockSurface::MockSurface(wl_resource* resource) : ServerObject(resource) {
} }
MockSurface::~MockSurface() { MockSurface::~MockSurface() {
if (xdg_surface && xdg_surface->resource()) if (xdg_surface_ && xdg_surface_->resource())
wl_resource_destroy(xdg_surface->resource()); wl_resource_destroy(xdg_surface_->resource());
} }
MockSurface* MockSurface::FromResource(wl_resource* resource) { MockSurface* MockSurface::FromResource(wl_resource* resource) {
......
...@@ -54,17 +54,22 @@ class MockXdgSurface : public ServerObject { ...@@ -54,17 +54,22 @@ class MockXdgSurface : public ServerObject {
MOCK_METHOD1(SetAppId, void(const char* app_id)); MOCK_METHOD1(SetAppId, void(const char* app_id));
MOCK_METHOD1(AckConfigure, void(uint32_t serial)); MOCK_METHOD1(AckConfigure, void(uint32_t serial));
MOCK_METHOD4(SetWindowGeometry, MOCK_METHOD4(SetWindowGeometry,
void(int32_t x, int32_t y, int32_t widht, int32_t height)); void(int32_t x, int32_t y, int32_t width, int32_t height));
MOCK_METHOD0(SetMaximized, void()); MOCK_METHOD0(SetMaximized, void());
MOCK_METHOD0(UnsetMaximized, void()); MOCK_METHOD0(UnsetMaximized, void());
MOCK_METHOD0(SetFullscreen, void()); MOCK_METHOD0(SetFullscreen, void());
MOCK_METHOD0(UnsetFullscreen, void()); MOCK_METHOD0(UnsetFullscreen, void());
MOCK_METHOD0(SetMinimized, void()); MOCK_METHOD0(SetMinimized, void());
// Used when xdg v6 is used. void set_xdg_toplevel(std::unique_ptr<MockXdgTopLevel> xdg_toplevel) {
std::unique_ptr<MockXdgTopLevel> xdg_toplevel; xdg_toplevel_ = std::move(xdg_toplevel);
}
MockXdgTopLevel* xdg_toplevel() { return xdg_toplevel_.get(); }
private: private:
// Used when xdg v6 is used.
std::unique_ptr<MockXdgTopLevel> xdg_toplevel_;
DISALLOW_COPY_AND_ASSIGN(MockXdgSurface); DISALLOW_COPY_AND_ASSIGN(MockXdgSurface);
}; };
...@@ -95,9 +100,14 @@ class MockSurface : public ServerObject { ...@@ -95,9 +100,14 @@ class MockSurface : public ServerObject {
void(int32_t x, int32_t y, int32_t width, int32_t height)); void(int32_t x, int32_t y, int32_t width, int32_t height));
MOCK_METHOD0(Commit, void()); MOCK_METHOD0(Commit, void());
std::unique_ptr<MockXdgSurface> xdg_surface; void set_xdg_surface(std::unique_ptr<MockXdgSurface> xdg_surface) {
xdg_surface_ = std::move(xdg_surface);
}
MockXdgSurface* xdg_surface() { return xdg_surface_.get(); }
private: private:
std::unique_ptr<MockXdgSurface> xdg_surface_;
DISALLOW_COPY_AND_ASSIGN(MockSurface); DISALLOW_COPY_AND_ASSIGN(MockSurface);
}; };
...@@ -207,11 +217,26 @@ class MockSeat : public Global { ...@@ -207,11 +217,26 @@ class MockSeat : public Global {
MockSeat(); MockSeat();
~MockSeat() override; ~MockSeat() override;
void set_pointer(std::unique_ptr<MockPointer> pointer) {
pointer_ = std::move(pointer);
}
MockPointer* pointer() { return pointer_.get(); }
void set_keyboard(std::unique_ptr<MockKeyboard> keyboard) {
keyboard_ = std::move(keyboard);
}
MockKeyboard* keyboard() { return keyboard_.get(); }
void set_touch(std::unique_ptr<MockTouch> touch) {
touch_ = std::move(touch);
}
MockTouch* touch() { return touch_.get(); }
private:
std::unique_ptr<MockPointer> pointer_; std::unique_ptr<MockPointer> pointer_;
std::unique_ptr<MockKeyboard> keyboard_; std::unique_ptr<MockKeyboard> keyboard_;
std::unique_ptr<MockTouch> touch_; std::unique_ptr<MockTouch> touch_;
private:
DISALLOW_COPY_AND_ASSIGN(MockSeat); DISALLOW_COPY_AND_ASSIGN(MockSeat);
}; };
......
...@@ -36,7 +36,7 @@ class WaylandKeyboardTest : public WaylandTest { ...@@ -36,7 +36,7 @@ class WaylandKeyboardTest : public WaylandTest {
Sync(); Sync();
keyboard_ = server_.seat()->keyboard_.get(); keyboard_ = server_.seat()->keyboard();
ASSERT_TRUE(keyboard_); ASSERT_TRUE(keyboard_);
#if BUILDFLAG(USE_XKBCOMMON) #if BUILDFLAG(USE_XKBCOMMON)
......
...@@ -30,7 +30,7 @@ class WaylandPointerTest : public WaylandTest { ...@@ -30,7 +30,7 @@ class WaylandPointerTest : public WaylandTest {
Sync(); Sync();
pointer_ = server_.seat()->pointer_.get(); pointer_ = server_.seat()->pointer();
ASSERT_TRUE(pointer_); ASSERT_TRUE(pointer_);
} }
......
...@@ -38,7 +38,7 @@ class WaylandTouchTest : public WaylandTest { ...@@ -38,7 +38,7 @@ class WaylandTouchTest : public WaylandTest {
Sync(); Sync();
touch_ = server_.seat()->touch_.get(); touch_ = server_.seat()->touch();
ASSERT_TRUE(touch_); ASSERT_TRUE(touch_);
} }
......
...@@ -39,7 +39,7 @@ class WaylandWindowTest : public WaylandTest { ...@@ -39,7 +39,7 @@ class WaylandWindowTest : public WaylandTest {
void SetUp() override { void SetUp() override {
WaylandTest::SetUp(); WaylandTest::SetUp();
xdg_surface_ = surface_->xdg_surface.get(); xdg_surface_ = surface_->xdg_surface();
ASSERT_TRUE(xdg_surface_); ASSERT_TRUE(xdg_surface_);
} }
...@@ -48,7 +48,7 @@ class WaylandWindowTest : public WaylandTest { ...@@ -48,7 +48,7 @@ class WaylandWindowTest : public WaylandTest {
int height, int height,
uint32_t serial, uint32_t serial,
struct wl_array* states) { struct wl_array* states) {
if (!xdg_surface_->xdg_toplevel) { if (!xdg_surface_->xdg_toplevel()) {
xdg_surface_send_configure(xdg_surface_->resource(), width, height, xdg_surface_send_configure(xdg_surface_->resource(), width, height,
states, serial); states, serial);
return; return;
...@@ -57,8 +57,8 @@ class WaylandWindowTest : public WaylandTest { ...@@ -57,8 +57,8 @@ class WaylandWindowTest : public WaylandTest {
// In xdg_shell_v6, both surfaces send serial configure event and toplevel // In xdg_shell_v6, both surfaces send serial configure event and toplevel
// surfaces send other data like states, heights and widths. // surfaces send other data like states, heights and widths.
zxdg_surface_v6_send_configure(xdg_surface_->resource(), serial); zxdg_surface_v6_send_configure(xdg_surface_->resource(), serial);
ASSERT_TRUE(xdg_surface_->xdg_toplevel); ASSERT_TRUE(xdg_surface_->xdg_toplevel());
zxdg_toplevel_v6_send_configure(xdg_surface_->xdg_toplevel->resource(), zxdg_toplevel_v6_send_configure(xdg_surface_->xdg_toplevel()->resource(),
width, height, states); width, height, states);
} }
...@@ -67,7 +67,7 @@ class WaylandWindowTest : public WaylandTest { ...@@ -67,7 +67,7 @@ class WaylandWindowTest : public WaylandTest {
wl::MockXdgSurface* GetXdgSurface() { wl::MockXdgSurface* GetXdgSurface() {
if (GetParam() == kXdgShellV5) if (GetParam() == kXdgShellV5)
return xdg_surface_; return xdg_surface_;
return xdg_surface_->xdg_toplevel.get(); return xdg_surface_->xdg_toplevel();
} }
void SetWlArrayWithState(uint32_t state, wl_array* states) { void SetWlArrayWithState(uint32_t state, wl_array* states) {
...@@ -363,7 +363,7 @@ TEST_P(WaylandWindowTest, HasCaptureUpdatedOnPointerEvents) { ...@@ -363,7 +363,7 @@ TEST_P(WaylandWindowTest, HasCaptureUpdatedOnPointerEvents) {
Sync(); Sync();
wl::MockPointer* pointer = server_.seat()->pointer_.get(); wl::MockPointer* pointer = server_.seat()->pointer();
ASSERT_TRUE(pointer); ASSERT_TRUE(pointer);
wl_pointer_send_enter(pointer->resource(), 1, surface_->resource(), 0, 0); wl_pointer_send_enter(pointer->resource(), 1, surface_->resource(), 0, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment