OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/aura/window_targeter.h" | 5 #include "ui/aura/window_targeter.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "ui/aura/scoped_window_targeter.h" | 9 #include "ui/aura/scoped_window_targeter.h" |
8 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
9 #include "ui/aura/test/test_window_delegate.h" | 11 #include "ui/aura/test/test_window_delegate.h" |
10 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
11 #include "ui/events/event_utils.h" | 13 #include "ui/events/event_utils.h" |
12 #include "ui/events/test/test_event_handler.h" | 14 #include "ui/events/test/test_event_handler.h" |
13 | 15 |
14 namespace aura { | 16 namespace aura { |
15 | 17 |
16 // Always returns the same window. | 18 // Always returns the same window. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Now install a targeter on the |child| that looks at the window id as well | 235 // Now install a targeter on the |child| that looks at the window id as well |
234 // as the bounds and makes sure the event reaches the target only if the id of | 236 // as the bounds and makes sure the event reaches the target only if the id of |
235 // the window is equal to 1 (correct). | 237 // the window is equal to 1 (correct). |
236 ui::MouseEvent mouse3(ui::ET_MOUSE_MOVED, gfx::Point(8, 8), gfx::Point(8, 8), | 238 ui::MouseEvent mouse3(ui::ET_MOUSE_MOVED, gfx::Point(8, 8), gfx::Point(8, 8), |
237 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 239 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
238 child_r->SetEventTargeter( | 240 child_r->SetEventTargeter( |
239 scoped_ptr<ui::EventTargeter>(new IdCheckingEventTargeter(1))); | 241 scoped_ptr<ui::EventTargeter>(new IdCheckingEventTargeter(1))); |
240 EXPECT_EQ(child_r, targeter->FindTargetForEvent(root_target, &mouse3)); | 242 EXPECT_EQ(child_r, targeter->FindTargetForEvent(root_target, &mouse3)); |
241 | 243 |
242 // restore original WindowTargeter for |child|. | 244 // restore original WindowTargeter for |child|. |
243 child_r->SetEventTargeter(original_targeter.Pass()); | 245 child_r->SetEventTargeter(std::move(original_targeter)); |
244 | 246 |
245 // Target |grandchild| location. | 247 // Target |grandchild| location. |
246 ui::MouseEvent second(ui::ET_MOUSE_MOVED, gfx::Point(12, 12), | 248 ui::MouseEvent second(ui::ET_MOUSE_MOVED, gfx::Point(12, 12), |
247 gfx::Point(12, 12), ui::EventTimeForNow(), ui::EF_NONE, | 249 gfx::Point(12, 12), ui::EventTimeForNow(), ui::EF_NONE, |
248 ui::EF_NONE); | 250 ui::EF_NONE); |
249 EXPECT_EQ(grandchild_r, targeter->FindTargetForEvent(root_target, &second)); | 251 EXPECT_EQ(grandchild_r, targeter->FindTargetForEvent(root_target, &second)); |
250 | 252 |
251 // Target |child| location. | 253 // Target |child| location. |
252 ui::MouseEvent third(ui::ET_MOUSE_MOVED, gfx::Point(8, 8), gfx::Point(8, 8), | 254 ui::MouseEvent third(ui::ET_MOUSE_MOVED, gfx::Point(8, 8), gfx::Point(8, 8), |
253 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 255 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 child->SetEventTargeter( | 288 child->SetEventTargeter( |
287 scoped_ptr<ui::EventTargeter>(new IgnoreWindowTargeter())); | 289 scoped_ptr<ui::EventTargeter>(new IgnoreWindowTargeter())); |
288 | 290 |
289 ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), | 291 ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::Point(10, 10), |
290 gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_NONE, | 292 gfx::Point(10, 10), ui::EventTimeForNow(), ui::EF_NONE, |
291 ui::EF_NONE); | 293 ui::EF_NONE); |
292 EXPECT_EQ(root_window(), targeter->FindTargetForEvent(root_target, &mouse2)); | 294 EXPECT_EQ(root_window(), targeter->FindTargetForEvent(root_target, &mouse2)); |
293 } | 295 } |
294 | 296 |
295 } // namespace aura | 297 } // namespace aura |
OLD | NEW |