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

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

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 years, 4 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
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 13 matching lines...) Expand all
24 static int window_id = 0; 24 static int window_id = 0;
25 return CreateTestWindowInShellWithDelegate( 25 return CreateTestWindowInShellWithDelegate(
26 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 26 aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(),
27 window_id++, 27 window_id++,
28 bounds); 28 bounds);
29 } 29 }
30 30
31 static aura::Window* GetTarget(const gfx::Point& location) { 31 static aura::Window* GetTarget(const gfx::Point& location) {
32 scoped_ptr<DragDropTracker> tracker( 32 scoped_ptr<DragDropTracker> tracker(
33 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); 33 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL));
34 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, location, location, 34 ui::MouseEvent e(
35 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 35 ui::ET_MOUSE_DRAGGED, location, location, ui::EventTimeForNow(),
36 ui::EF_NONE, ui::EF_NONE,
37 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
36 aura::Window* target = tracker->GetTarget(e); 38 aura::Window* target = tracker->GetTarget(e);
37 return target; 39 return target;
38 } 40 }
39 41
40 static ui::LocatedEvent* ConvertEvent(aura::Window* target, 42 static ui::LocatedEvent* ConvertEvent(aura::Window* target,
41 const ui::MouseEvent& event) { 43 const ui::MouseEvent& event) {
42 scoped_ptr<DragDropTracker> tracker( 44 scoped_ptr<DragDropTracker> tracker(
43 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL)); 45 new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL));
44 ui::LocatedEvent* converted = tracker->ConvertEvent(target, event); 46 ui::LocatedEvent* converted = tracker->ConvertEvent(target, event);
45 return converted; 47 return converted;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 125
124 scoped_ptr<aura::Window> window1( 126 scoped_ptr<aura::Window> window1(
125 CreateTestWindow(gfx::Rect(300, 100, 100, 100))); 127 CreateTestWindow(gfx::Rect(300, 100, 100, 100)));
126 window1->Show(); 128 window1->Show();
127 129
128 // Make RootWindow0 active so that capture window is parented to it. 130 // Make RootWindow0 active so that capture window is parented to it.
129 Shell::GetInstance()->set_target_root_window(root_windows[0]); 131 Shell::GetInstance()->set_target_root_window(root_windows[0]);
130 132
131 // Start tracking from the RootWindow0 and converts the mouse event into 133 // Start tracking from the RootWindow0 and converts the mouse event into
132 // |window0|'s coodinates. 134 // |window0|'s coodinates.
133 ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), 135 ui::MouseEvent original00(
134 gfx::Point(50, 50), ui::EventTimeForNow(), 136 ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50), gfx::Point(50, 50),
135 ui::EF_NONE, ui::EF_NONE); 137 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
138 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
136 scoped_ptr<ui::LocatedEvent> converted00(ConvertEvent(window0.get(), 139 scoped_ptr<ui::LocatedEvent> converted00(ConvertEvent(window0.get(),
137 original00)); 140 original00));
138 EXPECT_EQ(original00.type(), converted00->type()); 141 EXPECT_EQ(original00.type(), converted00->type());
139 EXPECT_EQ("50,50", converted00->location().ToString()); 142 EXPECT_EQ("50,50", converted00->location().ToString());
140 EXPECT_EQ("50,50", converted00->root_location().ToString()); 143 EXPECT_EQ("50,50", converted00->root_location().ToString());
141 EXPECT_EQ(original00.flags(), converted00->flags()); 144 EXPECT_EQ(original00.flags(), converted00->flags());
142 145
143 // Start tracking from the RootWindow0 and converts the mouse event into 146 // Start tracking from the RootWindow0 and converts the mouse event into
144 // |window1|'s coodinates. 147 // |window1|'s coodinates.
145 ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), 148 ui::MouseEvent original01(
146 gfx::Point(350, 150), ui::EventTimeForNow(), 149 ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150), gfx::Point(350, 150),
147 ui::EF_NONE, ui::EF_NONE); 150 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
151 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
148 scoped_ptr<ui::LocatedEvent> converted01(ConvertEvent(window1.get(), 152 scoped_ptr<ui::LocatedEvent> converted01(ConvertEvent(window1.get(),
149 original01)); 153 original01));
150 EXPECT_EQ(original01.type(), converted01->type()); 154 EXPECT_EQ(original01.type(), converted01->type());
151 EXPECT_EQ("50,50", converted01->location().ToString()); 155 EXPECT_EQ("50,50", converted01->location().ToString());
152 EXPECT_EQ("150,150", converted01->root_location().ToString()); 156 EXPECT_EQ("150,150", converted01->root_location().ToString());
153 EXPECT_EQ(original01.flags(), converted01->flags()); 157 EXPECT_EQ(original01.flags(), converted01->flags());
154 158
155 // Make RootWindow1 active so that capture window is parented to it. 159 // Make RootWindow1 active so that capture window is parented to it.
156 Shell::GetInstance()->set_target_root_window(root_windows[1]); 160 Shell::GetInstance()->set_target_root_window(root_windows[1]);
157 161
158 // Start tracking from the RootWindow1 and converts the mouse event into 162 // Start tracking from the RootWindow1 and converts the mouse event into
159 // |window0|'s coodinates. 163 // |window0|'s coodinates.
160 ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), 164 ui::MouseEvent original10(
161 gfx::Point(-150, 50), ui::EventTimeForNow(), 165 ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50), gfx::Point(-150, 50),
162 ui::EF_NONE, ui::EF_NONE); 166 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
167 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
163 scoped_ptr<ui::LocatedEvent> converted10(ConvertEvent(window0.get(), 168 scoped_ptr<ui::LocatedEvent> converted10(ConvertEvent(window0.get(),
164 original10)); 169 original10));
165 EXPECT_EQ(original10.type(), converted10->type()); 170 EXPECT_EQ(original10.type(), converted10->type());
166 EXPECT_EQ("50,50", converted10->location().ToString()); 171 EXPECT_EQ("50,50", converted10->location().ToString());
167 EXPECT_EQ("50,50", converted10->root_location().ToString()); 172 EXPECT_EQ("50,50", converted10->root_location().ToString());
168 EXPECT_EQ(original10.flags(), converted10->flags()); 173 EXPECT_EQ(original10.flags(), converted10->flags());
169 174
170 // Start tracking from the RootWindow1 and converts the mouse event into 175 // Start tracking from the RootWindow1 and converts the mouse event into
171 // |window1|'s coodinates. 176 // |window1|'s coodinates.
172 ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), 177 ui::MouseEvent original11(
173 gfx::Point(150, 150), ui::EventTimeForNow(), 178 ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150), gfx::Point(150, 150),
174 ui::EF_NONE, ui::EF_NONE); 179 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
180 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
175 scoped_ptr<ui::LocatedEvent> converted11(ConvertEvent(window1.get(), 181 scoped_ptr<ui::LocatedEvent> converted11(ConvertEvent(window1.get(),
176 original11)); 182 original11));
177 EXPECT_EQ(original11.type(), converted11->type()); 183 EXPECT_EQ(original11.type(), converted11->type());
178 EXPECT_EQ("50,50", converted11->location().ToString()); 184 EXPECT_EQ("50,50", converted11->location().ToString());
179 EXPECT_EQ("150,150", converted11->root_location().ToString()); 185 EXPECT_EQ("150,150", converted11->root_location().ToString());
180 EXPECT_EQ(original11.flags(), converted11->flags()); 186 EXPECT_EQ(original11.flags(), converted11->flags());
181 } 187 }
182 188
183 } // namespace test 189 } // namespace test
184 } // namespace aura 190 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698