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

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

Issue 15889009: ash: Stop propagation of gesture events when drag drop is in progress. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 7 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_controller.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_controller.h" 5 #include "ash/drag_drop/drag_drop_controller.h"
6 6
7 #include "ash/drag_drop/drag_drop_tracker.h" 7 #include "ash/drag_drop/drag_drop_tracker.h"
8 #include "ash/drag_drop/drag_image_view.h" 8 #include "ash/drag_drop/drag_image_view.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 gesture_type, 279 gesture_type,
280 location.x(), 280 location.x(),
281 location.y(), 281 location.y(),
282 0, 282 0,
283 ui::EventTimeForNow(), 283 ui::EventTimeForNow(),
284 ui::GestureEventDetails(gesture_type, 0, 0), 284 ui::GestureEventDetails(gesture_type, 0, 0),
285 1); 285 1);
286 Shell::GetPrimaryRootWindow()->DispatchGestureEvent(&gesture_event); 286 Shell::GetPrimaryRootWindow()->DispatchGestureEvent(&gesture_event);
287 } 287 }
288 288
289 bool IsGestureEventType(ui::EventType type) {
290 switch (type) {
291 case ui::ET_GESTURE_SCROLL_BEGIN:
292 case ui::ET_GESTURE_SCROLL_END:
293 case ui::ET_GESTURE_SCROLL_UPDATE:
294 case ui::ET_GESTURE_TAP:
295 case ui::ET_GESTURE_TAP_CANCEL:
296 case ui::ET_GESTURE_TAP_DOWN:
297 case ui::ET_GESTURE_BEGIN:
298 case ui::ET_GESTURE_END:
299 case ui::ET_GESTURE_TWO_FINGER_TAP:
300 case ui::ET_GESTURE_PINCH_BEGIN:
301 case ui::ET_GESTURE_PINCH_END:
302 case ui::ET_GESTURE_PINCH_UPDATE:
303 case ui::ET_GESTURE_LONG_PRESS:
304 case ui::ET_GESTURE_LONG_TAP:
305 case ui::ET_GESTURE_MULTIFINGER_SWIPE:
306 case ui::ET_SCROLL_FLING_CANCEL:
307 case ui::ET_SCROLL_FLING_START:
308 return true;
309 default:
310 break;
311 }
312 return false;
313 }
314
289 } // namespace 315 } // namespace
290 316
291 class DragDropControllerTest : public AshTestBase { 317 class DragDropControllerTest : public AshTestBase {
292 public: 318 public:
293 DragDropControllerTest() : AshTestBase() {} 319 DragDropControllerTest() : AshTestBase() {}
294 virtual ~DragDropControllerTest() {} 320 virtual ~DragDropControllerTest() {}
295 321
296 virtual void SetUp() OVERRIDE { 322 virtual void SetUp() OVERRIDE {
297 AshTestBase::SetUp(); 323 AshTestBase::SetUp();
298 drag_drop_controller_.reset(new TestDragDropController); 324 drag_drop_controller_.reset(new TestDragDropController);
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 1167 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
1142 1168
1143 // Since dragging has started, |handler| should not receive unhandled events. 1169 // Since dragging has started, |handler| should not receive unhandled events.
1144 UpdateDragData(&data); 1170 UpdateDragData(&data);
1145 gfx::Point gesture_location = point; 1171 gfx::Point gesture_location = point;
1146 int num_drags = drag_view->width(); 1172 int num_drags = drag_view->width();
1147 for (int i = 0; i < num_drags; ++i) { 1173 for (int i = 0; i < num_drags; ++i) {
1148 gesture_location.Offset(1, 0); 1174 gesture_location.Offset(1, 0);
1149 handler.Reset(); 1175 handler.Reset();
1150 DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location); 1176 DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location);
1151 EXPECT_TRUE(handler.handled_event_received()); 1177 EXPECT_FALSE(handler.handled_event_received());
1152 EXPECT_FALSE(handler.unhandled_event_received()); 1178 EXPECT_FALSE(handler.unhandled_event_received());
1153 1179
1154 // Execute any scheduled draws to process deferred mouse events. 1180 // Execute any scheduled draws to process deferred mouse events.
1181 RunAllPendingInMessageLoop();
1182 }
1183
1184 // Handler should not receive any other gestures that DragDropController
1185 // does not care about.
1186 std::set<ui::EventType> drag_drop_gestures;
1187 drag_drop_gestures.insert(ui::ET_GESTURE_SCROLL_UPDATE);
1188 drag_drop_gestures.insert(ui::ET_GESTURE_SCROLL_END);
1189 drag_drop_gestures.insert(ui::ET_GESTURE_LONG_TAP);
1190 drag_drop_gestures.insert(ui::ET_SCROLL_FLING_START);
1191 for (ui::EventType type = ui::ET_UNKNOWN; type < ui::ET_LAST;
1192 type = static_cast<ui::EventType>(type + 1)) {
1193 if (!IsGestureEventType(type) ||
1194 drag_drop_gestures.find(type) != drag_drop_gestures.end())
1195 continue;
1196
1197 handler.Reset();
1198 DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location);
1199 EXPECT_FALSE(handler.handled_event_received());
1200 EXPECT_FALSE(handler.unhandled_event_received());
1201
1202 // Execute any scheduled draws to process deferred mouse events.
1155 RunAllPendingInMessageLoop(); 1203 RunAllPendingInMessageLoop();
1156 } 1204 }
1157 1205
1158 // End dragging. 1206 // End dragging.
1159 DispatchGesture(ui::ET_GESTURE_SCROLL_END, gesture_location); 1207 DispatchGesture(ui::ET_GESTURE_SCROLL_END, gesture_location);
1160 EXPECT_TRUE(drag_drop_controller_->drop_received_); 1208 EXPECT_TRUE(drag_drop_controller_->drop_received_);
1161 } 1209 }
1162 1210
1163 } // namespace test 1211 } // namespace test
1164 } // namespace aura 1212 } // namespace aura
OLDNEW
« no previous file with comments | « ash/drag_drop/drag_drop_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698