Skip to content

Commit

Permalink
Changing size of clickable area for expand arrow icon + unit testing
Browse files Browse the repository at this point in the history
Users should be able to bring up the full app list view by touching any
area near the expand arrow icon.

Bug: 906858
Change-Id: I4c39ddbbeb2bf6b7ac529aa758d161f54e67d8a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1652619
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Cameron Womack <camw@google.com>
Cr-Commit-Position: refs/heads/master@{#668571}
  • Loading branch information
Cameron Womack authored and Commit Bot committed Jun 12, 2019
1 parent 7262f7d commit aa3310b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
38 changes: 38 additions & 0 deletions ash/app_list/app_list_controller_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,44 @@ TEST_F(AppListControllerImplTest, CloseNotificationWithAppListShown) {
0u, message_center::MessageCenter::Get()->GetPopupNotifications().size());
}

// Tests that full screen apps list opens when user touches on or near the
// expand view arrow. (see https://crbug.com/906858)
TEST_F(AppListControllerImplTest,
EnterFullScreenModeAfterTappingNearExpandArrow) {
ShowAppListNow();
ASSERT_EQ(ash::AppListViewState::kPeeking,
GetAppListView()->app_list_state());

// Get in screen bounds of arrow
const gfx::Rect expand_arrow = GetAppListView()
->app_list_main_view()
->contents_view()
->expand_arrow_view()
->GetBoundsInScreen();

// Tap expand arrow icon and check that full screen apps view is entered.
ui::test::EventGenerator* event_generator = GetEventGenerator();
event_generator->GestureTapAt(expand_arrow.CenterPoint());
ASSERT_EQ(ash::AppListViewState::kFullscreenAllApps,
GetAppListView()->app_list_state());

// Hide the AppListView. Wait until animation is finished
DismissAppListNow();
base::RunLoop().RunUntilIdle();

// Re-enter peeking mode and test that tapping near (but not directly on)
// the expand arrow icon still brings up full app list view.
ShowAppListNow();
ASSERT_EQ(ash::AppListViewState::kPeeking,
GetAppListView()->app_list_state());

event_generator->GestureTapAt(
gfx::Point(expand_arrow.top_right().x(), expand_arrow.top_right().y()));

ASSERT_EQ(ash::AppListViewState::kFullscreenAllApps,
GetAppListView()->app_list_state());
}

class AppListControllerImplMetricsTest : public AshTestBase {
public:
AppListControllerImplMetricsTest() = default;
Expand Down
14 changes: 14 additions & 0 deletions ash/app_list/views/expand_arrow_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ ExpandArrowView::ExpandArrowView(ContentsView* contents_view,
!AppListView::ShortAnimationsForTesting()) {
ScheduleHintingAnimation(true);
}
SetEventTargeter(std::make_unique<views::ViewTargeter>(this));
}

ExpandArrowView::~ExpandArrowView() = default;
Expand Down Expand Up @@ -379,4 +380,17 @@ void ExpandArrowView::ResetHintingAnimation() {
Layout();
}

bool ExpandArrowView::DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const {
DCHECK_EQ(target, this);
gfx::Rect button_bounds = GetLocalBounds();
// Increase clickable area for the button from
// (kTileWidth x height) to
// (3 * height - width).
int horizontal_padding =
button_bounds.width() - (button_bounds.height() * 1.5);
button_bounds.Inset(gfx::Insets(0, horizontal_padding));
return button_bounds.Intersects(rect);
}

} // namespace app_list
8 changes: 7 additions & 1 deletion ash/app_list/views/expand_arrow_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "ash/app_list/app_list_export.h"
#include "base/memory/weak_ptr.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view_targeter_delegate.h"

namespace gfx {
class SlideAnimation;
Expand All @@ -28,7 +29,8 @@ class ContentsView;

// A tile item for the expand arrow on the start page.
class APP_LIST_EXPORT ExpandArrowView : public views::Button,
public views::ButtonListener {
public views::ButtonListener,
public views::ViewTargeterDelegate {
public:
ExpandArrowView(ContentsView* contents_view, AppListView* app_list_view);
~ExpandArrowView() override;
Expand Down Expand Up @@ -64,6 +66,10 @@ class APP_LIST_EXPORT ExpandArrowView : public views::Button,
void StartHintingAnimation();
void ResetHintingAnimation();

// views::ViewTargeterDelegate:
bool DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const override;

ContentsView* const contents_view_;
AppListView* const app_list_view_; // Owned by the views hierarchy.

Expand Down

0 comments on commit aa3310b

Please sign in to comment.