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 { ...@@ -43,7 +43,7 @@ class WaylandPointerTest : public WaylandTest {
TEST_P(WaylandPointerTest, Leave) { TEST_P(WaylandPointerTest, Leave) {
MockPlatformWindowDelegate other_delegate; MockPlatformWindowDelegate other_delegate;
WaylandWindow other_window(&other_delegate, &connection, WaylandWindow other_window(&other_delegate, connection.get(),
gfx::Rect(0, 0, 10, 10)); gfx::Rect(0, 0, 10, 10));
gfx::AcceleratedWidget other_widget = gfx::kNullAcceleratedWidget; gfx::AcceleratedWidget other_widget = gfx::kNullAcceleratedWidget;
EXPECT_CALL(other_delegate, OnAcceleratedWidgetAvailable(_, _)) EXPECT_CALL(other_delegate, OnAcceleratedWidgetAvailable(_, _))
......
...@@ -19,7 +19,7 @@ namespace ui { ...@@ -19,7 +19,7 @@ namespace ui {
class WaylandSurfaceFactoryTest : public WaylandTest { class WaylandSurfaceFactoryTest : public WaylandTest {
public: public:
WaylandSurfaceFactoryTest() : surface_factory(&connection) {} WaylandSurfaceFactoryTest() : surface_factory(connection.get()) {}
~WaylandSurfaceFactoryTest() override {} ~WaylandSurfaceFactoryTest() override {}
......
...@@ -11,17 +11,22 @@ using ::testing::_; ...@@ -11,17 +11,22 @@ using ::testing::_;
namespace ui { namespace ui {
WaylandTest::WaylandTest() WaylandTest::WaylandTest() {
: window(&delegate, &connection, gfx::Rect(0, 0, 800, 600)) {} // 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() {} WaylandTest::~WaylandTest() {}
void WaylandTest::SetUp() { void WaylandTest::SetUp() {
ASSERT_TRUE(server.Start(GetParam())); ASSERT_TRUE(server.Start(GetParam()));
ASSERT_TRUE(connection.Initialize()); ASSERT_TRUE(connection->Initialize());
EXPECT_CALL(delegate, OnAcceleratedWidgetAvailable(_, _)) EXPECT_CALL(delegate, OnAcceleratedWidgetAvailable(_, _))
.WillOnce(SaveArg<0>(&widget)); .WillOnce(SaveArg<0>(&widget));
ASSERT_TRUE(window.Initialize()); ASSERT_TRUE(window->Initialize());
ASSERT_NE(widget, gfx::kNullAcceleratedWidget); ASSERT_NE(widget, gfx::kNullAcceleratedWidget);
// Wait for the client to flush all pending requests from initialization. // Wait for the client to flush all pending requests from initialization.
......
...@@ -37,9 +37,9 @@ class WaylandTest : public ::testing::TestWithParam<uint32_t> { ...@@ -37,9 +37,9 @@ class WaylandTest : public ::testing::TestWithParam<uint32_t> {
wl::FakeServer server; wl::FakeServer server;
wl::MockSurface* surface; wl::MockSurface* surface;
WaylandConnection connection;
MockPlatformWindowDelegate delegate; MockPlatformWindowDelegate delegate;
WaylandWindow window; std::unique_ptr<WaylandConnection> connection;
std::unique_ptr<WaylandWindow> window;
gfx::AcceleratedWidget widget = gfx::kNullAcceleratedWidget; gfx::AcceleratedWidget widget = gfx::kNullAcceleratedWidget;
private: private:
......
...@@ -90,7 +90,7 @@ class WaylandWindowTest : public WaylandTest { ...@@ -90,7 +90,7 @@ class WaylandWindowTest : public WaylandTest {
TEST_P(WaylandWindowTest, SetTitle) { TEST_P(WaylandWindowTest, SetTitle) {
EXPECT_CALL(*GetXdgSurface(), SetTitle(StrEq("hello"))); EXPECT_CALL(*GetXdgSurface(), SetTitle(StrEq("hello")));
window.SetTitle(base::ASCIIToUTF16("hello")); window->SetTitle(base::ASCIIToUTF16("hello"));
} }
TEST_P(WaylandWindowTest, MaximizeAndRestore) { TEST_P(WaylandWindowTest, MaximizeAndRestore) {
...@@ -102,16 +102,16 @@ TEST_P(WaylandWindowTest, MaximizeAndRestore) { ...@@ -102,16 +102,16 @@ TEST_P(WaylandWindowTest, MaximizeAndRestore) {
EXPECT_CALL(*GetXdgSurface(), SetMaximized()); EXPECT_CALL(*GetXdgSurface(), SetMaximized());
EXPECT_CALL(*GetXdgSurface(), UnsetMaximized()); EXPECT_CALL(*GetXdgSurface(), UnsetMaximized());
window.Maximize(); window->Maximize();
SendConfigureEvent(0, 0, serial, &states); SendConfigureEvent(0, 0, serial, &states);
Sync(); Sync();
window.Restore(); window->Restore();
} }
TEST_P(WaylandWindowTest, Minimize) { TEST_P(WaylandWindowTest, Minimize) {
EXPECT_CALL(*GetXdgSurface(), SetMinimized()); EXPECT_CALL(*GetXdgSurface(), SetMinimized());
window.Minimize(); window->Minimize();
} }
TEST_P(WaylandWindowTest, SetFullscreenAndRestore) { TEST_P(WaylandWindowTest, SetFullscreenAndRestore) {
...@@ -122,11 +122,11 @@ TEST_P(WaylandWindowTest, SetFullscreenAndRestore) { ...@@ -122,11 +122,11 @@ TEST_P(WaylandWindowTest, SetFullscreenAndRestore) {
EXPECT_CALL(*GetXdgSurface(), SetFullscreen()); EXPECT_CALL(*GetXdgSurface(), SetFullscreen());
EXPECT_CALL(*GetXdgSurface(), UnsetFullscreen()); EXPECT_CALL(*GetXdgSurface(), UnsetFullscreen());
window.ToggleFullscreen(); window->ToggleFullscreen();
SendConfigureEvent(0, 0, 1, &states); SendConfigureEvent(0, 0, 1, &states);
Sync(); Sync();
window.Restore(); window->Restore();
} }
TEST_P(WaylandWindowTest, SetMaximizedFullscreenAndRestore) { TEST_P(WaylandWindowTest, SetMaximizedFullscreenAndRestore) {
...@@ -138,31 +138,31 @@ TEST_P(WaylandWindowTest, SetMaximizedFullscreenAndRestore) { ...@@ -138,31 +138,31 @@ TEST_P(WaylandWindowTest, SetMaximizedFullscreenAndRestore) {
EXPECT_CALL(*GetXdgSurface(), SetMaximized()); EXPECT_CALL(*GetXdgSurface(), SetMaximized());
EXPECT_CALL(*GetXdgSurface(), UnsetMaximized()); EXPECT_CALL(*GetXdgSurface(), UnsetMaximized());
window.Maximize(); window->Maximize();
SetWlArrayWithState(XDG_SURFACE_STATE_MAXIMIZED, &states); SetWlArrayWithState(XDG_SURFACE_STATE_MAXIMIZED, &states);
SendConfigureEvent(0, 0, 2, &states); SendConfigureEvent(0, 0, 2, &states);
Sync(); Sync();
window.ToggleFullscreen(); window->ToggleFullscreen();
SetWlArrayWithState(XDG_SURFACE_STATE_FULLSCREEN, &states); SetWlArrayWithState(XDG_SURFACE_STATE_FULLSCREEN, &states);
SendConfigureEvent(0, 0, 3, &states); SendConfigureEvent(0, 0, 3, &states);
Sync(); Sync();
window.Restore(); window->Restore();
} }
TEST_P(WaylandWindowTest, CanDispatchMouseEventDefault) { TEST_P(WaylandWindowTest, CanDispatchMouseEventDefault) {
EXPECT_FALSE(window.CanDispatchEvent(&test_mouse_event)); EXPECT_FALSE(window->CanDispatchEvent(&test_mouse_event));
} }
TEST_P(WaylandWindowTest, CanDispatchMouseEventFocus) { TEST_P(WaylandWindowTest, CanDispatchMouseEventFocus) {
window.set_pointer_focus(true); window->set_pointer_focus(true);
EXPECT_TRUE(window.CanDispatchEvent(&test_mouse_event)); EXPECT_TRUE(window->CanDispatchEvent(&test_mouse_event));
} }
TEST_P(WaylandWindowTest, CanDispatchMouseEventUnfocus) { TEST_P(WaylandWindowTest, CanDispatchMouseEventUnfocus) {
window.set_pointer_focus(false); window->set_pointer_focus(false);
EXPECT_FALSE(window.CanDispatchEvent(&test_mouse_event)); EXPECT_FALSE(window->CanDispatchEvent(&test_mouse_event));
} }
ACTION_P(CloneEvent, ptr) { ACTION_P(CloneEvent, ptr) {
...@@ -172,7 +172,7 @@ ACTION_P(CloneEvent, ptr) { ...@@ -172,7 +172,7 @@ ACTION_P(CloneEvent, ptr) {
TEST_P(WaylandWindowTest, DispatchEvent) { TEST_P(WaylandWindowTest, DispatchEvent) {
std::unique_ptr<Event> event; std::unique_ptr<Event> event;
EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event)); EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event));
window.DispatchEvent(&test_mouse_event); window->DispatchEvent(&test_mouse_event);
ASSERT_TRUE(event); ASSERT_TRUE(event);
ASSERT_TRUE(event->IsMouseEvent()); ASSERT_TRUE(event->IsMouseEvent());
auto* mouse_event = event->AsMouseEvent(); 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