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 "ui/aura/scoped_window_targeter.h" | 7 #include "ui/aura/scoped_window_targeter.h" |
8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
9 #include "ui/aura/test/test_window_delegate.h" | 9 #include "ui/aura/test/test_window_delegate.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
11 #include "ui/events/test/test_event_handler.h" | 11 #include "ui/events/test/test_event_handler.h" |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
14 | 14 |
15 // Always returns the same window. | 15 // Always returns the same window. |
16 class StaticWindowTargeter : public ui::EventTargeter { | 16 class StaticWindowTargeter : public ui::EventTargeter { |
17 public: | 17 public: |
18 explicit StaticWindowTargeter(aura::Window* window) | 18 explicit StaticWindowTargeter(aura::Window* window) |
19 : window_(window) {} | 19 : window_(window) {} |
20 virtual ~StaticWindowTargeter() {} | 20 ~StaticWindowTargeter() override {} |
21 | 21 |
22 private: | 22 private: |
23 // ui::EventTargeter: | 23 // ui::EventTargeter: |
24 virtual ui::EventTarget* FindTargetForLocatedEvent( | 24 ui::EventTarget* FindTargetForLocatedEvent(ui::EventTarget* root, |
25 ui::EventTarget* root, | 25 ui::LocatedEvent* event) override { |
26 ui::LocatedEvent* event) override { | |
27 return window_; | 26 return window_; |
28 } | 27 } |
29 | 28 |
30 Window* window_; | 29 Window* window_; |
31 | 30 |
32 DISALLOW_COPY_AND_ASSIGN(StaticWindowTargeter); | 31 DISALLOW_COPY_AND_ASSIGN(StaticWindowTargeter); |
33 }; | 32 }; |
34 | 33 |
35 class WindowTargeterTest : public test::AuraTestBase { | 34 class WindowTargeterTest : public test::AuraTestBase { |
36 public: | 35 public: |
37 WindowTargeterTest() {} | 36 WindowTargeterTest() {} |
38 virtual ~WindowTargeterTest() {} | 37 ~WindowTargeterTest() override {} |
39 | 38 |
40 Window* root_window() { return AuraTestBase::root_window(); } | 39 Window* root_window() { return AuraTestBase::root_window(); } |
41 }; | 40 }; |
42 | 41 |
43 gfx::RectF GetEffectiveVisibleBoundsInRootWindow(Window* window) { | 42 gfx::RectF GetEffectiveVisibleBoundsInRootWindow(Window* window) { |
44 gfx::RectF bounds = gfx::Rect(window->bounds().size()); | 43 gfx::RectF bounds = gfx::Rect(window->bounds().size()); |
45 Window* root = window->GetRootWindow(); | 44 Window* root = window->GetRootWindow(); |
46 CHECK(window->layer()); | 45 CHECK(window->layer()); |
47 CHECK(root->layer()); | 46 CHECK(root->layer()); |
48 gfx::Transform transform; | 47 gfx::Transform transform; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 EXPECT_EQ(gfx::RectF(300, 30, 200, 40).ToString(), | 170 EXPECT_EQ(gfx::RectF(300, 30, 200, 40).ToString(), |
172 GetEffectiveVisibleBoundsInRootWindow(window.get()).ToString()); | 171 GetEffectiveVisibleBoundsInRootWindow(window.get()).ToString()); |
173 { | 172 { |
174 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, | 173 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, |
175 ui::EF_NONE, ui::EF_NONE); | 174 ui::EF_NONE, ui::EF_NONE); |
176 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &mouse)); | 175 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &mouse)); |
177 } | 176 } |
178 } | 177 } |
179 | 178 |
180 } // namespace aura | 179 } // namespace aura |
OLD | NEW |