Commit 88bf4fca authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Disable context menus on the back and overflow buttons.

UX requests we disable context menus on the back button and overflow
buttons in the shelf.

Removed tests for these cases and added new ones for not showing
the menus.

Bug: 875334
Change-Id: I45c320a148e8f7ad39abd0e8181e59e3c4b663fe
Reviewed-on: https://chromium-review.googlesource.com/1180073Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584219}
parent 2666f20b
......@@ -371,7 +371,6 @@ void ShelfView::Init() {
AddChildView(child);
}
overflow_button_ = new OverflowButton(this, shelf_);
overflow_button_->set_context_menu_controller(this);
ConfigureChildView(overflow_button_);
AddChildView(overflow_button_);
UpdateBackButton();
......@@ -1138,7 +1137,9 @@ views::View* ShelfView::CreateViewForItem(const ShelfItem& item) {
return nullptr;
}
view->set_context_menu_controller(this);
if (item.type != TYPE_BACK_BUTTON)
view->set_context_menu_controller(this);
ConfigureChildView(view);
return view;
}
......
......@@ -1998,11 +1998,42 @@ TEST_F(ShelfViewTest, TabletModeStartAndEndClosesContextMenu) {
TEST_F(ShelfViewTest, AppListButtonShowsContextMenu) {
ui::test::EventGenerator* generator = GetEventGenerator();
AppListButton* app_list_button = shelf_view_->GetAppListButton();
generator->MoveMouseTo(app_list_button->GetBoundsInScreen().CenterPoint());
generator->PressRightButton();
EXPECT_TRUE(test_api_->CloseMenu());
}
// Tests that the back button does not show a context menu.
TEST_F(ShelfViewTest, NoContextMenuOnBackButton) {
ui::test::EventGenerator* generator = GetEventGenerator();
// Enable tablet mode to show the back button. Wait for tablet mode animations
// to finish in order for the BackButton to move out from under the
// AppListButton.
Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
test_api_->RunMessageLoopUntilAnimationsDone();
views::View* back_button = shelf_view_->GetBackButton();
generator->MoveMouseTo(back_button->GetBoundsInScreen().CenterPoint());
generator->PressRightButton();
EXPECT_FALSE(test_api_->CloseMenu());
}
// Tests that the overflow button does not show a context menu.
TEST_F(ShelfViewTest, NoContextMenuOnOverflowButton) {
ui::test::EventGenerator* generator = GetEventGenerator();
AddButtonsUntilOverflow();
views::View* overflow_button = test_api_->overflow_button();
generator->MoveMouseTo(overflow_button->GetBoundsInScreen().CenterPoint());
generator->PressRightButton();
EXPECT_FALSE(test_api_->CloseMenu());
}
// Tests that a ShelfButton ink drop highlight is set to ACTIVATED when a menu
// is shown by mouse.
TEST_F(ShelfViewTest, ShelfButtonShowsInkDropHighlightOnMenuShow) {
......@@ -3036,35 +3067,6 @@ TEST_F(OverflowButtonInkDropTest, TouchDragOutAndBack) {
EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
}
// Tests ink drop state transitions for the overflow button when the user long
// presses on the button to show the context menu.
TEST_F(OverflowButtonInkDropTest, TouchContextMenu) {
ui::test::EventGenerator* generator = GetEventGenerator();
generator->set_current_location(GetScreenPointInsideOverflowButton());
base::ScopedMockTimeMessageLoopTaskRunner mock_task_runner;
generator->PressTouch();
EXPECT_EQ(views::InkDropState::ACTION_PENDING,
overflow_button_ink_drop_->GetTargetInkDropState());
EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
ElementsAre(views::InkDropState::ACTION_PENDING));
mock_task_runner->FastForwardUntilNoTasksRemain();
EXPECT_EQ(views::InkDropState::HIDDEN,
overflow_button_ink_drop_->GetTargetInkDropState());
EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
ElementsAre(views::InkDropState::ALTERNATE_ACTION_PENDING,
views::InkDropState::HIDDEN));
generator->ReleaseTouch();
EXPECT_EQ(views::InkDropState::HIDDEN,
overflow_button_ink_drop_->GetTargetInkDropState());
EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
IsEmpty());
EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
}
// Test fixture to run overflow button tests for LTR and RTL directions.
class OverflowButtonTextDirectionTest
: public OverflowButtonInkDropTest,
......@@ -3245,27 +3247,6 @@ TEST_F(OverflowButtonActiveInkDropTest, MouseDragOutAndBack) {
EXPECT_FALSE(test_api_->IsShowingOverflowBubble());
}
// Tests ink drop state transitions for the overflow button when it is active
// and the user right clicks on the button to show the context menu.
TEST_F(OverflowButtonActiveInkDropTest, MouseContextMenu) {
ui::test::EventGenerator* generator = GetEventGenerator();
generator->MoveMouseTo(GetScreenPointInsideOverflowButton());
generator->PressRightButton();
EXPECT_EQ(views::InkDropState::ACTIVATED,
overflow_button_ink_drop_->GetTargetInkDropState());
EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
IsEmpty());
generator->ReleaseRightButton();
EXPECT_EQ(views::InkDropState::ACTIVATED,
overflow_button_ink_drop_->GetTargetInkDropState());
EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
IsEmpty());
ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
}
// Tests ink drop state transitions for the overflow button when it is active
// and the user taps on it.
TEST_F(OverflowButtonActiveInkDropTest, TouchDeactivate) {
......@@ -3348,34 +3329,6 @@ TEST_F(OverflowButtonActiveInkDropTest, TouchDragOutAndBack) {
ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
}
// Tests ink drop state transitions for the overflow button when it is active
// and the user long presses on the button to show the context menu.
TEST_F(OverflowButtonActiveInkDropTest, TouchContextMenu) {
ui::test::EventGenerator* generator = GetEventGenerator();
generator->set_current_location(GetScreenPointInsideOverflowButton());
base::ScopedMockTimeMessageLoopTaskRunner mock_task_runner;
generator->PressTouch();
EXPECT_EQ(views::InkDropState::ACTIVATED,
overflow_button_ink_drop_->GetTargetInkDropState());
EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
IsEmpty());
mock_task_runner->FastForwardUntilNoTasksRemain();
EXPECT_EQ(views::InkDropState::ACTIVATED,
overflow_button_ink_drop_->GetTargetInkDropState());
EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
IsEmpty());
generator->ReleaseTouch();
EXPECT_EQ(views::InkDropState::ACTIVATED,
overflow_button_ink_drop_->GetTargetInkDropState());
EXPECT_THAT(overflow_button_ink_drop_->GetAndResetRequestedStates(),
IsEmpty());
ASSERT_TRUE(test_api_->IsShowingOverflowBubble());
}
class ShelfViewFocusTest : public ShelfViewTest {
public:
ShelfViewFocusTest() = default;
......
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