chromium/components/autofill/core/browser/autofill_profile_import_process_unittest.cc

// Copyright 2021 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/autofill_profile_import_process.h"

#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/autofill/core/browser/address_data_manager.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/data_model/autofill_profile_test_api.h"
#include "components/autofill/core/browser/data_model/autofill_structured_address_test_utils.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/profile_token_quality.h"
#include "components/autofill/core/browser/profile_token_quality_test_api.h"
#include "components/autofill/core/browser/test_address_data_manager.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/browser/test_autofill_clock.h"
#include "components/autofill/core/browser/test_utils/test_profiles.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

namespace {

// Test that two AutofillProfiles have the same `record_type() and `Compare()`
// equal. This is useful for testing profile migration, which changes a
// profile's record_type and GUID (preventing the use of operator==).
MATCHER(CompareWithRecordType, "") {}

class AutofillProfileImportProcessTest : public testing::Test {};

// Tests the import process for the scenario, that the user accepts the import
// of their first profile.
TEST_F(AutofillProfileImportProcessTest, ImportFirstProfile_UserAccepts) {}

// Tests the import process for the scenario, that the import of a new profile
// is blocked.
TEST_F(AutofillProfileImportProcessTest, ImportFirstProfile_ImportIsBlocked) {}

// Tests the import process for the scenario, that the user accepts the import
// of their first profile but with additional edits..
TEST_F(AutofillProfileImportProcessTest,
       ImportFirstProfile_UserAcceptsWithEdits) {}

// Tests the import process for the scenario, that the user declines the import
// of their first profile.
TEST_F(AutofillProfileImportProcessTest, ImportFirstProfile_UserRejects) {}

// Tests the import of a profile that is an exact duplicate of the only already
// existing profile.
TEST_F(AutofillProfileImportProcessTest, ImportDuplicateProfile) {}

// Tests that an incorrectly complemented country doesn't lead to an almost-
// duplicate profile import.
// Regression test for crbug.com/1376937.
TEST_F(AutofillProfileImportProcessTest, IncorrectlyComplementedCountry) {}

// Tests the import of a profile that is an exact duplicate of an already
// existing profile along with other profiles that are not mergeable or
// updateable with the observed profile.
TEST_F(AutofillProfileImportProcessTest,
       ImportDuplicateProfile_OutOfMultipleProfiles) {}

// Tests that importing a profile that is an exact duplicate of a kAccount
// profile is rejected as a duplicate.
TEST_F(AutofillProfileImportProcessTest, ImportDuplicateProfile_kAccount) {}

// Tests that importing a profile that is a subset of a kAccount profile is
// rejected as a duplicate.
TEST_F(AutofillProfileImportProcessTest, ImportSubsetProfile_kAccount) {}

// Tests that importing a profile that is a superset of a kAccount profile
// results in an update. The record type of resulting profile remains kAccount.
TEST_F(AutofillProfileImportProcessTest,
       ImportSupersetProfile_kAccount_PostStorage) {}

// Tests that an import can cause a silent update of a `kAccount` profile.
TEST_F(AutofillProfileImportProcessTest, ImportSilentUpdate_kAccount) {}

// Tests the accepted import of a profile that is mergeable with an already
// existing profile.
TEST_F(AutofillProfileImportProcessTest, MergeWithExistingProfile_Accepted) {}

// Tests the accepted import of a profile that is mergeable with an already
// existing profile for the scenario that the user introduced additional edits.
TEST_F(AutofillProfileImportProcessTest,
       MergeWithExistingProfile_AcceptWithEdits) {}

// Tests the accepted import of a profile that is mergeable with an already
// existing profile for the scenario that there are multiple profiles stored.
TEST_F(AutofillProfileImportProcessTest,
       MergeWithExistingProfile_MultipleStoredProfiles_Accepted) {}

// Tests the rejection of the merge of the observed profile with an already
// existing one.
TEST_F(AutofillProfileImportProcessTest, MergeWithExistingProfile_Rejected) {}

// Tests the scenario in which the observed profile results in a silent update
// of the only already existing profile.
TEST_F(AutofillProfileImportProcessTest, SilentlyUpdateProfile) {}

// Tests the scenario in which an observed profile can be merged with an
// existing profile while another already existing profile can be silently
// updated. In this test, the users accepts the merge.
TEST_F(AutofillProfileImportProcessTest, BothMergeAndSilentUpdate_Accepted) {}

// Tests the scenario in which an observed profile can be merged with an
// existing profile while another already existing profile can be silently
// updated. In this test, the users declines the merge.
TEST_F(AutofillProfileImportProcessTest, BothMergeAndSilentUpdate_Rejected) {}

// Tests the scenario in which an observed profile can be merged with an
// existing profile for which updates are blocked while another already existing
// profile can be silently updated.
TEST_F(AutofillProfileImportProcessTest, BlockedMergeAndSilentUpdate) {}

// Tests the scenario in which an observed profile can be merged with an
// existing profile for which updates are blocked.
TEST_F(AutofillProfileImportProcessTest, BlockedMerge) {}

// Tests the scenario in which the observed profile results in a silent update
// of the only already existing profile. The import process only supports
// silent updates.
TEST_F(AutofillProfileImportProcessTest,
       SilentlyUpdateProfile_WithIncompleteProfile) {}

// Tests the scenario in which the observed profile is not imported since the
// import process only silent updates.
TEST_F(AutofillProfileImportProcessTest, SilentlyUpdateProfile_WithNewProfile) {}

// Tests the scenario in which an observed profile cannot be merged with an
// existing profile while another already existing profile can be silently
// updated since the import process allows for silent update only
TEST_F(AutofillProfileImportProcessTest,
       SilentlyUpdateProfile_NoMergeOnlySilentUpdate) {}

// Tests that for eligible users, new profiles are of record type kAccount.
TEST_F(AutofillProfileImportProcessTest, NewProfileRecordType) {}

// Two `kLocalOrSyncable` profiles are stored. One of them is observed during
// submission. Expected that this profile is offered for migration.
// After accepting, expect that the profile's record type has changed and that
// the second profile is left unaltered.
TEST_F(AutofillProfileImportProcessTest, MigrateProfileToAccount) {}

// Test that the profile to migrate can be silently updated. Expect that after
// accepting the migration, the stored profile has record type `kAccount` and
// was silently updated.
TEST_F(AutofillProfileImportProcessTest, MigrateProfileToAccount_SilentUpdate) {}

// Even if a profile migration is rejected, silent updates are applied.
TEST_F(AutofillProfileImportProcessTest,
       MigrateProfileToAccount_SilentUpdate_Decline) {}

// Expect that no migration is offered for ineligible users.
TEST_F(AutofillProfileImportProcessTest,
       MigrateProfileToAccount_IneligibleUser) {}

// Expect that no migration is offered for ineligible profiles.
TEST_F(AutofillProfileImportProcessTest,
       MigrateProfileToAccount_IneligibleProfile) {}

// Tests around the behavior of new/update profile prompts when a profile is
// autofilled and some autofilled values are manually edited by the user.
class QuasiDuplicateUpdateTest : public AutofillProfileImportProcessTest {};

TEST_F(QuasiDuplicateUpdateTest, NonLowQualityTokenEdited) {}

TEST_F(QuasiDuplicateUpdateTest, LowQualityTokenEdited) {}

}  // namespace

}  // namespace autofill