Index: ash/system/tray/system_tray_unittest.cc |
diff --git a/ash/system/tray/system_tray_unittest.cc b/ash/system/tray/system_tray_unittest.cc |
index 771e4deaa296aad7245c4aac0f73f4c99d32c060..13dd5bf1c035f3abb3fd64b49a114364bb043d9c 100644 |
--- a/ash/system/tray/system_tray_unittest.cc |
+++ b/ash/system/tray/system_tray_unittest.cc |
@@ -66,11 +66,14 @@ class SystemTrayTest : public AshTestBase { |
// Swiping on the system tray and ends with finger released. |
void SendGestureEvent(gfx::Point& start, |
float delta, |
+ float begin_scroll_y_hint, |
bool is_fling, |
- float velocity_y) { |
+ float velocity_y, |
+ bool is_on_bubble) { |
sammiequon
2017/06/29 21:28:19
what happens when |is_on_bubble| is true but |star
minch1
2017/06/30 17:02:30
Since |start| can be point on the system tray, els
sammiequon
2017/06/30 17:46:02
Acknowledged.
|
SystemTray* system_tray = GetPrimarySystemTray(); |
base::TimeTicks timestamp = base::TimeTicks::Now(); |
- SendScrollStartAndUpdate(start, delta, timestamp); |
+ SendScrollStartAndUpdate(start, delta, begin_scroll_y_hint, timestamp, |
sammiequon
2017/06/29 21:28:19
AFAICT, |velocity_y| tells the direction as well?
minch1
2017/06/30 17:02:30
I think the |velocity_y| is only for fling event?
sammiequon
2017/06/30 17:46:02
Acknowledged.
|
+ is_on_bubble); |
ui::GestureEventDetails details = |
is_fling |
@@ -78,25 +81,45 @@ class SystemTrayTest : public AshTestBase { |
: ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END); |
ui::GestureEvent event = ui::GestureEvent(start.x(), start.y() + delta, |
ui::EF_NONE, timestamp, details); |
- system_tray->OnGestureEvent(&event); |
+ if (is_on_bubble) { |
+ system_tray->ProcessGestureEventOnBubbleView( |
+ &event, system_tray->GetSystemBubble()->bubble_view()); |
+ } else { |
+ system_tray->OnGestureEvent(&event); |
+ } |
} |
// Swiping on the system tray without releasing the finger. |
void SendScrollStartAndUpdate(gfx::Point& start, |
float delta, |
- base::TimeTicks& timestamp) { |
+ float begin_scroll_y_hint, |
+ base::TimeTicks& timestamp, |
+ bool is_on_bubble) { |
SystemTray* system_tray = GetPrimarySystemTray(); |
- ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN); |
+ ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN, 0, |
+ begin_scroll_y_hint); |
ui::GestureEvent begin_event = ui::GestureEvent( |
start.x(), start.y(), ui::EF_NONE, timestamp, begin_details); |
- system_tray->OnGestureEvent(&begin_event); |
+ |
+ if (is_on_bubble) { |
+ system_tray->ProcessGestureEventOnBubbleView( |
+ &begin_event, system_tray->GetSystemBubble()->bubble_view()); |
+ } else { |
+ system_tray->OnGestureEvent(&begin_event); |
+ } |
ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0, |
delta); |
timestamp += base::TimeDelta::FromMilliseconds(100); |
ui::GestureEvent update_event = ui::GestureEvent( |
start.x(), start.y() + delta, ui::EF_NONE, timestamp, update_details); |
- system_tray->OnGestureEvent(&update_event); |
+ |
+ if (is_on_bubble) { |
+ system_tray->ProcessGestureEventOnBubbleView( |
+ &update_event, system_tray->GetSystemBubble()->bubble_view()); |
+ } else { |
+ system_tray->OnGestureEvent(&update_event); |
+ } |
} |
// Open the default system tray bubble to get the height of the bubble and |
@@ -151,7 +174,7 @@ TEST_F(SystemTrayTest, SwipingOnShelfDuringAnimation) { |
// Swiping up exceed one third of the height of the bubble should show the |
// bubble. |
float delta = -original_bounds.height() / 2; |
- SendGestureEvent(start, delta, false, 0); |
+ SendGestureEvent(start, delta, -1, false, 0, false); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
gfx::Rect current_bounds = GetSystemBubbleBoundsInScreen(); |
@@ -164,7 +187,8 @@ TEST_F(SystemTrayTest, SwipingOnShelfDuringAnimation) { |
// Fling down on the shelf with a velocity that exceeds |kFlingVelocity|. |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
- SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); |
+ SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity + 1, |
+ false); |
current_bounds = GetSystemBubbleBoundsInScreen(); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
@@ -189,7 +213,8 @@ TEST_F(SystemTrayTest, FlingOnSystemTray) { |
// larger than |kFlingVelocity| and the dragging amount is larger than one |
// third of the height of the bubble. |
float delta = -GetSystemBubbleHeight(); |
- SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity + 1)); |
+ SendGestureEvent(start, delta, -1, true, -(SystemTray::kFlingVelocity + 1), |
+ false); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
system_tray->CloseSystemBubble(); |
@@ -197,7 +222,8 @@ TEST_F(SystemTrayTest, FlingOnSystemTray) { |
// larger than |kFlingVelocity| even the dragging amount is less than one |
// third of the height of the bubble. |
delta /= 4; |
- SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity + 1)); |
+ SendGestureEvent(start, delta, -1, true, -(SystemTray::kFlingVelocity + 1), |
+ false); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
system_tray->CloseSystemBubble(); |
@@ -205,7 +231,8 @@ TEST_F(SystemTrayTest, FlingOnSystemTray) { |
// less than |kFlingVelocity| but the dragging amount if larger than one third |
// of the height of the bubble. |
delta = -GetSystemBubbleHeight(); |
- SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity - 1)); |
+ SendGestureEvent(start, delta, -1, true, -(SystemTray::kFlingVelocity - 1), |
+ false); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
system_tray->CloseSystemBubble(); |
@@ -213,25 +240,29 @@ TEST_F(SystemTrayTest, FlingOnSystemTray) { |
// is less than |kFlingVelocity| and the dragging amount is less than one |
// third of the height of the bubble. |
delta /= 4; |
- SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity - 1)); |
+ SendGestureEvent(start, delta, -1, true, -(SystemTray::kFlingVelocity - 1), |
+ false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
// Fling down on the system tray should close the bubble if the |velocity_y| |
// is larger than kFLingVelocity. |
- SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); |
+ SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity + 1, |
+ false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
// Fling down on the system tray should close the bubble if the |velocity_y| |
// is larger than |kFlingVelocity| even the dragging amount is larger than one |
// third of the height of the bubble. |
delta = -GetSystemBubbleHeight(); |
- SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); |
+ SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity + 1, |
+ false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
// Fling down on the system tray should open the bubble if the |velocity_y| is |
// less than |kFlingVelocity| but the dragging amount exceed one third of the |
// height of the bubble. |
- SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity - 1); |
+ SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity - 1, |
+ false); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
system_tray->CloseSystemBubble(); |
@@ -239,7 +270,8 @@ TEST_F(SystemTrayTest, FlingOnSystemTray) { |
// is less than |kFlingVelocity| and the dragging amount is less than one |
// third of the height of the bubble. |
delta /= 4; |
- SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity - 1); |
+ SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity - 1, |
+ false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
} |
@@ -254,7 +286,7 @@ TEST_F(SystemTrayTest, TapOutsideCloseBubble) { |
Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
true); |
base::TimeTicks timestamp = base::TimeTicks::Now(); |
- SendScrollStartAndUpdate(start, delta, timestamp); |
+ SendScrollStartAndUpdate(start, delta, -1, timestamp, false); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
ui::test::EventGenerator& generator = GetEventGenerator(); |
@@ -276,27 +308,27 @@ TEST_F(SystemTrayTest, SwipingOnSystemTray) { |
Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
- SendGestureEvent(start, delta, false, 0); |
+ SendGestureEvent(start, delta, -1, false, 0, false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
// Swiping up on the system tray should show the system tray bubble if it is |
// in maximize mode. |
Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
true); |
- SendGestureEvent(start, delta, false, 0); |
+ SendGestureEvent(start, delta, -1, false, 0, false); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
system_tray->CloseSystemBubble(); |
// Swiping up less than one third of the bubble's height should not show the |
// bubble. |
delta /= 4; |
- SendGestureEvent(start, delta, false, 0); |
+ SendGestureEvent(start, delta, -1, false, 0, false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
// Swiping up more than one third of the bubble's height should show the |
// bubble. |
delta = -GetSystemBubbleHeight() / 2; |
- SendGestureEvent(start, delta, false, 0); |
+ SendGestureEvent(start, delta, -1, false, 0, false); |
EXPECT_TRUE(system_tray->HasSystemBubble()); |
system_tray->CloseSystemBubble(); |
@@ -304,19 +336,44 @@ TEST_F(SystemTrayTest, SwipingOnSystemTray) { |
// shelf is left alignment. |
delta = -GetSystemBubbleHeight(); |
shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
- SendGestureEvent(start, delta, false, 0); |
+ SendGestureEvent(start, delta, -1, false, 0, false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
// Swiping up on system tray should not show the system tray bubble if the |
// shelf is right alignment. |
shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
- SendGestureEvent(start, delta, false, 0); |
+ SendGestureEvent(start, delta, -1, false, 0, false); |
+ EXPECT_FALSE(system_tray->HasSystemBubble()); |
+ |
+ // Begins to scroll downward on the shelf should not show the system tray |
+ // bubble. |
+ shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
+ SendGestureEvent(start, delta, 1, false, 0, false); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
+} |
- // Swiping down on the shelf should not show the system tray bubble. |
+// Swiping on opened system tray bubble. |
+TEST_F(SystemTrayTest, SwipingOnSystemTrayBubble) { |
+ Shelf* shelf = GetPrimaryShelf(); |
+ SystemTray* system_tray = GetPrimarySystemTray(); |
shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
- delta = -delta; |
- SendGestureEvent(start, delta, false, 0); |
+ Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
+ true); |
+ |
+ // Begins to scroll downward and swiping down more than one third of the |
+ // bubble's height should close the bubble. |
+ system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
+ gfx::Rect bounds = |
+ system_tray->GetSystemBubble()->bubble_view()->GetLocalBounds(); |
+ float delta = bounds.height() / 2; |
+ gfx::Point start(bounds.x() + 5, bounds.y() + 5); |
+ SendGestureEvent(start, delta, 1, false, 0, true); |
+ EXPECT_FALSE(system_tray->HasSystemBubble()); |
+ |
+ // Begins to scroll upward and swiping down more than one third of the |
+ // bubble's height should also close the bubble. |
+ system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
+ SendGestureEvent(start, delta, -1, false, 0, true); |
EXPECT_FALSE(system_tray->HasSystemBubble()); |
} |