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

Side by Side Diff: content/browser/renderer_host/input/touch_selection_controller_unittest.cc

Issue 486763004: Fixed the issue of insertion handle not clearing on single tap on empty field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit testcase and fixed nits. Created 6 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
« no previous file with comments | « content/browser/renderer_host/input/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 "content/browser/renderer_host/input/touch_selection_controller.h" 5 #include "content/browser/renderer_host/input/touch_selection_controller.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/events/test/mock_motion_event.h" 8 #include "ui/events/test/mock_motion_event.h"
9 9
10 using ui::test::MockMotionEvent; 10 using ui::test::MockMotionEvent;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 controller().HideAndDisallowShowingAutomatically(); 249 controller().HideAndDisallowShowingAutomatically();
250 EXPECT_EQ(INSERTION_CLEARED, GetLastEventType()); 250 EXPECT_EQ(INSERTION_CLEARED, GetLastEventType());
251 251
252 // Long-pressing should show the handle even if the editable region is empty. 252 // Long-pressing should show the handle even if the editable region is empty.
253 insertion_rect.Offset(2, -2); 253 insertion_rect.Offset(2, -2);
254 controller().OnLongPressEvent(); 254 controller().OnLongPressEvent();
255 controller().OnSelectionEmpty(true); 255 controller().OnSelectionEmpty(true);
256 ChangeInsertion(insertion_rect, visible); 256 ChangeInsertion(insertion_rect, visible);
257 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType()); 257 EXPECT_EQ(INSERTION_SHOWN, GetLastEventType());
258 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor()); 258 EXPECT_EQ(insertion_rect.bottom_left(), GetLastEventAnchor());
259
260 // Single Tap on an empty edit field should clear insertion handle.
261 controller().OnTapEvent();
262 EXPECT_EQ(INSERTION_CLEARED, GetLastEventType());
259 } 263 }
260 264
261 TEST_F(TouchSelectionControllerTest, InsertionAppearsAfterTapFollowingTyping) { 265 TEST_F(TouchSelectionControllerTest, InsertionAppearsAfterTapFollowingTyping) {
262 gfx::RectF insertion_rect(5, 5, 0, 10); 266 gfx::RectF insertion_rect(5, 5, 0, 10);
263 bool visible = true; 267 bool visible = true;
264 268
265 // Simulate the user tapping an empty text field. 269 // Simulate the user tapping an empty text field.
266 controller().OnTapEvent(); 270 controller().OnTapEvent();
267 controller().OnSelectionEditable(true); 271 controller().OnSelectionEditable(true);
268 controller().OnSelectionEmpty(true); 272 controller().OnSelectionEmpty(true);
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 646
643 visible = true; 647 visible = true;
644 ChangeInsertion(insertion_rect, visible); 648 ChangeInsertion(insertion_rect, visible);
645 EXPECT_FALSE(GetAndResetNeedsAnimate()); 649 EXPECT_FALSE(GetAndResetNeedsAnimate());
646 650
647 controller().SetTemporarilyHidden(false); 651 controller().SetTemporarilyHidden(false);
648 EXPECT_TRUE(GetAndResetNeedsAnimate()); 652 EXPECT_TRUE(GetAndResetNeedsAnimate());
649 } 653 }
650 654
651 } // namespace content 655 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698