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

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: minor 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..dc0f01800ccd63def84e8e706d2880f24d686c03 100644
--- a/athena/home/home_card_gesture_manager_unittest.cc
+++ b/athena/home/home_card_gesture_manager_unittest.cc
@@ -180,9 +180,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 changes.
pkotwicz 2014/09/18 21:24:26 changes -> move
Jun Mukai 2014/09/18 21:57:29 Done.
+ 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 move.
+ 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 +225,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 +252,24 @@ 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_);
+}
+
+// Sometimes the fling event happens after the estimated height gets to bottom
+// state, but the state should not change to centered but remain in bottom.
pkotwicz 2014/09/18 21:24:26 I am not sure whether this test case is very usefu
Jun Mukai 2014/09/18 21:57:29 Hmm, a weak fling doesn't cause any effects ("Weak
+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, 800);
+ 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