Chromium Code Reviews| Index: ash/drag_drop/drag_drop_tracker_unittest.cc |
| diff --git a/ash/drag_drop/drag_drop_tracker_unittest.cc b/ash/drag_drop/drag_drop_tracker_unittest.cc |
| index f41633b75331c8b6acd169fa4354f0b787a51f1b..b560ec5a5f08f6edb62eb9c4cf482eb61278eeda 100644 |
| --- a/ash/drag_drop/drag_drop_tracker_unittest.cc |
| +++ b/ash/drag_drop/drag_drop_tracker_unittest.cc |
| @@ -6,6 +6,8 @@ |
| #include <memory> |
| +#include "ash/aura/wm_window_aura.h" |
| +#include "ash/common/scoped_root_window_for_new_windows.h" |
| #include "ash/common/shell_window_ids.h" |
| #include "ash/shell.h" |
| #include "ash/test/ash_test_base.h" |
| @@ -66,47 +68,53 @@ TEST_F(DragDropTrackerTest, GetTarget) { |
| EXPECT_EQ("0,0 100x100", window0->GetBoundsInScreen().ToString()); |
| EXPECT_EQ("300,100 100x100", window1->GetBoundsInScreen().ToString()); |
| - // Make RootWindow0 active so that capture window is parented to it. |
| - Shell::GetInstance()->set_target_root_window(root_windows[0]); |
| + { |
| + // Make RootWindow0 active so that capture window is parented to it. |
| + ScopedRootWindowForNewWindows root_for_new_windows( |
|
msw
2016/08/02 01:04:50
optional nit: ScopedRootWindowForNewWindows for fi
James Cook
2016/08/02 16:16:04
Done.
|
| + WmWindowAura::Get(root_windows[0])); |
| - // Start tracking from the RootWindow1 and check the point on RootWindow0 that |
| - // |window0| covers. |
| - EXPECT_EQ(window0.get(), GetTarget(gfx::Point(50, 50))); |
| + // Start tracking from the RootWindow1 and check the point on RootWindow0 |
| + // that |window0| covers. |
| + EXPECT_EQ(window0.get(), GetTarget(gfx::Point(50, 50))); |
| - // Start tracking from the RootWindow0 and check the point on RootWindow0 that |
| - // neither |window0| nor |window1| covers. |
| - EXPECT_NE(window0.get(), GetTarget(gfx::Point(150, 150))); |
| - EXPECT_NE(window1.get(), GetTarget(gfx::Point(150, 150))); |
| + // Start tracking from the RootWindow0 and check the point on RootWindow0 |
| + // that neither |window0| nor |window1| covers. |
| + EXPECT_NE(window0.get(), GetTarget(gfx::Point(150, 150))); |
| + EXPECT_NE(window1.get(), GetTarget(gfx::Point(150, 150))); |
| - // Start tracking from the RootWindow0 and check the point on RootWindow1 that |
| - // |window1| covers. |
| - EXPECT_EQ(window1.get(), GetTarget(gfx::Point(350, 150))); |
| + // Start tracking from the RootWindow0 and check the point on RootWindow1 |
| + // that |window1| covers. |
| + EXPECT_EQ(window1.get(), GetTarget(gfx::Point(350, 150))); |
| - // Start tracking from the RootWindow0 and check the point on RootWindow1 that |
| - // neither |window0| nor |window1| covers. |
| - EXPECT_NE(window0.get(), GetTarget(gfx::Point(50, 250))); |
| - EXPECT_NE(window1.get(), GetTarget(gfx::Point(50, 250))); |
| + // Start tracking from the RootWindow0 and check the point on RootWindow1 |
| + // that neither |window0| nor |window1| covers. |
| + EXPECT_NE(window0.get(), GetTarget(gfx::Point(50, 250))); |
| + EXPECT_NE(window1.get(), GetTarget(gfx::Point(50, 250))); |
| + } |
| - // Make RootWindow1 active so that capture window is parented to it. |
| - Shell::GetInstance()->set_target_root_window(root_windows[1]); |
| + { |
| + // Make RootWindow1 active so that capture window is parented to it. |
| + ScopedRootWindowForNewWindows root_for_new_windows( |
| + WmWindowAura::Get(root_windows[1])); |
| - // Start tracking from the RootWindow1 and check the point on RootWindow0 that |
| - // |window0| covers. |
| - EXPECT_EQ(window0.get(), GetTarget(gfx::Point(-150, 50))); |
| + // Start tracking from the RootWindow1 and check the point on RootWindow0 |
| + // that |window0| covers. |
| + EXPECT_EQ(window0.get(), GetTarget(gfx::Point(-150, 50))); |
| - // Start tracking from the RootWindow1 and check the point on RootWindow0 that |
| - // neither |window0| nor |window1| covers. |
| - EXPECT_NE(window0.get(), GetTarget(gfx::Point(150, -50))); |
| - EXPECT_NE(window1.get(), GetTarget(gfx::Point(150, -50))); |
| + // Start tracking from the RootWindow1 and check the point on RootWindow0 |
| + // that neither |window0| nor |window1| covers. |
| + EXPECT_NE(window0.get(), GetTarget(gfx::Point(150, -50))); |
| + EXPECT_NE(window1.get(), GetTarget(gfx::Point(150, -50))); |
| - // Start tracking from the RootWindow1 and check the point on RootWindow1 that |
| - // |window1| covers. |
| - EXPECT_EQ(window1.get(), GetTarget(gfx::Point(150, 150))); |
| + // Start tracking from the RootWindow1 and check the point on RootWindow1 |
| + // that |window1| covers. |
| + EXPECT_EQ(window1.get(), GetTarget(gfx::Point(150, 150))); |
| - // Start tracking from the RootWindow1 and check the point on RootWindow1 that |
| - // neither |window0| nor |window1| covers. |
| - EXPECT_NE(window0.get(), GetTarget(gfx::Point(50, 50))); |
| - EXPECT_NE(window1.get(), GetTarget(gfx::Point(50, 50))); |
| + // Start tracking from the RootWindow1 and check the point on RootWindow1 |
| + // that |window0| nor |window1| covers. |
| + EXPECT_NE(window0.get(), GetTarget(gfx::Point(50, 50))); |
| + EXPECT_NE(window1.get(), GetTarget(gfx::Point(50, 50))); |
| + } |
| } |
| TEST_F(DragDropTrackerTest, ConvertEvent) { |
| @@ -125,59 +133,65 @@ TEST_F(DragDropTrackerTest, ConvertEvent) { |
| CreateTestWindow(gfx::Rect(300, 100, 100, 100))); |
| window1->Show(); |
| - // Make RootWindow0 active so that capture window is parented to it. |
| - Shell::GetInstance()->set_target_root_window(root_windows[0]); |
| - |
| - // Start tracking from the RootWindow0 and converts the mouse event into |
| - // |window0|'s coodinates. |
| - ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), |
| - gfx::Point(50, 50), ui::EventTimeForNow(), |
| - ui::EF_NONE, ui::EF_NONE); |
| - std::unique_ptr<ui::LocatedEvent> converted00( |
| - ConvertEvent(window0.get(), original00)); |
| - EXPECT_EQ(original00.type(), converted00->type()); |
| - EXPECT_EQ("50,50", converted00->location().ToString()); |
| - EXPECT_EQ("50,50", converted00->root_location().ToString()); |
| - EXPECT_EQ(original00.flags(), converted00->flags()); |
| - |
| - // Start tracking from the RootWindow0 and converts the mouse event into |
| - // |window1|'s coodinates. |
| - ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), |
| - gfx::Point(350, 150), ui::EventTimeForNow(), |
| - ui::EF_NONE, ui::EF_NONE); |
| - std::unique_ptr<ui::LocatedEvent> converted01( |
| - ConvertEvent(window1.get(), original01)); |
| - EXPECT_EQ(original01.type(), converted01->type()); |
| - EXPECT_EQ("50,50", converted01->location().ToString()); |
| - EXPECT_EQ("150,150", converted01->root_location().ToString()); |
| - EXPECT_EQ(original01.flags(), converted01->flags()); |
| - |
| - // Make RootWindow1 active so that capture window is parented to it. |
| - Shell::GetInstance()->set_target_root_window(root_windows[1]); |
| - |
| - // Start tracking from the RootWindow1 and converts the mouse event into |
| - // |window0|'s coodinates. |
| - ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), |
| - gfx::Point(-150, 50), ui::EventTimeForNow(), |
| - ui::EF_NONE, ui::EF_NONE); |
| - std::unique_ptr<ui::LocatedEvent> converted10( |
| - ConvertEvent(window0.get(), original10)); |
| - EXPECT_EQ(original10.type(), converted10->type()); |
| - EXPECT_EQ("50,50", converted10->location().ToString()); |
| - EXPECT_EQ("50,50", converted10->root_location().ToString()); |
| - EXPECT_EQ(original10.flags(), converted10->flags()); |
| - |
| - // Start tracking from the RootWindow1 and converts the mouse event into |
| - // |window1|'s coodinates. |
| - ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), |
| - gfx::Point(150, 150), ui::EventTimeForNow(), |
| - ui::EF_NONE, ui::EF_NONE); |
| - std::unique_ptr<ui::LocatedEvent> converted11( |
| - ConvertEvent(window1.get(), original11)); |
| - EXPECT_EQ(original11.type(), converted11->type()); |
| - EXPECT_EQ("50,50", converted11->location().ToString()); |
| - EXPECT_EQ("150,150", converted11->root_location().ToString()); |
| - EXPECT_EQ(original11.flags(), converted11->flags()); |
| + { |
| + // Make RootWindow0 active so that capture window is parented to it. |
| + ScopedRootWindowForNewWindows root_for_new_windows( |
|
msw
2016/08/02 01:04:50
optional nit: ScopedRootWindowForNewWindows for fi
|
| + WmWindowAura::Get(root_windows[0])); |
| + |
| + // Start tracking from the RootWindow0 and converts the mouse event into |
| + // |window0|'s coodinates. |
| + ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), |
| + gfx::Point(50, 50), ui::EventTimeForNow(), |
| + ui::EF_NONE, ui::EF_NONE); |
| + std::unique_ptr<ui::LocatedEvent> converted00( |
| + ConvertEvent(window0.get(), original00)); |
| + EXPECT_EQ(original00.type(), converted00->type()); |
| + EXPECT_EQ("50,50", converted00->location().ToString()); |
| + EXPECT_EQ("50,50", converted00->root_location().ToString()); |
| + EXPECT_EQ(original00.flags(), converted00->flags()); |
| + |
| + // Start tracking from the RootWindow0 and converts the mouse event into |
| + // |window1|'s coodinates. |
| + ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), |
| + gfx::Point(350, 150), ui::EventTimeForNow(), |
| + ui::EF_NONE, ui::EF_NONE); |
| + std::unique_ptr<ui::LocatedEvent> converted01( |
| + ConvertEvent(window1.get(), original01)); |
| + EXPECT_EQ(original01.type(), converted01->type()); |
| + EXPECT_EQ("50,50", converted01->location().ToString()); |
| + EXPECT_EQ("150,150", converted01->root_location().ToString()); |
| + EXPECT_EQ(original01.flags(), converted01->flags()); |
| + } |
| + |
| + { |
| + // Make RootWindow1 active so that capture window is parented to it. |
| + ScopedRootWindowForNewWindows root_for_new_windows( |
| + WmWindowAura::Get(root_windows[1])); |
| + |
| + // Start tracking from the RootWindow1 and converts the mouse event into |
| + // |window0|'s coodinates. |
| + ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), |
| + gfx::Point(-150, 50), ui::EventTimeForNow(), |
| + ui::EF_NONE, ui::EF_NONE); |
| + std::unique_ptr<ui::LocatedEvent> converted10( |
| + ConvertEvent(window0.get(), original10)); |
| + EXPECT_EQ(original10.type(), converted10->type()); |
| + EXPECT_EQ("50,50", converted10->location().ToString()); |
| + EXPECT_EQ("50,50", converted10->root_location().ToString()); |
| + EXPECT_EQ(original10.flags(), converted10->flags()); |
| + |
| + // Start tracking from the RootWindow1 and converts the mouse event into |
| + // |window1|'s coodinates. |
| + ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), |
| + gfx::Point(150, 150), ui::EventTimeForNow(), |
| + ui::EF_NONE, ui::EF_NONE); |
| + std::unique_ptr<ui::LocatedEvent> converted11( |
| + ConvertEvent(window1.get(), original11)); |
| + EXPECT_EQ(original11.type(), converted11->type()); |
| + EXPECT_EQ("50,50", converted11->location().ToString()); |
| + EXPECT_EQ("150,150", converted11->root_location().ToString()); |
| + EXPECT_EQ(original11.flags(), converted11->flags()); |
| + } |
| } |
| } // namespace test |