| OLD | NEW |
| 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" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return result; | 39 return result; |
| 40 } | 40 } |
| 41 int GetProgressCountAndReset() { | 41 int GetProgressCountAndReset() { |
| 42 int result = progress_count_; | 42 int result = progress_count_; |
| 43 progress_count_ = 0; | 43 progress_count_ = 0; |
| 44 return result; | 44 return result; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Process a gesture event for our use case. | 47 // Process a gesture event for our use case. |
| 48 bool ProcessGestureEvent(ui::EventType type, int y) { | 48 bool ProcessGestureEvent(ui::EventType type, int y) { |
| 49 ui::GestureEvent event(0, y, ui::EF_NONE, base::TimeDelta(), | 49 ui::GestureEventDetails details; |
| 50 ui::GestureEventDetails(type, 0, (y - last_y_))); | 50 if (type == ui::ET_GESTURE_SCROLL_BEGIN || |
| 51 type == ui::ET_GESTURE_SCROLL_UPDATE) |
| 52 details = ui::GestureEventDetails(type, 0, (y - last_y_)); |
| 53 else |
| 54 details = ui::GestureEventDetails(type); |
| 55 ui::GestureEvent event(0, y, ui::EF_NONE, base::TimeDelta(), details); |
| 51 if (type == ui::ET_GESTURE_SCROLL_BEGIN) { | 56 if (type == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 52 // Compute the position that the home card would have wrt to the top of | 57 // Compute the position that the home card would have wrt to the top of |
| 53 // the screen if the screen had screen_bounds(). | 58 // the screen if the screen had screen_bounds(). |
| 54 HomeCard::State state = HomeCard::Get()->GetState(); | 59 HomeCard::State state = HomeCard::Get()->GetState(); |
| 55 int home_card_top = 0; | 60 int home_card_top = 0; |
| 56 if (state == HomeCard::VISIBLE_BOTTOM) | 61 if (state == HomeCard::VISIBLE_BOTTOM) |
| 57 home_card_top = screen_bounds().height() - kHomeCardHeight; | 62 home_card_top = screen_bounds().height() - kHomeCardHeight; |
| 58 else if (state == HomeCard::VISIBLE_MINIMIZED) | 63 else if (state == HomeCard::VISIBLE_MINIMIZED) |
| 59 home_card_top = screen_bounds().height() - kHomeCardMinimizedHeight; | 64 home_card_top = screen_bounds().height() - kHomeCardMinimizedHeight; |
| 60 | 65 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 EXPECT_EQ(0, GetProgressCountAndReset()); | 227 EXPECT_EQ(0, GetProgressCountAndReset()); |
| 223 | 228 |
| 224 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010); | 229 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 1010); |
| 225 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 800); | 230 ProcessGestureEvent(ui::ET_GESTURE_SCROLL_UPDATE, 800); |
| 226 ProcessFlingGesture(-30.0f); | 231 ProcessFlingGesture(-30.0f); |
| 227 EXPECT_EQ(1, GetEndCountAndReset()); | 232 EXPECT_EQ(1, GetEndCountAndReset()); |
| 228 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_); | 233 EXPECT_EQ(HomeCard::VISIBLE_BOTTOM, final_state_); |
| 229 } | 234 } |
| 230 | 235 |
| 231 } // namespace athena | 236 } // namespace athena |
| OLD | NEW |