Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <wayland-server-core.h> | 5 #include <wayland-server-core.h> |
| 6 #include <xdg-shell-unstable-v5-server-protocol.h> | 6 #include <xdg-shell-unstable-v5-server-protocol.h> |
| 7 | 7 |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/events/event.h" | |
| 11 #include "ui/ozone/platform/wayland/fake_server.h" | 12 #include "ui/ozone/platform/wayland/fake_server.h" |
| 12 #include "ui/ozone/platform/wayland/mock_platform_window_delegate.h" | 13 #include "ui/ozone/platform/wayland/mock_platform_window_delegate.h" |
| 13 #include "ui/ozone/platform/wayland/wayland_display.h" | 14 #include "ui/ozone/platform/wayland/wayland_display.h" |
| 14 #include "ui/ozone/platform/wayland/wayland_window.h" | 15 #include "ui/ozone/platform/wayland/wayland_window.h" |
| 15 | 16 |
| 16 using ::testing::Eq; | 17 using ::testing::Eq; |
| 17 using ::testing::Mock; | 18 using ::testing::Mock; |
| 18 using ::testing::SaveArg; | 19 using ::testing::SaveArg; |
| 19 using ::testing::StrEq; | 20 using ::testing::StrEq; |
| 20 using ::testing::_; | 21 using ::testing::_; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 TEST_F(WaylandWindowTest, Minimize) { | 103 TEST_F(WaylandWindowTest, Minimize) { |
| 103 EXPECT_CALL(*xdg_surface, SetMinimized()); | 104 EXPECT_CALL(*xdg_surface, SetMinimized()); |
| 104 window.Minimize(); | 105 window.Minimize(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 TEST_F(WaylandWindowTest, Restore) { | 108 TEST_F(WaylandWindowTest, Restore) { |
| 108 EXPECT_CALL(*xdg_surface, UnsetMaximized()); | 109 EXPECT_CALL(*xdg_surface, UnsetMaximized()); |
| 109 window.Restore(); | 110 window.Restore(); |
| 110 } | 111 } |
| 111 | 112 |
| 113 namespace { | |
| 114 MouseEvent test_mouse_event(ET_MOUSE_PRESSED, | |
| 115 gfx::Point(10, 15), | |
| 116 gfx::Point(10, 15), | |
| 117 base::TimeDelta::FromSeconds(123456), | |
| 118 EF_LEFT_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON, | |
| 119 EF_LEFT_MOUSE_BUTTON); | |
|
spang
2016/02/24 16:42:21
It should go on the class.
Michael Forney
2016/02/24 19:32:21
Done.
| |
| 120 } // namespace | |
| 121 | |
| 122 TEST_F(WaylandWindowTest, CanDispatchMouseEventDefault) { | |
| 123 EXPECT_FALSE(window.CanDispatchEvent(&test_mouse_event)); | |
| 124 } | |
| 125 | |
| 126 TEST_F(WaylandWindowTest, CanDispatchMouseEventFocus) { | |
| 127 window.set_pointer_focus(true); | |
| 128 EXPECT_TRUE(window.CanDispatchEvent(&test_mouse_event)); | |
| 129 } | |
| 130 | |
| 131 TEST_F(WaylandWindowTest, CanDispatchMouseEventUnfocus) { | |
| 132 window.set_pointer_focus(false); | |
| 133 EXPECT_FALSE(window.CanDispatchEvent(&test_mouse_event)); | |
| 134 } | |
| 135 | |
| 136 ACTION_P(CloneEvent, ptr) { | |
| 137 *ptr = Event::Clone(*arg0); | |
| 138 } | |
| 139 | |
| 140 TEST_F(WaylandWindowTest, DispatchEvent) { | |
| 141 scoped_ptr<Event> event; | |
| 142 EXPECT_CALL(delegate, DispatchEvent(_)).WillOnce(CloneEvent(&event)); | |
| 143 window.DispatchEvent(&test_mouse_event); | |
| 144 ASSERT_TRUE(event); | |
| 145 ASSERT_TRUE(event->IsMouseEvent()); | |
| 146 auto mouse_event = static_cast<MouseEvent*>(event.get()); | |
| 147 EXPECT_EQ(mouse_event->location_f(), test_mouse_event.location_f()); | |
| 148 EXPECT_EQ(mouse_event->root_location_f(), test_mouse_event.root_location_f()); | |
| 149 EXPECT_EQ(mouse_event->time_stamp(), test_mouse_event.time_stamp()); | |
| 150 EXPECT_EQ(mouse_event->button_flags(), test_mouse_event.button_flags()); | |
| 151 EXPECT_EQ(mouse_event->changed_button_flags(), | |
| 152 test_mouse_event.changed_button_flags()); | |
| 153 } | |
| 154 | |
| 112 TEST_F(WaylandWindowTest, ConfigureEvent) { | 155 TEST_F(WaylandWindowTest, ConfigureEvent) { |
| 113 wl_array states; | 156 wl_array states; |
| 114 wl_array_init(&states); | 157 wl_array_init(&states); |
| 115 xdg_surface_send_configure(xdg_surface->resource(), 1000, 1000, &states, 12); | 158 xdg_surface_send_configure(xdg_surface->resource(), 1000, 1000, &states, 12); |
| 116 xdg_surface_send_configure(xdg_surface->resource(), 1500, 1000, &states, 13); | 159 xdg_surface_send_configure(xdg_surface->resource(), 1500, 1000, &states, 13); |
| 117 | 160 |
| 118 // Make sure that the implementation does not call OnBoundsChanged for each | 161 // Make sure that the implementation does not call OnBoundsChanged for each |
| 119 // configure event if it receives multiple in a row. | 162 // configure event if it receives multiple in a row. |
| 120 EXPECT_CALL(delegate, OnBoundsChanged(_)).Times(0); | 163 EXPECT_CALL(delegate, OnBoundsChanged(_)).Times(0); |
| 121 Sync(); | 164 Sync(); |
| 122 Mock::VerifyAndClearExpectations(&delegate); | 165 Mock::VerifyAndClearExpectations(&delegate); |
| 123 | 166 |
| 124 EXPECT_CALL(delegate, OnBoundsChanged(Eq(gfx::Rect(0, 0, 1500, 1000)))); | 167 EXPECT_CALL(delegate, OnBoundsChanged(Eq(gfx::Rect(0, 0, 1500, 1000)))); |
| 125 EXPECT_CALL(*xdg_surface, AckConfigure(13)); | 168 EXPECT_CALL(*xdg_surface, AckConfigure(13)); |
| 126 window.ApplyPendingBounds(); | 169 window.ApplyPendingBounds(); |
| 127 } | 170 } |
| 128 | 171 |
| 129 } // namespace ui | 172 } // namespace ui |
| OLD | NEW |