1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/plus_addresses/metrics/plus_address_submission_logger.h"
#include <string_view>
#include <utility>
#include <vector>
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/types/cxx23_to_underlying.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/foundations/test_autofill_client.h"
#include "components/autofill/core/browser/foundations/test_autofill_driver.h"
#include "components/autofill/core/browser/foundations/test_browser_autofill_manager.h"
#include "components/autofill/core/browser/integrators/password_form_classification.h"
#include "components/autofill/core/browser/integrators/plus_addresses/autofill_plus_address_delegate.h"
#include "components/autofill/core/browser/suggestions/suggestion_type.h"
#include "components/autofill/core/browser/test_utils/autofill_form_test_utils.h"
#include "components/autofill/core/common/autofill_test_utils.h"
#include "components/autofill/core/common/form_data_test_api.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h"
#include "components/signin/public/identity_manager/account_capabilities_test_mutator.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/ukm/test_ukm_recorder.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace plus_addresses::metrics {
namespace {
using ::autofill::FieldType;
using ::autofill::FormData;
using ::autofill::SuggestionType;
using ::autofill::test::FormDescription;
using ::testing::ElementsAreArray;
using ::testing::IsEmpty;
using PasswordFormType = autofill::PasswordFormClassification::Type;
using SuggestionContext =
autofill::AutofillPlusAddressDelegate::SuggestionContext;
constexpr char kGaiaAccount[] = "foo123@gmail.com";
constexpr char16_t kGaiaAccount_U16[] = u"foo123@gmail.com";
constexpr char kSamplePlusAddress[] = "plus@plus.com";
constexpr char16_t kSamplePlusAddress_U16[] = u"plus@plus.com";
constexpr auto kSubmissionSource =
autofill::mojom::SubmissionSource::FORM_SUBMISSION;
constexpr char kNonCommerceUrl[] = "https://www.foo.com";
constexpr char kCommerceUrl[] = "https://www.buy-stuff.com/checkout.html";
constexpr char kManagedDomain[] = "corporate.com";
// Short-hands for the bucket enum used to record bucketed plus address counts.
constexpr int64_t kNoPlusAddress = 0;
constexpr int64_t kOneToThreePlusAddresses = 1;
constexpr int64_t kMoreThanThreePlusAddresses = 2;
ukm::TestUkmRecorder::HumanReadableUkmMetrics CreateUkmMetrics(
size_t field_count_browser_form,
size_t field_count_renderer_form,
int64_t plus_address_count,
bool is_checkout_or_cart_page,
bool is_managed,
bool is_newly_created,
bool submitted_plus_address,
PasswordFormType password_form_type,
SuggestionContext suggestion_context,
bool was_shown_create_suggestion) {
ukm::TestUkmRecorder::HumanReadableUkmMetrics metrics;
metrics["FieldCountBrowserForm"] = field_count_browser_form;
metrics["FieldCountRendererForm"] = field_count_renderer_form;
metrics["PlusAddressCount"] = plus_address_count;
metrics["CheckoutOrCartPage"] = is_checkout_or_cart_page;
metrics["ManagedProfile"] = is_managed;
metrics["NewlyCreatedPlusAddress"] = is_newly_created;
metrics["SubmittedPlusAddress"] = submitted_plus_address;
metrics["PasswordFormType"] = base::to_underlying(password_form_type);
metrics["SuggestionContext"] = base::to_underlying(suggestion_context);
metrics["WasShownCreateSuggestion"] = was_shown_create_suggestion;
return metrics;
}
class PlusAddressSubmissionLoggerTest : public ::testing::Test {
public:
PlusAddressSubmissionLoggerTest()
: submission_logger_(
identity_manager(),
base::BindRepeating(
&PlusAddressSubmissionLoggerTest::VerifyPlusAddress,
base::Unretained(this))) {
SetPlusAddresses({kSamplePlusAddress});
}
protected:
FormData GetEmailForm() {
const auto field_types = std::vector<FieldType>({FieldType::EMAIL_ADDRESS});
FormData form = autofill::test::GetFormData(field_types);
autofill_manager_.AddSeenForm(form, field_types);
return form;
}
FormData GetLargeForm() {
auto field_types = std::vector<FieldType>(39);
field_types[0] = FieldType::EMAIL_ADDRESS;
FormData form = autofill::test::GetFormData(field_types);
autofill_manager_.AddSeenForm(form, field_types);
return form;
}
void SetPlusAddresses(std::vector<std::string> plus_addresses) {
plus_addresses_ = std::move(plus_addresses);
}
std::vector<ukm::TestUkmRecorder::HumanReadableUkmMetrics> GetUkmMetrics() {
return autofill_client_.GetUkmRecorder()->GetMetrics(
ukm::builders::PlusAddresses_Submission::kEntryName,
{"FieldCountBrowserForm", "FieldCountRendererForm", "PlusAddressCount",
"CheckoutOrCartPage", "ManagedProfile", "NewlyCreatedPlusAddress",
"SubmittedPlusAddress", "PasswordFormType", "SuggestionContext",
"WasShownCreateSuggestion"});
}
bool VerifyPlusAddress(const std::string& plus_address) {
return base::Contains(plus_addresses_, plus_address);
}
autofill::TestBrowserAutofillManager& autofill_manager() {
return autofill_manager_;
}
autofill::TestAutofillClient& autofill_client() { return autofill_client_; }
signin::IdentityTestEnvironment& identity_env() { return identity_test_env_; }
signin::IdentityManager* identity_manager() {
return identity_test_env_.identity_manager();
}
PlusAddressSubmissionLogger& submission_logger() {
return submission_logger_;
}
private:
base::test::ScopedFeatureList feature_list_{};
base::test::TaskEnvironment task_environment_;
autofill::test::AutofillUnitTestEnvironment autofill_test_environment_;
signin::IdentityTestEnvironment identity_test_env_;
autofill::TestAutofillClient autofill_client_;
autofill::TestAutofillDriver autofill_driver_{&autofill_client_};
autofill::TestBrowserAutofillManager autofill_manager_{&autofill_driver_};
PlusAddressSubmissionLogger submission_logger_;
// The known set of plus addresses. Used for verifying whether a field's value
// is a plus address.
std::vector<std::string> plus_addresses_;
};
// Tests that no metrics are recorded for signed out users.
TEST_F(PlusAddressSubmissionLoggerTest, NoMetricForSignedOutUsers) {
FormData form = GetEmailForm();
submission_logger().OnPlusAddressSuggestionShown(
autofill_manager(), form.global_id(), test_api(form).field(0).global_id(),
SuggestionContext::kAutofillProfileOnEmailField,
PasswordFormType::kNoPasswordForm,
SuggestionType::kFillExistingPlusAddress,
/*plus_address_count=*/1);
test_api(form).field(0).set_value(kSamplePlusAddress_U16);
autofill_manager().OnFormSubmitted(form, kSubmissionSource);
EXPECT_THAT(GetUkmMetrics(), IsEmpty());
}
struct PlusAddressSubmissionTestCase {
struct Input {
enum class SampleForm {
// A form with a single email field.
kEmailForm,
// A form with 39 fields, of which the first one has an email
// classification.
kLargeForm
};
SampleForm sample_form = SampleForm::kEmailForm;
SuggestionContext context = SuggestionContext::kAutofillProfileOnEmailField;
PasswordFormType form_type = PasswordFormType::kNoPasswordForm;
SuggestionType suggestion_type = SuggestionType::kCreateNewPlusAddress;
int64_t plus_address_count = kNoPlusAddress;
std::u16string submitted_value;
bool is_managed_profile = false;
std::string main_frame_url = kNonCommerceUrl;
};
const Input input;
const std::vector<ukm::TestUkmRecorder::HumanReadableUkmMetrics> ukms;
struct Uma {
// If set, contains the value of the single `PlusAddresses.Submission` that
// was emitted. Otherwise, no `PlusAddresses.Submission` emission is
// expected.
std::optional<bool> submitted_plus_address;
// If set, contains the value of the single
// `PlusAddress.Submission.FirstTimeUser.No` histogram that was emitted.
// Otherwise, no emission is expected for this histogram.
std::optional<bool> submitted_plus_address_first_time_user_no;
// If set, contains the value of the single
// `PlusAddress.Submission.FirstTimeUser.Yes` histogram that was emitted.
// Otherwise, no emission is expected for this histogram.
std::optional<bool> submitted_plus_address_first_time_user_yes;
// If set, contains the value of the single
// `PlusAddress.Submission.ManagedUser.No` histogram that was emitted.
// Otherwise, no emission is expected for this histogram.
std::optional<bool> submitted_plus_address_managed_user_no;
// If set, contains the value of the single
// `PlusAddress.Submission.ManagedUser.Yes` histogram that was emitted.
// Otherwise, no emission is expected for this histogram.
std::optional<bool> submitted_plus_address_managed_user_yes;
// If set, contains the value of the
// `PlusAddress.Submission.IsSingleFieldRendererForm' histogram that was
// emitted. Otherwise, no emission is expected for this histogram.
std::optional<bool> submitted_plus_address_is_single_field_renderer_form;
// If set, contains the value of the
// `PlusAddress.Submission.IsSingleFieldRendererForm.ManagedUser.No'
// histogram that was emitted. Otherwise, no emission is expected for this
// histogram.
std::optional<bool>
submitted_plus_address_is_single_field_renderer_form_managed_user_no;
};
const Uma uma;
};
class PlusAddressSubmissionTestWithParam
: public PlusAddressSubmissionLoggerTest,
public ::testing::WithParamInterface<PlusAddressSubmissionTestCase> {};
// Parametrized test that checks that the expected UKM is recorded. The test
// simulates that the user is logged in and submits a previously focused form
TEST_P(PlusAddressSubmissionTestWithParam, SubmittingFormRecordsUkm) {
base::HistogramTester histogram_tester;
const PlusAddressSubmissionTestCase::Input& input = GetParam().input;
AccountInfo account_info = identity_env().MakeAccountAvailable(
kGaiaAccount, {signin::ConsentLevel::kSignin});
if (input.is_managed_profile) {
account_info.hosted_domain = kManagedDomain;
AccountCapabilitiesTestMutator(&account_info.capabilities)
.set_is_subject_to_enterprise_policies(true);
identity_env().UpdateAccountInfoForAccount(account_info);
}
autofill_client().set_last_committed_primary_main_frame_url(
GURL(input.main_frame_url));
FormData form = [&] {
switch (input.sample_form) {
using enum PlusAddressSubmissionTestCase::Input::SampleForm;
case kEmailForm:
return GetEmailForm();
case kLargeForm:
return GetLargeForm();
}
}();
submission_logger().OnPlusAddressSuggestionShown(
autofill_manager(), form.global_id(), test_api(form).field(0).global_id(),
input.context, input.form_type, input.suggestion_type,
input.plus_address_count);
test_api(form).field(0).set_value(input.submitted_value);
autofill_manager().OnFormSubmitted(form, kSubmissionSource);
EXPECT_THAT(GetUkmMetrics(), ElementsAreArray(GetParam().ukms));
auto check_boolean_histogram = [&](std::string_view histogram_suffix,
std::optional<bool> expected_value) {
const std::string histogram = base::StrCat(
{PlusAddressSubmissionLogger::kUmaSubmissionPrefix, histogram_suffix});
if (expected_value) {
histogram_tester.ExpectUniqueSample(histogram, *expected_value, 1);
} else {
histogram_tester.ExpectTotalCount(histogram, 0);
}
};
const PlusAddressSubmissionTestCase::Uma& uma = GetParam().uma;
check_boolean_histogram("", uma.submitted_plus_address);
check_boolean_histogram(".ManagedUser.No",
uma.submitted_plus_address_managed_user_no);
check_boolean_histogram(".ManagedUser.Yes",
uma.submitted_plus_address_managed_user_yes);
check_boolean_histogram(
".SingleFieldRendererForm",
uma.submitted_plus_address_is_single_field_renderer_form);
check_boolean_histogram(
".SingleFieldRendererForm.ManagedUser.No",
uma.submitted_plus_address_is_single_field_renderer_form_managed_user_no);
}
INSTANTIATE_TEST_SUITE_P(
PlusAddressSubmissionTest,
PlusAddressSubmissionTestWithParam,
::testing::Values(
PlusAddressSubmissionTestCase{
// Submission of an email form after creating and filling a new plus
// address.
.input = {.context =
SuggestionContext::kAutofillProfileOnEmailField,
.form_type = PasswordFormType::kNoPasswordForm,
.suggestion_type = SuggestionType::kCreateNewPlusAddress,
.plus_address_count = 0,
.submitted_value = kSamplePlusAddress_U16},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/1,
/*field_count_renderer_form=*/1,
/*plus_address_count=*/kNoPlusAddress,
/*is_checkout_or_cart_page=*/false,
/*is_managed=*/false,
/*is_newly_created=*/true,
/*submitted_plus_address=*/true,
PasswordFormType::kNoPasswordForm,
SuggestionContext::kAutofillProfileOnEmailField,
/*was_shown_create_suggestion=*/true)},
.uma =
{.submitted_plus_address = true,
.submitted_plus_address_first_time_user_yes = true,
.submitted_plus_address_managed_user_no = true,
.submitted_plus_address_is_single_field_renderer_form = true,
.submitted_plus_address_is_single_field_renderer_form_managed_user_no =
true}},
// Submission of an email form after seeing combined plus address &
// Autocomplete suggestions and creating and filling a new plus address.
PlusAddressSubmissionTestCase{
.input = {.context = SuggestionContext::kAutocomplete,
.form_type = PasswordFormType::kNoPasswordForm,
.suggestion_type = SuggestionType::kCreateNewPlusAddress,
.plus_address_count = 0,
.submitted_value = kSamplePlusAddress_U16},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/1,
/*field_count_renderer_form=*/1,
/*plus_address_count=*/kNoPlusAddress,
/*is_checkout_or_cart_page=*/false,
/*is_managed=*/false,
/*is_newly_created=*/true,
/*submitted_plus_address=*/true,
PasswordFormType::kNoPasswordForm,
SuggestionContext::kAutocomplete,
/*was_shown_create_suggestion=*/true)},
.uma =
{.submitted_plus_address = true,
.submitted_plus_address_first_time_user_yes = true,
.submitted_plus_address_managed_user_no = true,
.submitted_plus_address_is_single_field_renderer_form = true,
.submitted_plus_address_is_single_field_renderer_form_managed_user_no =
true}},
// Submission of an email form after seeing combined plus address &
// Autocomplete suggestions and creating and filling a new plus address
// using Desktop's creation suggestion.
PlusAddressSubmissionTestCase{
.input = {.context = SuggestionContext::kAutocomplete,
.form_type = PasswordFormType::kNoPasswordForm,
.suggestion_type =
SuggestionType::kCreateNewPlusAddressInline,
.plus_address_count = 0,
.submitted_value = kSamplePlusAddress_U16},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/1,
/*field_count_renderer_form=*/1,
/*plus_address_count=*/kNoPlusAddress,
/*is_checkout_or_cart_page=*/false,
/*is_managed=*/false,
/*is_newly_created=*/true,
/*submitted_plus_address=*/true,
PasswordFormType::kNoPasswordForm,
SuggestionContext::kAutocomplete,
/*was_shown_create_suggestion=*/true)},
.uma =
{.submitted_plus_address = true,
.submitted_plus_address_first_time_user_yes = true,
.submitted_plus_address_managed_user_no = true,
.submitted_plus_address_is_single_field_renderer_form = true,
.submitted_plus_address_is_single_field_renderer_form_managed_user_no =
true}},
// Submission of an email form after filling an existing plus address.
PlusAddressSubmissionTestCase{
.input =
{.context = SuggestionContext::kAutofillProfileOnEmailField,
.form_type = PasswordFormType::kSingleUsernameForm,
.suggestion_type = SuggestionType::kFillExistingPlusAddress,
.plus_address_count = 1,
.submitted_value = kSamplePlusAddress_U16},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/1,
/*field_count_renderer_form=*/1,
/*plus_address_count=*/kOneToThreePlusAddresses,
/*is_checkout_or_cart_page=*/false,
/*is_managed=*/false,
/*is_newly_created=*/false,
/*submitted_plus_address=*/true,
PasswordFormType::kSingleUsernameForm,
SuggestionContext::kAutofillProfileOnEmailField,
/*was_shown_create_suggestion=*/false)},
.uma =
{.submitted_plus_address = true,
.submitted_plus_address_first_time_user_no = true,
.submitted_plus_address_managed_user_no = true,
.submitted_plus_address_is_single_field_renderer_form = true,
.submitted_plus_address_is_single_field_renderer_form_managed_user_no =
true}},
// Submission from a managed account.
PlusAddressSubmissionTestCase{
.input =
{.context = SuggestionContext::kAutofillProfileOnEmailField,
.form_type = PasswordFormType::kSingleUsernameForm,
.suggestion_type = SuggestionType::kFillExistingPlusAddress,
.plus_address_count = 1,
.submitted_value = kSamplePlusAddress_U16,
.is_managed_profile = true},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/1,
/*field_count_renderer_form=*/1,
/*plus_address_count=*/kOneToThreePlusAddresses,
/*is_checkout_or_cart_page=*/false,
/*is_managed=*/true,
/*is_newly_created=*/false,
/*submitted_plus_address=*/true,
PasswordFormType::kSingleUsernameForm,
SuggestionContext::kAutofillProfileOnEmailField,
/*was_shown_create_suggestion=*/false)},
.uma = {.submitted_plus_address = true,
.submitted_plus_address_first_time_user_no = true,
.submitted_plus_address_managed_user_yes = true,
.submitted_plus_address_is_single_field_renderer_form =
true}},
// Submission from a main frame URL with a checkout context.
PlusAddressSubmissionTestCase{
.input =
{.context = SuggestionContext::kAutofillProfileOnEmailField,
.form_type = PasswordFormType::kSingleUsernameForm,
.suggestion_type = SuggestionType::kFillExistingPlusAddress,
.plus_address_count = 1,
.submitted_value = kSamplePlusAddress_U16,
.main_frame_url = kCommerceUrl},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/1,
/*field_count_renderer_form=*/1,
/*plus_address_count=*/kOneToThreePlusAddresses,
/*is_checkout_or_cart_page=*/true,
/*is_managed=*/false,
/*is_newly_created=*/false,
/*submitted_plus_address=*/true,
PasswordFormType::kSingleUsernameForm,
SuggestionContext::kAutofillProfileOnEmailField,
/*was_shown_create_suggestion=*/false)},
.uma =
{.submitted_plus_address = true,
.submitted_plus_address_first_time_user_no = true,
.submitted_plus_address_managed_user_no = true,
.submitted_plus_address_is_single_field_renderer_form = true,
.submitted_plus_address_is_single_field_renderer_form_managed_user_no =
true}},
// Submission of an email form with GAIA email after seeing a fill plus
// address suggestion.
PlusAddressSubmissionTestCase{
.input =
{.context = SuggestionContext::kAutofillProfileOnEmailField,
.form_type = PasswordFormType::kSingleUsernameForm,
.suggestion_type = SuggestionType::kFillExistingPlusAddress,
.plus_address_count = 4,
.submitted_value = kGaiaAccount_U16},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/1,
/*field_count_renderer_form=*/1,
/*plus_address_count=*/kMoreThanThreePlusAddresses,
/*is_checkout_or_cart_page=*/false,
/*is_managed=*/false,
/*is_newly_created=*/false,
/*submitted_plus_address=*/false,
PasswordFormType::kSingleUsernameForm,
SuggestionContext::kAutofillProfileOnEmailField,
/*was_shown_create_suggestion=*/false)},
.uma =
{.submitted_plus_address = false,
.submitted_plus_address_first_time_user_no = false,
.submitted_plus_address_managed_user_no = false,
.submitted_plus_address_is_single_field_renderer_form = false,
.submitted_plus_address_is_single_field_renderer_form_managed_user_no =
false}},
// Submission of an email form with GAIA email after seeing a create
// plus address suggestion.
PlusAddressSubmissionTestCase{
.input = {.context =
SuggestionContext::kAutofillProfileOnEmailField,
.form_type = PasswordFormType::kNoPasswordForm,
.suggestion_type = SuggestionType::kCreateNewPlusAddress,
.plus_address_count = 1,
.submitted_value = kGaiaAccount_U16},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/1,
/*field_count_renderer_form=*/1,
/*plus_address_count=*/kOneToThreePlusAddresses,
/*is_checkout_or_cart_page=*/false,
/*is_managed=*/false,
/*is_newly_created=*/false,
/*submitted_plus_address=*/false,
PasswordFormType::kNoPasswordForm,
SuggestionContext::kAutofillProfileOnEmailField,
/*was_shown_create_suggestion=*/true)},
.uma =
{.submitted_plus_address = false,
.submitted_plus_address_first_time_user_no = false,
.submitted_plus_address_managed_user_no = false,
.submitted_plus_address_is_single_field_renderer_form = false,
.submitted_plus_address_is_single_field_renderer_form_managed_user_no =
false}},
// Submission of a form with many fields - the field counts are
// bucketed.
PlusAddressSubmissionTestCase{
.input = {.sample_form = PlusAddressSubmissionTestCase::Input::
SampleForm::kLargeForm,
.context =
SuggestionContext::kAutofillProfileOnEmailField,
.form_type = PasswordFormType::kNoPasswordForm,
.suggestion_type = SuggestionType::kCreateNewPlusAddress,
.plus_address_count = 1,
.submitted_value = kSamplePlusAddress_U16},
.ukms = {CreateUkmMetrics(
/*field_count_browser_form=*/38,
/*field_count_renderer_form=*/38,
/*plus_address_count=*/kOneToThreePlusAddresses,
/*is_checkout_or_cart_page=*/false,
/*is_managed=*/false,
/*is_newly_created=*/true,
/*submitted_plus_address=*/true,
PasswordFormType::kNoPasswordForm,
SuggestionContext::kAutofillProfileOnEmailField,
/*was_shown_create_suggestion=*/true)},
.uma = {.submitted_plus_address = true,
.submitted_plus_address_first_time_user_no = true,
.submitted_plus_address_managed_user_no = true}},
// Submission of an email form after filling no email address at all.
PlusAddressSubmissionTestCase{
.input =
{.context = SuggestionContext::kAutofillProfileOnEmailField,
.form_type = PasswordFormType::kSingleUsernameForm,
.suggestion_type = SuggestionType::kFillExistingPlusAddress,
.plus_address_count = kOneToThreePlusAddresses,
.submitted_value = u"Some name"},
.ukms = {},
.uma = {}}));
} // namespace
} // namespace plus_addresses::metrics
|