chromium/components/autofill/core/browser/webdata/addresses/contact_info_sync_util_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/webdata/addresses/contact_info_sync_util.h"

#include "base/feature_list.h"
#include "base/hash/hash.h"
#include "base/strings/to_string.h"
#include "base/test/scoped_feature_list.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/autofill_profile_test_api.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/profile_token_quality_test_api.h"
#include "components/autofill/core/common/autofill_features.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

namespace {

ContactInfoSpecifics;

constexpr char kGuid[] =;
constexpr char kInvalidGuid[] =;
constexpr int kNonChromeModifier =;
const auto kUseDate =;
const auto kUseDate2 =;
// No third last use date, to test that absence is handled correctly.
const auto kModificationDate =;

// Returns a profile with all fields set. Contains identical data to the data
// returned from `ConstructBaseSpecifics()`.
AutofillProfile ConstructBaseProfile(
    AddressCountryCode country_code = AddressCountryCode("ES")) {}

AutofillProfile ConstructCompleteProfileAU() {}

AutofillProfile ConstructCompleteProfileDE() {}

AutofillProfile ConstructCompleteProfileBR() {}

AutofillProfile ConstructCompleteProfileMX() {}

AutofillProfile ConstructCompleteProfileIN() {}

// Helper function to set ContactInfoSpecifics::String- and IntegerToken
// together with their verification status and value_hash.
template <typename TokenType, typename Value>
void SetToken(TokenType* token,
              const Value& value,
              ContactInfoSpecifics::VerificationStatus status) {}

// Returns ContactInfoSpecifics with all fields set. Contains identical data to
// the profile returned from `ConstructBaseProfile()`.
ContactInfoSpecifics ConstructBaseSpecifics() {}

ContactInfoSpecifics ConstructCompleteSpecificsAU() {}

ContactInfoSpecifics ConstructCompleteSpecificsDE() {}

ContactInfoSpecifics ConstructCompleteSpecificsBR() {}

ContactInfoSpecifics ConstructCompleteSpecificsMX() {}

ContactInfoSpecifics ConstructCompleteSpecificsIN() {}

}  // namespace

enum class I18nCountryModel {};

// The tests are parametrized with a country to assert that all custom address
// models are supported.
class ContactInfoSyncUtilTest
    : public testing::Test,
      public testing::WithParamInterface<I18nCountryModel> {};

// Test that converting AutofillProfile -> ContactInfoSpecifics works.
TEST_P(ContactInfoSyncUtilTest,
       CreateContactInfoEntityDataFromAutofillProfile) {}

// Test that only profiles with valid GUID are converted.
TEST_F(ContactInfoSyncUtilTest,
       CreateContactInfoEntityDataFromAutofillProfile_InvalidGUID) {}

// Test that AutofillProfiles with invalid record type are not converted.
TEST_F(ContactInfoSyncUtilTest,
       CreateContactInfoEntityDataFromAutofillProfile_InvalidRecordType) {}

// Test that supported fields and nested messages are successfully trimmed.
TEST_F(ContactInfoSyncUtilTest, TrimAllSupportedFieldsFromRemoteSpecifics) {}

// Test that supported fields and nested messages are successfully trimmed but
// that unsupported fields are preserved.
TEST_F(ContactInfoSyncUtilTest,
       TrimAllSupportedFieldsFromRemoteSpecifics_PreserveUnsupportedFields) {}

// Test that the conversion of a profile to specifics preserve the unsupported
// fields.
TEST_P(ContactInfoSyncUtilTest, ContactInfoSpecificsFromAutofillProfile) {}

// Test that converting ContactInfoSpecifics -> AutofillProfile works.
TEST_P(ContactInfoSyncUtilTest, CreateAutofillProfileFromContactInfoSpecifics) {}

// Test that only specifics with valid GUID are converted.
TEST_F(ContactInfoSyncUtilTest,
       CreateAutofillProfileFromContactInfoSpecifics_InvalidGUID) {}

// Tests that if a token's `value` changes by external means, its observations
// are reset.
TEST_F(ContactInfoSyncUtilTest, ObservationResetting) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace autofill