Commit 60ef03d4 authored by MinChen's avatar MinChen Committed by Commit Bot

Dragging up on app list button to open the launcher.

Changes,
1. Don't handle the scroll gesture events in AppListButton::OnGestureEvent, let
   the ShelfView handle it instead.
2. Add a test for the swiping on applist button to open launcher.

Bug: 758071
Change-Id: I71557411e9de6cd21bdb76c52dfb545a1e621783
Reviewed-on: https://chromium-review.googlesource.com/685535
Commit-Queue: min c <minch@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504492}
parent bb4a02e2
...@@ -148,17 +148,7 @@ void AppListButton::OnGestureEvent(ui::GestureEvent* event) { ...@@ -148,17 +148,7 @@ void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
switch (event->type()) { switch (event->type()) {
case ui::ET_GESTURE_SCROLL_BEGIN: case ui::ET_GESTURE_SCROLL_BEGIN:
AnimateInkDrop(views::InkDropState::HIDDEN, event); AnimateInkDrop(views::InkDropState::HIDDEN, event);
shelf_view_->PointerPressedOnButton(this, ShelfView::TOUCH, *event); ImageButton::OnGestureEvent(event);
event->SetHandled();
return;
case ui::ET_GESTURE_SCROLL_UPDATE:
shelf_view_->PointerDraggedOnButton(this, ShelfView::TOUCH, *event);
event->SetHandled();
return;
case ui::ET_GESTURE_SCROLL_END:
case ui::ET_SCROLL_FLING_START:
shelf_view_->PointerReleasedOnButton(this, ShelfView::TOUCH, false);
event->SetHandled();
return; return;
case ui::ET_GESTURE_TAP: case ui::ET_GESTURE_TAP:
case ui::ET_GESTURE_TAP_CANCEL: case ui::ET_GESTURE_TAP_CANCEL:
......
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
#include "ash/shelf/app_list_button.h" #include "ash/shelf/app_list_button.h"
#include "ash/public/cpp/config.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_view.h" #include "ash/shelf/shelf_view.h"
#include "ash/shelf/shelf_view_test_api.h" #include "ash/shelf/shelf_view_test_api.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -19,6 +21,7 @@ ...@@ -19,6 +21,7 @@
#include "ui/app_list/presenter/app_list.h" #include "ui/app_list/presenter/app_list.h"
#include "ui/app_list/presenter/test/test_app_list_presenter.h" #include "ui/app_list/presenter/test/test_app_list_presenter.h"
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
#include "ui/events/test/event_generator.h"
namespace ash { namespace ash {
...@@ -91,6 +94,34 @@ TEST_F(AppListButtonTest, LongPressGestureWithoutVoiceInteractionFlag) { ...@@ -91,6 +94,34 @@ TEST_F(AppListButtonTest, LongPressGestureWithoutVoiceInteractionFlag) {
EXPECT_EQ(0u, test_app_list_presenter.voice_session_count()); EXPECT_EQ(0u, test_app_list_presenter.voice_session_count());
} }
TEST_F(AppListButtonTest, SwipingupToOpenFullscreenAppList) {
// TODO: investigate failure in mash, http://crbug.com/695686.
if (Shell::GetAshConfig() == Config::MASH)
return;
Shelf* shelf = GetPrimaryShelf();
EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
// Start the drag from the center of the applist button's bottom.
gfx::Point center_point = app_list_button()->GetAppListButtonCenterPoint();
gfx::Point start(center_point.x(),
center_point.y() + app_list_button()->height() / 2.f);
views::View::ConvertPointToScreen(app_list_button(), &start);
// Swiping up less than peeking threshold should keep the app list at PEEKING
// state.
gfx::Point end =
start -
gfx::Vector2d(
0, ShelfLayoutManager::kAppListDragSnapToPeekingThreshold - 10);
GetEventGenerator().GestureScrollSequence(
start, end, base::TimeDelta::FromMilliseconds(100), 4 /* steps */);
RunAllPendingInMessageLoop();
EXPECT_EQ(1u, test_app_list_presenter.show_count());
EXPECT_GE(test_app_list_presenter.set_y_position_count(), 1u);
EXPECT_EQ(app_list::mojom::AppListState::PEEKING,
test_app_list_presenter.app_list_state());
}
class VoiceInteractionAppListButtonTest : public AppListButtonTest { class VoiceInteractionAppListButtonTest : public AppListButtonTest {
public: public:
VoiceInteractionAppListButtonTest() {} VoiceInteractionAppListButtonTest() {}
......
...@@ -1656,6 +1656,7 @@ TEST_F(ShelfLayoutManagerFullscreenAppListTest, ...@@ -1656,6 +1656,7 @@ TEST_F(ShelfLayoutManagerFullscreenAppListTest,
test_app_list_presenter.app_list_state()); test_app_list_presenter.app_list_state());
// Swiping up more than the close threshold but less than peeking threshold // Swiping up more than the close threshold but less than peeking threshold
// should keep the app list at PEEKING state.
delta.set_y(ShelfLayoutManager::kAppListDragSnapToPeekingThreshold - 10); delta.set_y(ShelfLayoutManager::kAppListDragSnapToPeekingThreshold - 10);
end = start - delta; end = start - delta;
generator.GestureScrollSequence(start, end, kTimeDelta, kNumScrollSteps); generator.GestureScrollSequence(start, end, kTimeDelta, kNumScrollSteps);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment