#include "components/autofill/core/browser/autofill_optimization_guide.h"
#include <memory>
#include "base/ranges/algorithm.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/country_type.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/data_model/credit_card_benefit.h"
#include "components/autofill/core/browser/data_model/credit_card_test_api.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/form_structure_test_api.h"
#include "components/autofill/core/browser/payments/constants.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/test_personal_data_manager.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_test_utils.h"
#include "components/autofill/core/common/credit_card_network_identifiers.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_data_test_api.h"
#include "components/optimization_guide/core/optimization_guide_decider.h"
#include "components/optimization_guide/core/optimization_guide_decision.h"
#include "components/optimization_guide/core/optimization_metadata.h"
#include "components/prefs/pref_service.h"
#include "components/sync/test/test_sync_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace autofill {
CreateTestCreditCardFormData;
CreateTestIbanFormData;
class MockOptimizationGuideDecider
: public optimization_guide::OptimizationGuideDecider { … };
class AutofillOptimizationGuideTest : public testing::Test { … };
TEST_F(AutofillOptimizationGuideTest, EnsureIntegratorInitializedCorrectly) { … }
TEST_F(AutofillOptimizationGuideTest, IbanFieldFound_IbanAutofillBlocked) { … }
TEST_F(AutofillOptimizationGuideTest, CreditCardFormFound_VcnMerchantOptOut) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_VcnMerchantOptOut_NotVisaNetwork) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_VcnMerchantOptOut_IssuerEnrollment) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_VcnMerchantOptOut_NotEnrolledInVirtualCard) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_VcnMerchantOptOut_NoPersonalDataManager) { … }
TEST_F(AutofillOptimizationGuideTest, OptimizationTypeToRegisterNotFound) { … }
TEST_F(AutofillOptimizationGuideTest,
FormWithMultipleOptimizationTypesToRegisterFound) { … }
TEST_F(AutofillOptimizationGuideTest,
ShouldBlockSingleFieldSuggestions_IbanAutofillBlocked) { … }
TEST_F(AutofillOptimizationGuideTest,
ShouldNotBlockSingleFieldSuggestions_IbanAutofillBlocked) { … }
TEST_F(
AutofillOptimizationGuideTest,
ShouldNotBlockSingleFieldSuggestions_IbanAutofillBlocked_FieldTypeForBlockingNotFound) { … }
TEST_F(AutofillOptimizationGuideTest,
ShouldBlockFormFieldSuggestion_VcnMerchantOptOutVisa) { … }
TEST_F(AutofillOptimizationGuideTest,
ShouldBlockFormFieldSuggestion_VcnMerchantOptOutDiscover) { … }
TEST_F(AutofillOptimizationGuideTest,
ShouldBlockFormFieldSuggestion_VcnMerchantOptOutMastercard) { … }
TEST_F(AutofillOptimizationGuideTest,
ShouldNotBlockFormFieldSuggestion_VcnMerchantOptOut_UrlNotBlocked) { … }
TEST_F(AutofillOptimizationGuideTest,
ShouldNotBlockFormFieldSuggestion_VcnMerchantOptOut_IssuerEnrollment) { … }
TEST_F(
AutofillOptimizationGuideTest,
ShouldNotBlockFormFieldSuggestion_VcnMerchantOptOut_NetworkDoesNotHaveBlocklist) { … }
TEST_F(AutofillOptimizationGuideTest,
ShouldBlockBenefitSuggestionLabelsForCardAndUrl_CapitalOne_BlockedUrl) { … }
TEST_F(
AutofillOptimizationGuideTest,
ShouldNotBlockBenefitSuggestionLabelsForCardAndUrl_CapitalOne_UnblockedUrl) { … }
TEST_F(
AutofillOptimizationGuideTest,
ShouldNotBlockBenefitSuggestionLabelsForCardAndUrl_CapitalOne_UnknownDecision) { … }
TEST_F(
AutofillOptimizationGuideTest,
ShouldNotBlockBenefitSuggestionLabelsForCardAndUrl_NonCapitalOne_BlockedUrl) { … }
TEST_F(
AutofillOptimizationGuideTest,
ShouldNotBlockBenefitSuggestionLabelsForCardAndUrl_NonCapitalOne_UnblockedUrl) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_AmexCategoryBenefits) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_CapitalOneCategoryBenefits) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_AmexCategoryBenefits_ExperimentDisabled) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_CapitalOneCategoryBenefits_ExperimentDisabled) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
BUILDFLAG(IS_CHROMEOS)
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_AmountExtractionAllowed) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_AmountExtractionAllowed_FlagOff) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_AmountExtractionAllowed_NoServerCreditCardFound) { … }
TEST_F(AutofillOptimizationGuideTest,
CreditCardFormFound_AmountExtractionAllowed_NoPersonalDataManager) { … }
#endif
TEST_F(AutofillOptimizationGuideTest, AutofillAblation) { … }
struct BenefitOptimizationToBenefitCategoryTestCase { … };
class BenefitOptimizationToBenefitCategoryTest
: public AutofillOptimizationGuideTest,
public testing::WithParamInterface<
BenefitOptimizationToBenefitCategoryTestCase> { … };
TEST_P(BenefitOptimizationToBenefitCategoryTest,
GetBenefitCategoryForOptimizationType) { … }
INSTANTIATE_TEST_SUITE_P(…);
}