Commit 5d24d399 authored by Stephane Zermatten's avatar Stephane Zermatten Committed by Commit Bot

[Autofill Assistant] Add back support for prompt choices without chips.

Before this change, a PromptProto.Choice with only element_exists would
be rendered as a chip with no names.

After this change, we can add PromptProto.Choice again with only
element_exists set and no chip definitions set, neither name, nor icon,
nor chip type. This is useful to script automatic end of the prompt
action.

Bug: b/132950869
Change-Id: Ie552934311d8345c4a5496b10d7a63e2bc97c705
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1617520Reviewed-by: default avatarJordan Demeulenaere <jdemeulenaere@chromium.org>
Commit-Queue: Jordan Demeulenaere <jdemeulenaere@chromium.org>
Auto-Submit: Stephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662549}
parent ea30c011
......@@ -111,10 +111,15 @@ void PromptAction::UpdateChips() {
auto chips = std::make_unique<std::vector<Chip>>();
for (int i = 0; i < proto_.prompt().choices_size(); i++) {
auto& choice_proto = proto_.prompt().choices(i);
if (!precondition_results_[i] && !choice_proto.allow_disabling()) {
// hide chip.
// Don't show choices with no names, icon or types; they're likely just
// there for auto_select_if_element_exists.
if (choice_proto.name().empty() && choice_proto.chip_icon() == NO_ICON &&
choice_proto.chip_type() == UNKNOWN_CHIP_TYPE)
continue;
// Hide chips whose precondition don't match.
if (!precondition_results_[i] && !choice_proto.allow_disabling())
continue;
}
chips->emplace_back();
Chip& chip = chips->back();
......
......@@ -162,6 +162,7 @@ TEST_F(PromptActionTest, AutoSelect) {
PromptAction action(proto_);
action.ProcessAction(&mock_action_delegate_, callback_.Get());
EXPECT_THAT(chips_, Pointee(SizeIs(0)));
EXPECT_CALL(mock_web_controller_,
OnElementCheck(Eq(Selector({"element"})), _))
......@@ -182,7 +183,6 @@ TEST_F(PromptActionTest, AutoSelectWithButton) {
ok_proto->set_name("Ok");
ok_proto->set_chip_type(HIGHLIGHTED_ACTION);
ok_proto->set_server_payload("ok");
ok_proto->add_show_only_if_element_exists()->add_selectors("element");
auto* choice_proto = prompt_proto_->add_choices();
choice_proto->set_server_payload("auto-select");
......
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