Commit f738447c authored by Nicholas Hollingum's avatar Nicholas Hollingum Committed by Commit Bot

Adding new context-menu icons for crostini apps

New icons include:
 - Shutting down the vm from the terminal's context menu
 - Switching to {low,high}-density mode for a crostini apps

The icons were created by sgabriel@ and converted to .icon format using
a skiafy tool (http://evanstade.github.io/skiafy/).

Bug: 930858
Change-Id: I9b4b952c810685f5e067a63c9749ad853cc849f3
Reviewed-on: https://chromium-review.googlesource.com/c/1490358Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Nic Hollingum <hollingum@google.com>
Cr-Commit-Position: refs/heads/master@{#636164}
parent 2d33cbf8
......@@ -189,7 +189,6 @@ void LauncherContextMenu::AddContextMenuOption(ui::SimpleMenuModel* menu_model,
const gfx::VectorIcon& LauncherContextMenu::GetCommandIdVectorIcon(
ash::CommandId type,
int string_id) const {
static const gfx::VectorIcon blank = {};
switch (type) {
case ash::MENU_OPEN_NEW:
if (string_id == IDS_APP_LIST_CONTEXT_MENU_NEW_TAB)
......@@ -211,22 +210,26 @@ const gfx::VectorIcon& LauncherContextMenu::GetCommandIdVectorIcon(
case ash::LAUNCH_TYPE_FULLSCREEN:
case ash::LAUNCH_TYPE_WINDOW:
// Check items use a default icon in touchable and default context menus.
return blank;
return gfx::kNoneIcon;
case ash::NOTIFICATION_CONTAINER:
NOTREACHED() << "NOTIFICATION_CONTAINER does not have an icon, and it is "
"added to the model by NotificationMenuController.";
return blank;
return gfx::kNoneIcon;
case ash::STOP_APP:
// TODO(crbug.com/930869) This is a placeholder, the real icon has not
// been approved yet.
return blank;
if (string_id == IDS_CROSTINI_SHUT_DOWN_LINUX_MENU_ITEM)
return views::kLinuxShutdownIcon;
return gfx::kNoneIcon;
case ash::CROSTINI_USE_HIGH_DENSITY:
return views::kLinuxHighDensityIcon;
case ash::CROSTINI_USE_LOW_DENSITY:
return views::kLinuxLowDensityIcon;
case ash::LAUNCH_APP_SHORTCUT_FIRST:
case ash::LAUNCH_APP_SHORTCUT_LAST:
case ash::COMMAND_ID_COUNT:
NOTREACHED();
return blank;
return gfx::kNoneIcon;
default:
NOTREACHED();
return blank;
return gfx::kNoneIcon;
}
}
......@@ -526,6 +526,8 @@ TEST_F(LauncherContextMenuTest, InternalAppShelfContextMenuOptionsNumber) {
TEST_F(LauncherContextMenuTest, CrostiniTerminalApp) {
crostini::CrostiniTestHelper crostini_helper(profile());
const std::string app_id = crostini::kCrostiniTerminalId;
crostini::CrostiniManager::GetForProfile(profile())->AddRunningVmForTesting(
crostini::kCrostiniDefaultVmName);
controller()->PinAppWithID(app_id);
const ash::ShelfItem* item = controller()->GetItem(ash::ShelfID(app_id));
......@@ -544,6 +546,51 @@ TEST_F(LauncherContextMenuTest, CrostiniTerminalApp) {
EXPECT_TRUE(menu->GetIconAt(i, &icon));
EXPECT_FALSE(icon.IsEmpty());
}
// When crostini is running, the terminal should have an option to kill the
// vm.
EXPECT_TRUE(IsItemEnabledInMenu(menu.get(), ash::STOP_APP));
}
// Checks the context menu for a "normal" crostini app (i.e. a registered one).
// Particularly, we ensure that the density changing option exists.
TEST_F(LauncherContextMenuTest, CrostiniNormalApp) {
crostini::CrostiniTestHelper crostini_helper(profile());
const std::string app_name = "foo";
crostini_helper.AddApp(crostini::CrostiniTestHelper::BasicApp(app_name));
const std::string app_id =
crostini::CrostiniTestHelper::GenerateAppId(app_name);
crostini::CrostiniRegistryServiceFactory::GetForProfile(profile())
->AppLaunched(app_id);
controller()->PinAppWithID(app_id);
const ash::ShelfItem* item = controller()->GetItem(ash::ShelfID(app_id));
ASSERT_TRUE(item);
ash::ShelfItemDelegate* item_delegate =
model()->GetShelfItemDelegate(ash::ShelfID(app_id));
ASSERT_TRUE(item_delegate);
int64_t primary_id = GetPrimaryDisplay().id();
// We force a scale factor of 2.0, to check that the normal app has a menu
// option to change the dpi settings.
UpdateDisplay("1920x1080*2.0");
std::unique_ptr<ui::MenuModel> menu =
GetContextMenu(item_delegate, primary_id);
// Check that every menu item has an icon
for (int i = 0; i < menu->GetItemCount(); ++i) {
gfx::Image icon;
EXPECT_TRUE(menu->GetIconAt(i, &icon));
EXPECT_FALSE(icon.IsEmpty());
}
// Precisely which density option is shown is not important to us, we only
// care that one is shown.
EXPECT_TRUE(IsItemEnabledInMenu(menu.get(), ash::CROSTINI_USE_LOW_DENSITY) ||
IsItemEnabledInMenu(menu.get(), ash::CROSTINI_USE_HIGH_DENSITY));
}
// Confirms the menu items for unregistered crostini apps (i.e. apps that do not
......
......@@ -26,6 +26,9 @@ aggregate_vector_icons("views_vector_icons") {
"ic_close.icon",
"info.icon",
"launch.icon",
"linux_high_density.icon",
"linux_low_density.icon",
"linux_shutdown.icon",
"menu_check.icon",
"menu_drop_arrow.icon",
"menu_radio_empty.icon",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 20,
MOVE_TO, 7, 17,
V_LINE_TO, 7,
R_H_LINE_TO, 10,
R_V_LINE_TO, 10,
CLOSE,
R_MOVE_TO, 8, -2,
V_LINE_TO, 9,
H_LINE_TO, 9,
R_V_LINE_TO, 6,
CLOSE,
R_MOVE_TO, 2, -10,
R_H_LINE_TO, -2,
V_LINE_TO, 3,
R_H_LINE_TO, 2,
CLOSE,
MOVE_TO, 5, 17,
H_LINE_TO, 3,
R_V_LINE_TO, -2,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 8, -12,
R_H_LINE_TO, -2,
V_LINE_TO, 3,
R_H_LINE_TO, 2,
CLOSE,
MOVE_TO, 9, 5,
H_LINE_TO, 7,
V_LINE_TO, 3,
R_H_LINE_TO, 2,
CLOSE,
MOVE_TO, 5, 5,
H_LINE_TO, 3,
V_LINE_TO, 3,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 0, 4,
H_LINE_TO, 3,
V_LINE_TO, 7,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 0, 4,
H_LINE_TO, 3,
R_V_LINE_TO, -2,
R_H_LINE_TO, 2,
CLOSE
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 20,
MOVE_TO, 9, 17,
H_LINE_TO, 3,
V_LINE_TO, 3,
R_H_LINE_TO, 14,
R_V_LINE_TO, 6,
R_H_LINE_TO, -2,
V_LINE_TO, 5,
H_LINE_TO, 5,
R_V_LINE_TO, 10,
R_H_LINE_TO, 4,
CLOSE,
R_MOVE_TO, 8, 0,
R_H_LINE_TO, -2,
R_V_LINE_TO, -2,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, -4, 0,
R_H_LINE_TO, -2,
R_V_LINE_TO, -2,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, -4, -4,
H_LINE_TO, 7,
R_V_LINE_TO, -2,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 0, -4,
H_LINE_TO, 7,
V_LINE_TO, 7,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 4, 0,
R_H_LINE_TO, -2,
V_LINE_TO, 7,
R_H_LINE_TO, 2,
CLOSE,
R_MOVE_TO, 4, 4,
R_H_LINE_TO, -2,
R_V_LINE_TO, -2,
R_H_LINE_TO, 2,
CLOSE
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 20,
MOVE_TO, 14.24f, 5.76f,
R_ARC_TO, 1, 1, 0, 1, 1, 1.41f, -1.41f,
R_ARC_TO, 8, 8, 0, 1, 1, -11.31f, 0,
R_ARC_TO, 1, 1, 0, 1, 1, 1.41f, 1.41f,
R_ARC_TO, 6, 6, 0, 1, 0, 8.49f, 0,
CLOSE,
MOVE_TO, 9, 3,
R_ARC_TO, 1, 1, 0, 0, 1, 2, 0,
R_V_LINE_TO, 8,
R_ARC_TO, 1, 1, 0, 1, 1, -2, 0,
CLOSE
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