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

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

Issue 2733603003: Tapping/longpressing should result in INSERTION_HANDLE_SHOWN (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « ui/touch_selection/touch_selection_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 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/touch_selection_controller.h" 5 #include "ui/touch_selection/touch_selection_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 insertion_rect.Offset(1, 0); 248 insertion_rect.Offset(1, 0);
249 ChangeInsertion(insertion_rect, visible); 249 ChangeInsertion(insertion_rect, visible);
250 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_MOVED)); 250 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_MOVED));
251 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart()); 251 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart());
252 252
253 insertion_rect.Offset(0, 1); 253 insertion_rect.Offset(0, 1);
254 ChangeInsertion(insertion_rect, visible); 254 ChangeInsertion(insertion_rect, visible);
255 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_MOVED)); 255 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_MOVED));
256 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart()); 256 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart());
257 257
258 OnTapEvent();
259 insertion_rect.Offset(1, 0);
260 ChangeInsertion(insertion_rect, visible);
261 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_SHOWN));
262 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventStart());
263
258 ClearInsertion(); 264 ClearInsertion();
259 EXPECT_THAT(GetAndResetEvents(), 265 EXPECT_THAT(GetAndResetEvents(),
260 ElementsAre(INSERTION_HANDLE_CLEARED)); 266 ElementsAre(INSERTION_HANDLE_CLEARED));
261 } 267 }
262 268
263 TEST_F(TouchSelectionControllerTest, InsertionToSelectionTransition) { 269 TEST_F(TouchSelectionControllerTest, InsertionToSelectionTransition) {
264 OnLongPressEvent(); 270 OnLongPressEvent();
265 271
266 gfx::RectF start_rect(5, 5, 0, 10); 272 gfx::RectF start_rect(5, 5, 0, 10);
267 gfx::RectF end_rect(50, 5, 0, 10); 273 gfx::RectF end_rect(50, 5, 0, 10);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 SetDraggingEnabled(true); 481 SetDraggingEnabled(true);
476 482
477 gfx::RectF anchor_rect(10, 0, 0, 10); 483 gfx::RectF anchor_rect(10, 0, 0, 10);
478 bool visible = true; 484 bool visible = true;
479 ChangeInsertion(anchor_rect, visible); 485 ChangeInsertion(anchor_rect, visible);
480 EXPECT_THAT(GetAndResetEvents(), 486 EXPECT_THAT(GetAndResetEvents(),
481 ElementsAre(INSERTION_HANDLE_SHOWN)); 487 ElementsAre(INSERTION_HANDLE_SHOWN));
482 EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventStart()); 488 EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventStart());
483 489
484 // Tapping again shouldn't reset the active insertion point. 490 // Tapping again shouldn't reset the active insertion point.
485 OnTapEvent();
mohsen 2017/03/07 03:30:10 Can you explain why this is removed. We are simula
amaralp 2017/03/07 04:20:38 Tapping on the handle will cause |TouchSelectionCo
486 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0); 491 MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0);
487 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); 492 EXPECT_TRUE(controller().WillHandleTouchEvent(event));
488 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_DRAG_STARTED)); 493 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_DRAG_STARTED));
489 EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventStart()); 494 EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventStart());
490 495
491 event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 0, 0); 496 event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 0, 0);
492 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); 497 EXPECT_TRUE(controller().WillHandleTouchEvent(event));
493 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_TAPPED, 498 EXPECT_THAT(GetAndResetEvents(), ElementsAre(INSERTION_HANDLE_TAPPED,
494 INSERTION_HANDLE_DRAG_STOPPED)); 499 INSERTION_HANDLE_DRAG_STOPPED));
495 EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventStart()); 500 EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventStart());
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 offset_rect.x(), offset_rect.bottom()); 1249 offset_rect.x(), offset_rect.bottom());
1245 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); 1250 EXPECT_TRUE(controller().WillHandleTouchEvent(event));
1246 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_HANDLE_DRAG_STOPPED)); 1251 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_HANDLE_DRAG_STOPPED));
1247 EXPECT_EQ(test_controller.GetStartHandleOrientation(), 1252 EXPECT_EQ(test_controller.GetStartHandleOrientation(),
1248 TouchHandleOrientation::LEFT); 1253 TouchHandleOrientation::LEFT);
1249 EXPECT_EQ(test_controller.GetEndHandleOrientation(), 1254 EXPECT_EQ(test_controller.GetEndHandleOrientation(),
1250 TouchHandleOrientation::RIGHT); 1255 TouchHandleOrientation::RIGHT);
1251 } 1256 }
1252 1257
1253 } // namespace ui 1258 } // namespace ui
OLDNEW
« no previous file with comments | « ui/touch_selection/touch_selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698