Chromium Code Reviews| 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" |
| 11 #include "ui/aura/test/test_windows.h" | 11 #include "ui/aura/test/test_windows.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | 13 #include "ui/aura/window_event_dispatcher.h" |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 namespace test { | 16 namespace test { |
| 17 | 17 |
| 18 class DragDropTrackerTest : public test::AshTestBase { | 18 class DragDropTrackerTest : public test::AshTestBase { |
| 19 public: | 19 public: |
| 20 virtual void SetUp() OVERRIDE { | 20 virtual void SetUp() OVERRIDE { |
| 21 AshTestBase::SetUp(); | 21 AshTestBase::SetUp(); |
| 22 UpdateDisplay("200x200,300x300"); | |
| 23 } | 22 } |
| 24 | 23 |
| 25 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { | 24 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { |
| 26 static int window_id = 0; | 25 static int window_id = 0; |
| 27 return CreateTestWindowInShellWithDelegate( | 26 return CreateTestWindowInShellWithDelegate( |
| 28 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), | 27 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), |
| 29 window_id++, | 28 window_id++, |
| 30 bounds); | 29 bounds); |
| 31 } | 30 } |
| 32 | 31 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 44 | 43 |
| 45 static ui::LocatedEvent* ConvertEvent(aura::Window* target, | 44 static ui::LocatedEvent* ConvertEvent(aura::Window* target, |
| 46 const ui::MouseEvent& event) { | 45 const ui::MouseEvent& event) { |
| 47 scoped_ptr<DragDropTracker> tracker( | 46 scoped_ptr<DragDropTracker> tracker( |
| 48 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); | 47 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); |
| 49 ui::LocatedEvent* converted = tracker->ConvertEvent(target, event); | 48 ui::LocatedEvent* converted = tracker->ConvertEvent(target, event); |
| 50 return converted; | 49 return converted; |
| 51 } | 50 } |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 // TODO(mazda): Remove this once ash/wm/coordinate_conversion.h supports | 53 TEST_F(DragDropTrackerTest, GetTarget) { |
| 55 // non-X11 platforms. | 54 if (!SupportsMultipleDisplays()) |
|
dnicoara
2014/09/18 16:48:06
This is needed since Windows doesn't support multi
| |
| 56 #if defined(USE_X11) | 55 return; |
| 57 #define MAYBE_GetTarget GetTarget | |
| 58 #else | |
| 59 #define MAYBE_GetTarget DISABLED_GetTarget | |
| 60 #endif | |
| 61 | 56 |
| 62 TEST_F(DragDropTrackerTest, MAYBE_GetTarget) { | 57 UpdateDisplay("200x200,300x300"); |
| 63 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 58 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 64 EXPECT_EQ(2U, root_windows.size()); | 59 EXPECT_EQ(2U, root_windows.size()); |
| 65 | 60 |
| 66 scoped_ptr<aura::Window> window0( | 61 scoped_ptr<aura::Window> window0( |
| 67 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | 62 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); |
| 68 window0->Show(); | 63 window0->Show(); |
| 69 | 64 |
| 70 scoped_ptr<aura::Window> window1( | 65 scoped_ptr<aura::Window> window1( |
| 71 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); | 66 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); |
| 72 window1->Show(); | 67 window1->Show(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 // Start tracking from the RootWindow1 and check the point on RootWindow1 that | 106 // Start tracking from the RootWindow1 and check the point on RootWindow1 that |
| 112 // |window1| covers. | 107 // |window1| covers. |
| 113 EXPECT_EQ(window1.get(), GetTarget(gfx::Point(150, 150))); | 108 EXPECT_EQ(window1.get(), GetTarget(gfx::Point(150, 150))); |
| 114 | 109 |
| 115 // Start tracking from the RootWindow1 and check the point on RootWindow1 that | 110 // Start tracking from the RootWindow1 and check the point on RootWindow1 that |
| 116 // neither |window0| nor |window1| covers. | 111 // neither |window0| nor |window1| covers. |
| 117 EXPECT_NE(window0.get(), GetTarget(gfx::Point(50, 50))); | 112 EXPECT_NE(window0.get(), GetTarget(gfx::Point(50, 50))); |
| 118 EXPECT_NE(window1.get(), GetTarget(gfx::Point(50, 50))); | 113 EXPECT_NE(window1.get(), GetTarget(gfx::Point(50, 50))); |
| 119 } | 114 } |
| 120 | 115 |
| 121 // TODO(mazda): Remove this once ash/wm/coordinate_conversion.h supports | 116 TEST_F(DragDropTrackerTest, ConvertEvent) { |
| 122 // non-X11 platforms. | 117 if (!SupportsMultipleDisplays()) |
| 123 #if defined(USE_X11) | 118 return; |
| 124 #define MAYBE_ConvertEvent ConvertEvent | |
| 125 #else | |
| 126 #define MAYBE_ConvertEvent DISABLED_ConvertEvent | |
| 127 #endif | |
| 128 | 119 |
| 129 TEST_F(DragDropTrackerTest, MAYBE_ConvertEvent) { | 120 UpdateDisplay("200x200,300x300"); |
| 130 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 121 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 131 EXPECT_EQ(2U, root_windows.size()); | 122 EXPECT_EQ(2U, root_windows.size()); |
| 132 | 123 |
| 133 scoped_ptr<aura::Window> window0( | 124 scoped_ptr<aura::Window> window0( |
| 134 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); | 125 CreateTestWindow(gfx::Rect(0, 0, 100, 100))); |
| 135 window0->Show(); | 126 window0->Show(); |
| 136 | 127 |
| 137 scoped_ptr<aura::Window> window1( | 128 scoped_ptr<aura::Window> window1( |
| 138 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); | 129 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); |
| 139 window1->Show(); | 130 window1->Show(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 scoped_ptr<ui::LocatedEvent> converted11(ConvertEvent(window1.get(), | 187 scoped_ptr<ui::LocatedEvent> converted11(ConvertEvent(window1.get(), |
| 197 original11)); | 188 original11)); |
| 198 EXPECT_EQ(original11.type(), converted11->type()); | 189 EXPECT_EQ(original11.type(), converted11->type()); |
| 199 EXPECT_EQ("50,50", converted11->location().ToString()); | 190 EXPECT_EQ("50,50", converted11->location().ToString()); |
| 200 EXPECT_EQ("150,150", converted11->root_location().ToString()); | 191 EXPECT_EQ("150,150", converted11->root_location().ToString()); |
| 201 EXPECT_EQ(original11.flags(), converted11->flags()); | 192 EXPECT_EQ(original11.flags(), converted11->flags()); |
| 202 } | 193 } |
| 203 | 194 |
| 204 } // namespace test | 195 } // namespace test |
| 205 } // namespace aura | 196 } // namespace aura |
| OLD | NEW |