chromium/components/autofill/core/browser/crowdsourcing/disambiguate_possible_field_types_unittest.cc

// 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/autofill/core/browser/crowdsourcing/disambiguate_possible_field_types.h"

#include "base/ranges/algorithm.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_data_test_api.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

CreateTestFormField;
ElementsAre;
UnorderedElementsAre;

// Tests that `DisambiguatePossibleFieldTypes` makes the correct choices.
class DisambiguatePossibleFieldTypesTest : public ::testing::Test {};

// Name disambiguation.
// An ambiguous name field that has no next field and that is preceded by a non
// credit card field should be disambiguated as a non credit card name.
TEST_F(DisambiguatePossibleFieldTypesTest,
       AmbiguousNamePrecededByAddressDisambiguatesToAddress) {}

// An ambiguous name field that has no next field and that is preceded by a
// credit card field should be disambiguated as a credit card name.
TEST_F(DisambiguatePossibleFieldTypesTest,
       AmbiguousNamePrecededByCreditCardDisambiguatesToCreditCard) {}

// An ambiguous name field that has no previous field and that is followed by an
// address field should be disambiguated as an address name.
TEST_F(DisambiguatePossibleFieldTypesTest,
       AmbiguousNameFollowedByAddressDisambiguatesToAddress) {}

// An ambiguous name field that has no previous field and that is followed by a
// credit card field should be disambiguated as a credit card name.
TEST_F(DisambiguatePossibleFieldTypesTest,
       AmbiguousNameFollowedByCreditCardDisambiguatesToCreditCard) {}

// An ambiguous name field that is preceded and followed by non credit card
// fields should be disambiguated as a non credit card name.
TEST_F(DisambiguatePossibleFieldTypesTest,
       AmbiguousNameSurroundedByAddressDisambiguatesToAddress) {}

// An ambiguous name field that is preceded and followed by credit card fields
// should be disambiguated as a credit card name.
TEST_F(DisambiguatePossibleFieldTypesTest,
       AmbiguousNameSurroundedByCreditCardDisambiguatesToCreditCard) {}

// An ambiguous name field that is preceded by a non credit card field and
// followed by a credit card field should not be disambiguated.
TEST_F(DisambiguatePossibleFieldTypesTest,
       AmbiguousNamePrecededByAddressFollowedByCreditCardRemainsAmbiguous) {}

// An ambiguous name field that is preceded by a credit card field and followed
// by a non credit card field should not be disambiguated.
TEST_F(DisambiguatePossibleFieldTypesTest,
       AmbiguousNamePrecededByCreditCardFollowedByAddressRemainsAmbiguous) {}

TEST_F(DisambiguatePossibleFieldTypesTest,
       AutofilledFieldDisambiguatesToAutofilledType) {}

}  // namespace autofill