chromium/storage/browser/quota/quota_database_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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "storage/browser/quota/quota_database.h"

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

#include <algorithm>
#include <iterator>
#include <memory>
#include <set>

#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/sequence_checker.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 "build/build_config.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/cpp/constants.h"
#include "sql/database.h"
#include "sql/meta_table.h"
#include "sql/sqlite_result_code.h"
#include "sql/sqlite_result_code_values.h"
#include "sql/statement.h"
#include "sql/test/scoped_error_expecter.h"
#include "sql/test/test_helpers.h"
#include "storage/browser/quota/quota_client_type.h"
#include "storage/browser/quota/quota_features.h"
#include "storage/browser/quota/quota_internals.mojom.h"
#include "storage/browser/quota/storage_directory_util.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom-shared.h"
#include "url/gurl.h"

StorageKey;

namespace storage {

namespace {

// Declared to shorten the line lengths.
static const blink::mojom::StorageType kTemp =;
static const blink::mojom::StorageType kSync =;

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

static constexpr char kDatabaseName[] =;

bool ContainsBucket(const std::set<BucketLocator>& buckets,
                    const BucketInfo& target_bucket) {}

}  // namespace

// Test parameter indicates if the database should be created for incognito
// mode, if stale buckets should be evicted, and if orphan buckets should be
// evicted.
class QuotaDatabaseTest
    : public testing::TestWithParam<std::tuple<bool, bool, bool>> {};

TEST_P(QuotaDatabaseTest, EnsureOpened) {}

TEST_P(QuotaDatabaseTest, UpdateOrCreateBucket) {}

TEST_P(QuotaDatabaseTest, UpdateBucket) {}

TEST_P(QuotaDatabaseTest, GetOrCreateBucketDeprecated) {}

TEST_P(QuotaDatabaseTest, GetBucket) {}

TEST_P(QuotaDatabaseTest, GetBucketById) {}

TEST_P(QuotaDatabaseTest, GetBucketsForType) {}

TEST_P(QuotaDatabaseTest, GetBucketsForHost) {}

TEST_P(QuotaDatabaseTest, GetBucketsForStorageKey) {}

TEST_P(QuotaDatabaseTest, BucketLastAccessTimeLRU) {}

TEST_P(QuotaDatabaseTest, BucketPersistence) {}

TEST_P(QuotaDatabaseTest, SetStorageKeyLastAccessTime) {}

TEST_P(QuotaDatabaseTest, GetStorageKeysForType) {}

TEST_P(QuotaDatabaseTest, BucketLastModifiedBetween) {}

TEST_P(QuotaDatabaseTest, RegisterInitialStorageKeyInfo) {}

TEST_P(QuotaDatabaseTest, DumpBucketTable) {}

TEST_P(QuotaDatabaseTest, DeleteBucketData) {}

// Non-parameterized tests.
TEST_P(QuotaDatabaseTest, BootstrapFlag) {}

TEST_P(QuotaDatabaseTest, OpenCorruptedDatabase) {}

TEST_P(QuotaDatabaseTest, QuotaDatabasePathMigration) {}

// Test for crbug.com/1316581.
TEST_P(QuotaDatabaseTest, QuotaDatabasePathBadMigration) {}

// Test for crbug.com/1322375.
//
// base::CreateDirectory behaves differently on Mac and allows directory
// migration to succeed when we expect failure.
#if !BUILDFLAG(IS_APPLE)
TEST_P(QuotaDatabaseTest, QuotaDatabaseDirectoryMigrationError) {}
#endif  // !BUILDFLAG(IS_APPLE)

TEST_P(QuotaDatabaseTest, UpdateOrCreateBucket_CorruptedDatabase) {}

TEST_P(QuotaDatabaseTest, Expiration) {}

TEST_P(QuotaDatabaseTest, Stale) {}

TEST_P(QuotaDatabaseTest, Orphan) {}

TEST_P(QuotaDatabaseTest, PersistentPolicy) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace storage