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

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

Issue 359033002: [Android] Enable composited selection updates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_native_handles_0_compositor
Patch Set: Rebase Created 6 years, 3 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 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 EXPECT_FALSE(GetAndResetNeedsAnimate()); 625 EXPECT_FALSE(GetAndResetNeedsAnimate());
626 626
627 // If the client doesn't support animation, no animation should be triggered. 627 // If the client doesn't support animation, no animation should be triggered.
628 SetAnimationEnabled(false); 628 SetAnimationEnabled(false);
629 controller().OnTapEvent(); 629 controller().OnTapEvent();
630 visible = true; 630 visible = true;
631 ChangeInsertion(insertion_rect, visible); 631 ChangeInsertion(insertion_rect, visible);
632 EXPECT_FALSE(GetAndResetNeedsAnimate()); 632 EXPECT_FALSE(GetAndResetNeedsAnimate());
633 } 633 }
634 634
635 TEST_F(TouchSelectionControllerTest, TemporarilyHidden) {
636 controller().OnTapEvent();
637 controller().OnSelectionEditable(true);
638
639 gfx::RectF insertion_rect(5, 5, 0, 10);
640
641 bool visible = true;
642 ChangeInsertion(insertion_rect, visible);
643 EXPECT_FALSE(GetAndResetNeedsAnimate());
644
645 controller().SetTemporarilyHidden(true);
646 EXPECT_TRUE(GetAndResetNeedsAnimate());
647
648 visible = false;
649 ChangeInsertion(insertion_rect, visible);
650 EXPECT_FALSE(GetAndResetNeedsAnimate());
651
652 visible = true;
653 ChangeInsertion(insertion_rect, visible);
654 EXPECT_FALSE(GetAndResetNeedsAnimate());
655
656 controller().SetTemporarilyHidden(false);
657 EXPECT_TRUE(GetAndResetNeedsAnimate());
658 }
659
660 TEST_F(TouchSelectionControllerTest, SelectionClearOnTap) { 635 TEST_F(TouchSelectionControllerTest, SelectionClearOnTap) {
661 gfx::RectF start_rect(5, 5, 0, 10); 636 gfx::RectF start_rect(5, 5, 0, 10);
662 gfx::RectF end_rect(50, 5, 0, 10); 637 gfx::RectF end_rect(50, 5, 0, 10);
663 bool visible = true; 638 bool visible = true;
664 639
665 controller().OnLongPressEvent(); 640 controller().OnLongPressEvent();
666 ChangeSelection(start_rect, visible, end_rect, visible); 641 ChangeSelection(start_rect, visible, end_rect, visible);
667 642
668 // Selection should not be cleared if the selection bounds have not changed. 643 // Selection should not be cleared if the selection bounds have not changed.
669 controller().OnTapEvent(); 644 controller().OnTapEvent();
670 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType()); 645 EXPECT_EQ(SELECTION_SHOWN, GetLastEventType());
671 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor()); 646 EXPECT_EQ(start_rect.bottom_left(), GetLastEventAnchor());
672 647
673 controller().OnTapEvent(); 648 controller().OnTapEvent();
674 ClearSelection(); 649 ClearSelection();
675 EXPECT_EQ(SELECTION_CLEARED, GetLastEventType()); 650 EXPECT_EQ(SELECTION_CLEARED, GetLastEventType());
676 EXPECT_EQ(gfx::PointF(), GetLastEventAnchor()); 651 EXPECT_EQ(gfx::PointF(), GetLastEventAnchor());
677 } 652 }
678 653
679 } // namespace content 654 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698