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

Side by Side Diff: ui/touch_selection/longpress_drag_selector_unittest.cc

Issue 1424683002: Refactor TouchSelectionDraggableClient APIs Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « ui/touch_selection/longpress_drag_selector.cc ('k') | ui/touch_selection/touch_handle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/touch_selection/longpress_drag_selector.h" 5 #include "ui/touch_selection/longpress_drag_selector.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/events/test/motion_event_test_utils.h" 8 #include "ui/events/test/motion_event_test_utils.h"
9 9
10 using ui::test::MockMotionEvent; 10 using ui::test::MockMotionEvent;
(...skipping 21 matching lines...) Expand all
32 bool GetAndResetActiveStateChanged() { 32 bool GetAndResetActiveStateChanged() {
33 bool active_state_changed = active_state_changed_; 33 bool active_state_changed = active_state_changed_;
34 active_state_changed_ = false; 34 active_state_changed_ = false;
35 return active_state_changed; 35 return active_state_changed;
36 } 36 }
37 37
38 bool IsDragging() const { return dragging_; } 38 bool IsDragging() const { return dragging_; }
39 const gfx::PointF& DragPosition() const { return drag_position_; } 39 const gfx::PointF& DragPosition() const { return drag_position_; }
40 40
41 // LongPressDragSelectorClient implementation. 41 // LongPressDragSelectorClient implementation.
42 void OnDragBegin(const TouchSelectionDraggable& handler, 42 void OnDragEvent(const TouchHandleDragEvent event,
43 const gfx::PointF& drag_position) override { 43 const TouchSelectionDraggable& draggable,
44 dragging_ = true; 44 const gfx::PointF& position) override {
45 drag_position_ = drag_position; 45 switch (event) {
46 } 46 case HANDLE_DRAG_BEGIN:
47 47 dragging_ = true;
48 void OnDragUpdate(const TouchSelectionDraggable& handler, 48 drag_position_ = position;
49 const gfx::PointF& drag_position) override { 49 break;
50 drag_position_ = drag_position; 50 case HANDLE_DRAG_UPDATE:
51 } 51 drag_position_ = position;
52 52 break;
53 void OnDragEnd(const TouchSelectionDraggable& handler) override { 53 case HANDLE_DRAG_END:
54 dragging_ = false; 54 dragging_ = false;
55 default:
56 NOTREACHED() << "Invalid handle drag event";
57 }
55 } 58 }
56 59
57 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override { 60 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override {
58 return delta.LengthSquared() < (kSlop * kSlop); 61 return delta.LengthSquared() < (kSlop * kSlop);
59 } 62 }
60 63
61 void OnLongPressDragActiveStateChanged() override { 64 void OnLongPressDragActiveStateChanged() override {
62 active_state_changed_ = true; 65 active_state_changed_ = true;
63 } 66 }
64 67
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 EXPECT_TRUE(IsDragging()); 361 EXPECT_TRUE(IsDragging());
359 EXPECT_EQ(selection_end, DragPosition()); 362 EXPECT_EQ(selection_end, DragPosition());
360 363
361 // Release the touch sequence, ending the drag. 364 // Release the touch sequence, ending the drag.
362 EXPECT_FALSE(selector.WillHandleTouchEvent(event.ReleasePoint())); 365 EXPECT_FALSE(selector.WillHandleTouchEvent(event.ReleasePoint()));
363 EXPECT_FALSE(IsDragging()); 366 EXPECT_FALSE(IsDragging());
364 EXPECT_TRUE(GetAndResetActiveStateChanged()); 367 EXPECT_TRUE(GetAndResetActiveStateChanged());
365 } 368 }
366 369
367 } // namespace ui 370 } // namespace ui
OLDNEW
« no previous file with comments | « ui/touch_selection/longpress_drag_selector.cc ('k') | ui/touch_selection/touch_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698