| 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 "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 bounds); | 30 bounds); |
| 31 } | 31 } |
| 32 | 32 |
| 33 static aura::Window* GetTarget(const gfx::Point& location) { | 33 static aura::Window* GetTarget(const gfx::Point& location) { |
| 34 scoped_ptr<internal::DragDropTracker> tracker( | 34 scoped_ptr<internal::DragDropTracker> tracker( |
| 35 new internal::DragDropTracker(Shell::GetPrimaryRootWindow(), | 35 new internal::DragDropTracker(Shell::GetPrimaryRootWindow(), |
| 36 NULL)); | 36 NULL)); |
| 37 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, | 37 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, |
| 38 location, | 38 location, |
| 39 location, | 39 location, |
| 40 ui::EF_NONE, |
| 40 ui::EF_NONE); | 41 ui::EF_NONE); |
| 41 aura::Window* target = tracker->GetTarget(e); | 42 aura::Window* target = tracker->GetTarget(e); |
| 42 return target; | 43 return target; |
| 43 } | 44 } |
| 44 | 45 |
| 45 static ui::LocatedEvent* ConvertEvent(aura::Window* target, | 46 static ui::LocatedEvent* ConvertEvent(aura::Window* target, |
| 46 const ui::MouseEvent& event) { | 47 const ui::MouseEvent& event) { |
| 47 scoped_ptr<internal::DragDropTracker> tracker( | 48 scoped_ptr<internal::DragDropTracker> tracker( |
| 48 new internal::DragDropTracker(Shell::GetPrimaryRootWindow(), | 49 new internal::DragDropTracker(Shell::GetPrimaryRootWindow(), |
| 49 NULL)); | 50 NULL)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 window1->Show(); | 141 window1->Show(); |
| 141 | 142 |
| 142 // Make RootWindow0 active so that capture window is parented to it. | 143 // Make RootWindow0 active so that capture window is parented to it. |
| 143 Shell::GetInstance()->set_target_root_window(root_windows[0]); | 144 Shell::GetInstance()->set_target_root_window(root_windows[0]); |
| 144 | 145 |
| 145 // Start tracking from the RootWindow0 and converts the mouse event into | 146 // Start tracking from the RootWindow0 and converts the mouse event into |
| 146 // |window0|'s coodinates. | 147 // |window0|'s coodinates. |
| 147 ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, | 148 ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, |
| 148 gfx::Point(50, 50), | 149 gfx::Point(50, 50), |
| 149 gfx::Point(50, 50), | 150 gfx::Point(50, 50), |
| 151 ui::EF_NONE, |
| 150 ui::EF_NONE); | 152 ui::EF_NONE); |
| 151 scoped_ptr<ui::LocatedEvent> converted00(ConvertEvent(window0.get(), | 153 scoped_ptr<ui::LocatedEvent> converted00(ConvertEvent(window0.get(), |
| 152 original00)); | 154 original00)); |
| 153 EXPECT_EQ(original00.type(), converted00->type()); | 155 EXPECT_EQ(original00.type(), converted00->type()); |
| 154 EXPECT_EQ("50,50", converted00->location().ToString()); | 156 EXPECT_EQ("50,50", converted00->location().ToString()); |
| 155 EXPECT_EQ("50,50", converted00->root_location().ToString()); | 157 EXPECT_EQ("50,50", converted00->root_location().ToString()); |
| 156 EXPECT_EQ(original00.flags(), converted00->flags()); | 158 EXPECT_EQ(original00.flags(), converted00->flags()); |
| 157 | 159 |
| 158 // Start tracking from the RootWindow0 and converts the mouse event into | 160 // Start tracking from the RootWindow0 and converts the mouse event into |
| 159 // |window1|'s coodinates. | 161 // |window1|'s coodinates. |
| 160 ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, | 162 ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, |
| 161 gfx::Point(350, 150), | 163 gfx::Point(350, 150), |
| 162 gfx::Point(350, 150), | 164 gfx::Point(350, 150), |
| 165 ui::EF_NONE, |
| 163 ui::EF_NONE); | 166 ui::EF_NONE); |
| 164 scoped_ptr<ui::LocatedEvent> converted01(ConvertEvent(window1.get(), | 167 scoped_ptr<ui::LocatedEvent> converted01(ConvertEvent(window1.get(), |
| 165 original01)); | 168 original01)); |
| 166 EXPECT_EQ(original01.type(), converted01->type()); | 169 EXPECT_EQ(original01.type(), converted01->type()); |
| 167 EXPECT_EQ("50,50", converted01->location().ToString()); | 170 EXPECT_EQ("50,50", converted01->location().ToString()); |
| 168 EXPECT_EQ("150,150", converted01->root_location().ToString()); | 171 EXPECT_EQ("150,150", converted01->root_location().ToString()); |
| 169 EXPECT_EQ(original01.flags(), converted01->flags()); | 172 EXPECT_EQ(original01.flags(), converted01->flags()); |
| 170 | 173 |
| 171 // Make RootWindow1 active so that capture window is parented to it. | 174 // Make RootWindow1 active so that capture window is parented to it. |
| 172 Shell::GetInstance()->set_target_root_window(root_windows[1]); | 175 Shell::GetInstance()->set_target_root_window(root_windows[1]); |
| 173 | 176 |
| 174 // Start tracking from the RootWindow1 and converts the mouse event into | 177 // Start tracking from the RootWindow1 and converts the mouse event into |
| 175 // |window0|'s coodinates. | 178 // |window0|'s coodinates. |
| 176 ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, | 179 ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, |
| 177 gfx::Point(-150, 50), | 180 gfx::Point(-150, 50), |
| 178 gfx::Point(-150, 50), | 181 gfx::Point(-150, 50), |
| 182 ui::EF_NONE, |
| 179 ui::EF_NONE); | 183 ui::EF_NONE); |
| 180 scoped_ptr<ui::LocatedEvent> converted10(ConvertEvent(window0.get(), | 184 scoped_ptr<ui::LocatedEvent> converted10(ConvertEvent(window0.get(), |
| 181 original10)); | 185 original10)); |
| 182 EXPECT_EQ(original10.type(), converted10->type()); | 186 EXPECT_EQ(original10.type(), converted10->type()); |
| 183 EXPECT_EQ("50,50", converted10->location().ToString()); | 187 EXPECT_EQ("50,50", converted10->location().ToString()); |
| 184 EXPECT_EQ("50,50", converted10->root_location().ToString()); | 188 EXPECT_EQ("50,50", converted10->root_location().ToString()); |
| 185 EXPECT_EQ(original10.flags(), converted10->flags()); | 189 EXPECT_EQ(original10.flags(), converted10->flags()); |
| 186 | 190 |
| 187 // Start tracking from the RootWindow1 and converts the mouse event into | 191 // Start tracking from the RootWindow1 and converts the mouse event into |
| 188 // |window1|'s coodinates. | 192 // |window1|'s coodinates. |
| 189 ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, | 193 ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, |
| 190 gfx::Point(150, 150), | 194 gfx::Point(150, 150), |
| 191 gfx::Point(150, 150), | 195 gfx::Point(150, 150), |
| 196 ui::EF_NONE, |
| 192 ui::EF_NONE); | 197 ui::EF_NONE); |
| 193 scoped_ptr<ui::LocatedEvent> converted11(ConvertEvent(window1.get(), | 198 scoped_ptr<ui::LocatedEvent> converted11(ConvertEvent(window1.get(), |
| 194 original11)); | 199 original11)); |
| 195 EXPECT_EQ(original11.type(), converted11->type()); | 200 EXPECT_EQ(original11.type(), converted11->type()); |
| 196 EXPECT_EQ("50,50", converted11->location().ToString()); | 201 EXPECT_EQ("50,50", converted11->location().ToString()); |
| 197 EXPECT_EQ("150,150", converted11->root_location().ToString()); | 202 EXPECT_EQ("150,150", converted11->root_location().ToString()); |
| 198 EXPECT_EQ(original11.flags(), converted11->flags()); | 203 EXPECT_EQ(original11.flags(), converted11->flags()); |
| 199 } | 204 } |
| 200 | 205 |
| 201 } // namespace test | 206 } // namespace test |
| 202 } // namespace aura | 207 } // namespace aura |
| OLD | NEW |