Show different string when GIFs are disabled for Picker.
Introduce a new category type kEmojis which is only emojis. Handle it the same way as kEmojisGifs, except give it a different string. Fixed: b:359333065 Change-Id: I6c3817b644ca5cbd24bb419ec2984561e3f41ba2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5785426 Reviewed-by: Michael Cui <mlcui@google.com> Commit-Queue: Darren Shen <shend@chromium.org> Cr-Commit-Position: refs/heads/main@{#1341525}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
36969e9f0b
commit
b052b5de88
ash
ash_strings.grd
ash_strings_grd
picker
public
cpp
picker
chrome/browser/ui/ash/picker
@ -7373,6 +7373,10 @@ New install
|
||||
desc="This string appears in a selectable menu item in a menu. When selected, it opens the ChromeOS emoji picker. The term 'more' indicates that it has more than just emojis and GIFs, including symbols and emoticons.">
|
||||
Emojis, GIFs, and more
|
||||
</message>
|
||||
<message name="IDS_PICKER_EMOJIS_CATEGORY_LABEL"
|
||||
desc="This string appears in a selectable menu item in a menu. When selected, it opens the ChromeOS emoji picker. The term 'more' indicates that it has more than just emojis, including symbols and emoticons.">
|
||||
Emojis and more
|
||||
</message>
|
||||
<message name="IDS_PICKER_LINKS_CATEGORY_LABEL"
|
||||
desc="This string appears in a selectable menu item in a menu. When selected, it navigates to another page showing the user's recent browsing history. Browsing history refers to recent websites that the user has visited.">
|
||||
Browsing history
|
||||
|
@ -0,0 +1 @@
|
||||
d207aaff6c5f3119d7c03ff50e2953c5c2a63c33
|
@ -112,6 +112,7 @@ cros_events::PickerAction ConvertToCrosEventAction(
|
||||
case PickerCategory::kLinks:
|
||||
return cros_events::PickerAction::OPEN_LINKS;
|
||||
case PickerCategory::kEmojisGifs:
|
||||
case PickerCategory::kEmojis:
|
||||
return cros_events::PickerAction::OPEN_EXPRESSIONS;
|
||||
case PickerCategory::kClipboard:
|
||||
return cros_events::PickerAction::OPEN_CLIPBOARD;
|
||||
|
@ -94,7 +94,8 @@ std::vector<PickerCategory> PickerModel::GetAvailableCategories() const {
|
||||
}
|
||||
categories.push_back(PickerCategory::kLinks);
|
||||
if (text_input_type_ != ui::TextInputType::TEXT_INPUT_TYPE_URL) {
|
||||
categories.push_back(PickerCategory::kEmojisGifs);
|
||||
categories.push_back(is_gifs_enabled_ ? PickerCategory::kEmojisGifs
|
||||
: PickerCategory::kEmojis);
|
||||
}
|
||||
categories.insert(categories.end(), {
|
||||
PickerCategory::kClipboard,
|
||||
|
@ -40,7 +40,7 @@ TEST(PickerModel, AvailableCategoriesWithNoSelectedTextHasCorrectOrdering) {
|
||||
EXPECT_THAT(
|
||||
model.GetAvailableCategories(),
|
||||
ElementsAre(PickerCategory::kEditorWrite, PickerCategory::kLinks,
|
||||
PickerCategory::kEmojisGifs, PickerCategory::kClipboard,
|
||||
PickerCategory::kEmojis, PickerCategory::kClipboard,
|
||||
PickerCategory::kDriveFiles, PickerCategory::kLocalFiles,
|
||||
PickerCategory::kDatesTimes, PickerCategory::kUnitsMaths));
|
||||
}
|
||||
@ -87,12 +87,44 @@ TEST(PickerModel, AvailableCategoriesContainsEditorRewriteWhenEnabled) {
|
||||
Contains(PickerCategory::kEditorRewrite));
|
||||
}
|
||||
|
||||
TEST(PickerModel, AvailableCategoriesContainsEmojisAndGifsWhenGifsEnabled) {
|
||||
sync_preferences::TestingPrefServiceSyncable prefs;
|
||||
prefs.registry()->RegisterBooleanPref(prefs::kEmojiPickerGifSupportEnabled,
|
||||
true);
|
||||
input_method::FakeImeKeyboard fake_ime_keyboard;
|
||||
ui::FakeTextInputClient client({.type = ui::TEXT_INPUT_TYPE_TEXT});
|
||||
|
||||
PickerModel model(/*prefs=*/&prefs, &client, &fake_ime_keyboard,
|
||||
PickerModel::EditorStatus::kEnabled);
|
||||
EXPECT_THAT(model.GetAvailableCategories(),
|
||||
Contains(PickerCategory::kEmojisGifs));
|
||||
EXPECT_THAT(model.GetAvailableCategories(),
|
||||
Not(Contains(PickerCategory::kEmojis)));
|
||||
}
|
||||
|
||||
TEST(PickerModel, AvailableCategoriesContainsOnlyEmojisWhenGifsDisables) {
|
||||
sync_preferences::TestingPrefServiceSyncable prefs;
|
||||
prefs.registry()->RegisterBooleanPref(prefs::kEmojiPickerGifSupportEnabled,
|
||||
false);
|
||||
input_method::FakeImeKeyboard fake_ime_keyboard;
|
||||
ui::FakeTextInputClient client({.type = ui::TEXT_INPUT_TYPE_TEXT});
|
||||
|
||||
PickerModel model(/*prefs=*/&prefs, &client, &fake_ime_keyboard,
|
||||
PickerModel::EditorStatus::kEnabled);
|
||||
EXPECT_THAT(model.GetAvailableCategories(),
|
||||
Contains(PickerCategory::kEmojis));
|
||||
EXPECT_THAT(model.GetAvailableCategories(),
|
||||
Not(Contains(PickerCategory::kEmojisGifs)));
|
||||
}
|
||||
|
||||
TEST(PickerModel, AvailableCategoriesDoesNotContainExpressionsForUrlFields) {
|
||||
input_method::FakeImeKeyboard fake_ime_keyboard;
|
||||
ui::FakeTextInputClient client({.type = ui::TEXT_INPUT_TYPE_URL});
|
||||
|
||||
PickerModel model(/*prefs=*/nullptr, &client, &fake_ime_keyboard,
|
||||
PickerModel::EditorStatus::kEnabled);
|
||||
EXPECT_THAT(model.GetAvailableCategories(),
|
||||
Not(Contains(PickerCategory::kEmojis)));
|
||||
EXPECT_THAT(model.GetAvailableCategories(),
|
||||
Not(Contains(PickerCategory::kEmojisGifs)));
|
||||
}
|
||||
|
@ -1206,6 +1206,12 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
.no_selection_action = PickerActionType::kDo,
|
||||
.has_selection_action = PickerActionType::kDo,
|
||||
},
|
||||
{
|
||||
.result = PickerSearchResult::Category(PickerCategory::kEmojis),
|
||||
.unfocused_action = PickerActionType::kDo,
|
||||
.no_selection_action = PickerActionType::kDo,
|
||||
.has_selection_action = PickerActionType::kDo,
|
||||
},
|
||||
{
|
||||
.result = PickerSearchResult::SearchRequest(u"", u"", {}),
|
||||
.unfocused_action = PickerActionType::kDo,
|
||||
|
@ -93,6 +93,7 @@ void PickerSuggestionsController::GetSuggestionsForCategory(
|
||||
client_->GetSuggestedLinkResults(std::move(callback));
|
||||
return;
|
||||
case PickerCategory::kEmojisGifs:
|
||||
case PickerCategory::kEmojis:
|
||||
NOTREACHED_NORETURN();
|
||||
case PickerCategory::kDriveFiles:
|
||||
client_->GetRecentDriveFileResults(kMaxRecentFiles, std::move(callback));
|
||||
|
@ -68,6 +68,7 @@ constexpr base::span<const PickerCategory> kAllCategories = {(PickerCategory[]){
|
||||
PickerCategory::kEditorRewrite,
|
||||
PickerCategory::kLinks,
|
||||
PickerCategory::kEmojisGifs,
|
||||
PickerCategory::kEmojis,
|
||||
PickerCategory::kClipboard,
|
||||
PickerCategory::kDriveFiles,
|
||||
PickerCategory::kLocalFiles,
|
||||
|
@ -61,6 +61,7 @@ constexpr base::span<const PickerCategory> kAllCategories = {(PickerCategory[]){
|
||||
PickerCategory::kEditorRewrite,
|
||||
PickerCategory::kLinks,
|
||||
PickerCategory::kEmojisGifs,
|
||||
PickerCategory::kEmojis,
|
||||
PickerCategory::kClipboard,
|
||||
PickerCategory::kDriveFiles,
|
||||
PickerCategory::kLocalFiles,
|
||||
|
@ -16,6 +16,7 @@ ASH_EXPORT PickerCategoryType GetPickerCategoryType(PickerCategory category) {
|
||||
return PickerCategoryType::kEditorRewrite;
|
||||
case PickerCategory::kLinks:
|
||||
case PickerCategory::kEmojisGifs:
|
||||
case PickerCategory::kEmojis:
|
||||
case PickerCategory::kClipboard:
|
||||
case PickerCategory::kDriveFiles:
|
||||
case PickerCategory::kLocalFiles:
|
||||
|
@ -21,6 +21,7 @@ const gfx::VectorIcon& GetVectorIconForPickerCategory(PickerCategory category) {
|
||||
// TODO: b/322926823 - Use correct icons.
|
||||
return kPencilIcon;
|
||||
case PickerCategory::kEmojisGifs:
|
||||
case PickerCategory::kEmojis:
|
||||
return kPickerEmojiIcon;
|
||||
case PickerCategory::kLinks:
|
||||
return kPickerBrowsingHistoryIcon;
|
||||
|
@ -39,6 +39,8 @@ std::u16string GetLabelForPickerCategory(PickerCategory category) {
|
||||
return l10n_util::GetStringUTF16(IDS_PICKER_LINKS_CATEGORY_LABEL);
|
||||
case PickerCategory::kEmojisGifs:
|
||||
return l10n_util::GetStringUTF16(IDS_PICKER_EXPRESSIONS_CATEGORY_LABEL);
|
||||
case PickerCategory::kEmojis:
|
||||
return l10n_util::GetStringUTF16(IDS_PICKER_EMOJIS_CATEGORY_LABEL);
|
||||
case PickerCategory::kClipboard:
|
||||
return l10n_util::GetStringUTF16(IDS_PICKER_CLIPBOARD_CATEGORY_LABEL);
|
||||
case PickerCategory::kDriveFiles:
|
||||
@ -76,6 +78,7 @@ std::u16string GetSearchFieldPlaceholderTextForPickerCategory(
|
||||
case PickerCategory::kEditorWrite:
|
||||
case PickerCategory::kEditorRewrite:
|
||||
case PickerCategory::kEmojisGifs:
|
||||
case PickerCategory::kEmojis:
|
||||
NOTREACHED_NORETURN();
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +244,7 @@ std::u16string GetNoResultsFoundDescription(PickerCategory category) {
|
||||
case PickerCategory::kEditorWrite:
|
||||
case PickerCategory::kEditorRewrite:
|
||||
case PickerCategory::kEmojisGifs:
|
||||
case PickerCategory::kEmojis:
|
||||
NOTREACHED_NORETURN();
|
||||
}
|
||||
}
|
||||
@ -292,7 +293,9 @@ PickerView::PickerView(PickerViewDelegate* delegate,
|
||||
|
||||
AddMainContainerView(layout_type);
|
||||
if (base::Contains(delegate_->GetAvailableCategories(),
|
||||
PickerCategory::kEmojisGifs)) {
|
||||
PickerCategory::kEmojisGifs) ||
|
||||
base::Contains(delegate_->GetAvailableCategories(),
|
||||
PickerCategory::kEmojis)) {
|
||||
AddEmojiBarView();
|
||||
}
|
||||
|
||||
@ -684,7 +687,8 @@ void PickerView::SelectCategoryWithQuery(PickerCategory category,
|
||||
session_metrics.SetSelectedCategory(category);
|
||||
selected_category_ = category;
|
||||
|
||||
if (category == PickerCategory::kEmojisGifs) {
|
||||
if (category == PickerCategory::kEmojisGifs ||
|
||||
category == PickerCategory::kEmojis) {
|
||||
if (auto* widget = GetWidget()) {
|
||||
// TODO(b/316936394): Correctly handle opening of emoji picker. Probably
|
||||
// best to wait for the IME on focus event, or save some coordinates and
|
||||
|
@ -156,6 +156,16 @@ class PickerViewTest : public AshTestBase {
|
||||
metrics::structured::TestStructuredMetricsRecorder metrics_recorder_;
|
||||
};
|
||||
|
||||
// PickerViewTest parameterized by the Emoji Category.
|
||||
class PickerViewEmojiTest : public PickerViewTest,
|
||||
public testing::WithParamInterface<PickerCategory> {
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(,
|
||||
PickerViewEmojiTest,
|
||||
testing::ValuesIn({PickerCategory::kEmojisGifs,
|
||||
PickerCategory::kEmojis}));
|
||||
|
||||
class FakePickerViewDelegate : public PickerViewDelegate {
|
||||
public:
|
||||
using FakeSearchFunction =
|
||||
@ -304,9 +314,9 @@ PickerItemView* GetFirstCategoryItemView(PickerView* picker_view) {
|
||||
->second->item_views_for_testing()[0];
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, SizeIsLessThanMaxWhenNoContentWithoutEmojiBar) {
|
||||
TEST_P(PickerViewEmojiTest, SizeIsLessThanMaxWhenNoContentWithoutEmojiBar) {
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kEmojisGifs},
|
||||
.available_categories = {GetParam()},
|
||||
});
|
||||
auto widget = PickerWidget::Create(&delegate, kDefaultAnchorBounds);
|
||||
widget->Show();
|
||||
@ -316,9 +326,9 @@ TEST_F(PickerViewTest, SizeIsLessThanMaxWhenNoContentWithoutEmojiBar) {
|
||||
EXPECT_LT(view->size().height(), 300);
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, SizeIsLessThanMaxWhenNoContentWithEmojiBar) {
|
||||
TEST_P(PickerViewEmojiTest, SizeIsLessThanMaxWhenNoContentWithEmojiBar) {
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kEmojisGifs},
|
||||
.available_categories = {GetParam()},
|
||||
});
|
||||
auto widget = PickerWidget::Create(&delegate, kDefaultAnchorBounds);
|
||||
widget->Show();
|
||||
@ -341,9 +351,9 @@ TEST_F(PickerViewTest, SizeIsMaxWhenLotsOfContentWithoutEmojiBar) {
|
||||
EXPECT_EQ(view->size(), gfx::Size(kPickerViewWidth, 300));
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, SizeIsMaxWhenLotsOfContentWithEmojiBar) {
|
||||
TEST_P(PickerViewEmojiTest, SizeIsMaxWhenLotsOfContentWithEmojiBar) {
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kEmojisGifs},
|
||||
.available_categories = {GetParam()},
|
||||
.zero_state_suggested_results =
|
||||
std::vector<PickerSearchResult>(10, PickerSearchResult::Text(u"abc")),
|
||||
});
|
||||
@ -692,10 +702,9 @@ TEST_F(PickerViewTest, SearchingWithCategoryKeepsShowingBackButton) {
|
||||
.GetVisible());
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, SelectingCategoryHidesEmojiBar) {
|
||||
TEST_P(PickerViewEmojiTest, SelectingCategoryHidesEmojiBar) {
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kLinks,
|
||||
PickerCategory::kEmojisGifs},
|
||||
.available_categories = {PickerCategory::kLinks, GetParam()},
|
||||
});
|
||||
auto widget = PickerWidget::Create(&delegate, kDefaultAnchorBounds);
|
||||
widget->Show();
|
||||
@ -709,10 +718,9 @@ TEST_F(PickerViewTest, SelectingCategoryHidesEmojiBar) {
|
||||
EXPECT_FALSE(picker_view->emoji_bar_view_for_testing()->GetVisible());
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, ReturningToZeroStateFromCategoryPageShowsEmojiBar) {
|
||||
TEST_P(PickerViewEmojiTest, ReturningToZeroStateFromCategoryPageShowsEmojiBar) {
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kLinks,
|
||||
PickerCategory::kEmojisGifs},
|
||||
.available_categories = {PickerCategory::kLinks, GetParam()},
|
||||
});
|
||||
auto widget = PickerWidget::Create(&delegate, kDefaultAnchorBounds);
|
||||
widget->Show();
|
||||
@ -1297,10 +1305,10 @@ TEST_F(PickerViewTest, NoMainResultsAndNoEmojisIsAnnounced) {
|
||||
EXPECT_EQ(counter.GetCount(ax::mojom::Event::kLiveRegionChanged), 1);
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, NoMainResultsAndSomeEmojisIsAnnounced) {
|
||||
TEST_P(PickerViewEmojiTest, NoMainResultsAndSomeEmojisIsAnnounced) {
|
||||
base::test::TestFuture<FakePickerViewDelegate::SearchResultsCallback> future;
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kEmojisGifs},
|
||||
.available_categories = {GetParam()},
|
||||
.search_function = base::BindLambdaForTesting(
|
||||
[&](std::u16string_view query,
|
||||
FakePickerViewDelegate::SearchResultsCallback callback) {
|
||||
@ -1624,9 +1632,9 @@ TEST_F(PickerViewTest, StopsSearchWhenCategorySelectedInSearchResults) {
|
||||
EXPECT_TRUE(stop_search_future.Wait());
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, SearchingShowsExpressionResultsInEmojiBar) {
|
||||
TEST_P(PickerViewEmojiTest, SearchingShowsExpressionResultsInEmojiBar) {
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kEmojisGifs},
|
||||
.available_categories = {GetParam()},
|
||||
.emoji_results = {PickerSearchResult::Emoji(u"😊"),
|
||||
PickerSearchResult::Symbol(u"♬")},
|
||||
});
|
||||
@ -1643,9 +1651,9 @@ TEST_F(PickerViewTest, SearchingShowsExpressionResultsInEmojiBar) {
|
||||
Truly(&views::IsViewClass<PickerSymbolItemView>)));
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, InitiallyShowsSuggestedEmojis) {
|
||||
TEST_P(PickerViewEmojiTest, InitiallyShowsSuggestedEmojis) {
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kEmojisGifs},
|
||||
.available_categories = {GetParam()},
|
||||
.suggested_emojis = {"😊", "👍"},
|
||||
});
|
||||
auto widget = PickerWidget::Create(&delegate, kDefaultAnchorBounds);
|
||||
@ -1938,9 +1946,9 @@ TEST_F(PickerViewTest, MainContentAboveSearchFieldNearBottomOfScreen) {
|
||||
view->search_field_view_for_testing().GetBoundsInScreen().y());
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest, ShowsEmojiPickerWhenClickingOnExpressions) {
|
||||
TEST_P(PickerViewEmojiTest, ShowsEmojiPickerWhenClickingOnExpressions) {
|
||||
FakePickerViewDelegate delegate({
|
||||
.available_categories = {PickerCategory::kEmojisGifs},
|
||||
.available_categories = {GetParam()},
|
||||
});
|
||||
auto widget = PickerWidget::Create(&delegate, kDefaultAnchorBounds);
|
||||
widget->Show();
|
||||
@ -2604,10 +2612,9 @@ TEST_F(PickerViewTest, KeyNavigationToSeeMoreResults) {
|
||||
.GetVisible());
|
||||
}
|
||||
|
||||
TEST_F(PickerViewTest,
|
||||
TEST_P(PickerViewEmojiTest,
|
||||
ClickingMoreEmojisButtonOpensEmojiPickerWithQuerySearch) {
|
||||
FakePickerViewDelegate delegate(
|
||||
{.available_categories = {PickerCategory::kEmojisGifs}});
|
||||
FakePickerViewDelegate delegate({.available_categories = {GetParam()}});
|
||||
auto widget = PickerWidget::Create(&delegate, kDefaultAnchorBounds);
|
||||
widget->Show();
|
||||
PressAndReleaseKey(ui::KeyboardCode::VKEY_A, ui::EF_NONE);
|
||||
|
@ -17,6 +17,7 @@ enum class ASH_PUBLIC_EXPORT PickerCategory {
|
||||
// General categories:
|
||||
kLinks,
|
||||
kEmojisGifs,
|
||||
kEmojis,
|
||||
kClipboard,
|
||||
kDriveFiles,
|
||||
kLocalFiles,
|
||||
|
@ -274,6 +274,7 @@ void PickerClientImpl::StartCrosSearch(
|
||||
case ash::PickerCategory::kEditorWrite:
|
||||
case ash::PickerCategory::kEditorRewrite:
|
||||
case ash::PickerCategory::kEmojisGifs:
|
||||
case ash::PickerCategory::kEmojis:
|
||||
case ash::PickerCategory::kClipboard:
|
||||
case ash::PickerCategory::kDatesTimes:
|
||||
case ash::PickerCategory::kUnitsMaths:
|
||||
@ -521,6 +522,7 @@ PickerClientImpl::CreateSearchProviderForCategory(
|
||||
case ash::PickerCategory::kEditorWrite:
|
||||
case ash::PickerCategory::kEditorRewrite:
|
||||
case ash::PickerCategory::kEmojisGifs:
|
||||
case ash::PickerCategory::kEmojis:
|
||||
case ash::PickerCategory::kClipboard:
|
||||
case ash::PickerCategory::kDatesTimes:
|
||||
case ash::PickerCategory::kUnitsMaths:
|
||||
|
Reference in New Issue
Block a user