Commit 67ebc1eb authored by sandromaggi's avatar sandromaggi Committed by Commit Bot

[Autofill Assistant] ProgressBar off by 1

The definition states that the icon to activate is its index, not index +1.

Bug: b/168611883
Change-Id: I83349198e0ca4b555e01e7d0a713d5ce580ef41b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424138
Auto-Submit: Sandro Maggi <sandromaggi@google.com>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#809863}
parent 1127af8a
......@@ -189,20 +189,20 @@ public class AutofillAssistantProgressBarIntegrationTest {
.addChoices(Choice.newBuilder().setChip(
ChipProto.newBuilder().setText("Next"))))
.build());
list.add((ActionProto) ActionProto.newBuilder()
.setShowProgressBar(ShowProgressBarProto.newBuilder().setActiveStep(1))
.build());
list.add(
(ActionProto) ActionProto.newBuilder()
.setShowProgressBar(
ShowProgressBarProto.newBuilder().setActiveStepIdentifier("icon_2"))
.build());
list.add((ActionProto) ActionProto.newBuilder()
.setPrompt(PromptProto.newBuilder()
.setMessage("Next Step")
.addChoices(Choice.newBuilder().setChip(
ChipProto.newBuilder().setText("Next"))))
.build());
list.add(
(ActionProto) ActionProto.newBuilder()
.setShowProgressBar(
ShowProgressBarProto.newBuilder().setActiveStepIdentifier("icon_4"))
.build());
list.add((ActionProto) ActionProto.newBuilder()
.setShowProgressBar(ShowProgressBarProto.newBuilder().setActiveStep(4))
.build());
list.add((ActionProto) ActionProto.newBuilder()
.setPrompt(PromptProto.newBuilder()
.setMessage("Final Step")
......
......@@ -289,11 +289,8 @@ bool Controller::SetProgressActiveStepIdentifier(
return false;
}
SetProgressActiveStep(
std::distance(
step_progress_bar_configuration_->annotated_step_icons().cbegin(),
it) +
1);
SetProgressActiveStep(std::distance(
step_progress_bar_configuration_->annotated_step_icons().cbegin(), it));
return true;
}
......
......@@ -745,7 +745,7 @@ TEST_F(ControllerTest, ProgressStepClampsOverflowToMax) {
EXPECT_EQ(3, *controller_->GetProgressActiveStep());
}
TEST_F(ControllerTest, SetProgressStepFromIdentifierFails) {
TEST_F(ControllerTest, SetProgressStepFromIdentifier) {
Start();
ShowProgressBarProto::StepProgressBarConfiguration config;
......@@ -754,9 +754,9 @@ TEST_F(ControllerTest, SetProgressStepFromIdentifierFails) {
config.add_annotated_step_icons()->set_identifier("icon2");
controller_->SetStepProgressBarConfiguration(config);
EXPECT_CALL(mock_observer_, OnProgressActiveStepChanged(2)).Times(1);
EXPECT_CALL(mock_observer_, OnProgressActiveStepChanged(1)).Times(1);
EXPECT_TRUE(controller_->SetProgressActiveStepIdentifier("icon2"));
EXPECT_EQ(2, *controller_->GetProgressActiveStep());
EXPECT_EQ(1, *controller_->GetProgressActiveStep());
}
TEST_F(ControllerTest, SetProgressStepFromUnknownIdentifier) {
......
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