Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: components/exo/pointer_unittest.cc

Issue 2396883003: exo: Fix dragging edge cases (Closed)
Patch Set: Fix unit tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ash/aura/wm_window_aura.h" 5 #include "ash/aura/wm_window_aura.h"
6 #include "ash/common/shell_window_ids.h" 6 #include "ash/common/shell_window_ids.h"
7 #include "ash/common/wm/window_positioning_utils.h" 7 #include "ash/common/wm/window_positioning_utils.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "components/exo/buffer.h" 10 #include "components/exo/buffer.h"
11 #include "components/exo/display.h"
11 #include "components/exo/pointer.h" 12 #include "components/exo/pointer.h"
12 #include "components/exo/pointer_delegate.h" 13 #include "components/exo/pointer_delegate.h"
13 #include "components/exo/shell_surface.h" 14 #include "components/exo/shell_surface.h"
14 #include "components/exo/surface.h" 15 #include "components/exo/surface.h"
15 #include "components/exo/test/exo_test_base.h" 16 #include "components/exo/test/exo_test_base.h"
16 #include "components/exo/test/exo_test_helper.h" 17 #include "components/exo/test/exo_test_helper.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "ui/events/event_utils.h" 19 #include "ui/events/event_utils.h"
19 #include "ui/events/test/event_generator.h" 20 #include "ui/events/test/event_generator.h"
20 21
(...skipping 14 matching lines...) Expand all
35 MOCK_METHOD2(OnPointerMotion, void(base::TimeTicks, const gfx::PointF&)); 36 MOCK_METHOD2(OnPointerMotion, void(base::TimeTicks, const gfx::PointF&));
36 MOCK_METHOD3(OnPointerButton, void(base::TimeTicks, int, bool)); 37 MOCK_METHOD3(OnPointerButton, void(base::TimeTicks, int, bool));
37 MOCK_METHOD3(OnPointerScroll, 38 MOCK_METHOD3(OnPointerScroll,
38 void(base::TimeTicks, const gfx::Vector2dF&, bool)); 39 void(base::TimeTicks, const gfx::Vector2dF&, bool));
39 MOCK_METHOD1(OnPointerScrollCancel, void(base::TimeTicks)); 40 MOCK_METHOD1(OnPointerScrollCancel, void(base::TimeTicks));
40 MOCK_METHOD1(OnPointerScrollStop, void(base::TimeTicks)); 41 MOCK_METHOD1(OnPointerScrollStop, void(base::TimeTicks));
41 MOCK_METHOD0(OnPointerFrame, void()); 42 MOCK_METHOD0(OnPointerFrame, void());
42 }; 43 };
43 44
44 TEST_F(PointerTest, SetCursor) { 45 TEST_F(PointerTest, SetCursor) {
46 const Display display;
45 std::unique_ptr<Surface> surface(new Surface); 47 std::unique_ptr<Surface> surface(new Surface);
46 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 48 std::unique_ptr<ShellSurface> shell_surface(
49 new ShellSurface(display, surface.get()));
47 gfx::Size buffer_size(10, 10); 50 gfx::Size buffer_size(10, 10);
48 std::unique_ptr<Buffer> buffer( 51 std::unique_ptr<Buffer> buffer(
49 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 52 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
50 surface->Attach(buffer.get()); 53 surface->Attach(buffer.get());
51 surface->Commit(); 54 surface->Commit();
52 55
53 MockPointerDelegate delegate; 56 MockPointerDelegate delegate;
54 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); 57 std::unique_ptr<Pointer> pointer(new Pointer(&delegate));
55 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 58 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
56 59
(...skipping 16 matching lines...) Expand all
73 pointer->SetCursor(pointer_surface.get(), gfx::Point(1, 1)); 76 pointer->SetCursor(pointer_surface.get(), gfx::Point(1, 1));
74 77
75 // Unset pointer surface. 78 // Unset pointer surface.
76 pointer->SetCursor(nullptr, gfx::Point()); 79 pointer->SetCursor(nullptr, gfx::Point());
77 80
78 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); 81 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
79 pointer.reset(); 82 pointer.reset();
80 } 83 }
81 84
82 TEST_F(PointerTest, OnPointerEnter) { 85 TEST_F(PointerTest, OnPointerEnter) {
86 const Display display;
83 std::unique_ptr<Surface> surface(new Surface); 87 std::unique_ptr<Surface> surface(new Surface);
84 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 88 std::unique_ptr<ShellSurface> shell_surface(
89 new ShellSurface(display, surface.get()));
85 gfx::Size buffer_size(10, 10); 90 gfx::Size buffer_size(10, 10);
86 std::unique_ptr<Buffer> buffer( 91 std::unique_ptr<Buffer> buffer(
87 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 92 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
88 surface->Attach(buffer.get()); 93 surface->Attach(buffer.get());
89 surface->Commit(); 94 surface->Commit();
90 95
91 MockPointerDelegate delegate; 96 MockPointerDelegate delegate;
92 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); 97 std::unique_ptr<Pointer> pointer(new Pointer(&delegate));
93 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 98 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
94 99
95 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get())) 100 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
96 .WillRepeatedly(testing::Return(true)); 101 .WillRepeatedly(testing::Return(true));
97 EXPECT_CALL(delegate, OnPointerFrame()).Times(1); 102 EXPECT_CALL(delegate, OnPointerFrame()).Times(1);
98 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0)); 103 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0));
99 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin()); 104 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin());
100 105
101 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); 106 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
102 pointer.reset(); 107 pointer.reset();
103 } 108 }
104 109
105 TEST_F(PointerTest, OnPointerLeave) { 110 TEST_F(PointerTest, OnPointerLeave) {
111 const Display display;
106 std::unique_ptr<Surface> surface(new Surface); 112 std::unique_ptr<Surface> surface(new Surface);
107 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 113 std::unique_ptr<ShellSurface> shell_surface(
114 new ShellSurface(display, surface.get()));
108 gfx::Size buffer_size(10, 10); 115 gfx::Size buffer_size(10, 10);
109 std::unique_ptr<Buffer> buffer( 116 std::unique_ptr<Buffer> buffer(
110 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 117 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
111 surface->Attach(buffer.get()); 118 surface->Attach(buffer.get());
112 surface->Commit(); 119 surface->Commit();
113 120
114 MockPointerDelegate delegate; 121 MockPointerDelegate delegate;
115 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); 122 std::unique_ptr<Pointer> pointer(new Pointer(&delegate));
116 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 123 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
117 124
118 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get())) 125 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
119 .WillRepeatedly(testing::Return(true)); 126 .WillRepeatedly(testing::Return(true));
120 EXPECT_CALL(delegate, OnPointerFrame()).Times(2); 127 EXPECT_CALL(delegate, OnPointerFrame()).Times(2);
121 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0)); 128 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0));
122 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin()); 129 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin());
123 130
124 EXPECT_CALL(delegate, OnPointerLeave(surface.get())); 131 EXPECT_CALL(delegate, OnPointerLeave(surface.get()));
125 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().bottom_right()); 132 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().bottom_right());
126 133
127 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); 134 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
128 pointer.reset(); 135 pointer.reset();
129 } 136 }
130 137
131 TEST_F(PointerTest, OnPointerMotion) { 138 TEST_F(PointerTest, OnPointerMotion) {
139 const Display display;
132 std::unique_ptr<Surface> surface(new Surface); 140 std::unique_ptr<Surface> surface(new Surface);
133 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 141 std::unique_ptr<ShellSurface> shell_surface(
142 new ShellSurface(display, surface.get()));
134 gfx::Size buffer_size(10, 10); 143 gfx::Size buffer_size(10, 10);
135 std::unique_ptr<Buffer> buffer( 144 std::unique_ptr<Buffer> buffer(
136 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 145 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
137 surface->Attach(buffer.get()); 146 surface->Attach(buffer.get());
138 surface->Commit(); 147 surface->Commit();
139 148
140 MockPointerDelegate delegate; 149 MockPointerDelegate delegate;
141 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); 150 std::unique_ptr<Pointer> pointer(new Pointer(&delegate));
142 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 151 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
143 152
(...skipping 24 matching lines...) Expand all
168 EXPECT_CALL(delegate, OnPointerLeave(surface.get())); 177 EXPECT_CALL(delegate, OnPointerLeave(surface.get()));
169 EXPECT_CALL(delegate, OnPointerEnter(sub_surface.get(), gfx::PointF(), 0)); 178 EXPECT_CALL(delegate, OnPointerEnter(sub_surface.get(), gfx::PointF(), 0));
170 generator.MoveMouseTo(sub_surface->window()->GetBoundsInScreen().origin()); 179 generator.MoveMouseTo(sub_surface->window()->GetBoundsInScreen().origin());
171 180
172 EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(1, 1))); 181 EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(1, 1)));
173 generator.MoveMouseTo(sub_surface->window()->GetBoundsInScreen().origin() + 182 generator.MoveMouseTo(sub_surface->window()->GetBoundsInScreen().origin() +
174 gfx::Vector2d(1, 1)); 183 gfx::Vector2d(1, 1));
175 184
176 std::unique_ptr<Surface> child_surface(new Surface); 185 std::unique_ptr<Surface> child_surface(new Surface);
177 std::unique_ptr<ShellSurface> child_shell_surface(new ShellSurface( 186 std::unique_ptr<ShellSurface> child_shell_surface(new ShellSurface(
178 child_surface.get(), shell_surface.get(), gfx::Rect(9, 9, 1, 1), true, 187 display, child_surface.get(), shell_surface.get(), gfx::Rect(9, 9, 1, 1),
179 ash::kShellWindowId_DefaultContainer)); 188 true, ash::kShellWindowId_DefaultContainer));
180 gfx::Size child_buffer_size(15, 15); 189 gfx::Size child_buffer_size(15, 15);
181 std::unique_ptr<Buffer> child_buffer( 190 std::unique_ptr<Buffer> child_buffer(
182 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(child_buffer_size))); 191 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(child_buffer_size)));
183 child_surface->Attach(child_buffer.get()); 192 child_surface->Attach(child_buffer.get());
184 child_surface->Commit(); 193 child_surface->Commit();
185 194
186 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(child_surface.get())) 195 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(child_surface.get()))
187 .WillRepeatedly(testing::Return(true)); 196 .WillRepeatedly(testing::Return(true));
188 197
189 EXPECT_CALL(delegate, OnPointerLeave(sub_surface.get())); 198 EXPECT_CALL(delegate, OnPointerLeave(sub_surface.get()));
190 EXPECT_CALL(delegate, OnPointerEnter(child_surface.get(), gfx::PointF(), 0)); 199 EXPECT_CALL(delegate, OnPointerEnter(child_surface.get(), gfx::PointF(), 0));
191 generator.MoveMouseTo(child_surface->window()->GetBoundsInScreen().origin()); 200 generator.MoveMouseTo(child_surface->window()->GetBoundsInScreen().origin());
192 201
193 EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(10, 10))); 202 EXPECT_CALL(delegate, OnPointerMotion(testing::_, gfx::PointF(10, 10)));
194 generator.MoveMouseTo(child_surface->window()->GetBoundsInScreen().origin() + 203 generator.MoveMouseTo(child_surface->window()->GetBoundsInScreen().origin() +
195 gfx::Vector2d(10, 10)); 204 gfx::Vector2d(10, 10));
196 205
197 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); 206 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
198 pointer.reset(); 207 pointer.reset();
199 } 208 }
200 209
201 TEST_F(PointerTest, OnPointerButton) { 210 TEST_F(PointerTest, OnPointerButton) {
211 const Display display;
202 std::unique_ptr<Surface> surface(new Surface); 212 std::unique_ptr<Surface> surface(new Surface);
203 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 213 std::unique_ptr<ShellSurface> shell_surface(
214 new ShellSurface(display, surface.get()));
204 gfx::Size buffer_size(10, 10); 215 gfx::Size buffer_size(10, 10);
205 std::unique_ptr<Buffer> buffer( 216 std::unique_ptr<Buffer> buffer(
206 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 217 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
207 surface->Attach(buffer.get()); 218 surface->Attach(buffer.get());
208 surface->Commit(); 219 surface->Commit();
209 220
210 MockPointerDelegate delegate; 221 MockPointerDelegate delegate;
211 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); 222 std::unique_ptr<Pointer> pointer(new Pointer(&delegate));
212 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 223 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
213 224
214 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get())) 225 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
215 .WillRepeatedly(testing::Return(true)); 226 .WillRepeatedly(testing::Return(true));
216 EXPECT_CALL(delegate, OnPointerFrame()).Times(3); 227 EXPECT_CALL(delegate, OnPointerFrame()).Times(3);
217 228
218 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0)); 229 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0));
219 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin()); 230 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin());
220 231
221 EXPECT_CALL(delegate, 232 EXPECT_CALL(delegate,
222 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true)); 233 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, true));
223 EXPECT_CALL(delegate, 234 EXPECT_CALL(delegate,
224 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false)); 235 OnPointerButton(testing::_, ui::EF_LEFT_MOUSE_BUTTON, false));
225 generator.ClickLeftButton(); 236 generator.ClickLeftButton();
226 237
227 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); 238 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
228 pointer.reset(); 239 pointer.reset();
229 } 240 }
230 241
231 TEST_F(PointerTest, OnPointerScroll) { 242 TEST_F(PointerTest, OnPointerScroll) {
243 const Display display;
232 std::unique_ptr<Surface> surface(new Surface); 244 std::unique_ptr<Surface> surface(new Surface);
233 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 245 std::unique_ptr<ShellSurface> shell_surface(
246 new ShellSurface(display, surface.get()));
234 gfx::Size buffer_size(10, 10); 247 gfx::Size buffer_size(10, 10);
235 std::unique_ptr<Buffer> buffer( 248 std::unique_ptr<Buffer> buffer(
236 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 249 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
237 surface->Attach(buffer.get()); 250 surface->Attach(buffer.get());
238 surface->Commit(); 251 surface->Commit();
239 252
240 MockPointerDelegate delegate; 253 MockPointerDelegate delegate;
241 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); 254 std::unique_ptr<Pointer> pointer(new Pointer(&delegate));
242 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 255 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
243 gfx::Point location = surface->window()->GetBoundsInScreen().origin(); 256 gfx::Point location = surface->window()->GetBoundsInScreen().origin();
(...skipping 14 matching lines...) Expand all
258 OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false)); 271 OnPointerScroll(testing::_, gfx::Vector2dF(1.2, 1.2), false));
259 EXPECT_CALL(delegate, OnPointerScrollStop(testing::_)); 272 EXPECT_CALL(delegate, OnPointerScrollStop(testing::_));
260 } 273 }
261 generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1); 274 generator.ScrollSequence(location, base::TimeDelta(), 1, 1, 1, 1);
262 275
263 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); 276 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
264 pointer.reset(); 277 pointer.reset();
265 } 278 }
266 279
267 TEST_F(PointerTest, OnPointerScrollDiscrete) { 280 TEST_F(PointerTest, OnPointerScrollDiscrete) {
281 const Display display;
268 std::unique_ptr<Surface> surface(new Surface); 282 std::unique_ptr<Surface> surface(new Surface);
269 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 283 std::unique_ptr<ShellSurface> shell_surface(
284 new ShellSurface(display, surface.get()));
270 gfx::Size buffer_size(10, 10); 285 gfx::Size buffer_size(10, 10);
271 std::unique_ptr<Buffer> buffer( 286 std::unique_ptr<Buffer> buffer(
272 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 287 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
273 surface->Attach(buffer.get()); 288 surface->Attach(buffer.get());
274 surface->Commit(); 289 surface->Commit();
275 290
276 MockPointerDelegate delegate; 291 MockPointerDelegate delegate;
277 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); 292 std::unique_ptr<Pointer> pointer(new Pointer(&delegate));
278 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 293 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
279 294
280 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get())) 295 EXPECT_CALL(delegate, CanAcceptPointerEventsForSurface(surface.get()))
281 .WillRepeatedly(testing::Return(true)); 296 .WillRepeatedly(testing::Return(true));
282 EXPECT_CALL(delegate, OnPointerFrame()).Times(2); 297 EXPECT_CALL(delegate, OnPointerFrame()).Times(2);
283 298
284 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0)); 299 EXPECT_CALL(delegate, OnPointerEnter(surface.get(), gfx::PointF(), 0));
285 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin()); 300 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().origin());
286 301
287 EXPECT_CALL(delegate, 302 EXPECT_CALL(delegate,
288 OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), true)); 303 OnPointerScroll(testing::_, gfx::Vector2dF(1, 1), true));
289 generator.MoveMouseWheel(1, 1); 304 generator.MoveMouseWheel(1, 1);
290 305
291 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); 306 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
292 pointer.reset(); 307 pointer.reset();
293 } 308 }
294 309
295 TEST_F(PointerTest, IgnorePointerEventDuringModal) { 310 TEST_F(PointerTest, IgnorePointerEventDuringModal) {
311 const Display display;
296 std::unique_ptr<Surface> surface(new Surface); 312 std::unique_ptr<Surface> surface(new Surface);
297 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); 313 std::unique_ptr<ShellSurface> shell_surface(
314 new ShellSurface(display, surface.get()));
298 std::unique_ptr<Buffer> buffer( 315 std::unique_ptr<Buffer> buffer(
299 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(10, 10)))); 316 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(10, 10))));
300 surface->Attach(buffer.get()); 317 surface->Attach(buffer.get());
301 surface->Commit(); 318 surface->Commit();
302 gfx::Point location = surface->window()->GetBoundsInScreen().origin(); 319 gfx::Point location = surface->window()->GetBoundsInScreen().origin();
303 320
304 MockPointerDelegate delegate; 321 MockPointerDelegate delegate;
305 std::unique_ptr<Pointer> pointer(new Pointer(&delegate)); 322 std::unique_ptr<Pointer> pointer(new Pointer(&delegate));
306 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); 323 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow());
307 324
308 // Create surface for modal window. 325 // Create surface for modal window.
309 std::unique_ptr<Surface> surface2(new Surface); 326 std::unique_ptr<Surface> surface2(new Surface);
310 std::unique_ptr<ShellSurface> shell_surface2( 327 std::unique_ptr<ShellSurface> shell_surface2(
311 new ShellSurface(surface2.get(), nullptr, gfx::Rect(0, 0, 5, 5), true, 328 new ShellSurface(display, surface2.get(), nullptr, gfx::Rect(0, 0, 5, 5),
312 ash::kShellWindowId_SystemModalContainer)); 329 true, ash::kShellWindowId_SystemModalContainer));
313 std::unique_ptr<Buffer> buffer2( 330 std::unique_ptr<Buffer> buffer2(
314 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(5, 5)))); 331 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(5, 5))));
315 surface2->Attach(buffer2.get()); 332 surface2->Attach(buffer2.get());
316 surface2->Commit(); 333 surface2->Commit();
317 ash::wm::CenterWindow(ash::WmWindowAura::Get(surface2->window())); 334 ash::wm::CenterWindow(ash::WmWindowAura::Get(surface2->window()));
318 gfx::Point location2 = surface2->window()->GetBoundsInScreen().origin(); 335 gfx::Point location2 = surface2->window()->GetBoundsInScreen().origin();
319 336
320 // Make the window modal. 337 // Make the window modal.
321 shell_surface2->SetSystemModal(true); 338 shell_surface2->SetSystemModal(true);
322 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); 339 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 EXPECT_CALL(delegate, OnPointerLeave(surface.get())); 462 EXPECT_CALL(delegate, OnPointerLeave(surface.get()));
446 } 463 }
447 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().bottom_right()); 464 generator.MoveMouseTo(surface->window()->GetBoundsInScreen().bottom_right());
448 465
449 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get())); 466 EXPECT_CALL(delegate, OnPointerDestroying(pointer.get()));
450 pointer.reset(); 467 pointer.reset();
451 } 468 }
452 469
453 } // namespace 470 } // namespace
454 } // namespace exo 471 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698