chromium/components/autofill/core/browser/webdata/addresses/autofill_profile_sync_util_unittest.cc

// Copyright 2018 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/autofill_profile_sync_util.h"

#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/core/browser/country_type.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/autofill_profile_test_api.h"
#include "components/autofill/core/browser/data_model/autofill_structured_address_component.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/test_autofill_clock.h"
#include "components/autofill/core/browser/webdata/autofill_table_utils.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/sync/protocol/autofill_specifics.pb.h"
#include "components/sync/protocol/entity_data.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {

namespace {
ASCIIToUTF16;
UTF16ToUTF8;
UTF8ToUTF16;
AutofillProfileSpecifics;
EntityData;

// Some guids for testing.
const char kGuid[] =;
const char kGuidInvalid[] =;

const base::Time kJune2017 =;

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

AutofillProfile ConstructCompleteProfileBR() {}

AutofillProfile ConstructCompleteProfileAU() {}

AutofillProfile ConstructCompleteProfileDE() {}

AutofillProfile ConstructCompleteProfileMX() {}

AutofillProfile ConstructCompleteProfileIN() {}

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

AutofillProfileSpecifics ConstructCompleteSpecificsBR() {}

AutofillProfileSpecifics ConstructCompleteSpecificsAU() {}

AutofillProfileSpecifics ConstructCompleteSpecificsDE() {}

AutofillProfileSpecifics ConstructCompleteSpecificsMX() {}

AutofillProfileSpecifics ConstructCompleteSpecificsIN() {}

enum class I18nCountryModel {};

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

// Ensure that all profile fields are able to be synced up from the client to
// the server.
TEST_P(AutofillProfileSyncUtilTest, CreateEntityDataFromAutofillProfile) {}

// Test that fields not set for the input are empty in the output.
TEST_F(AutofillProfileSyncUtilTest, CreateEntityDataFromAutofillProfile_Empty) {}

// Test that long fields get trimmed.
TEST_F(AutofillProfileSyncUtilTest,
       CreateEntityDataFromAutofillProfile_Trimmed) {}

// Test that long non-ascii fields get correctly trimmed.
TEST_F(AutofillProfileSyncUtilTest,
       CreateEntityDataFromAutofillProfile_TrimmedNonASCII) {}

// Ensure that all profile fields are able to be synced down from the server to
// the client (and nothing gets uploaded back).
TEST_P(AutofillProfileSyncUtilTest, CreateAutofillProfileFromSpecifics) {}

// Test that fields not set for the input are also not set on the output.
TEST_F(AutofillProfileSyncUtilTest, CreateAutofillProfileFromSpecifics_Empty) {}

// Test that nullopt is produced if the input guid is invalid.
TEST_F(AutofillProfileSyncUtilTest,
       CreateAutofillProfileFromSpecifics_Invalid) {}

// Test that if conflicting info is set for address home, the (deprecated) line1
// & line2 fields get overwritten by the street_address field.
TEST_F(AutofillProfileSyncUtilTest,
       CreateAutofillProfileFromSpecifics_HomeAddressWins) {}

// Test that country names (used in the past for the field) get correctly parsed
// into country code.
TEST_F(AutofillProfileSyncUtilTest,
       CreateAutofillProfileFromSpecifics_CountryNameParsed) {}

// Tests that guid is returned as storage key.
TEST_F(AutofillProfileSyncUtilTest, GetStorageKeyFromAutofillProfile) {}

// Tests that guid is returned as storage key.
TEST_F(AutofillProfileSyncUtilTest, GetStorageKeyFromAutofillProfileSpecifics) {}

// Tests that empty string is returned for entry with invalid guid.
TEST_F(AutofillProfileSyncUtilTest,
       GetStorageKeyFromAutofillProfileSpecifics_Invalid) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace
}  // namespace autofill