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

Side by Side Diff: athena/home/home_card_gesture_manager_unittest.cc

Issue 582923002: Do not EASE_IN_OUT after fling, rather EASE_OUT. (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 unified diff | Download patch
« no previous file with comments | « athena/home/home_card_gesture_manager.cc ('k') | athena/home/home_card_impl.h » ('j') | 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 "athena/home/home_card_gesture_manager.h" 5 #include "athena/home/home_card_gesture_manager.h"
6 6
7 #include "athena/home/home_card_constants.h" 7 #include "athena/home/home_card_constants.h"
8 #include "athena/home/public/home_card.h" 8 #include "athena/home/public/home_card.h"
9 #include "athena/test/athena_test_base.h" 9 #include "athena/test/athena_test_base.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "ui/events/event.h" 11 #include "ui/events/event.h"
12 #include "ui/events/event_constants.h" 12 #include "ui/events/event_constants.h"
13 13
14 namespace athena { 14 namespace athena {
15 15
16 class HomeCardGestureManagerTest : public test::AthenaTestBase, 16 class HomeCardGestureManagerTest : public test::AthenaTestBase,
17 public HomeCardGestureManager::Delegate { 17 public HomeCardGestureManager::Delegate {
18 public: 18 public:
19 HomeCardGestureManagerTest() 19 HomeCardGestureManagerTest()
20 : final_state_(HomeCard::HIDDEN), 20 : final_state_(HomeCard::HIDDEN),
21 last_from_state_(HomeCard::HIDDEN), 21 last_from_state_(HomeCard::HIDDEN),
22 last_to_state_(HomeCard::HIDDEN), 22 last_to_state_(HomeCard::HIDDEN),
23 last_progress_(0.0f), 23 last_progress_(0.0f),
24 was_fling_(false),
24 last_y_(0), 25 last_y_(0),
25 progress_count_(0), 26 progress_count_(0),
26 end_count_(0) {} 27 end_count_(0) {}
27 virtual ~HomeCardGestureManagerTest() {} 28 virtual ~HomeCardGestureManagerTest() {}
28 29
29 // testing::Test: 30 // testing::Test:
30 virtual void SetUp() OVERRIDE { 31 virtual void SetUp() OVERRIDE {
31 test::AthenaTestBase::SetUp(); 32 test::AthenaTestBase::SetUp();
32 gesture_manager_.reset(new HomeCardGestureManager(this, screen_bounds())); 33 gesture_manager_.reset(new HomeCardGestureManager(this, screen_bounds()));
33 } 34 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 76 }
76 77
77 int screen_height() const { 78 int screen_height() const {
78 return screen_bounds().height(); 79 return screen_bounds().height();
79 } 80 }
80 81
81 HomeCard::State final_state_; 82 HomeCard::State final_state_;
82 HomeCard::State last_from_state_; 83 HomeCard::State last_from_state_;
83 HomeCard::State last_to_state_; 84 HomeCard::State last_to_state_;
84 float last_progress_; 85 float last_progress_;
86 bool was_fling_;
85 87
86 private: 88 private:
87 gfx::Rect screen_bounds() const { 89 gfx::Rect screen_bounds() const {
88 return gfx::Rect(0, 0, 1280, 1024); 90 return gfx::Rect(0, 0, 1280, 1024);
89 } 91 }
90 92
91 // HomeCardGestureManager::Delegate: 93 // HomeCardGestureManager::Delegate:
92 virtual void OnGestureEnded(HomeCard::State final_state) OVERRIDE { 94 virtual void OnGestureEnded(HomeCard::State final_state,
95 bool is_fling) OVERRIDE {
93 final_state_ = final_state; 96 final_state_ = final_state;
97 was_fling_ = is_fling;
94 ++end_count_; 98 ++end_count_;
95 } 99 }
96 100
97 virtual void OnGestureProgressed(HomeCard::State from_state, 101 virtual void OnGestureProgressed(HomeCard::State from_state,
98 HomeCard::State to_state, 102 HomeCard::State to_state,
99 float progress) OVERRIDE { 103 float progress) OVERRIDE {
100 last_from_state_ = from_state; 104 last_from_state_ = from_state;
101 last_to_state_ = to_state; 105 last_to_state_ = to_state;
102 last_progress_ = progress; 106 last_progress_ = progress;
103 ++progress_count_; 107 ++progress_count_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EXPECT_LT(progress_800, last_progress_); 159 EXPECT_LT(progress_800, last_progress_);
156 160
157 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 810); 161 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 810);
158 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, last_from_state_); 162 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, last_from_state_);
159 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, last_to_state_); 163 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, last_to_state_);
160 EXPECT_GT(progress_800, last_progress_); 164 EXPECT_GT(progress_800, last_progress_);
161 165
162 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 810)); 166 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 810));
163 EXPECT_EQ(1, GetEndCountAndReset()); 167 EXPECT_EQ(1, GetEndCountAndReset());
164 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_); 168 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
169 EXPECT_FALSE(was_fling_);
165 } 170 }
166 171
167 // Test gesture progress when the gesture is initiated when the home card is in 172 // Test gesture progress when the gesture is initiated when the home card is in
168 // the centered state. 173 // the centered state.
169 TEST_F(HomeCardGestureManagerTest, StartCentered) { 174 TEST_F(HomeCardGestureManagerTest, StartCentered) {
170 HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED); 175 HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED);
171 176
172 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 20)); 177 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 20));
173 178
174 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 10); 179 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 10);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1000); 218 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1000);
214 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 1000)); 219 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 1000));
215 EXPECT_EQ(1, GetEndCountAndReset()); 220 EXPECT_EQ(1, GetEndCountAndReset());
216 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, final_state_); 221 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, final_state_);
217 222
218 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 950)); 223 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 950));
219 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 300); 224 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 300);
220 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 300)); 225 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_END, 300));
221 EXPECT_EQ(1, GetEndCountAndReset()); 226 EXPECT_EQ(1, GetEndCountAndReset());
222 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, final_state_); 227 EXPECT_EQ(HomeCard::VISIBLE_CENTERED, final_state_);
228 EXPECT_FALSE(was_fling_);
223 } 229 }
224 230
225 TEST_F(HomeCardGestureManagerTest, FlingUpAtEnd) { 231 TEST_F(HomeCardGestureManagerTest, FlingUpAtEnd) {
226 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); 232 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
227 233
228 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 1020)); 234 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 1020));
229 EXPECT_EQ(0, GetEndCountAndReset()); 235 EXPECT_EQ(0, GetEndCountAndReset());
230 EXPECT_EQ(0, GetProgressCountAndReset()); 236 EXPECT_EQ(0, GetProgressCountAndReset());
231 237
232 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010); 238 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010);
233 ProcessFlingGesture(-150.0f); 239 ProcessFlingGesture(-150.0f);
234 EXPECT_EQ(1, GetEndCountAndReset()); 240 EXPECT_EQ(1, GetEndCountAndReset());
235 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_); 241 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
242 EXPECT_TRUE(was_fling_);
236 } 243 }
237 244
238 TEST_F(HomeCardGestureManagerTest, FlingDownAtEnd) { 245 TEST_F(HomeCardGestureManagerTest, FlingDownAtEnd) {
239 HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED); 246 HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED);
240 247
241 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 20)); 248 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 20));
242 EXPECT_EQ(0, GetEndCountAndReset()); 249 EXPECT_EQ(0, GetEndCountAndReset());
243 EXPECT_EQ(0, GetProgressCountAndReset()); 250 EXPECT_EQ(0, GetProgressCountAndReset());
244 251
245 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 30); 252 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 30);
246 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 100); 253 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 100);
247 ProcessFlingGesture(150.0f); 254 ProcessFlingGesture(150.0f);
248 EXPECT_EQ(1, GetEndCountAndReset()); 255 EXPECT_EQ(1, GetEndCountAndReset());
249 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_); 256 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
257 EXPECT_TRUE(was_fling_);
250 } 258 }
251 259
252 TEST_F(HomeCardGestureManagerTest, WeakFling) { 260 TEST_F(HomeCardGestureManagerTest, WeakFling) {
253 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); 261 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
254 262
255 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 1020)); 263 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 1020));
256 EXPECT_EQ(0, GetEndCountAndReset()); 264 EXPECT_EQ(0, GetEndCountAndReset());
257 EXPECT_EQ(0, GetProgressCountAndReset()); 265 EXPECT_EQ(0, GetProgressCountAndReset());
258 266
259 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010); 267 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010);
260 ProcessFlingGesture(-30.0f); 268 ProcessFlingGesture(-30.0f);
261 EXPECT_EQ(1, GetEndCountAndReset()); 269 EXPECT_EQ(1, GetEndCountAndReset());
262 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, final_state_); 270 EXPECT_EQ(HomeCard::VISIBLE_MINIMIZED, final_state_);
271 EXPECT_FALSE(was_fling_);
263 } 272 }
264 273
265 // Test the situation where the user intends a single fling but the finger 274 // Test the situation where the user intends a single fling but the finger
266 // touches the screen long enough, so that the home card becomes bigger than the 275 // touches the screen long enough, so that the home card becomes bigger than the
267 // height of VISIBLE_BOTTOM state due to the scroll events. 276 // height of VISIBLE_BOTTOM state due to the scroll events.
268 // In this case the fling event should not change the final state from 277 // In this case the fling event should not change the final state from
269 // VISIBLE_BOTTOM to VISIBLE_CENTERED because the user's intention was a single 278 // VISIBLE_BOTTOM to VISIBLE_CENTERED because the user's intention was a single
270 // fling. See http://crbug.com/415211 279 // fling. See http://crbug.com/415211
271 TEST_F(HomeCardGestureManagerTest, FastFling) { 280 TEST_F(HomeCardGestureManagerTest, FastFling) {
272 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState()); 281 ASSERT_EQ(HomeCard::VISIBLE_MINIMIZED, HomeCard::Get()->GetState());
273 282
274 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 1020)); 283 EXPECT_TRUE(ProcessGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN, 1020));
275 EXPECT_EQ(0, GetEndCountAndReset()); 284 EXPECT_EQ(0, GetEndCountAndReset());
276 EXPECT_EQ(0, GetProgressCountAndReset()); 285 EXPECT_EQ(0, GetProgressCountAndReset());
277 286
278 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010); 287 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010);
279 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 288 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE,
280 screen_height() - kHomeCardHeight); 289 screen_height() - kHomeCardHeight);
281 ProcessFlingGesture(-150.0f); 290 ProcessFlingGesture(-150.0f);
282 EXPECT_EQ(1, GetEndCountAndReset()); 291 EXPECT_EQ(1, GetEndCountAndReset());
283 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_); 292 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_);
293 EXPECT_TRUE(was_fling_);
284 } 294 }
285 295
286 } // namespace athena 296 } // namespace athena
OLDNEW
« no previous file with comments | « athena/home/home_card_gesture_manager.cc ('k') | athena/home/home_card_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698