| 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/scoped_root_window_for_new_windows.h" | 9 #include "ash/common/scoped_root_window_for_new_windows.h" |
| 10 #include "ash/common/wm_window.h" | 10 #include "ash/common/wm_window.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 26 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
| 27 static int window_id = 0; | 27 static int window_id = 0; |
| 28 return CreateTestWindowInShellWithDelegate( | 28 return CreateTestWindowInShellWithDelegate( |
| 29 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), | 29 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), |
| 30 window_id++, bounds); | 30 window_id++, bounds); |
| 31 } | 31 } |
| 32 | 32 |
| 33 static aura::Window* GetTarget(const gfx::Point& location) { | 33 static aura::Window* GetTarget(const gfx::Point& location) { |
| 34 std::unique_ptr<DragDropTracker> tracker( | 34 std::unique_ptr<DragDropTracker> tracker( |
| 35 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); | 35 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); |
| 36 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, location, location, | 36 ui::MouseEvent e( |
| 37 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 37 ui::ET_MOUSE_DRAGGED, location, location, ui::EventTimeForNow(), |
| 38 ui::EF_NONE, ui::EF_NONE, |
| 39 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 38 aura::Window* target = tracker->GetTarget(e); | 40 aura::Window* target = tracker->GetTarget(e); |
| 39 return target; | 41 return target; |
| 40 } | 42 } |
| 41 | 43 |
| 42 static ui::LocatedEvent* ConvertEvent(aura::Window* target, | 44 static ui::LocatedEvent* ConvertEvent(aura::Window* target, |
| 43 const ui::MouseEvent& event) { | 45 const ui::MouseEvent& event) { |
| 44 std::unique_ptr<DragDropTracker> tracker( | 46 std::unique_ptr<DragDropTracker> tracker( |
| 45 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); | 47 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); |
| 46 ui::LocatedEvent* converted = tracker->ConvertEvent(target, event); | 48 ui::LocatedEvent* converted = tracker->ConvertEvent(target, event); |
| 47 return converted; | 49 return converted; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 std::unique_ptr<aura::Window> window1( | 124 std::unique_ptr<aura::Window> window1( |
| 123 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); | 125 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); |
| 124 window1->Show(); | 126 window1->Show(); |
| 125 | 127 |
| 126 // RootWindow0 is active so the capture window is parented to it. | 128 // RootWindow0 is active so the capture window is parented to it. |
| 127 EXPECT_EQ(WmWindow::Get(root_windows[0]), | 129 EXPECT_EQ(WmWindow::Get(root_windows[0]), |
| 128 Shell::GetWmRootWindowForNewWindows()); | 130 Shell::GetWmRootWindowForNewWindows()); |
| 129 | 131 |
| 130 // Start tracking from the RootWindow0 and converts the mouse event into | 132 // Start tracking from the RootWindow0 and converts the mouse event into |
| 131 // |window0|'s coodinates. | 133 // |window0|'s coodinates. |
| 132 ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), | 134 ui::MouseEvent original00( |
| 133 gfx::Point(50, 50), ui::EventTimeForNow(), | 135 ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), gfx::Point(50, 50), |
| 134 ui::EF_NONE, ui::EF_NONE); | 136 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE, |
| 137 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 135 std::unique_ptr<ui::LocatedEvent> converted00( | 138 std::unique_ptr<ui::LocatedEvent> converted00( |
| 136 ConvertEvent(window0.get(), original00)); | 139 ConvertEvent(window0.get(), original00)); |
| 137 EXPECT_EQ(original00.type(), converted00->type()); | 140 EXPECT_EQ(original00.type(), converted00->type()); |
| 138 EXPECT_EQ("50,50", converted00->location().ToString()); | 141 EXPECT_EQ("50,50", converted00->location().ToString()); |
| 139 EXPECT_EQ("50,50", converted00->root_location().ToString()); | 142 EXPECT_EQ("50,50", converted00->root_location().ToString()); |
| 140 EXPECT_EQ(original00.flags(), converted00->flags()); | 143 EXPECT_EQ(original00.flags(), converted00->flags()); |
| 141 | 144 |
| 142 // Start tracking from the RootWindow0 and converts the mouse event into | 145 // Start tracking from the RootWindow0 and converts the mouse event into |
| 143 // |window1|'s coodinates. | 146 // |window1|'s coodinates. |
| 144 ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), | 147 ui::MouseEvent original01( |
| 145 gfx::Point(350, 150), ui::EventTimeForNow(), | 148 ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), gfx::Point(350, 150), |
| 146 ui::EF_NONE, ui::EF_NONE); | 149 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE, |
| 150 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 147 std::unique_ptr<ui::LocatedEvent> converted01( | 151 std::unique_ptr<ui::LocatedEvent> converted01( |
| 148 ConvertEvent(window1.get(), original01)); | 152 ConvertEvent(window1.get(), original01)); |
| 149 EXPECT_EQ(original01.type(), converted01->type()); | 153 EXPECT_EQ(original01.type(), converted01->type()); |
| 150 EXPECT_EQ("50,50", converted01->location().ToString()); | 154 EXPECT_EQ("50,50", converted01->location().ToString()); |
| 151 EXPECT_EQ("150,150", converted01->root_location().ToString()); | 155 EXPECT_EQ("150,150", converted01->root_location().ToString()); |
| 152 EXPECT_EQ(original01.flags(), converted01->flags()); | 156 EXPECT_EQ(original01.flags(), converted01->flags()); |
| 153 | 157 |
| 154 // Make RootWindow1 active so that capture window is parented to it. | 158 // Make RootWindow1 active so that capture window is parented to it. |
| 155 ScopedRootWindowForNewWindows root_for_new_windows( | 159 ScopedRootWindowForNewWindows root_for_new_windows( |
| 156 WmWindow::Get(root_windows[1])); | 160 WmWindow::Get(root_windows[1])); |
| 157 | 161 |
| 158 // Start tracking from the RootWindow1 and converts the mouse event into | 162 // Start tracking from the RootWindow1 and converts the mouse event into |
| 159 // |window0|'s coodinates. | 163 // |window0|'s coodinates. |
| 160 ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), | 164 ui::MouseEvent original10( |
| 161 gfx::Point(-150, 50), ui::EventTimeForNow(), | 165 ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), gfx::Point(-150, 50), |
| 162 ui::EF_NONE, ui::EF_NONE); | 166 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE, |
| 167 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 163 std::unique_ptr<ui::LocatedEvent> converted10( | 168 std::unique_ptr<ui::LocatedEvent> converted10( |
| 164 ConvertEvent(window0.get(), original10)); | 169 ConvertEvent(window0.get(), original10)); |
| 165 EXPECT_EQ(original10.type(), converted10->type()); | 170 EXPECT_EQ(original10.type(), converted10->type()); |
| 166 EXPECT_EQ("50,50", converted10->location().ToString()); | 171 EXPECT_EQ("50,50", converted10->location().ToString()); |
| 167 EXPECT_EQ("50,50", converted10->root_location().ToString()); | 172 EXPECT_EQ("50,50", converted10->root_location().ToString()); |
| 168 EXPECT_EQ(original10.flags(), converted10->flags()); | 173 EXPECT_EQ(original10.flags(), converted10->flags()); |
| 169 | 174 |
| 170 // Start tracking from the RootWindow1 and converts the mouse event into | 175 // Start tracking from the RootWindow1 and converts the mouse event into |
| 171 // |window1|'s coodinates. | 176 // |window1|'s coodinates. |
| 172 ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), | 177 ui::MouseEvent original11( |
| 173 gfx::Point(150, 150), ui::EventTimeForNow(), | 178 ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), gfx::Point(150, 150), |
| 174 ui::EF_NONE, ui::EF_NONE); | 179 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE, |
| 180 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 175 std::unique_ptr<ui::LocatedEvent> converted11( | 181 std::unique_ptr<ui::LocatedEvent> converted11( |
| 176 ConvertEvent(window1.get(), original11)); | 182 ConvertEvent(window1.get(), original11)); |
| 177 EXPECT_EQ(original11.type(), converted11->type()); | 183 EXPECT_EQ(original11.type(), converted11->type()); |
| 178 EXPECT_EQ("50,50", converted11->location().ToString()); | 184 EXPECT_EQ("50,50", converted11->location().ToString()); |
| 179 EXPECT_EQ("150,150", converted11->root_location().ToString()); | 185 EXPECT_EQ("150,150", converted11->root_location().ToString()); |
| 180 EXPECT_EQ(original11.flags(), converted11->flags()); | 186 EXPECT_EQ(original11.flags(), converted11->flags()); |
| 181 } | 187 } |
| 182 | 188 |
| 183 } // namespace test | 189 } // namespace test |
| 184 } // namespace aura | 190 } // namespace aura |
| OLD | NEW |