Commit 1ef59e1d authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Touchable App Context Menu dead code cleanup

Remove code that is dead now that touchable app menus are enabled by
default.

Bug: 906684
Change-Id: I28bb46da596ba93e0bbc01c0685ed1cc1b7ec0ac
Reviewed-on: https://chromium-review.googlesource.com/c/1341064
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611008}
parent f1b12ddf
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "ash/public/cpp/shelf_item_delegate.h" #include "ash/public/cpp/shelf_item_delegate.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "ui/base/ui_base_features.h"
#include "ui/display/types/display_constants.h" #include "ui/display/types/display_constants.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
...@@ -28,11 +27,7 @@ ShelfApplicationMenuModel::ShelfApplicationMenuModel( ...@@ -28,11 +27,7 @@ ShelfApplicationMenuModel::ShelfApplicationMenuModel(
std::vector<mojom::MenuItemPtr> items, std::vector<mojom::MenuItemPtr> items,
ShelfItemDelegate* delegate) ShelfItemDelegate* delegate)
: ui::SimpleMenuModel(this), items_(std::move(items)), delegate_(delegate) { : ui::SimpleMenuModel(this), items_(std::move(items)), delegate_(delegate) {
if (!features::IsTouchableAppContextMenuEnabled())
AddSeparator(ui::SPACING_SEPARATOR);
AddItem(kInvalidCommandId, title); AddItem(kInvalidCommandId, title);
if (!features::IsTouchableAppContextMenuEnabled())
AddSeparator(ui::SPACING_SEPARATOR);
for (size_t i = 0; i < items_.size(); i++) { for (size_t i = 0; i < items_.size(); i++) {
mojom::MenuItem* item = items_[i].get(); mojom::MenuItem* item = items_[i].get();
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/menu/menu_config.h" #include "ui/views/controls/menu/menu_config.h"
...@@ -62,11 +61,6 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -62,11 +61,6 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
->tablet_mode_controller() ->tablet_mode_controller()
->IsTabletModeWindowManagerEnabled(); ->IsTabletModeWindowManagerEnabled();
// When touchable app context menus are enabled in tablet mode, shelf
// alignment option is not shown.
const bool skip_clamshell_only_options =
features::IsTouchableAppContextMenuEnabled() && is_tablet_mode;
const views::MenuConfig& menu_config = views::MenuConfig::instance(); const views::MenuConfig& menu_config = views::MenuConfig::instance();
// In fullscreen, the shelf is either hidden or auto-hidden, depending on // In fullscreen, the shelf is either hidden or auto-hidden, depending on
...@@ -78,7 +72,6 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -78,7 +72,6 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
const bool is_autohide_set = const bool is_autohide_set =
GetShelfAutoHideBehaviorPref(prefs, display_id) == GetShelfAutoHideBehaviorPref(prefs, display_id) ==
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
if (features::IsTouchableAppContextMenuEnabled()) {
auto_hide->type = ui::MenuModel::TYPE_COMMAND; auto_hide->type = ui::MenuModel::TYPE_COMMAND;
auto_hide->image = gfx::CreateVectorIcon( auto_hide->image = gfx::CreateVectorIcon(
is_autohide_set ? kAlwaysShowShelfIcon : kAutoHideIcon, is_autohide_set ? kAlwaysShowShelfIcon : kAutoHideIcon,
...@@ -86,20 +79,17 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -86,20 +79,17 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
auto_hide->label = GetStringUTF16( auto_hide->label = GetStringUTF16(
is_autohide_set ? IDS_ASH_SHELF_CONTEXT_MENU_ALWAYS_SHOW_SHELF is_autohide_set ? IDS_ASH_SHELF_CONTEXT_MENU_ALWAYS_SHOW_SHELF
: IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); : IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
} else {
auto_hide->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
auto_hide->type = ui::MenuModel::TYPE_CHECK;
auto_hide->checked = is_autohide_set;
}
auto_hide->command_id = ShelfContextMenuModel::MENU_AUTO_HIDE; auto_hide->command_id = ShelfContextMenuModel::MENU_AUTO_HIDE;
auto_hide->enabled = true; auto_hide->enabled = true;
menu->push_back(std::move(auto_hide)); menu->push_back(std::move(auto_hide));
} }
// Only allow shelf alignment modifications by the owner or user. // Only allow shelf alignment modifications by the owner or user. In tablet
// mode, the shelf alignment option is not shown.
LoginStatus status = Shell::Get()->session_controller()->login_status(); LoginStatus status = Shell::Get()->session_controller()->login_status();
if ((status == LoginStatus::USER || status == LoginStatus::OWNER) && if ((status == LoginStatus::USER || status == LoginStatus::OWNER) &&
!skip_clamshell_only_options) { !is_tablet_mode) {
const ShelfAlignment alignment = GetShelfAlignmentPref(prefs, display_id); const ShelfAlignment alignment = GetShelfAlignmentPref(prefs, display_id);
mojom::MenuItemPtr alignment_menu(mojom::MenuItem::New()); mojom::MenuItemPtr alignment_menu(mojom::MenuItem::New());
alignment_menu->type = ui::MenuModel::TYPE_SUBMENU; alignment_menu->type = ui::MenuModel::TYPE_SUBMENU;
...@@ -107,11 +97,9 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -107,11 +97,9 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
alignment_menu->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_POSITION); alignment_menu->label = GetStringUTF16(IDS_ASH_SHELF_CONTEXT_MENU_POSITION);
alignment_menu->submenu = MenuItemList(); alignment_menu->submenu = MenuItemList();
alignment_menu->enabled = !is_tablet_mode; alignment_menu->enabled = !is_tablet_mode;
if (features::IsTouchableAppContextMenuEnabled()) {
alignment_menu->image = gfx::CreateVectorIcon( alignment_menu->image = gfx::CreateVectorIcon(
kShelfPositionIcon, menu_config.touchable_icon_size, kShelfPositionIcon, menu_config.touchable_icon_size,
menu_config.touchable_icon_color); menu_config.touchable_icon_color);
}
mojom::MenuItemPtr left(mojom::MenuItem::New()); mojom::MenuItemPtr left(mojom::MenuItem::New());
left->type = ui::MenuModel::TYPE_RADIO; left->type = ui::MenuModel::TYPE_RADIO;
...@@ -146,11 +134,9 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) { ...@@ -146,11 +134,9 @@ void AddLocalMenuItems(MenuItemList* menu, int64_t display_id) {
wallpaper->command_id = ShelfContextMenuModel::MENU_CHANGE_WALLPAPER; wallpaper->command_id = ShelfContextMenuModel::MENU_CHANGE_WALLPAPER;
wallpaper->label = GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER); wallpaper->label = GetStringUTF16(IDS_AURA_SET_DESKTOP_WALLPAPER);
wallpaper->enabled = true; wallpaper->enabled = true;
if (features::IsTouchableAppContextMenuEnabled()) {
wallpaper->image = wallpaper->image =
gfx::CreateVectorIcon(kWallpaperIcon, menu_config.touchable_icon_size, gfx::CreateVectorIcon(kWallpaperIcon, menu_config.touchable_icon_size,
menu_config.touchable_icon_color); menu_config.touchable_icon_color);
}
menu->push_back(std::move(wallpaper)); menu->push_back(std::move(wallpaper));
} }
} }
...@@ -165,7 +151,7 @@ ShelfContextMenuModel::ShelfContextMenuModel(MenuItemList menu_items, ...@@ -165,7 +151,7 @@ ShelfContextMenuModel::ShelfContextMenuModel(MenuItemList menu_items,
delegate_(delegate), delegate_(delegate),
display_id_(display_id) { display_id_(display_id) {
// Append shelf settings and wallpaper items if no shelf item was selected. // Append shelf settings and wallpaper items if no shelf item was selected.
if (!features::IsTouchableAppContextMenuEnabled() || !delegate) if (!delegate)
AddLocalMenuItems(&menu_items_, display_id); AddLocalMenuItems(&menu_items_, display_id);
menu_utils::PopulateMenuFromMojoMenuItems(this, this, menu_items_, menu_utils::PopulateMenuFromMojoMenuItems(this, this, menu_items_,
&submenus_); &submenus_);
......
...@@ -102,7 +102,7 @@ class ASH_EXPORT ShelfController : public message_center::MessageCenterObserver, ...@@ -102,7 +102,7 @@ class ASH_EXPORT ShelfController : public message_center::MessageCenterObserver,
// Changes to the local ShelfModel should not be reported during this time. // Changes to the local ShelfModel should not be reported during this time.
bool applying_remote_shelf_model_changes_ = false; bool applying_remote_shelf_model_changes_ = false;
// Whether touchable context menus have been enabled for app icons on the // Whether notification indicators have been enabled for app icons in the
// shelf. // shelf.
const bool is_notification_indicator_enabled_; const bool is_notification_indicator_enabled_;
......
...@@ -209,14 +209,13 @@ TEST_F(ShelfControllerTest, ShelfItemImageSynchronization) { ...@@ -209,14 +209,13 @@ TEST_F(ShelfControllerTest, ShelfItemImageSynchronization) {
EXPECT_FALSE(controller->model()->items()[index].image.isNull()); EXPECT_FALSE(controller->model()->items()[index].image.isNull());
} }
class ShelfControllerTouchableContextMenuTest : public AshTestBase { class ShelfControllerNotificationIndicatorTest : public AshTestBase {
public: public:
ShelfControllerTouchableContextMenuTest() = default; ShelfControllerNotificationIndicatorTest() = default;
~ShelfControllerTouchableContextMenuTest() override = default; ~ShelfControllerNotificationIndicatorTest() override = default;
void SetUp() override { void SetUp() override {
scoped_feature_list_.InitWithFeatures( scoped_feature_list_.InitWithFeatures({features::kNotificationIndicator},
{features::kTouchableAppContextMenu, features::kNotificationIndicator},
{}); {});
AshTestBase::SetUp(); AshTestBase::SetUp();
} }
...@@ -224,12 +223,12 @@ class ShelfControllerTouchableContextMenuTest : public AshTestBase { ...@@ -224,12 +223,12 @@ class ShelfControllerTouchableContextMenuTest : public AshTestBase {
private: private:
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(ShelfControllerTouchableContextMenuTest); DISALLOW_COPY_AND_ASSIGN(ShelfControllerNotificationIndicatorTest);
}; };
// Tests that the ShelfController keeps the ShelfModel updated on new // Tests that the ShelfController keeps the ShelfModel updated on new
// notifications. // notifications.
TEST_F(ShelfControllerTouchableContextMenuTest, HasNotificationBasic) { TEST_F(ShelfControllerNotificationIndicatorTest, HasNotificationBasic) {
ShelfController* controller = Shell::Get()->shelf_controller(); ShelfController* controller = Shell::Get()->shelf_controller();
const std::string app_id("app_id"); const std::string app_id("app_id");
ShelfItem item; ShelfItem item;
......
...@@ -1622,19 +1622,14 @@ void ShelfView::UpdateOverflowRange(ShelfView* overflow_view) const { ...@@ -1622,19 +1622,14 @@ void ShelfView::UpdateOverflowRange(ShelfView* overflow_view) const {
gfx::Rect ShelfView::GetMenuAnchorRect(const views::View& source, gfx::Rect ShelfView::GetMenuAnchorRect(const views::View& source,
const gfx::Point& location, const gfx::Point& location,
bool context_menu) const { bool context_menu) const {
const bool for_item = ShelfItemForView(&source); // Application menus for items are anchored on the icon bounds.
if (ShelfItemForView(&source) || !context_menu)
return source.GetBoundsInScreen();
const gfx::Rect shelf_bounds_in_screen = const gfx::Rect shelf_bounds_in_screen =
is_overflow_mode() is_overflow_mode()
? owner_overflow_bubble_->bubble_view()->GetBubbleBounds() ? owner_overflow_bubble_->bubble_view()->GetBubbleBounds()
: GetBoundsInScreen(); : GetBoundsInScreen();
const gfx::Rect& source_bounds_in_screen = source.GetBoundsInScreen();
// Application menus and touchable menus for items are anchored on the icon
// bounds.
if ((features::IsTouchableAppContextMenuEnabled() && for_item) ||
!context_menu) {
return source_bounds_in_screen;
}
gfx::Point origin; gfx::Point origin;
switch (shelf_->alignment()) { switch (shelf_->alignment()) {
case SHELF_ALIGNMENT_BOTTOM: case SHELF_ALIGNMENT_BOTTOM:
...@@ -1648,31 +1643,7 @@ gfx::Rect ShelfView::GetMenuAnchorRect(const views::View& source, ...@@ -1648,31 +1643,7 @@ gfx::Rect ShelfView::GetMenuAnchorRect(const views::View& source,
origin = gfx::Point(shelf_bounds_in_screen.x(), location.y()); origin = gfx::Point(shelf_bounds_in_screen.x(), location.y());
break; break;
} }
return gfx::Rect(origin, return gfx::Rect(origin, gfx::Size());
for_item ? source_bounds_in_screen.size() : gfx::Size());
}
views::MenuAnchorPosition ShelfView::GetMenuAnchorPosition(
bool for_item,
bool context_menu) const {
if (features::IsTouchableAppContextMenuEnabled()) {
return shelf_->IsHorizontalAlignment()
? views::MENU_ANCHOR_BUBBLE_TOUCHABLE_ABOVE
: views::MENU_ANCHOR_BUBBLE_TOUCHABLE_LEFT;
}
if (!context_menu) {
switch (shelf_->alignment()) {
case SHELF_ALIGNMENT_BOTTOM:
case SHELF_ALIGNMENT_BOTTOM_LOCKED:
return views::MENU_ANCHOR_BUBBLE_ABOVE;
case SHELF_ALIGNMENT_LEFT:
return views::MENU_ANCHOR_BUBBLE_RIGHT;
case SHELF_ALIGNMENT_RIGHT:
return views::MENU_ANCHOR_BUBBLE_LEFT;
}
}
return shelf_->IsHorizontalAlignment() ? views::MENU_ANCHOR_FIXED_BOTTOMCENTER
: views::MENU_ANCHOR_FIXED_SIDECENTER;
} }
gfx::Rect ShelfView::GetBoundsForDragInsertInScreen() { gfx::Rect ShelfView::GetBoundsForDragInsertInScreen() {
...@@ -2091,16 +2062,12 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model, ...@@ -2091,16 +2062,12 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model,
closing_event_time_ = base::TimeTicks(); closing_event_time_ = base::TimeTicks();
// NOTE: If you convert to HAS_MNEMONICS be sure to update menu building code. // NOTE: If you convert to HAS_MNEMONICS be sure to update menu building code.
int run_types = 0; int run_types = views::MenuRunner::USE_TOUCHABLE_LAYOUT;
if (context_menu) { if (context_menu) {
run_types |= run_types |=
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::FIXED_ANCHOR; views::MenuRunner::CONTEXT_MENU | views::MenuRunner::FIXED_ANCHOR;
} }
// Only use the touchable layout if the menu is for an app.
if (features::IsTouchableAppContextMenuEnabled())
run_types |= views::MenuRunner::USE_TOUCHABLE_LAYOUT;
const ShelfItem* item = ShelfItemForView(source); const ShelfItem* item = ShelfItemForView(source);
// Only selected shelf items with context menu opened can be dragged. // Only selected shelf items with context menu opened can be dragged.
if (context_menu && item && ShelfButtonIsInDrag(item->type, source) && if (context_menu && item && ShelfButtonIsInDrag(item->type, source) &&
...@@ -2114,7 +2081,10 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model, ...@@ -2114,7 +2081,10 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::SimpleMenuModel> menu_model,
base::BindOnce(&ShelfView::OnMenuClosed, base::Unretained(this), source)); base::BindOnce(&ShelfView::OnMenuClosed, base::Unretained(this), source));
shelf_menu_model_adapter_->Run( shelf_menu_model_adapter_->Run(
GetMenuAnchorRect(*source, click_point, context_menu), GetMenuAnchorRect(*source, click_point, context_menu),
GetMenuAnchorPosition(item, context_menu), run_types); shelf_->IsHorizontalAlignment()
? views::MENU_ANCHOR_BUBBLE_TOUCHABLE_ABOVE
: views::MENU_ANCHOR_BUBBLE_TOUCHABLE_LEFT,
run_types);
} }
void ShelfView::OnMenuClosed(views::View* source) { void ShelfView::OnMenuClosed(views::View* source) {
......
...@@ -381,13 +381,6 @@ class ASH_EXPORT ShelfView : public views::View, ...@@ -381,13 +381,6 @@ class ASH_EXPORT ShelfView : public views::View,
const gfx::Point& location, const gfx::Point& location,
bool context_menu) const; bool context_menu) const;
// Gets the menu anchor position for a menu. |for_item| is true if the menu is
// for an item on the shelf, or false if the menu is for the shelf view
// itself, |context_menu| is whether the menu will be an application menu or
// context menu, and |touch_menu| is whether the menu was initiated by touch.
views::MenuAnchorPosition GetMenuAnchorPosition(bool for_item,
bool context_menu) const;
// Overridden from views::View: // Overridden from views::View:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override; void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
......
...@@ -2190,69 +2190,30 @@ TEST_F(ShelfViewTest, DragAppAfterContextMenuIsShownInAutoHideShelf) { ...@@ -2190,69 +2190,30 @@ TEST_F(ShelfViewTest, DragAppAfterContextMenuIsShownInAutoHideShelf) {
EXPECT_EQ(first_app_id, model_->items()[last_index].id); EXPECT_EQ(first_app_id, model_->items()[last_index].id);
} }
struct TouchableAppContextMenuTestParams { // Tests that the app list button does not show a context menu on right click.
TouchableAppContextMenuTestParams(bool enable_touchable_app_context_menu, TEST_F(ShelfViewTest, AppListButtonDoesNotShowContextMenu) {
bool context_menu) ui::test::EventGenerator* generator = GetEventGenerator();
: enable_touchable_app_context_menu(enable_touchable_app_context_menu), const AppListButton* app_list_button = shelf_view_->GetAppListButton();
context_menu(context_menu) {} generator->MoveMouseTo(app_list_button->GetBoundsInScreen().CenterPoint());
// Whether to enable the touchable app context menu feature. generator->PressRightButton();
bool enable_touchable_app_context_menu; EXPECT_FALSE(test_api_->CloseMenu());
// Whether the menu is shown as an application or context menu. }
bool context_menu; // Test class that tests both context and application menus.
}; class ShelfViewMenuTest : public ShelfViewTest,
public testing::WithParamInterface<bool> {
class ShelfViewTouchableContextMenuTest
: public ShelfViewTest,
public testing::WithParamInterface<TouchableAppContextMenuTestParams> {
public: public:
ShelfViewTouchableContextMenuTest() = default; ShelfViewMenuTest() = default;
~ShelfViewTouchableContextMenuTest() override = default; ~ShelfViewMenuTest() override = default;
void SetUp() override {
// If the test is parameterized, respect the parameter. Otherwise enable
// touchable app context menus by default.
const bool enable_touchable_app_context_menu =
testing::UnitTest::GetInstance()->current_test_info()->value_param()
? GetParam().enable_touchable_app_context_menu
: true;
std::vector<base::Feature> enabled_features = {
features::kNotificationIndicator};
if (enable_touchable_app_context_menu)
enabled_features.push_back(features::kTouchableAppContextMenu);
scoped_feature_list_.InitWithFeatures(enabled_features, {});
ShelfViewTest::SetUp();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(ShelfViewTouchableContextMenuTest); DISALLOW_COPY_AND_ASSIGN(ShelfViewMenuTest);
}; };
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(, ShelfViewMenuTest, testing::Bool());
TouchableDisabledAppMenu,
ShelfViewTouchableContextMenuTest,
::testing::Values(TouchableAppContextMenuTestParams(false, false)));
INSTANTIATE_TEST_CASE_P(
TouchableEnabledAppMenu,
ShelfViewTouchableContextMenuTest,
::testing::Values(TouchableAppContextMenuTestParams(true, false)));
INSTANTIATE_TEST_CASE_P(
TouchableDisabledContextMenu,
ShelfViewTouchableContextMenuTest,
::testing::Values(TouchableAppContextMenuTestParams(false, true)));
INSTANTIATE_TEST_CASE_P(
TouchableEnabledContextMenu,
ShelfViewTouchableContextMenuTest,
::testing::Values(TouchableAppContextMenuTestParams(true, true)));
// Tests that menu anchor points are aligned with the shelf button bounds. // Tests that menu anchor points are aligned with the shelf button bounds.
TEST_P(ShelfViewTouchableContextMenuTest, ShelfViewMenuAnchorPoint) { TEST_P(ShelfViewMenuTest, ShelfViewMenuAnchorPoint) {
const ShelfButton* shelf_button = GetButtonByID(AddApp()); const ShelfButton* shelf_button = GetButtonByID(AddApp());
const bool context_menu = GetParam().context_menu; const bool context_menu = GetParam();
EXPECT_EQ(ash::ShelfAlignment::SHELF_ALIGNMENT_BOTTOM, EXPECT_EQ(ash::ShelfAlignment::SHELF_ALIGNMENT_BOTTOM,
GetPrimaryShelf()->alignment()); GetPrimaryShelf()->alignment());
...@@ -2265,13 +2226,8 @@ TEST_P(ShelfViewTouchableContextMenuTest, ShelfViewMenuAnchorPoint) { ...@@ -2265,13 +2226,8 @@ TEST_P(ShelfViewTouchableContextMenuTest, ShelfViewMenuAnchorPoint) {
// Test for left shelf. // Test for left shelf.
GetPrimaryShelf()->SetAlignment(ash::ShelfAlignment::SHELF_ALIGNMENT_LEFT); GetPrimaryShelf()->SetAlignment(ash::ShelfAlignment::SHELF_ALIGNMENT_LEFT);
int expected_x = shelf_button->GetBoundsInScreen().x();
// Left shelf context menus when TouchableAppContextMenu is disabled anchor
// off of the right edge of the shelf.
if (context_menu && !features::IsTouchableAppContextMenuEnabled())
expected_x = shelf_button->GetBoundsInScreen().right();
EXPECT_EQ( EXPECT_EQ(
expected_x, shelf_button->GetBoundsInScreen().x(),
test_api_->GetMenuAnchorRect(*shelf_button, gfx::Point(), context_menu) test_api_->GetMenuAnchorRect(*shelf_button, gfx::Point(), context_menu)
.x()); .x());
...@@ -2284,19 +2240,27 @@ TEST_P(ShelfViewTouchableContextMenuTest, ShelfViewMenuAnchorPoint) { ...@@ -2284,19 +2240,27 @@ TEST_P(ShelfViewTouchableContextMenuTest, ShelfViewMenuAnchorPoint) {
.x()); .x());
} }
// Tests that the app list button does not show a context menu on right click // Test class that enables notification indicators.
// when touchable app context menus are enabled. class NotificationIndicatorTest : public ShelfViewTest {
TEST_F(ShelfViewTouchableContextMenuTest, AppListButtonDoesNotShowContextMenu) { public:
ui::test::EventGenerator* generator = GetEventGenerator(); NotificationIndicatorTest() = default;
const AppListButton* app_list_button = shelf_view_->GetAppListButton(); ~NotificationIndicatorTest() override = default;
generator->MoveMouseTo(app_list_button->GetBoundsInScreen().CenterPoint());
generator->PressRightButton(); void SetUp() override {
EXPECT_FALSE(test_api_->CloseMenu()); scoped_feature_list_.InitWithFeatures({features::kNotificationIndicator},
} {});
ShelfViewTest::SetUp();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(NotificationIndicatorTest);
};
// Tests that an item has a notification indicator when it recieves a // Tests that an item has a notification indicator when it recieves a
// notification. // notification.
TEST_F(ShelfViewTouchableContextMenuTest, AddedItemHasNotificationIndicator) { TEST_F(NotificationIndicatorTest, AddedItemHasNotificationIndicator) {
const ShelfID id_0 = AddApp(); const ShelfID id_0 = AddApp();
const std::string notification_id_0("notification_id_0"); const std::string notification_id_0("notification_id_0");
const ShelfButton* button_0 = GetButtonByID(id_0); const ShelfButton* button_0 = GetButtonByID(id_0);
...@@ -2336,7 +2300,7 @@ TEST_F(ShelfViewTouchableContextMenuTest, AddedItemHasNotificationIndicator) { ...@@ -2336,7 +2300,7 @@ TEST_F(ShelfViewTouchableContextMenuTest, AddedItemHasNotificationIndicator) {
// Tests that the notification indicator is active until all notifications have // Tests that the notification indicator is active until all notifications have
// been removed. // been removed.
TEST_F(ShelfViewTouchableContextMenuTest, TEST_F(NotificationIndicatorTest,
NotificationIndicatorStaysActiveUntilNotificationsAreGone) { NotificationIndicatorStaysActiveUntilNotificationsAreGone) {
const ShelfID app = AddApp(); const ShelfID app = AddApp();
const ShelfButton* button = GetButtonByID(app); const ShelfButton* button = GetButtonByID(app);
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_features.h"
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
#include "ui/wm/core/window_animations.h" #include "ui/wm/core/window_animations.h"
...@@ -70,11 +69,6 @@ void ShelfWindowWatcherItemDelegate::GetContextMenuItems( ...@@ -70,11 +69,6 @@ void ShelfWindowWatcherItemDelegate::GetContextMenuItems(
close->label = l10n_util::GetStringUTF16(IDS_CLOSE); close->label = l10n_util::GetStringUTF16(IDS_CLOSE);
close->enabled = true; close->enabled = true;
items.push_back(std::move(close)); items.push_back(std::move(close));
if (!features::IsTouchableAppContextMenuEnabled()) {
ash::mojom::MenuItemPtr separator(ash::mojom::MenuItem::New());
separator->type = ui::MenuModel::TYPE_SEPARATOR;
items.push_back(std::move(separator));
}
std::move(callback).Run(std::move(items)); std::move(callback).Run(std::move(items));
} }
......
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