Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: ash/drag_drop/drag_drop_tracker_unittest.cc

Issue 11009010: Set DragDropTracker's capture window's size to zero, otherwise, it gets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/drag_drop/drag_drop_tracker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 static aura::Window* CreateTestWindow(const gfx::Rect& bounds, 25 static aura::Window* CreateTestWindow(const gfx::Rect& bounds,
26 aura::Window* parent) { 26 aura::Window* parent) {
27 static int window_id = 0; 27 static int window_id = 0;
28 return aura::test::CreateTestWindowWithDelegate( 28 return aura::test::CreateTestWindowWithDelegate(
29 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 29 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(),
30 window_id++, 30 window_id++,
31 bounds, 31 bounds,
32 parent); 32 parent);
33 } 33 }
34 34
35 static aura::Window* GetTarget(aura::RootWindow* root_window, 35 static aura::Window* GetTarget(aura::RootWindow* root_window,
mazda 2012/10/01 19:33:24 Could you delete this |root_window| too?
36 const gfx::Point& location) { 36 const gfx::Point& location) {
37 scoped_ptr<internal::DragDropTracker> tracker( 37 scoped_ptr<internal::DragDropTracker> tracker(
38 new internal::DragDropTracker(root_window)); 38 new internal::DragDropTracker);
39 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, 39 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED,
40 location, 40 location,
41 location, 41 location,
42 ui::EF_NONE); 42 ui::EF_NONE);
43 aura::Window* target = tracker->GetTarget(e); 43 aura::Window* target = tracker->GetTarget(e);
44 return target; 44 return target;
45 } 45 }
46 46
47 static ui::MouseEvent* ConvertMouseEvent(aura::RootWindow* root_window, 47 static ui::MouseEvent* ConvertMouseEvent(aura::RootWindow* root_window,
mazda 2012/10/01 19:33:24 Could you delete this one as well?
48 aura::Window* target, 48 aura::Window* target,
49 const ui::MouseEvent& event) { 49 const ui::MouseEvent& event) {
50 scoped_ptr<internal::DragDropTracker> tracker( 50 scoped_ptr<internal::DragDropTracker> tracker(
51 new internal::DragDropTracker(root_window)); 51 new internal::DragDropTracker);
52 ui::MouseEvent* converted = tracker->ConvertMouseEvent(target, event); 52 ui::MouseEvent* converted = tracker->ConvertMouseEvent(target, event);
53 return converted; 53 return converted;
54 } 54 }
55 }; 55 };
56 56
57 // TODO(mazda): Remove this once ash/wm/coordinate_conversion.h supports 57 // TODO(mazda): Remove this once ash/wm/coordinate_conversion.h supports
58 // non-X11 platforms. 58 // non-X11 platforms.
59 #if defined(USE_X11) 59 #if defined(USE_X11)
60 #define MAYBE_GetTarget GetTarget 60 #define MAYBE_GetTarget GetTarget
61 #else 61 #else
62 #define MAYBE_GetTarget DISABLED_GetTarget 62 #define MAYBE_GetTarget DISABLED_GetTarget
63 #endif 63 #endif
64 64
65 TEST_F(DragDropTrackerTest, MAYBE_GetTarget) { 65 TEST_F(DragDropTrackerTest, MAYBE_GetTarget) {
66 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 66 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
67 EXPECT_EQ(2U, root_windows.size()); 67 EXPECT_EQ(2U, root_windows.size());
68 68
69 Shell::GetInstance()->set_active_root_window(root_windows[0]); 69 Shell::GetInstance()->set_active_root_window(root_windows[0]);
70 70
71 scoped_ptr<aura::Window> window0( 71 scoped_ptr<aura::Window> window0(
72 CreateTestWindow(gfx::Rect(0, 0, 100, 100), NULL)); 72 CreateTestWindow(gfx::Rect(0, 0, 100, 100), NULL));
73 window0->Show(); 73 window0->Show();
74 74
75 Shell::GetInstance()->set_active_root_window(root_windows[1]); 75 Shell::GetInstance()->set_active_root_window(root_windows[1]);
76 76
77 scoped_ptr<aura::Window> window1( 77 scoped_ptr<aura::Window> window1(
78 CreateTestWindow(gfx::Rect(100, 100, 100, 100), NULL)); 78 CreateTestWindow(gfx::Rect(100, 100, 100, 100), NULL));
79 window1->Show(); 79 window1->Show();
80 80
mazda 2012/10/01 19:33:24 I guess the active root window needs to be set to
81 // Start tracking from the RootWindow0 and check the point on RootWindow0 that 81 // Start tracking from the RootWindow0 and check the point on RootWindow0 that
82 // |window0| covers. 82 // |window0| covers.
83 EXPECT_EQ(window0.get(), GetTarget(root_windows[0], gfx::Point(50, 50))); 83 EXPECT_EQ(window0.get(), GetTarget(root_windows[0], gfx::Point(50, 50)));
84 84
85 // Start tracking from the RootWindow0 and check the point on RootWindow0 that 85 // Start tracking from the RootWindow0 and check the point on RootWindow0 that
86 // neither |window0| nor |window1| covers. 86 // neither |window0| nor |window1| covers.
87 EXPECT_NE(window0.get(), GetTarget(root_windows[0], gfx::Point(150, 150))); 87 EXPECT_NE(window0.get(), GetTarget(root_windows[0], gfx::Point(150, 150)));
88 EXPECT_NE(window1.get(), GetTarget(root_windows[0], gfx::Point(150, 150))); 88 EXPECT_NE(window1.get(), GetTarget(root_windows[0], gfx::Point(150, 150)));
89 89
90 // Start tracking from the RootWindow0 and check the point on RootWindow1 that 90 // Start tracking from the RootWindow0 and check the point on RootWindow1 that
91 // |window1| covers. 91 // |window1| covers.
92 EXPECT_EQ(window1.get(), GetTarget(root_windows[0], gfx::Point(350, 150))); 92 EXPECT_EQ(window1.get(), GetTarget(root_windows[0], gfx::Point(350, 150)));
93 93
94 // Start tracking from the RootWindow0 and check the point on RootWindow1 that 94 // Start tracking from the RootWindow0 and check the point on RootWindow1 that
95 // neither |window0| nor |window1| covers. 95 // neither |window0| nor |window1| covers.
96 EXPECT_NE(window0.get(), GetTarget(root_windows[0], gfx::Point(50, 250))); 96 EXPECT_NE(window0.get(), GetTarget(root_windows[0], gfx::Point(50, 250)));
97 EXPECT_NE(window1.get(), GetTarget(root_windows[0], gfx::Point(50, 250))); 97 EXPECT_NE(window1.get(), GetTarget(root_windows[0], gfx::Point(50, 250)));
98 98
mazda 2012/10/01 19:33:24 Here too. Shell::GetInstance()->set_active_root_w
99 // Start tracking from the RootWindow1 and check the point on RootWindow0 that 99 // Start tracking from the RootWindow1 and check the point on RootWindow0 that
100 // |window0| covers. 100 // |window0| covers.
101 EXPECT_EQ(window0.get(), GetTarget(root_windows[1], gfx::Point(-150, 50))); 101 EXPECT_EQ(window0.get(), GetTarget(root_windows[1], gfx::Point(-150, 50)));
102 102
103 // Start tracking from the RootWindow1 and check the point on RootWindow0 that 103 // Start tracking from the RootWindow1 and check the point on RootWindow0 that
104 // neither |window0| nor |window1| covers. 104 // neither |window0| nor |window1| covers.
105 EXPECT_NE(window0.get(), GetTarget(root_windows[1], gfx::Point(150, -50))); 105 EXPECT_NE(window0.get(), GetTarget(root_windows[1], gfx::Point(150, -50)));
106 EXPECT_NE(window1.get(), GetTarget(root_windows[1], gfx::Point(150, -50))); 106 EXPECT_NE(window1.get(), GetTarget(root_windows[1], gfx::Point(150, -50)));
107 107
108 // Start tracking from the RootWindow1 and check the point on RootWindow1 that 108 // Start tracking from the RootWindow1 and check the point on RootWindow1 that
(...skipping 20 matching lines...) Expand all
129 129
130 Shell::GetInstance()->set_active_root_window(root_windows[0]); 130 Shell::GetInstance()->set_active_root_window(root_windows[0]);
131 scoped_ptr<aura::Window> window0( 131 scoped_ptr<aura::Window> window0(
132 CreateTestWindow(gfx::Rect(0, 0, 100, 100), NULL)); 132 CreateTestWindow(gfx::Rect(0, 0, 100, 100), NULL));
133 window0->Show(); 133 window0->Show();
134 134
135 Shell::GetInstance()->set_active_root_window(root_windows[1]); 135 Shell::GetInstance()->set_active_root_window(root_windows[1]);
136 scoped_ptr<aura::Window> window1( 136 scoped_ptr<aura::Window> window1(
137 CreateTestWindow(gfx::Rect(100, 100, 100, 100), NULL)); 137 CreateTestWindow(gfx::Rect(100, 100, 100, 100), NULL));
138 window1->Show(); 138 window1->Show();
139 139
mazda 2012/10/01 19:33:24 Shell::GetInstance()->set_active_root_window(root_
140 // Start tracking from the RootWindow0 and converts the mouse event into 140 // Start tracking from the RootWindow0 and converts the mouse event into
141 // |window0|'s coodinates. 141 // |window0|'s coodinates.
142 ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, 142 ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED,
143 gfx::Point(50, 50), 143 gfx::Point(50, 50),
144 gfx::Point(50, 50), 144 gfx::Point(50, 50),
145 ui::EF_NONE); 145 ui::EF_NONE);
146 scoped_ptr<ui::MouseEvent> converted00(ConvertMouseEvent(root_windows[0], 146 scoped_ptr<ui::MouseEvent> converted00(ConvertMouseEvent(root_windows[0],
147 window0.get(), 147 window0.get(),
148 original00)); 148 original00));
149 EXPECT_EQ(original00.type(), converted00->type()); 149 EXPECT_EQ(original00.type(), converted00->type());
150 EXPECT_EQ("50,50", converted00->location().ToString()); 150 EXPECT_EQ("50,50", converted00->location().ToString());
151 EXPECT_EQ("50,50", converted00->root_location().ToString()); 151 EXPECT_EQ("50,50", converted00->root_location().ToString());
152 EXPECT_EQ(original00.flags(), converted00->flags()); 152 EXPECT_EQ(original00.flags(), converted00->flags());
153 153
154 // Start tracking from the RootWindow0 and converts the mouse event into 154 // Start tracking from the RootWindow0 and converts the mouse event into
155 // |window1|'s coodinates. 155 // |window1|'s coodinates.
156 ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, 156 ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED,
157 gfx::Point(350, 150), 157 gfx::Point(350, 150),
158 gfx::Point(350, 150), 158 gfx::Point(350, 150),
159 ui::EF_NONE); 159 ui::EF_NONE);
160 scoped_ptr<ui::MouseEvent> converted01(ConvertMouseEvent(root_windows[0], 160 scoped_ptr<ui::MouseEvent> converted01(ConvertMouseEvent(root_windows[0],
161 window1.get(), 161 window1.get(),
162 original01)); 162 original01));
163 EXPECT_EQ(original01.type(), converted01->type()); 163 EXPECT_EQ(original01.type(), converted01->type());
164 EXPECT_EQ("50,50", converted01->location().ToString()); 164 EXPECT_EQ("50,50", converted01->location().ToString());
165 EXPECT_EQ("150,150", converted01->root_location().ToString()); 165 EXPECT_EQ("150,150", converted01->root_location().ToString());
166 EXPECT_EQ(original01.flags(), converted01->flags()); 166 EXPECT_EQ(original01.flags(), converted01->flags());
167 167
mazda 2012/10/01 19:33:24 Shell::GetInstance()->set_active_root_window(root_
168 // Start tracking from the RootWindow1 and converts the mouse event into 168 // Start tracking from the RootWindow1 and converts the mouse event into
169 // |window0|'s coodinates. 169 // |window0|'s coodinates.
170 ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, 170 ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED,
171 gfx::Point(-150, 50), 171 gfx::Point(-150, 50),
172 gfx::Point(-150, 50), 172 gfx::Point(-150, 50),
173 ui::EF_NONE); 173 ui::EF_NONE);
174 scoped_ptr<ui::MouseEvent> converted10(ConvertMouseEvent(root_windows[1], 174 scoped_ptr<ui::MouseEvent> converted10(ConvertMouseEvent(root_windows[1],
175 window0.get(), 175 window0.get(),
176 original10)); 176 original10));
177 EXPECT_EQ(original10.type(), converted10->type()); 177 EXPECT_EQ(original10.type(), converted10->type());
(...skipping 11 matching lines...) Expand all
189 window1.get(), 189 window1.get(),
190 original11)); 190 original11));
191 EXPECT_EQ(original11.type(), converted11->type()); 191 EXPECT_EQ(original11.type(), converted11->type());
192 EXPECT_EQ("50,50", converted11->location().ToString()); 192 EXPECT_EQ("50,50", converted11->location().ToString());
193 EXPECT_EQ("150,150", converted11->root_location().ToString()); 193 EXPECT_EQ("150,150", converted11->root_location().ToString());
194 EXPECT_EQ(original11.flags(), converted11->flags()); 194 EXPECT_EQ(original11.flags(), converted11->flags());
195 } 195 }
196 196
197 } // namespace test 197 } // namespace test
198 } // namespace aura 198 } // namespace aura
OLDNEW
« no previous file with comments | « ash/drag_drop/drag_drop_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698