| 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/aura/wm_window_aura.h" | |
| 10 #include "ash/common/scoped_root_window_for_new_windows.h" | 9 #include "ash/common/scoped_root_window_for_new_windows.h" |
| 11 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| 11 #include "ash/common/wm_window.h" |
| 12 #include "ash/public/cpp/shell_window_ids.h" | 12 #include "ash/public/cpp/shell_window_ids.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
| 15 #include "ui/aura/test/test_windows.h" | 15 #include "ui/aura/test/test_windows.h" |
| 16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
| 18 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 namespace test { | 21 namespace test { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 std::unique_ptr<aura::Window> window1( | 64 std::unique_ptr<aura::Window> window1( |
| 65 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); | 65 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); |
| 66 window1->Show(); | 66 window1->Show(); |
| 67 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); | 67 EXPECT_EQ(root_windows[0], window0->GetRootWindow()); |
| 68 EXPECT_EQ(root_windows[1], window1->GetRootWindow()); | 68 EXPECT_EQ(root_windows[1], window1->GetRootWindow()); |
| 69 EXPECT_EQ("0,0 100x100", window0->GetBoundsInScreen().ToString()); | 69 EXPECT_EQ("0,0 100x100", window0->GetBoundsInScreen().ToString()); |
| 70 EXPECT_EQ("300,100 100x100", window1->GetBoundsInScreen().ToString()); | 70 EXPECT_EQ("300,100 100x100", window1->GetBoundsInScreen().ToString()); |
| 71 | 71 |
| 72 // RootWindow0 is active so the capture window is parented to it. | 72 // RootWindow0 is active so the capture window is parented to it. |
| 73 EXPECT_EQ(WmWindowAura::Get(root_windows[0]), | 73 EXPECT_EQ(WmWindow::Get(root_windows[0]), |
| 74 WmShell::Get()->GetRootWindowForNewWindows()); | 74 WmShell::Get()->GetRootWindowForNewWindows()); |
| 75 | 75 |
| 76 // Start tracking from the RootWindow1 and check the point on RootWindow0 that | 76 // Start tracking from the RootWindow1 and check the point on RootWindow0 that |
| 77 // |window0| covers. | 77 // |window0| covers. |
| 78 EXPECT_EQ(window0.get(), GetTarget(gfx::Point(50, 50))); | 78 EXPECT_EQ(window0.get(), GetTarget(gfx::Point(50, 50))); |
| 79 | 79 |
| 80 // Start tracking from the RootWindow0 and check the point on RootWindow0 that | 80 // Start tracking from the RootWindow0 and check the point on RootWindow0 that |
| 81 // neither |window0| nor |window1| covers. | 81 // neither |window0| nor |window1| covers. |
| 82 EXPECT_NE(window0.get(), GetTarget(gfx::Point(150, 150))); | 82 EXPECT_NE(window0.get(), GetTarget(gfx::Point(150, 150))); |
| 83 EXPECT_NE(window1.get(), GetTarget(gfx::Point(150, 150))); | 83 EXPECT_NE(window1.get(), GetTarget(gfx::Point(150, 150))); |
| 84 | 84 |
| 85 // Start tracking from the RootWindow0 and check the point on RootWindow1 that | 85 // Start tracking from the RootWindow0 and check the point on RootWindow1 that |
| 86 // |window1| covers. | 86 // |window1| covers. |
| 87 EXPECT_EQ(window1.get(), GetTarget(gfx::Point(350, 150))); | 87 EXPECT_EQ(window1.get(), GetTarget(gfx::Point(350, 150))); |
| 88 | 88 |
| 89 // Start tracking from the RootWindow0 and check the point on RootWindow1 that | 89 // Start tracking from the RootWindow0 and check the point on RootWindow1 that |
| 90 // neither |window0| nor |window1| covers. | 90 // neither |window0| nor |window1| covers. |
| 91 EXPECT_NE(window0.get(), GetTarget(gfx::Point(50, 250))); | 91 EXPECT_NE(window0.get(), GetTarget(gfx::Point(50, 250))); |
| 92 EXPECT_NE(window1.get(), GetTarget(gfx::Point(50, 250))); | 92 EXPECT_NE(window1.get(), GetTarget(gfx::Point(50, 250))); |
| 93 | 93 |
| 94 // Make RootWindow1 active so that capture window is parented to it. | 94 // Make RootWindow1 active so that capture window is parented to it. |
| 95 ScopedRootWindowForNewWindows root_for_new_windows( | 95 ScopedRootWindowForNewWindows root_for_new_windows( |
| 96 WmWindowAura::Get(root_windows[1])); | 96 WmWindow::Get(root_windows[1])); |
| 97 | 97 |
| 98 // Start tracking from the RootWindow1 and check the point on RootWindow0 that | 98 // Start tracking from the RootWindow1 and check the point on RootWindow0 that |
| 99 // |window0| covers. | 99 // |window0| covers. |
| 100 EXPECT_EQ(window0.get(), GetTarget(gfx::Point(-150, 50))); | 100 EXPECT_EQ(window0.get(), GetTarget(gfx::Point(-150, 50))); |
| 101 | 101 |
| 102 // Start tracking from the RootWindow1 and check the point on RootWindow0 that | 102 // Start tracking from the RootWindow1 and check the point on RootWindow0 that |
| 103 // neither |window0| nor |window1| covers. | 103 // neither |window0| nor |window1| covers. |
| 104 EXPECT_NE(window0.get(), GetTarget(gfx::Point(150, -50))); | 104 EXPECT_NE(window0.get(), GetTarget(gfx::Point(150, -50))); |
| 105 EXPECT_NE(window1.get(), GetTarget(gfx::Point(150, -50))); | 105 EXPECT_NE(window1.get(), GetTarget(gfx::Point(150, -50))); |
| 106 | 106 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 | 124 |
| 125 std::unique_ptr<aura::Window> window0( | 125 std::unique_ptr<aura::Window> window0( |
| 126 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | 126 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); |
| 127 window0->Show(); | 127 window0->Show(); |
| 128 | 128 |
| 129 std::unique_ptr<aura::Window> window1( | 129 std::unique_ptr<aura::Window> window1( |
| 130 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); | 130 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); |
| 131 window1->Show(); | 131 window1->Show(); |
| 132 | 132 |
| 133 // RootWindow0 is active so the capture window is parented to it. | 133 // RootWindow0 is active so the capture window is parented to it. |
| 134 EXPECT_EQ(WmWindowAura::Get(root_windows[0]), | 134 EXPECT_EQ(WmWindow::Get(root_windows[0]), |
| 135 WmShell::Get()->GetRootWindowForNewWindows()); | 135 WmShell::Get()->GetRootWindowForNewWindows()); |
| 136 | 136 |
| 137 // Start tracking from the RootWindow0 and converts the mouse event into | 137 // Start tracking from the RootWindow0 and converts the mouse event into |
| 138 // |window0|'s coodinates. | 138 // |window0|'s coodinates. |
| 139 ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), | 139 ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), |
| 140 gfx::Point(50, 50), ui::EventTimeForNow(), | 140 gfx::Point(50, 50), ui::EventTimeForNow(), |
| 141 ui::EF_NONE, ui::EF_NONE); | 141 ui::EF_NONE, ui::EF_NONE); |
| 142 std::unique_ptr<ui::LocatedEvent> converted00( | 142 std::unique_ptr<ui::LocatedEvent> converted00( |
| 143 ConvertEvent(window0.get(), original00)); | 143 ConvertEvent(window0.get(), original00)); |
| 144 EXPECT_EQ(original00.type(), converted00->type()); | 144 EXPECT_EQ(original00.type(), converted00->type()); |
| 145 EXPECT_EQ("50,50", converted00->location().ToString()); | 145 EXPECT_EQ("50,50", converted00->location().ToString()); |
| 146 EXPECT_EQ("50,50", converted00->root_location().ToString()); | 146 EXPECT_EQ("50,50", converted00->root_location().ToString()); |
| 147 EXPECT_EQ(original00.flags(), converted00->flags()); | 147 EXPECT_EQ(original00.flags(), converted00->flags()); |
| 148 | 148 |
| 149 // Start tracking from the RootWindow0 and converts the mouse event into | 149 // Start tracking from the RootWindow0 and converts the mouse event into |
| 150 // |window1|'s coodinates. | 150 // |window1|'s coodinates. |
| 151 ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), | 151 ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), |
| 152 gfx::Point(350, 150), ui::EventTimeForNow(), | 152 gfx::Point(350, 150), ui::EventTimeForNow(), |
| 153 ui::EF_NONE, ui::EF_NONE); | 153 ui::EF_NONE, ui::EF_NONE); |
| 154 std::unique_ptr<ui::LocatedEvent> converted01( | 154 std::unique_ptr<ui::LocatedEvent> converted01( |
| 155 ConvertEvent(window1.get(), original01)); | 155 ConvertEvent(window1.get(), original01)); |
| 156 EXPECT_EQ(original01.type(), converted01->type()); | 156 EXPECT_EQ(original01.type(), converted01->type()); |
| 157 EXPECT_EQ("50,50", converted01->location().ToString()); | 157 EXPECT_EQ("50,50", converted01->location().ToString()); |
| 158 EXPECT_EQ("150,150", converted01->root_location().ToString()); | 158 EXPECT_EQ("150,150", converted01->root_location().ToString()); |
| 159 EXPECT_EQ(original01.flags(), converted01->flags()); | 159 EXPECT_EQ(original01.flags(), converted01->flags()); |
| 160 | 160 |
| 161 // Make RootWindow1 active so that capture window is parented to it. | 161 // Make RootWindow1 active so that capture window is parented to it. |
| 162 ScopedRootWindowForNewWindows root_for_new_windows( | 162 ScopedRootWindowForNewWindows root_for_new_windows( |
| 163 WmWindowAura::Get(root_windows[1])); | 163 WmWindow::Get(root_windows[1])); |
| 164 | 164 |
| 165 // Start tracking from the RootWindow1 and converts the mouse event into | 165 // Start tracking from the RootWindow1 and converts the mouse event into |
| 166 // |window0|'s coodinates. | 166 // |window0|'s coodinates. |
| 167 ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), | 167 ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), |
| 168 gfx::Point(-150, 50), ui::EventTimeForNow(), | 168 gfx::Point(-150, 50), ui::EventTimeForNow(), |
| 169 ui::EF_NONE, ui::EF_NONE); | 169 ui::EF_NONE, ui::EF_NONE); |
| 170 std::unique_ptr<ui::LocatedEvent> converted10( | 170 std::unique_ptr<ui::LocatedEvent> converted10( |
| 171 ConvertEvent(window0.get(), original10)); | 171 ConvertEvent(window0.get(), original10)); |
| 172 EXPECT_EQ(original10.type(), converted10->type()); | 172 EXPECT_EQ(original10.type(), converted10->type()); |
| 173 EXPECT_EQ("50,50", converted10->location().ToString()); | 173 EXPECT_EQ("50,50", converted10->location().ToString()); |
| 174 EXPECT_EQ("50,50", converted10->root_location().ToString()); | 174 EXPECT_EQ("50,50", converted10->root_location().ToString()); |
| 175 EXPECT_EQ(original10.flags(), converted10->flags()); | 175 EXPECT_EQ(original10.flags(), converted10->flags()); |
| 176 | 176 |
| 177 // Start tracking from the RootWindow1 and converts the mouse event into | 177 // Start tracking from the RootWindow1 and converts the mouse event into |
| 178 // |window1|'s coodinates. | 178 // |window1|'s coodinates. |
| 179 ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), | 179 ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), |
| 180 gfx::Point(150, 150), ui::EventTimeForNow(), | 180 gfx::Point(150, 150), ui::EventTimeForNow(), |
| 181 ui::EF_NONE, ui::EF_NONE); | 181 ui::EF_NONE, ui::EF_NONE); |
| 182 std::unique_ptr<ui::LocatedEvent> converted11( | 182 std::unique_ptr<ui::LocatedEvent> converted11( |
| 183 ConvertEvent(window1.get(), original11)); | 183 ConvertEvent(window1.get(), original11)); |
| 184 EXPECT_EQ(original11.type(), converted11->type()); | 184 EXPECT_EQ(original11.type(), converted11->type()); |
| 185 EXPECT_EQ("50,50", converted11->location().ToString()); | 185 EXPECT_EQ("50,50", converted11->location().ToString()); |
| 186 EXPECT_EQ("150,150", converted11->root_location().ToString()); | 186 EXPECT_EQ("150,150", converted11->root_location().ToString()); |
| 187 EXPECT_EQ(original11.flags(), converted11->flags()); | 187 EXPECT_EQ(original11.flags(), converted11->flags()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 } // namespace test | 190 } // namespace test |
| 191 } // namespace aura | 191 } // namespace aura |
| OLD | NEW |