Commit 171890f6 authored by Christoph Schwering's avatar Christoph Schwering Committed by Commit Bot

Attempt to fix flaky AutofillMetricsTest.FormFillDuration.

CL 1388111 / Commit b2020be3 removed timestamps from OnFormSubmitted(),
the reason being that they were always Now(). They weren't always Now()
in the unit test. This commit re-adds the non-Now() timestamps to the
unit test.

Bug: 1009364
Change-Id: I1204ee2e6d43685c0ac7a2e77c93236cceadf42b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1860340
Commit-Queue: Dominic Battré <battre@chromium.org>
Auto-Submit: Christoph Schwering <schwering@google.com>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705663}
parent 928e16df
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "components/autofill/core/browser/test_autofill_client.h" #include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_autofill_driver.h" #include "components/autofill/core/browser/test_autofill_driver.h"
#include "components/autofill/core/browser/test_autofill_manager.h" #include "components/autofill/core/browser/test_autofill_manager.h"
#include "components/autofill/core/browser/test_autofill_tick_clock.h"
#include "components/autofill/core/browser/test_form_data_importer.h" #include "components/autofill/core/browser/test_form_data_importer.h"
#include "components/autofill/core/browser/test_form_structure.h" #include "components/autofill/core/browser/test_form_structure.h"
#include "components/autofill/core/browser/test_personal_data_manager.h" #include "components/autofill/core/browser/test_personal_data_manager.h"
...@@ -7562,6 +7563,10 @@ TEST_F(AutofillMetricsTest, UserHappinessFormInteraction_AddressForm) { ...@@ -7562,6 +7563,10 @@ TEST_F(AutofillMetricsTest, UserHappinessFormInteraction_AddressForm) {
// Verify that we correctly log metrics tracking the duration of form fill. // Verify that we correctly log metrics tracking the duration of form fill.
// TODO(crbug.com/1009364) Test is flake on many builders. // TODO(crbug.com/1009364) Test is flake on many builders.
TEST_F(AutofillMetricsTest, FormFillDuration) { TEST_F(AutofillMetricsTest, FormFillDuration) {
base::TimeTicks now = AutofillTickClock::NowTicks();
TestAutofillTickClock test_clock;
test_clock.SetNowTicks(now);
// Load a fillable form. // Load a fillable form.
FormData form; FormData form;
form.name = ASCIIToUTF16("TestForm"); form.name = ASCIIToUTF16("TestForm");
...@@ -7603,6 +7608,10 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { ...@@ -7603,6 +7608,10 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
SCOPED_TRACE("Test 1"); SCOPED_TRACE("Test 1");
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
autofill_manager_->OnFormsSeen(forms, AutofillTickClock::NowTicks()); autofill_manager_->OnFormsSeen(forms, AutofillTickClock::NowTicks());
base::TimeTicks parse_time = autofill_manager_->form_structures()
.begin()
->second->form_parsed_timestamp();
test_clock.SetNowTicks(parse_time + base::TimeDelta::FromMicroseconds(17));
autofill_manager_->OnFormSubmitted(form, false, autofill_manager_->OnFormSubmitted(form, false,
SubmissionSource::FORM_SUBMISSION); SubmissionSource::FORM_SUBMISSION);
...@@ -7629,6 +7638,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { ...@@ -7629,6 +7638,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
autofill_manager_->OnTextFieldDidChange( autofill_manager_->OnTextFieldDidChange(
form, form.fields.front(), gfx::RectF(), form, form.fields.front(), gfx::RectF(),
parse_time + base::TimeDelta::FromMicroseconds(3)); parse_time + base::TimeDelta::FromMicroseconds(3));
test_clock.SetNowTicks(parse_time + base::TimeDelta::FromMicroseconds(17));
autofill_manager_->OnFormSubmitted(form, false, autofill_manager_->OnFormSubmitted(form, false,
SubmissionSource::FORM_SUBMISSION); SubmissionSource::FORM_SUBMISSION);
...@@ -7656,6 +7666,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { ...@@ -7656,6 +7666,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
->second->form_parsed_timestamp(); ->second->form_parsed_timestamp();
autofill_manager_->OnDidFillAutofillFormData( autofill_manager_->OnDidFillAutofillFormData(
form, parse_time + base::TimeDelta::FromMicroseconds(5)); form, parse_time + base::TimeDelta::FromMicroseconds(5));
test_clock.SetNowTicks(parse_time + base::TimeDelta::FromMicroseconds(17));
autofill_manager_->OnFormSubmitted(form, false, autofill_manager_->OnFormSubmitted(form, false,
SubmissionSource::FORM_SUBMISSION); SubmissionSource::FORM_SUBMISSION);
...@@ -7689,6 +7700,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { ...@@ -7689,6 +7700,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
autofill_manager_->OnTextFieldDidChange( autofill_manager_->OnTextFieldDidChange(
form, form.fields.front(), gfx::RectF(), form, form.fields.front(), gfx::RectF(),
parse_time + base::TimeDelta::FromMicroseconds(3)); parse_time + base::TimeDelta::FromMicroseconds(3));
test_clock.SetNowTicks(parse_time + base::TimeDelta::FromMicroseconds(17));
autofill_manager_->OnFormSubmitted(form, false, autofill_manager_->OnFormSubmitted(form, false,
SubmissionSource::FORM_SUBMISSION); SubmissionSource::FORM_SUBMISSION);
...@@ -7720,6 +7732,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { ...@@ -7720,6 +7732,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
autofill_manager_->OnTextFieldDidChange( autofill_manager_->OnTextFieldDidChange(
form, form.fields.front(), gfx::RectF(), form, form.fields.front(), gfx::RectF(),
parse_time + base::TimeDelta::FromMicroseconds(3)); parse_time + base::TimeDelta::FromMicroseconds(3));
test_clock.SetNowTicks(parse_time + base::TimeDelta::FromMicroseconds(17));
autofill_manager_->OnFormSubmitted(form, false, autofill_manager_->OnFormSubmitted(form, false,
SubmissionSource::FORM_SUBMISSION); SubmissionSource::FORM_SUBMISSION);
...@@ -7748,6 +7761,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { ...@@ -7748,6 +7761,7 @@ TEST_F(AutofillMetricsTest, FormFillDuration) {
if (kv.second->form_parsed_timestamp() > parse_time) if (kv.second->form_parsed_timestamp() > parse_time)
parse_time = kv.second->form_parsed_timestamp(); parse_time = kv.second->form_parsed_timestamp();
} }
test_clock.SetNowTicks(parse_time + base::TimeDelta::FromMicroseconds(17));
autofill_manager_->OnFormSubmitted(second_form, false, autofill_manager_->OnFormSubmitted(second_form, false,
SubmissionSource::FORM_SUBMISSION); SubmissionSource::FORM_SUBMISSION);
......
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