| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/drag_drop/drag_drop_tracker.h" | 5 #include "ash/drag_drop/drag_drop_tracker.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ui/aura/test/test_windows.h" | 12 #include "ui/aura/test/test_windows.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 15 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 namespace test { | 18 namespace test { |
| 19 | 19 |
| 20 class DragDropTrackerTest : public test::AshTestBase { | 20 class DragDropTrackerTest : public test::AshTestBase { |
| 21 public: | 21 public: |
| 22 void SetUp() override { AshTestBase::SetUp(); } | 22 void SetUp() override { AshTestBase::SetUp(); } |
| 23 | 23 |
| 24 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 24 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
| 25 static int window_id = 0; | 25 static int window_id = 0; |
| 26 return CreateTestWindowInShellWithDelegate( | 26 return CreateTestWindowInShellWithDelegate( |
| 27 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), | 27 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), |
| 28 window_id++, | 28 window_id++, bounds); |
| 29 bounds); | |
| 30 } | 29 } |
| 31 | 30 |
| 32 static aura::Window* GetTarget(const gfx::Point& location) { | 31 static aura::Window* GetTarget(const gfx::Point& location) { |
| 33 std::unique_ptr<DragDropTracker> tracker( | 32 std::unique_ptr<DragDropTracker> tracker( |
| 34 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); | 33 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); |
| 35 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, location, location, | 34 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, location, location, |
| 36 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 35 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 37 aura::Window* target = tracker->GetTarget(e); | 36 aura::Window* target = tracker->GetTarget(e); |
| 38 return target; | 37 return target; |
| 39 } | 38 } |
| 40 | 39 |
| 41 static ui::LocatedEvent* ConvertEvent(aura::Window* target, | 40 static ui::LocatedEvent* ConvertEvent(aura::Window* target, |
| 42 const ui::MouseEvent& event) { | 41 const ui::MouseEvent& event) { |
| 43 std::unique_ptr<DragDropTracker> tracker( | 42 std::unique_ptr<DragDropTracker> tracker( |
| 44 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); | 43 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); |
| 45 ui::LocatedEvent* converted = tracker->ConvertEvent(target, event); | 44 ui::LocatedEvent* converted = tracker->ConvertEvent(target, event); |
| 46 return converted; | 45 return converted; |
| 47 } | 46 } |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 TEST_F(DragDropTrackerTest, GetTarget) { | 49 TEST_F(DragDropTrackerTest, GetTarget) { |
| 51 if (!SupportsMultipleDisplays()) | 50 if (!SupportsMultipleDisplays()) |
| 52 return; | 51 return; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 std::unique_ptr<ui::LocatedEvent> converted11( | 175 std::unique_ptr<ui::LocatedEvent> converted11( |
| 177 ConvertEvent(window1.get(), original11)); | 176 ConvertEvent(window1.get(), original11)); |
| 178 EXPECT_EQ(original11.type(), converted11->type()); | 177 EXPECT_EQ(original11.type(), converted11->type()); |
| 179 EXPECT_EQ("50,50", converted11->location().ToString()); | 178 EXPECT_EQ("50,50", converted11->location().ToString()); |
| 180 EXPECT_EQ("150,150", converted11->root_location().ToString()); | 179 EXPECT_EQ("150,150", converted11->root_location().ToString()); |
| 181 EXPECT_EQ(original11.flags(), converted11->flags()); | 180 EXPECT_EQ(original11.flags(), converted11->flags()); |
| 182 } | 181 } |
| 183 | 182 |
| 184 } // namespace test | 183 } // namespace test |
| 185 } // namespace aura | 184 } // namespace aura |
| OLD | NEW |