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

#include <memory>
#include <string_view>

#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.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/test_autofill_clock.h"
#include "components/autofill/core/browser/webdata/addresses/address_autofill_table.h"
#include "components/autofill/core/browser/webdata/addresses/contact_info_sync_util.h"
#include "components/autofill/core/browser/webdata/autofill_sync_metadata_table.h"
#include "components/autofill/core/browser/webdata/mock_autofill_webdata_backend.h"
#include "components/sync/base/features.h"
#include "components/sync/model/data_batch.h"
#include "components/sync/test/mock_data_type_local_change_processor.h"
#include "components/webdata/common/web_database.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

namespace {

_;
ElementsAre;
UnorderedElementsAre;

constexpr char kGUID1[] =;
constexpr char kGUID2[] =;
constexpr char kInvalidGUID[] =;

// Matches `syncer::EntityData*` and expects that the specifics of it match
// the `expected_profile`.
MATCHER_P(ContactInfoSpecificsEqualsProfile, expected_profile, "") {}

// Extracts all `ContactInfoSpecifics` from `batch`, converts them into
// `AutofillProfile`s and returns the result.
// Note that for consistency with the `AUTOFILL_PROFILE` sync type,
// `CONTACT_INFO` uses the same local `AutofillProfile` model.
std::vector<AutofillProfile> ExtractAutofillProfilesFromDataBatch(
    std::unique_ptr<syncer::DataBatch> batch) {}

AutofillProfile TestProfile(std::string_view guid) {}

}  // namespace

class ContactInfoSyncBridgeTest : public testing::Test {};

// Tests that a failure in the database initialization reports an error and
// doesn't cause a crash.
// Regression test for crbug.com/1421663.
TEST_F(ContactInfoSyncBridgeTest, InitializationFailure) {}

TEST_F(ContactInfoSyncBridgeTest, IsEntityDataValid) {}

TEST_F(ContactInfoSyncBridgeTest, GetStorageKey) {}

// Tests that during the initial sync, `MergeFullSyncData()` incorporates remote
// profiles.
TEST_F(ContactInfoSyncBridgeTest, MergeFullSyncData) {}

// Tests that when sync changes are applied, `ApplyIncrementalSyncChanges()`
// merges remotes changes into the local store. New local changes are not
// applied to sync.
TEST_F(ContactInfoSyncBridgeTest, ApplyIncrementalSyncChanges) {}

// Regression test checking that the modification date of incoming profiles is
// kept.
TEST_F(ContactInfoSyncBridgeTest,
       ApplyIncrementalSyncChanges_ModificationDate) {}

// Tests that `GetDataForCommit()` returns all local profiles of matching GUID.
TEST_F(ContactInfoSyncBridgeTest, GetDataForCommit) {}

// Tests that `GetAllDataForDebugging()` returns all local data.
TEST_F(ContactInfoSyncBridgeTest, GetAllDataForDebugging) {}

// Tests that new local profiles are pushed to Sync.
TEST_F(ContactInfoSyncBridgeTest, AutofillProfileChange_Add) {}

// Tests that updates to local profiles are pushed to Sync.
TEST_F(ContactInfoSyncBridgeTest, AutofillProfileChange_Update) {}

// Tests that the removal of local profiles is communicated to Sync.
TEST_F(ContactInfoSyncBridgeTest, AutofillProfileChange_Remove) {}

// Tests that `ApplyDisableSyncChanges()` clears all data in AutofillTable when
// the data type gets disabled.
TEST_F(ContactInfoSyncBridgeTest, ApplyDisableSyncChanges) {}

// Tests that trimming `ContactInfoSpecifics` with only supported values set
// results in a zero-length specifics.
TEST_F(ContactInfoSyncBridgeTest,
       TrimAllSupportedFieldsFromRemoteSpecificsPreservesOnlySupportedFields) {}

// Tests that trimming `ContactInfoSpecifics` with unsupported fields will only
// preserve the unknown fields.
TEST_F(ContactInfoSyncBridgeTest,
       TrimRemoteSpecificsReturnsEmptyProtoWhenAllFieldsAreSupported) {}
}  // namespace autofill