Commit 541a62b9 authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

[WebAPK] Fallback to shortcut name if short_name not provided

Bug: 1057381
Change-Id: I6e35e6991a96d452c41b9e5eee945948bf630ce5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093221Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Dominick Ng <dominickn@chromium.org>
Auto-Submit: Rayan Kanso <rayankans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748936}
parent 35aa76ef
......@@ -120,6 +120,13 @@ void ShortcutInfo::UpdateFromManifest(const blink::Manifest& manifest) {
if (shortcut_items.size() > kMaxShortcuts)
shortcut_items.resize(kMaxShortcuts);
for (auto& shortcut_item : shortcut_items) {
if (shortcut_item.short_name.string().empty()) {
shortcut_item.short_name =
base::NullableString16(shortcut_item.name, /* is_null= */ false);
}
}
int ideal_shortcut_icons_size_px =
ShortcutHelper::GetIdealShortcutIconSizeInPx();
for (const auto& manifest_shortcut : shortcut_items) {
......
......@@ -148,3 +148,17 @@ TEST_F(ShortcutInfoTest, ShortcutItemsPopulated) {
EXPECT_EQ(info_.best_shortcut_icon_urls[1].path(), "/i2_2");
EXPECT_FALSE(info_.best_shortcut_icon_urls[2].is_valid());
}
// Tests that if the optional shortcut short_name value is not provided, the
// required name value is used.
TEST_F(ShortcutInfoTest, ShortcutShortNameBackfilled) {
// Create a shortcut without a |short_name|.
manifest_.shortcuts.push_back(
CreateShortcut(/* name= */ "name", /* icons= */ {}));
info_.UpdateFromManifest(manifest_);
ASSERT_EQ(info_.shortcut_items.size(), 1u);
EXPECT_EQ(info_.shortcut_items[0].short_name.string(),
base::UTF8ToUTF16("name"));
}
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