chromium/components/autofill/core/browser/payments/iban_save_manager_unittest.cc

// Copyright 2022 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/payments/iban_save_manager.h"

#include "base/json/json_reader.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/uuid.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/data_model/iban.h"
#include "components/autofill/core/browser/payments/mock_test_payments_network_interface.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/payments_network_interface.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/strike_databases/payments/iban_save_strike_database.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_personal_data_manager.h"
#include "components/autofill/core/common/autofill_prefs.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"

namespace autofill {

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
namespace {

constexpr char kLegalMessageLines[] =;

constexpr char kInvalidLegalMessageLines[] =;

constexpr char16_t kCapitalizedIbanRegex[] =;

}  // namespace

class IbanSaveManagerTest : public testing::Test {};

TEST_F(IbanSaveManagerTest, AttemptToOfferSave_NewIban_ShouldOfferSave) {}

TEST_F(IbanSaveManagerTest, AttemptToOfferSave_LocalIban_ShouldOfferSave) {}

// Test that new IBANs should not be offered upload save to Google Payments if
// flag is off.
TEST_F(IbanSaveManagerTest, ShouldOfferUploadSave_NewIban_FlagOff) {}

// Test that new IBANs should not be offered upload save due to reaching the
// maximum limit.
TEST_F(IbanSaveManagerTest, ShouldOfferUploadSave_MaxServerIban) {}

// Test that new IBANs should be offered upload save to Google Payments.
TEST_F(IbanSaveManagerTest, ShouldOfferUploadSave_NewIban) {}

// Test that an existing local IBAN should still be offered upload save to
// Google Payments.
TEST_F(IbanSaveManagerTest, ShouldOfferUploadSave_LocalIban) {}

// Test that an existing local and server IBAN should not be offered save at
// all.
TEST_F(IbanSaveManagerTest, ShouldOfferUploadSave_LocalAndServerIban) {}

// Test that an existing server IBAN should not be offered save at all.
TEST_F(IbanSaveManagerTest, ShouldOfferUploadSave_ServerIban) {}

TEST_F(IbanSaveManagerTest, OnUserDidDecideOnLocalSave_Accepted) {}

TEST_F(IbanSaveManagerTest, OnUserDidDecideOnLocalSave_Declined) {}

TEST_F(IbanSaveManagerTest, OnUserDidDecideOnLocalSave_Ignored) {}

TEST_F(IbanSaveManagerTest, LocallySaveIban_NotEnoughStrikesShouldOfferToSave) {}

TEST_F(IbanSaveManagerTest, LocallySaveIban_MaxStrikesShouldNotOfferToSave) {}

TEST_F(IbanSaveManagerTest, OnUserDidDecideOnLocalSave_Accepted_ClearsStrikes) {}

TEST_F(IbanSaveManagerTest, OnUserDidDecideOnLocalSave_Declined_AddsStrike) {}

TEST_F(IbanSaveManagerTest, OnUserDidDecideOnLocalSave_Ignored_AddsStrike) {}

TEST_F(IbanSaveManagerTest, LocallySaveIban_OfferIbanSave) {}

TEST_F(IbanSaveManagerTest,
       LocallySaveIban_MaxStrikesShouldNotOfferToSave_Metrics) {}

TEST_F(IbanSaveManagerTest, StrikesPresentWhenIbanSaved_Local) {}

TEST_F(IbanSaveManagerTest, IsIbanUploadEnabled_SyncServiceNotAvailable) {}

TEST_F(IbanSaveManagerTest, IsIbanUploadEnabled_AuthError) {}

TEST_F(IbanSaveManagerTest,
       IsIbanUploadEnabled_SyncDoesNotHaveAutofillWalletDataActiveType) {}

TEST_F(IbanSaveManagerTest,
       IsIbanUploadEnabled_SyncServiceUsingExplicitPassphrase) {}

TEST_F(IbanSaveManagerTest, IsIbanUploadEnabled_SyncServiceLocalSyncOnly) {}

TEST_F(IbanSaveManagerTest, IsIbanUploadEnabled_Enabled) {}

// Test that upload save should be offered to a new IBAN when the preflight
// call succeeded and the `legal_message` is parsed successfully.
TEST_F(IbanSaveManagerTest, OfferUploadSave_NewIban_Success) {}

// Test that upload save should be not be offered for a new IBAN when the
// regex validation does not pass.
TEST_F(IbanSaveManagerTest, OfferUploadSave_NewIban_FailureOnRegexNotMatch) {}

// Test that upload save should not be offered when the preflight call failed.
// In this case, local save should be offered because the extracted IBAN is a
// new IBAN.
TEST_F(IbanSaveManagerTest,
       OfferUploadSave_NewIban_Failure_ThenAttemptToOfferLocalSave) {}

// Test that upload save should not be offered when the preflight call succeeded
// but the `legal_message` is not parsed successfully. In this case, local save
// should be offered because the extracted IBAN is a new IBAN.
TEST_F(
    IbanSaveManagerTest,
    OfferUploadSave_NewIban_InvalidLegalMessage_ThenAttemptToOfferLocalSave) {}

// call succeeded and the `legal_message` is parsed successfully.
TEST_F(IbanSaveManagerTest, OfferUploadSave_LocalIban_Success) {}

// Test that upload save should not be offered when the preflight call failed
// and the `legal_message` is parsed successfully. Then Local save should not be
// offered because the extracted IBAN already exists.
TEST_F(IbanSaveManagerTest,
       OfferUploadSave_LocalIban_Failure_LocalSaveNotOffered) {}

TEST_F(IbanSaveManagerTest, UploadSaveIban_Accept_SuccessShouldClearStrikes) {}

TEST_F(IbanSaveManagerTest, UploadSaveIban_Accept_FailureShouldAddStrike) {}

TEST_F(IbanSaveManagerTest, OnUserDidDecideOnUploadSave_Decline_AddsStrike) {}

TEST_F(IbanSaveManagerTest, OnUserDidDecideOnUploadSave_Ignore_AddsStrike) {}

// Test that offer-to-upload IBAN origin is logged as `kNewIban` for a new IBAN.
TEST_F(IbanSaveManagerTest, Metric_UploadOfferedIbanOrigin_NewIban) {}

// Test that offer-to-upload IBAN origin is logged as `kLocalIban` for a local
// IBAN.
TEST_F(IbanSaveManagerTest, Metric_UploadOfferedIbanOrigin_LocalIban) {}

// Test that when upload is offered for a new IBAN and the offer is accepted,
// `kAccepted` and `kNewIban` are logged.
TEST_F(IbanSaveManagerTest, Metric_AcceptedOfferedIbanOrigin_NewIban) {}

// Test that when upload is offered for an existing IBAN and the offer is
// accepted, `kAccepted` and `kLocalIban` are logged.
TEST_F(IbanSaveManagerTest, Metric_AcceptedOfferedIbanOrigin_LocalIban) {}

// Test that when upload is offered for a new IBAN and the offer is declined,
// `kDeclined` and `kNewIban` are logged.
TEST_F(IbanSaveManagerTest, Metric_DeclinedOfferedIbanOrigin_NewIban) {}

// Test that when upload is offered for an existing IBAN and the offer is
// declined, `kDeclined` and `kLocalIban` are logged.
TEST_F(IbanSaveManagerTest, Metric_DeclinedOfferedIbanOrigin_LocalIban) {}

// Test that when upload is offered for a new IBAN and the offer is ignored,
// `kIgnored` and `kNewIban` are logged.
TEST_F(IbanSaveManagerTest, Metric_IgnoredOfferedIbanOrigin_NewIban) {}

// Test that when upload is offered for an existing IBAN and the offer is
// ignored, `kIgnored` and `kLocalIban` are logged.
TEST_F(IbanSaveManagerTest, Metric_IgnoredOfferedIbanOrigin_LocalIban) {}

TEST_F(IbanSaveManagerTest, Metric_CountryOfSaveOffered_LocalIban) {}

TEST_F(IbanSaveManagerTest, Metric_CountryOfSaveOffered_ServerIban) {}

TEST_F(IbanSaveManagerTest, Metric_CountryOfSaveAccepted_LocalIban) {}

TEST_F(IbanSaveManagerTest, Metric_CountryOfSaveAccepted_ServerIban) {}

// Tests that the `RanLocalSaveFallback` metric records that a new IBAN was
// saved during the local IBAN save fallback for a server upload failure.
TEST_F(IbanSaveManagerTest,
       Metrics_OnUploadIban_FallbackToLocalSave_NewIbanAdded) {}

// Tests that the `RanLocalSaveFallback` metric records that an existing local
// IBAN was not saved during the local IBAN save fallback for a server upload
// failure.
TEST_F(IbanSaveManagerTest,
       Metrics_OnUploadIban_FallbackToLocalSave_LocalIbanNotAdded) {}

// Tests that the `RanLocalSaveFallback` metric records that a matched local
// IBAN (same IBAN value but different nickname) was not saved during the local
// IBAN save fallback for a server upload failure.
TEST_F(
    IbanSaveManagerTest,
    Metrics_OnUploadIban_FallbackToLocalSave_LocalIbanWithDifferentNicknameNotAdded) {}

#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)

}  // namespace autofill