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

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

Issue 1139123009: Ensure async selections after longpress activate the handles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« 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 "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 // Selection movement does not currently trigger a separate event. 568 // Selection movement does not currently trigger a separate event.
569 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_MOVED)); 569 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_MOVED));
570 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); 570 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart());
571 EXPECT_EQ(end_rect.bottom_left(), GetLastEventEnd()); 571 EXPECT_EQ(end_rect.bottom_left(), GetLastEventEnd());
572 572
573 ClearSelection(); 573 ClearSelection();
574 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED)); 574 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_CLEARED));
575 EXPECT_EQ(gfx::PointF(), GetLastEventStart()); 575 EXPECT_EQ(gfx::PointF(), GetLastEventStart());
576 } 576 }
577 577
578 TEST_F(TouchSelectionControllerTest, SelectionAllowsEmptyUpdateAfterLongPress) {
579 gfx::RectF start_rect(5, 5, 0, 10);
580 gfx::RectF end_rect(50, 5, 0, 10);
581 bool visible = true;
582
583 OnLongPressEvent();
584 EXPECT_THAT(GetAndResetEvents(), IsEmpty());
585
586 // There may be several empty updates after a longpress due to the
587 // asynchronous response. These empty updates should not prevent the selection
588 // handles from (eventually) activating.
589 ClearSelection();
590 EXPECT_THAT(GetAndResetEvents(), IsEmpty());
591
592 ClearSelection();
593 EXPECT_THAT(GetAndResetEvents(), IsEmpty());
594
595 ChangeSelection(start_rect, visible, end_rect, visible);
596 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN));
597 }
598
578 TEST_F(TouchSelectionControllerTest, SelectionRepeatedLongPress) { 599 TEST_F(TouchSelectionControllerTest, SelectionRepeatedLongPress) {
579 gfx::RectF start_rect(5, 5, 0, 10); 600 gfx::RectF start_rect(5, 5, 0, 10);
580 gfx::RectF end_rect(50, 5, 0, 10); 601 gfx::RectF end_rect(50, 5, 0, 10);
581 bool visible = true; 602 bool visible = true;
582 603
583 OnLongPressEvent(); 604 OnLongPressEvent();
584 ChangeSelection(start_rect, visible, end_rect, visible); 605 ChangeSelection(start_rect, visible, end_rect, visible);
585 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); 606 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN));
586 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); 607 EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart());
587 EXPECT_EQ(end_rect.bottom_left(), GetLastEventEnd()); 608 EXPECT_EQ(end_rect.bottom_left(), GetLastEventEnd());
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 // A point outside the rect should not be handled. 1040 // A point outside the rect should not be handled.
1020 EXPECT_FALSE(controller().WillHandleLongPressEvent(outer_point)); 1041 EXPECT_FALSE(controller().WillHandleLongPressEvent(outer_point));
1021 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); 1042 EXPECT_THAT(GetAndResetEvents(), IsEmpty());
1022 1043
1023 // A point inside the rect should be handled. 1044 // A point inside the rect should be handled.
1024 EXPECT_TRUE(controller().WillHandleLongPressEvent(inner_point)); 1045 EXPECT_TRUE(controller().WillHandleLongPressEvent(inner_point));
1025 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); 1046 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN));
1026 } 1047 }
1027 1048
1028 } // namespace ui 1049 } // 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