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

Unified Diff: athena/home/home_card_gesture_manager_unittest.cc

Issue 581933004: Update gesture logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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 side-by-side diff with in-line comments
Download patch
Index: athena/home/home_card_gesture_manager_unittest.cc
diff --git a/athena/home/home_card_gesture_manager_unittest.cc b/athena/home/home_card_gesture_manager_unittest.cc
index aea59b813cf4a7f8cc848829ef4d78d87fb13cf0..f1dac20d5ef9a1bf437ce5f0001b12eca34a9490 100644
--- a/athena/home/home_card_gesture_manager_unittest.cc
+++ b/athena/home/home_card_gesture_manager_unittest.cc
@@ -66,6 +66,7 @@ class HomeCardGestureManagerTest : public test::AthenaTestBase,
last_y_ = y;
return event.handled();
}
+
void ProcessFlingGesture(float velocity) {
ui::GestureEvent event(0, last_y_, ui::EF_NONE, base::TimeDelta(),
ui::GestureEventDetails(
@@ -73,6 +74,10 @@ class HomeCardGestureManagerTest : public test::AthenaTestBase,
gesture_manager_->ProcessGestureEvent(&event);
}
+ int screen_height() const {
+ return screen_bounds().height();
+ }
+
HomeCard::State final_state_;
HomeCard::State last_from_state_;
HomeCard::State last_to_state_;
@@ -180,9 +185,41 @@ TEST_F(HomeCardGestureManagerTest, StartCentered) {
EXPECT_GT(1.0f, last_progress_);
EXPECT_LT(0.0f, last_progress_);
- EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 1000));
+ ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 960);
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 960));
+ EXPECT_EQ(1, GetEndCountAndReset());
+ EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, final_state_);
+}
+
+// Test gesture progress when the gesture is initiated when the home card is in
+// the centered state.
+TEST_F(HomeCardGestureManagerTest, StartBottom) {
+ HomeCard::Get()->SetState(HomeCard::VISIBLE_BOTTOM);
+
+ // No changes for slight moves.
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 950));
+ ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 960);
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 960));
EXPECT_EQ(1, GetEndCountAndReset());
EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
+
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 950));
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 800));
+ EXPECT_EQ(1, GetEndCountAndReset());
+ EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
+
+ // State change for the bigger moves.
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 950));
+ ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1000);
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 1000));
+ EXPECT_EQ(1, GetEndCountAndReset());
+ EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, final_state_);
+
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 950));
+ ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 300);
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 300));
+ EXPECT_EQ(1, GetEndCountAndReset());
+ EXPECT_EQ(HomeCard::VISIBLE_CENTERED, final_state_);
}
TEST_F(HomeCardGestureManagerTest, FlingUpAtEnd) {
@@ -193,22 +230,20 @@ TEST_F(HomeCardGestureManagerTest, FlingUpAtEnd) {
EXPECT_EQ(0, GetProgressCountAndReset());
ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010);
- ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 800);
ProcessFlingGesture(-150.0f);
EXPECT_EQ(1, GetEndCountAndReset());
- EXPECT_EQ(HomeCard::VISIBLE_CENTERED, final_state_);
+ EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
}
TEST_F(HomeCardGestureManagerTest, FlingDownAtEnd) {
- ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
+ HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED);
- EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 1020));
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 20));
EXPECT_EQ(0, GetEndCountAndReset());
EXPECT_EQ(0, GetProgressCountAndReset());
- ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010);
- ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 800);
- ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 200);
+ ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 30);
+ ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 100);
ProcessFlingGesture(150.0f);
EXPECT_EQ(1, GetEndCountAndReset());
EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
@@ -222,9 +257,29 @@ TEST_F(HomeCardGestureManagerTest, WeakFling) {
EXPECT_EQ(0, GetProgressCountAndReset());
ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010);
- ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 800);
ProcessFlingGesture(-30.0f);
EXPECT_EQ(1, GetEndCountAndReset());
+ EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, final_state_);
+}
+
pkotwicz 2014/09/18 22:15:32 I now understand what the test tests. Thank you fo
Jun Mukai 2014/09/18 22:33:33 Done.
+// This test case adresses the situation where the user intends a single fling
+// but the finger touches the screen long enough, so that the home card becomes
+// bigger than the height of VISIBLE_BOTTOM state due to the scroll events.
+// In this case the fling event should not change the final state from
+// VISIBLE_BOTTOM to VISIBLE_CENTERED because the user's intention was a single
+// fling. See http://crbug.com/415211
+TEST_F(HomeCardGestureManagerTest, FastFling) {
+ ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
+
+ EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 1020));
+ EXPECT_EQ(0, GetEndCountAndReset());
+ EXPECT_EQ(0, GetProgressCountAndReset());
+
+ ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010);
+ ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE,
+ screen_height() - kHomeCardHeight);
+ ProcessFlingGesture(-150.0f);
+ EXPECT_EQ(1, GetEndCountAndReset());
EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
}
« athena/home/home_card_gesture_manager.cc ('K') | « athena/home/home_card_gesture_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698