chromium/storage/browser/quota/quota_manager_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <cstdint>
#include <memory>
#include <set>
#include <sstream>
#include <tuple>
#include <vector>

#include "base/containers/span.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/system/sys_info.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/time/time.h"
#include "components/services/storage/public/cpp/buckets/bucket_info.h"
#include "components/services/storage/public/cpp/buckets/bucket_locator.h"
#include "components/services/storage/public/cpp/buckets/constants.h"
#include "components/services/storage/public/mojom/quota_client.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "sql/test/test_helpers.h"
#include "storage/browser/quota/quota_client_type.h"
#include "storage/browser/quota/quota_database.h"
#include "storage/browser/quota/quota_features.h"
#include "storage/browser/quota/quota_internals.mojom.h"
#include "storage/browser/quota/quota_manager_impl.h"
#include "storage/browser/quota/quota_manager_proxy.h"
#include "storage/browser/quota/quota_override_handle.h"
#include "storage/browser/test/mock_quota_client.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/buckets/bucket_manager_host.mojom-shared.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom-shared.h"
#include "url/gurl.h"

StorageKey;
QuotaStatusCode;
StorageType;

namespace storage {

namespace {

// For shorter names.
const StorageType kTemp =;
const StorageType kSync =;

const blink::mojom::StorageType kStorageTemp =;
const blink::mojom::StorageType kStorageSync =;

// Values in bytes.
const int64_t kAvailableSpaceForApp =;
const int64_t kMustRemainAvailableForSystem =;
const int64_t kDefaultPoolSize =;
const int64_t kDefaultPerStorageKeyQuota =;
const int64_t kGigabytes =;

struct UsageAndQuotaResult {};

struct GlobalUsageResult {};

struct StorageCapacityResult {};

struct ClientBucketData {};

struct UsageWithBreakdown {};

struct UsageAndQuotaWithBreakdown {};

// Returns a deterministic value for the amount of available disk space.
int64_t GetAvailableDiskSpaceForTest() {}

QuotaAvailability GetVolumeInfoForTests(const base::FilePath& unused) {}

StorageKey ToStorageKey(const std::string& url) {}

const storage::mojom::BucketTableEntry* FindBucketTableEntry(
    const std::vector<storage::mojom::BucketTableEntryPtr>& bucket_entries,
    BucketId& id) {}

MATCHER_P3(MatchesBucketTableEntry, storage_key, type, use_count, "") {}

}  // namespace

class QuotaManagerImplTest : public testing::Test {};

TEST_F(QuotaManagerImplTest, QuotaDatabaseBootstrap) {}

TEST_F(QuotaManagerImplTest, CorruptionRecovery) {}

TEST_F(QuotaManagerImplTest, GetUsageInfo) {}

TEST_F(QuotaManagerImplTest, UpdateUsageInfo) {}

TEST_F(QuotaManagerImplTest, UpdateOrCreateBucket) {}

TEST_F(QuotaManagerImplTest, UpdateOrCreateBucket_Expiration) {}

TEST_F(QuotaManagerImplTest, UpdateOrCreateBucket_Overflow) {}

// Make sure `EvictExpiredBuckets` deletes expired buckets.
TEST_F(QuotaManagerImplTest, EvictExpiredBuckets) {}

TEST_F(QuotaManagerImplTest, GetOrCreateBucketSync) {}

TEST_F(QuotaManagerImplTest, GetBucket) {}

TEST_F(QuotaManagerImplTest, GetBucketById) {}

TEST_F(QuotaManagerImplTest, GetStorageKeysForType) {}

TEST_F(QuotaManagerImplTest, GetStorageKeysForTypeWithDatabaseError) {}

TEST_F(QuotaManagerImplTest, QuotaDatabaseResultHistogram) {}

TEST_F(QuotaManagerImplTest, GetBucketsForType) {}

TEST_F(QuotaManagerImplTest, GetBucketsForHost) {}

TEST_F(QuotaManagerImplTest, GetBucketsForStorageKey) {}

TEST_F(QuotaManagerImplTest, GetBucketsForStorageKey_Expiration) {}

TEST_F(QuotaManagerImplTest, EnforceQuota) {}

TEST_F(QuotaManagerImplTest, GetUsageAndQuota_Simple) {}

TEST_F(QuotaManagerImplTest, GetUsageAndQuota_SingleBucket) {}

TEST_F(QuotaManagerImplTest, GetUsage_NoClient) {}

TEST_F(QuotaManagerImplTest, GetUsage_EmptyClient) {}

TEST_F(QuotaManagerImplTest, GetTemporaryUsageAndQuota_MultiStorageKeys) {}

TEST_F(QuotaManagerImplTest, GetUsage_MultipleClients) {}

TEST_F(QuotaManagerImplTest, GetUsageWithBreakdown_Simple) {}

TEST_F(QuotaManagerImplTest, GetUsageWithBreakdown_NoClient) {}

TEST_F(QuotaManagerImplTest, GetUsageWithBreakdown_MultiStorageKeys) {}

TEST_F(QuotaManagerImplTest, GetUsageWithBreakdown_MultipleClients) {}

TEST_F(QuotaManagerImplTest, GetTemporaryUsage_WithModify) {}

TEST_F(QuotaManagerImplTest, GetTemporaryUsageAndQuota_WithAdditionalTasks) {}

TEST_F(QuotaManagerImplTest, GetTemporaryUsageAndQuota_NukeManager) {}

TEST_F(QuotaManagerImplTest, GetTemporaryUsageAndQuota_Overbudget) {}

TEST_F(QuotaManagerImplTest, GetTemporaryUsageAndQuota_Unlimited) {}

TEST_F(QuotaManagerImplTest, GetQuotaLowAvailableDiskSpace) {}

TEST_F(QuotaManagerImplTest, GetSyncableQuota) {}

TEST_F(QuotaManagerImplTest, GetUsage_Simple) {}

TEST_F(QuotaManagerImplTest, GetUsage_WithModification) {}

TEST_F(QuotaManagerImplTest, GetUsage_WithBucketModification) {}

TEST_F(QuotaManagerImplTest, GetUsage_WithDeleteBucket) {}

TEST_F(QuotaManagerImplTest, GetStorageCapacity) {}

TEST_F(QuotaManagerImplTest, EvictBucketData) {}

TEST_F(QuotaManagerImplTest, EvictBucketDataHistogram) {}

TEST_F(QuotaManagerImplTest, EvictBucketDataWithDeletionError) {}

TEST_F(QuotaManagerImplTest, GetEvictionRoundInfo) {}

TEST_F(QuotaManagerImplTest, DeleteHostDataNoClients) {}

TEST_F(QuotaManagerImplTest, DeleteHostDataSimple) {}

TEST_F(QuotaManagerImplTest, DeleteHostDataMultiple) {}

TEST_F(QuotaManagerImplTest, DeleteHostDataMultipleClientsDifferentTypes) {}

TEST_F(QuotaManagerImplTest, DeleteBucketNoClients) {}

TEST_F(QuotaManagerImplTest, DeleteBucketDataMultiple) {}

TEST_F(QuotaManagerImplTest, DeleteBucketDataMultipleClientsDifferentTypes) {}

TEST_F(QuotaManagerImplTest, FindAndDeleteBucketData) {}

TEST_F(QuotaManagerImplTest, FindAndDeleteBucketDataWithDBError) {}

TEST_F(QuotaManagerImplTest, GetDiskAvailabilityAndTempPoolSize) {}

TEST_F(QuotaManagerImplTest, GetDiskAvailabilityAndTempPoolSize_Incognito) {}

TEST_F(QuotaManagerImplTest, NotifyAndLRUBucket) {}

TEST_F(QuotaManagerImplTest, GetBucketsForEviction) {}

TEST_F(QuotaManagerImplTest, GetBucketsModifiedBetween) {}

TEST_F(QuotaManagerImplTest, GetBucketsModifiedBetweenWithDatabaseError) {}

TEST_F(QuotaManagerImplTest, DumpBucketTable) {}

TEST_F(QuotaManagerImplTest, RetrieveBucketsTable) {}

TEST_F(QuotaManagerImplTest, DeleteSpecificClientTypeSingleBucket) {}

TEST_F(QuotaManagerImplTest, DeleteMultipleClientTypesSingleBucket) {}

TEST_F(QuotaManagerImplTest, GetUsageAndQuota_Incognito) {}

TEST_F(QuotaManagerImplTest, GetUsageAndQuota_SessionOnly) {}

TEST_F(QuotaManagerImplTest, MaybeRunStoragePressureCallback) {}

TEST_F(QuotaManagerImplTest, OverrideQuotaForStorageKey) {}

TEST_F(QuotaManagerImplTest, OverrideQuotaForStorageKey_Disable) {}

TEST_F(QuotaManagerImplTest, WithdrawQuotaOverride) {}

TEST_F(QuotaManagerImplTest, QuotaChangeEvent_LargePartitionPressure) {}

TEST_F(QuotaManagerImplTest, QuotaChangeEvent_SmallPartitionPressure) {}

TEST_F(QuotaManagerImplTest, DeleteBucketData_QuotaManagerDeletedImmediately) {}

TEST_F(QuotaManagerImplTest, DeleteBucketData_CallbackDeletesQuotaManager) {}

TEST_F(QuotaManagerImplTest, DeleteHostData_CallbackDeletesQuotaManager) {}

TEST_F(QuotaManagerImplTest, SimulateStoragePressure_Incognito) {}

TEST_F(QuotaManagerImplTest,
       QuotaManagerObserver_NotifiedOnAddedChangedAndDeleted) {}

TEST_F(QuotaManagerImplTest, QuotaManagerObserver_NotifiedOnExpired) {}
}  // namespace storage