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

// Copyright 2024 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/address_data_manager.h"

#include <string>
#include <vector>

#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/with_feature_override.h"
#include "base/uuid.h"
#include "build/buildflag.h"
#include "components/autofill/core/browser/autofill_test_utils.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/personal_data_manager_test_utils.h"
#include "components/autofill/core/browser/profile_token_quality_test_api.h"
#include "components/autofill/core/browser/strike_databases/test_inmemory_strike_database.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/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/sync/base/features.h"
#include "components/sync/service/sync_user_settings.h"
#include "components/sync/test/test_sync_service.h"
#include "components/webdata/common/web_database_service.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace autofill {

namespace {

ElementsAre;
Pointee;
UnorderedElementsAre;

const base::Time kArbitraryTime =;
const base::Time kSomeLaterTime =;
const base::Time kMuchLaterTime =;

constexpr char kGuid[] =;

class MockAddressDataManagerObserver : public AddressDataManager::Observer {};

class AddressDataManagerTest : public testing::Test {};

TEST_F(AddressDataManagerTest, AddProfile) {}

TEST_F(AddressDataManagerTest, UpdateProfile_ModificationDate) {}

// Tests that profiles with record type`kAccount` and `kLocalOrSyncable` are
// loaded, and accessible via `GetProfiles()` and `GetProfilesByRecordType()`.
// If duplicates exist across record types, they should be considered distinct.
TEST_F(AddressDataManagerTest, GetProfiles) {}

// Tests the different orderings in which profiles can be retrieved.
TEST_F(AddressDataManagerTest, GetProfiles_Order) {}

// Test that profiles are not shown if |kAutofillProfileEnabled| is set to
// |false|.
TEST_F(AddressDataManagerTest, GetProfilesToSuggest_ProfileAutofillDisabled) {}

// Test that local and server profiles are not loaded into memory on start-up if
// |kAutofillProfileEnabled| is set to |false|.
TEST_F(AddressDataManagerTest,
       GetProfilesToSuggest_NoProfilesLoadedIfDisabled) {}

// Test that profiles are not added if `kAutofillProfileEnabled` is set to
// false.
TEST_F(AddressDataManagerTest, GetProfilesToSuggest_NoProfilesAddedIfDisabled) {}

// Tests that `GetProfilesForSettings()` orders by descending modification
// dates.
TEST_F(AddressDataManagerTest, GetProfilesForSettings) {}

// Adding, updating, removing operations without waiting in between.
TEST_F(AddressDataManagerTest, AddRemoveUpdateProfileSequence) {}

// Test that a new profile has its basic information set.
TEST_F(AddressDataManagerTest, AddProfile_BasicInformation) {}

// Test filling profiles with unicode strings and crazy characters.
TEST_F(AddressDataManagerTest, AddProfile_CrazyCharacters) {}

// Test filling in invalid values for profiles are saved as-is. Phone
// information entered into the settings UI is not validated or rejected except
// for duplicates.
TEST_F(AddressDataManagerTest, AddProfile_Invalid) {}

TEST_F(AddressDataManagerTest, AddUpdateRemoveProfiles) {}

// Tests that `UpdateProfile()` takes changes in the `ProfileTokenQuality`
// observations into considerations.
TEST_F(AddressDataManagerTest, UpdateProfile_NewObservations) {}

// Tests that when the value for a type changes, `UpdateProfile()` resets the
// observations for that type.
TEST_F(AddressDataManagerTest, UpdateProfile_ResetObservations) {}

TEST_F(AddressDataManagerTest, IsEligibleForAddressAccountStorage) {}

TEST_F(AddressDataManagerTest, IsCountryEligibleForAccountStorage) {}

TEST_F(AddressDataManagerTest, MigrateProfileToAccount) {}

// Test for http://crbug.com/50047. Makes sure that guids are populated
// correctly on load.
TEST_F(AddressDataManagerTest, PopulateUniqueIDsOnLoad) {}

TEST_F(AddressDataManagerTest, SetEmptyProfile) {}

TEST_F(AddressDataManagerTest, Refresh) {}

TEST_F(AddressDataManagerTest, UpdateLanguageCodeInProfile) {}

// Tests that the least recently used profile of two existing profiles is
// deleted, when an update of one of the profiles makes it a duplicate of the
// other, already existing profile. Here, the less recently used profile is
// edited to become a duplicate of the more recently used profile.
TEST_F(AddressDataManagerTest, CreateDuplicateWithAnUpdate) {}

// Tests that the least recently used profile of two existing profiles is
// deleted, when an update of one of the profiles makes it a duplicate of the
// other, already existing profile. Here, the more recently used profile is
// edited to become a duplicate of the less recently used profile.
TEST_F(AddressDataManagerTest,
       CreateDuplicateWithAnUpdate_UpdatedProfileWasMoreRecentlyUsed) {}

TEST_F(AddressDataManagerTest, RecordUseOf) {}

TEST_F(AddressDataManagerTest, SaveProfileMigrationStrikes) {}

TEST_F(AddressDataManagerTest, SaveProfileUpdateStrikes) {}

TEST_F(AddressDataManagerTest, SaveProfileSaveStrikes) {}

TEST_F(AddressDataManagerTest, ClearFullBrowsingHistory) {}

TEST_F(AddressDataManagerTest, ClearUrlsFromBrowsingHistory) {}

TEST_F(AddressDataManagerTest, ClearUrlsFromBrowsingHistoryInTimeRange) {}

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)

TEST_F(AddressDataManagerTest,
       IsEligibleForAddressAccountStorageSigninPending) {}

TEST_F(AddressDataManagerTest, AutofillSyncToggleAvailableInTransportMode) {}
#endif  // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)

TEST_F(AddressDataManagerTest, ChangeCallbackIsTriggeredOnAddedProfile) {}

}  // namespace

}  // namespace autofill