chromium/components/plus_addresses/plus_address_jit_allocator_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/plus_addresses/plus_address_jit_allocator.h"

#include <utility>

#include "base/test/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "base/types/expected.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_test_utils.h"
#include "components/plus_addresses/plus_address_types.h"
#include "net/http/http_status_code.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace plus_addresses {

namespace {

_;
InSequence;
Message;
NiceMock;

// Shorthands for common errors that the allocator can throw.
const PlusProfileOrError kNotSupportedError =;
const PlusProfileOrError kMaxRefreshesReachedError =;

url::Origin GetSampleOrigin1() {}

url::Origin GetSampleOrigin2() {}

}  // namespace

class PlusAddressJitAllocatorRefreshTest : public ::testing::Test {};

// Tests that the allocator translates the `AllocationMode` properly into the
// `refresh` parameter of the client.
TEST_F(PlusAddressJitAllocatorRefreshTest, RefreshParameterPassedOn) {}

TEST_F(PlusAddressJitAllocatorRefreshTest, AllocationIsNeverSynchronous) {}

// Tests that refreshing is only allowed `kMaxPlusAddressRefreshesPerOrigin`
// times per origin.
TEST_F(PlusAddressJitAllocatorRefreshTest, RefreshLimit) {}

// Tests that the allocator handles the server response for "refresh quota is
// exhausted" properly by disabling refresh for a cool down period.
TEST_F(PlusAddressJitAllocatorRefreshTest,
       HandleServerResponseForQuotaExhausted) {}

}  // namespace plus_addresses