Commit bf9f2827 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

[ozone/wayland] various driven-by style fixes.

Code in //ui/ozone/platform/wayland/fake_server.cc|h is quite
convoluted today. This a 3/n of a series of patches that clean it up.

Particularly, CL changes the wayland unittest's code to use the "bleh_"
terminology rather than "bleh" for class member declaration, as per
Chromium's coding style.

BUG=None
TBR=rjkroege@chromium.org

Change-Id: I3534937d2ed842b0723e622f39668d4ac6c557c0
Reviewed-on: https://chromium-review.googlesource.com/961143
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarAntonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#543072}
parent 4d51ebfa
......@@ -139,7 +139,7 @@ void GetPointer(wl_client* client, wl_resource* resource, uint32_t id) {
return;
}
auto* seat = GetUserDataAs<MockSeat>(resource);
seat->pointer.reset(new MockPointer(pointer_resource));
seat->pointer_.reset(new MockPointer(pointer_resource));
}
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;
}
auto* seat = GetUserDataAs<MockSeat>(resource);
seat->keyboard.reset(new MockKeyboard(keyboard_resource));
seat->keyboard_.reset(new MockKeyboard(keyboard_resource));
}
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;
}
auto* seat = GetUserDataAs<MockSeat>(resource);
seat->touch.reset(new MockTouch(touch_resource));
seat->touch_.reset(new MockTouch(touch_resource));
}
const struct wl_seat_interface seat_impl = {
......
......@@ -207,9 +207,9 @@ class MockSeat : public Global {
MockSeat();
~MockSeat() override;
std::unique_ptr<MockPointer> pointer;
std::unique_ptr<MockKeyboard> keyboard;
std::unique_ptr<MockTouch> touch;
std::unique_ptr<MockPointer> pointer_;
std::unique_ptr<MockKeyboard> keyboard_;
std::unique_ptr<MockTouch> touch_;
private:
DISALLOW_COPY_AND_ASSIGN(MockSeat);
......
......@@ -25,17 +25,17 @@ class WaylandPointerTest : public WaylandTest {
void SetUp() override {
WaylandTest::SetUp();
wl_seat_send_capabilities(server.seat()->resource(),
wl_seat_send_capabilities(server_.seat()->resource(),
WL_SEAT_CAPABILITY_POINTER);
Sync();
pointer = server.seat()->pointer.get();
ASSERT_TRUE(pointer);
pointer_ = server_.seat()->pointer_.get();
ASSERT_TRUE(pointer_);
}
protected:
wl::MockPointer* pointer;
wl::MockPointer* pointer_;
private:
DISALLOW_COPY_AND_ASSIGN(WaylandPointerTest);
......@@ -43,7 +43,7 @@ class WaylandPointerTest : public WaylandTest {
TEST_P(WaylandPointerTest, Leave) {
MockPlatformWindowDelegate other_delegate;
WaylandWindow other_window(&other_delegate, connection.get(),
WaylandWindow other_window(&other_delegate, connection_.get(),
gfx::Rect(0, 0, 10, 10));
gfx::AcceleratedWidget other_widget = gfx::kNullAcceleratedWidget;
EXPECT_CALL(other_delegate, OnAcceleratedWidgetAvailable(_, _))
......@@ -54,16 +54,16 @@ TEST_P(WaylandPointerTest, Leave) {
Sync();
wl::MockSurface* other_surface =
server.GetObject<wl::MockSurface>(other_widget);
server_.GetObject<wl::MockSurface>(other_widget);
ASSERT_TRUE(other_surface);
wl_pointer_send_enter(pointer->resource(), 1, surface->resource(), 0, 0);
wl_pointer_send_leave(pointer->resource(), 2, surface->resource());
wl_pointer_send_enter(pointer->resource(), 3, other_surface->resource(), 0,
wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0);
wl_pointer_send_leave(pointer_->resource(), 2, surface_->resource());
wl_pointer_send_enter(pointer_->resource(), 3, other_surface->resource(), 0,
0);
wl_pointer_send_button(pointer->resource(), 4, 1004, BTN_LEFT,
wl_pointer_send_button(pointer_->resource(), 4, 1004, BTN_LEFT,
WL_POINTER_BUTTON_STATE_PRESSED);
EXPECT_CALL(delegate, DispatchEvent(_)).Times(1);
EXPECT_CALL(delegate_, DispatchEvent(_)).Times(1);
// Do an extra Sync() here so that we process the second enter event before we
// destroy |other_window|.
......@@ -75,12 +75,13 @@ ACTION_P(CloneEvent, ptr) {
}
TEST_P(WaylandPointerTest, Motion) {
wl_pointer_send_enter(pointer->resource(), 1, surface->resource(), 0, 0);
wl_pointer_send_motion(pointer->resource(), 1002, wl_fixed_from_double(10.75),
wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0);
wl_pointer_send_motion(pointer_->resource(), 1002,
wl_fixed_from_double(10.75),
wl_fixed_from_double(20.375));
std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
Sync();
......@@ -95,15 +96,15 @@ TEST_P(WaylandPointerTest, Motion) {
}
TEST_P(WaylandPointerTest, MotionDragged) {
wl_pointer_send_enter(pointer->resource(), 1, surface->resource(), 0, 0);
wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_MIDDLE,
wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(), 0, 0);
wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_MIDDLE,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
wl_pointer_send_motion(pointer->resource(), 1003, wl_fixed_from_int(400),
EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
wl_pointer_send_motion(pointer_->resource(), 1003, wl_fixed_from_int(400),
wl_fixed_from_int(500));
Sync();
......@@ -119,16 +120,16 @@ TEST_P(WaylandPointerTest, MotionDragged) {
}
TEST_P(WaylandPointerTest, ButtonPress) {
wl_pointer_send_enter(pointer->resource(), 1, surface->resource(),
wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(200), wl_fixed_from_int(150));
wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_RIGHT,
wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_RIGHT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
wl_pointer_send_button(pointer->resource(), 3, 1003, BTN_LEFT,
EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
wl_pointer_send_button(pointer_->resource(), 3, 1003, BTN_LEFT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
......@@ -145,18 +146,18 @@ TEST_P(WaylandPointerTest, ButtonPress) {
}
TEST_P(WaylandPointerTest, ButtonRelease) {
wl_pointer_send_enter(pointer->resource(), 1, surface->resource(),
wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(50), wl_fixed_from_int(50));
wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_BACK,
wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_BACK,
WL_POINTER_BUTTON_STATE_PRESSED);
wl_pointer_send_button(pointer->resource(), 3, 1003, BTN_LEFT,
wl_pointer_send_button(pointer_->resource(), 3, 1003, BTN_LEFT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
wl_pointer_send_button(pointer->resource(), 4, 1004, BTN_LEFT,
EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
wl_pointer_send_button(pointer_->resource(), 4, 1004, BTN_LEFT,
WL_POINTER_BUTTON_STATE_RELEASED);
Sync();
......@@ -173,17 +174,17 @@ TEST_P(WaylandPointerTest, ButtonRelease) {
}
TEST_P(WaylandPointerTest, AxisVertical) {
wl_pointer_send_enter(pointer->resource(), 1, surface->resource(),
wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(0), wl_fixed_from_int(0));
wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_RIGHT,
wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_RIGHT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
// Wayland servers typically send a value of 10 per mouse wheel click.
wl_pointer_send_axis(pointer->resource(), 1003,
wl_pointer_send_axis(pointer_->resource(), 1003,
WL_POINTER_AXIS_VERTICAL_SCROLL, wl_fixed_from_int(20));
Sync();
......@@ -200,17 +201,17 @@ TEST_P(WaylandPointerTest, AxisVertical) {
}
TEST_P(WaylandPointerTest, AxisHorizontal) {
wl_pointer_send_enter(pointer->resource(), 1, surface->resource(),
wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(50), wl_fixed_from_int(75));
wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_LEFT,
wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_LEFT,
WL_POINTER_BUTTON_STATE_PRESSED);
Sync();
std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
// Wayland servers typically send a value of 10 per mouse wheel click.
wl_pointer_send_axis(pointer->resource(), 1003,
wl_pointer_send_axis(pointer_->resource(), 1003,
WL_POINTER_AXIS_HORIZONTAL_SCROLL,
wl_fixed_from_int(10));
......
......@@ -19,13 +19,13 @@ namespace ui {
class WaylandSurfaceFactoryTest : public WaylandTest {
public:
WaylandSurfaceFactoryTest() : surface_factory(connection.get()) {}
WaylandSurfaceFactoryTest() : surface_factory(connection_.get()) {}
~WaylandSurfaceFactoryTest() override {}
void SetUp() override {
WaylandTest::SetUp();
canvas = surface_factory.CreateCanvasForWidget(widget);
canvas = surface_factory.CreateCanvasForWidget(widget_);
ASSERT_TRUE(canvas);
}
......@@ -41,11 +41,11 @@ TEST_P(WaylandSurfaceFactoryTest, Canvas) {
canvas->GetSurface();
canvas->PresentCanvas(gfx::Rect(5, 10, 20, 15));
Expectation damage = EXPECT_CALL(*surface, Damage(5, 10, 20, 15));
Expectation damage = EXPECT_CALL(*surface_, Damage(5, 10, 20, 15));
wl_resource* buffer_resource = nullptr;
Expectation attach = EXPECT_CALL(*surface, Attach(_, 0, 0))
Expectation attach = EXPECT_CALL(*surface_, Attach(_, 0, 0))
.WillOnce(SaveArg<0>(&buffer_resource));
EXPECT_CALL(*surface, Commit()).After(damage, attach);
EXPECT_CALL(*surface_, Commit()).After(damage, attach);
Sync();
......@@ -65,11 +65,11 @@ TEST_P(WaylandSurfaceFactoryTest, CanvasResize) {
canvas->GetSurface();
canvas->PresentCanvas(gfx::Rect(0, 0, 100, 50));
Expectation damage = EXPECT_CALL(*surface, Damage(0, 0, 100, 50));
Expectation damage = EXPECT_CALL(*surface_, Damage(0, 0, 100, 50));
wl_resource* buffer_resource = nullptr;
Expectation attach = EXPECT_CALL(*surface, Attach(_, 0, 0))
Expectation attach = EXPECT_CALL(*surface_, Attach(_, 0, 0))
.WillOnce(SaveArg<0>(&buffer_resource));
EXPECT_CALL(*surface, Commit()).After(damage, attach);
EXPECT_CALL(*surface_, Commit()).After(damage, attach);
Sync();
......
......@@ -27,48 +27,48 @@ WaylandTest::WaylandTest() {
KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
std::make_unique<StubKeyboardLayoutEngine>());
#endif
connection.reset(new WaylandConnection);
window = std::make_unique<WaylandWindow>(&delegate, connection.get(),
gfx::Rect(0, 0, 800, 600));
connection_.reset(new WaylandConnection);
window_ = std::make_unique<WaylandWindow>(&delegate_, connection_.get(),
gfx::Rect(0, 0, 800, 600));
}
WaylandTest::~WaylandTest() {}
void WaylandTest::SetUp() {
ASSERT_TRUE(server.Start(GetParam()));
ASSERT_TRUE(connection->Initialize());
EXPECT_CALL(delegate, OnAcceleratedWidgetAvailable(_, _))
.WillOnce(SaveArg<0>(&widget));
ASSERT_TRUE(window->Initialize());
ASSERT_NE(widget, gfx::kNullAcceleratedWidget);
ASSERT_TRUE(server_.Start(GetParam()));
ASSERT_TRUE(connection_->Initialize());
EXPECT_CALL(delegate_, OnAcceleratedWidgetAvailable(_, _))
.WillOnce(SaveArg<0>(&widget_));
ASSERT_TRUE(window_->Initialize());
ASSERT_NE(widget_, gfx::kNullAcceleratedWidget);
// Wait for the client to flush all pending requests from initialization.
base::RunLoop().RunUntilIdle();
// Pause the server after it has responded to all incoming events.
server.Pause();
server_.Pause();
surface = server.GetObject<wl::MockSurface>(widget);
ASSERT_TRUE(surface);
surface_ = server_.GetObject<wl::MockSurface>(widget_);
ASSERT_TRUE(surface_);
initialized = true;
initialized_ = true;
}
void WaylandTest::TearDown() {
if (initialized)
if (initialized_)
Sync();
}
void WaylandTest::Sync() {
// Resume the server, flushing its pending events.
server.Resume();
server_.Resume();
// Wait for the client to finish processing these events.
base::RunLoop().RunUntilIdle();
// Pause the server, after it has finished processing any follow-up requests
// from the client.
server.Pause();
server_.Pause();
}
} // namespace ui
......@@ -35,17 +35,17 @@ class WaylandTest : public ::testing::TestWithParam<uint32_t> {
void Sync();
private:
bool initialized = false;
base::MessageLoopForUI message_loop;
base::MessageLoopForUI message_loop_;
bool initialized_ = false;
protected:
wl::FakeServer server;
wl::MockSurface* surface;
wl::FakeServer server_;
wl::MockSurface* surface_;
MockPlatformWindowDelegate delegate;
std::unique_ptr<WaylandConnection> connection;
std::unique_ptr<WaylandWindow> window;
gfx::AcceleratedWidget widget = gfx::kNullAcceleratedWidget;
MockPlatformWindowDelegate delegate_;
std::unique_ptr<WaylandConnection> connection_;
std::unique_ptr<WaylandWindow> window_;
gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
private:
#if BUILDFLAG(USE_XKBCOMMON)
......
......@@ -33,13 +33,13 @@ class WaylandTouchTest : public WaylandTest {
void SetUp() override {
WaylandTest::SetUp();
wl_seat_send_capabilities(server.seat()->resource(),
wl_seat_send_capabilities(server_.seat()->resource(),
WL_SEAT_CAPABILITY_TOUCH);
Sync();
touch = server.seat()->touch.get();
ASSERT_TRUE(touch);
touch_ = server_.seat()->touch_.get();
ASSERT_TRUE(touch_);
}
protected:
......@@ -51,7 +51,7 @@ class WaylandTouchTest : public WaylandTest {
EXPECT_EQ(event_type, key_event->type());
}
wl::MockTouch* touch;
wl::MockTouch* touch_;
private:
DISALLOW_COPY_AND_ASSIGN(WaylandTouchTest);
......@@ -59,21 +59,21 @@ class WaylandTouchTest : public WaylandTest {
TEST_P(WaylandTouchTest, KeypressAndMotion) {
std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillRepeatedly(CloneEvent(&event));
EXPECT_CALL(delegate_, DispatchEvent(_)).WillRepeatedly(CloneEvent(&event));
wl_touch_send_down(touch->resource(), 1, 0, surface->resource(), 0 /* id */,
wl_touch_send_down(touch_->resource(), 1, 0, surface_->resource(), 0 /* id */,
wl_fixed_from_int(50), wl_fixed_from_int(100));
Sync();
CheckEventType(ui::ET_TOUCH_PRESSED, event.get());
wl_touch_send_motion(touch->resource(), 500, 0 /* id */,
wl_touch_send_motion(touch_->resource(), 500, 0 /* id */,
wl_fixed_from_int(100), wl_fixed_from_int(100));
Sync();
CheckEventType(ui::ET_TOUCH_MOVED, event.get());
wl_touch_send_up(touch->resource(), 1, 1000, 0 /* id */);
wl_touch_send_up(touch_->resource(), 1, 1000, 0 /* id */);
Sync();
CheckEventType(ui::ET_TOUCH_RELEASED, event.get());
......
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