#include "components/plus_addresses/plus_address_preallocator.h"
#include <string>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/json/values_util.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/gmock_move_support.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/affiliations/core/browser/affiliation_utils.h"
#include "components/plus_addresses/features.h"
#include "components/plus_addresses/mock_plus_address_http_client.h"
#include "components/plus_addresses/plus_address_allocator.h"
#include "components/plus_addresses/plus_address_http_client.h"
#include "components/plus_addresses/plus_address_prefs.h"
#include "components/plus_addresses/plus_address_test_utils.h"
#include "components/plus_addresses/plus_address_types.h"
#include "components/plus_addresses/settings/fake_plus_address_setting_service.h"
#include "components/prefs/testing_pref_service.h"
#include "net/http/http_status_code.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace plus_addresses {
namespace {
RunOnceCallback;
CreatePreallocatedPlusAddress;
_;
InSequence;
IsEmpty;
MockFunction;
NiceMock;
SizeIs;
UnorderedElementsAre;
PlusProfileOrError PlusProfileFromPreallocatedAddress(
const url::Origin& origin,
std::string plus_address) { … }
MATCHER_P2(IsPreallocatedPlusAddress, end_of_life, address, "") { … }
base::RepeatingCallback<bool()> AlwaysEnabled() { … }
base::RepeatingCallback<bool()> NeverEnabled() { … }
}
class PlusAddressPreallocatorTest : public ::testing::Test { … };
TEST_F(PlusAddressPreallocatorTest,
PrunePreallocatedPlusAddressesWithEolInFuture) { … }
TEST_F(PlusAddressPreallocatorTest,
PrunePreallocatedPlusAddressesWithEolInPast) { … }
TEST_F(PlusAddressPreallocatorTest,
PrunePreallocatedPlusAddressesFixesNextIndex) { … }
TEST_F(PlusAddressPreallocatorTest,
PrunePreallocatedPlusAddressesWithMixedEols) { … }
TEST_F(PlusAddressPreallocatorTest, IsAllocationSychronousNoPlusAddresses) { … }
TEST_F(PlusAddressPreallocatorTest,
IsAllocationSychronousOutdatedPlusAddresses) { … }
TEST_F(PlusAddressPreallocatorTest, IsAllocationSychronousValidPlusAddresses) { … }
TEST_F(PlusAddressPreallocatorTest, RequestPreallocatedAddressesOnStartup) { … }
TEST_F(PlusAddressPreallocatorTest,
DoNotRequestPreallocatedAddressesOnStartupWhenFeatureIsDisabled) { … }
TEST_F(PlusAddressPreallocatorTest,
DoNotRequestPreallocatedAddressesOnStartupWhenNoticeNotAccepted) { … }
TEST_F(PlusAddressPreallocatorTest,
DoNotRequestPreallocatedAddressesOnStartupWhenGlobalToggleOff) { … }
TEST_F(PlusAddressPreallocatorTest,
DoNotRequestPreallocatedAddressesOnStartup) { … }
TEST_F(PlusAddressPreallocatorTest, HandleNetworkError) { … }
TEST_F(PlusAddressPreallocatorTest, RetryOnTimeout) { … }
TEST_F(PlusAddressPreallocatorTest, NoBackoffPeriodForUserTriggeredRequests) { … }
TEST_F(PlusAddressPreallocatorTest, AllocatePlusAddressForOpaqueOrigin) { … }
TEST_F(PlusAddressPreallocatorTest, AllocatePlusAddressWithToggleOff) { … }
TEST_F(PlusAddressPreallocatorTest, AllocatePlusAddressWithServiceDisabled) { … }
TEST_F(PlusAddressPreallocatorTest, AllocatePlusAddress) { … }
TEST_F(PlusAddressPreallocatorTest,
AllocatePlusAddressWithPreallocationAfterSomeExpire) { … }
TEST_F(PlusAddressPreallocatorTest,
AllocatePlusAddressWithPreallocationAfterAllExpire) { … }
TEST_F(PlusAddressPreallocatorTest, RemoveAllocatedPlusAddress) { … }
TEST_F(PlusAddressPreallocatorTest, ErrorDuringAllocationRequest) { … }
}