Commit 86a9d725 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

[ozone/wayland] Allocate some WaylandTest class members on the heap

... rather than on the stack. In practice, although the change
brings no behavior difference, it will allow WaylandTest ctor
to set the proper KeyboardLayoutEngine instance before the
WaylandConnection object is created, which in turn will allow
WaylandKeyboardTest unittests to be fixed (follow up patch).

BUG=None

Change-Id: I7f18965a90ea468591c7a6ac7a473c31a1a827cf
Reviewed-on: https://chromium-review.googlesource.com/847612Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#526710}
parent 24551430
......@@ -43,7 +43,7 @@ class WaylandPointerTest : public WaylandTest {
TEST_P(WaylandPointerTest, Leave) {
MockPlatformWindowDelegate other_delegate;
WaylandWindow other_window(&other_delegate, &connection,
WaylandWindow other_window(&other_delegate, connection.get(),
gfx::Rect(0, 0, 10, 10));
gfx::AcceleratedWidget other_widget = gfx::kNullAcceleratedWidget;
EXPECT_CALL(other_delegate, OnAcceleratedWidgetAvailable(_, _))
......
......@@ -19,7 +19,7 @@ namespace ui {
class WaylandSurfaceFactoryTest : public WaylandTest {
public:
WaylandSurfaceFactoryTest() : surface_factory(&connection) {}
WaylandSurfaceFactoryTest() : surface_factory(connection.get()) {}
~WaylandSurfaceFactoryTest() override {}
......
......@@ -11,17 +11,22 @@ using ::testing::_;
namespace ui {
WaylandTest::WaylandTest()
: window(&delegate, &connection, gfx::Rect(0, 0, 800, 600)) {}
WaylandTest::WaylandTest() {
// TODO(tonikitoo): Set the proper KeyboardLayoutEngine instance here,
// before the WaylandConnection is instantiated.
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());
ASSERT_TRUE(connection->Initialize());
EXPECT_CALL(delegate, OnAcceleratedWidgetAvailable(_, _))
.WillOnce(SaveArg<0>(&widget));
ASSERT_TRUE(window.Initialize());
ASSERT_TRUE(window->Initialize());
ASSERT_NE(widget, gfx::kNullAcceleratedWidget);
// Wait for the client to flush all pending requests from initialization.
......
......@@ -37,9 +37,9 @@ class WaylandTest : public ::testing::TestWithParam<uint32_t> {
wl::FakeServer server;
wl::MockSurface* surface;
WaylandConnection connection;
MockPlatformWindowDelegate delegate;
WaylandWindow window;
std::unique_ptr<WaylandConnection> connection;
std::unique_ptr<WaylandWindow> window;
gfx::AcceleratedWidget widget = gfx::kNullAcceleratedWidget;
private:
......
......@@ -90,7 +90,7 @@ class WaylandWindowTest : public WaylandTest {
TEST_P(WaylandWindowTest, SetTitle) {
EXPECT_CALL(*GetXdgSurface(), SetTitle(StrEq("hello")));
window.SetTitle(base::ASCIIToUTF16("hello"));
window->SetTitle(base::ASCIIToUTF16("hello"));
}
TEST_P(WaylandWindowTest, MaximizeAndRestore) {
......@@ -102,16 +102,16 @@ TEST_P(WaylandWindowTest, MaximizeAndRestore) {
EXPECT_CALL(*GetXdgSurface(), SetMaximized());
EXPECT_CALL(*GetXdgSurface(), UnsetMaximized());
window.Maximize();
window->Maximize();
SendConfigureEvent(0, 0, serial, &states);
Sync();
window.Restore();
window->Restore();
}
TEST_P(WaylandWindowTest, Minimize) {
EXPECT_CALL(*GetXdgSurface(), SetMinimized());
window.Minimize();
window->Minimize();
}
TEST_P(WaylandWindowTest, SetFullscreenAndRestore) {
......@@ -122,11 +122,11 @@ TEST_P(WaylandWindowTest, SetFullscreenAndRestore) {
EXPECT_CALL(*GetXdgSurface(), SetFullscreen());
EXPECT_CALL(*GetXdgSurface(), UnsetFullscreen());
window.ToggleFullscreen();
window->ToggleFullscreen();
SendConfigureEvent(0, 0, 1, &states);
Sync();
window.Restore();
window->Restore();
}
TEST_P(WaylandWindowTest, SetMaximizedFullscreenAndRestore) {
......@@ -138,31 +138,31 @@ TEST_P(WaylandWindowTest, SetMaximizedFullscreenAndRestore) {
EXPECT_CALL(*GetXdgSurface(), SetMaximized());
EXPECT_CALL(*GetXdgSurface(), UnsetMaximized());
window.Maximize();
window->Maximize();
SetWlArrayWithState(XDG_SURFACE_STATE_MAXIMIZED, &states);
SendConfigureEvent(0, 0, 2, &states);
Sync();
window.ToggleFullscreen();
window->ToggleFullscreen();
SetWlArrayWithState(XDG_SURFACE_STATE_FULLSCREEN, &states);
SendConfigureEvent(0, 0, 3, &states);
Sync();
window.Restore();
window->Restore();
}
TEST_P(WaylandWindowTest, CanDispatchMouseEventDefault) {
EXPECT_FALSE(window.CanDispatchEvent(&test_mouse_event));
EXPECT_FALSE(window->CanDispatchEvent(&test_mouse_event));
}
TEST_P(WaylandWindowTest, CanDispatchMouseEventFocus) {
window.set_pointer_focus(true);
EXPECT_TRUE(window.CanDispatchEvent(&test_mouse_event));
window->set_pointer_focus(true);
EXPECT_TRUE(window->CanDispatchEvent(&test_mouse_event));
}
TEST_P(WaylandWindowTest, CanDispatchMouseEventUnfocus) {
window.set_pointer_focus(false);
EXPECT_FALSE(window.CanDispatchEvent(&test_mouse_event));
window->set_pointer_focus(false);
EXPECT_FALSE(window->CanDispatchEvent(&test_mouse_event));
}
ACTION_P(CloneEvent, ptr) {
......@@ -172,7 +172,7 @@ ACTION_P(CloneEvent, ptr) {
TEST_P(WaylandWindowTest, DispatchEvent) {
std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
window.DispatchEvent(&test_mouse_event);
window->DispatchEvent(&test_mouse_event);
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsMouseEvent());
auto* mouse_event = event->AsMouseEvent();
......
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