chromium/storage/browser/file_system/obfuscated_file_util_unittest.cc

// Copyright 2013 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/file_system/obfuscated_file_util.h"

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

#include <limits>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.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/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "components/services/filesystem/public/mojom/types.mojom.h"
#include "net/base/features.h"
#include "net/base/io_buffer.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_operation_context.h"
#include "storage/browser/file_system/file_system_url.h"
#include "storage/browser/file_system/file_system_usage_cache.h"
#include "storage/browser/file_system/obfuscated_file_util_memory_delegate.h"
#include "storage/browser/file_system/sandbox_directory_database.h"
#include "storage/browser/file_system/sandbox_file_system_backend_delegate.h"
#include "storage/browser/file_system/sandbox_origin_database.h"
#include "storage/browser/quota/quota_manager.h"
#include "storage/browser/quota/quota_manager_proxy.h"
#include "storage/browser/test/async_file_test_helper.h"
#include "storage/browser/test/file_system_test_file_set.h"
#include "storage/browser/test/mock_file_change_observer.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "storage/browser/test/sandbox_file_system_test_helper.h"
#include "storage/browser/test/test_file_system_context.h"
#include "storage/common/database/database_identifier.h"
#include "storage/common/file_system/file_system_types.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/leveldatabase/leveldb_chrome.h"
#include "url/gurl.h"

Origin;

namespace storage {

namespace {

enum TestMode {};

bool FileExists(const base::FilePath& path) {}

int64_t GetLocalFileSize(const base::FilePath& path) {}

// After a move, the dest exists and the source doesn't.
// After a copy, both source and dest exist.
struct CopyMoveTestCaseRecord {};

const CopyMoveTestCaseRecord kCopyMoveTestCases[] =;

struct OriginEnumerationTestRecord {};

const OriginEnumerationTestRecord kOriginEnumerationTestRecords[] =;

FileSystemURL FileSystemURLAppend(const FileSystemURL& url,
                                  const base::FilePath::StringType& child) {}

FileSystemURL FileSystemURLAppendUTF8(const FileSystemURL& url,
                                      const std::string& child) {}

FileSystemURL FileSystemURLDirName(const FileSystemURL& url) {}

std::string GetTypeString(FileSystemType type) {}

bool HasFileSystemType(
    ObfuscatedFileUtil::AbstractStorageKeyEnumerator* enumerator,
    FileSystemType type) {}

}  // namespace

// TODO(ericu): The vast majority of this and the other FSFU subclass tests
// could theoretically be shared.  It would basically be a FSFU interface
// compliance test, and only the subclass-specific bits that look into the
// implementation would need to be written per-subclass.
class ObfuscatedFileUtilTest : public testing::Test,
                               public ::testing::WithParamInterface<TestMode> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(ObfuscatedFileUtilTest, TestCreateAndDeleteFile) {}

TEST_P(ObfuscatedFileUtilTest, TestTruncate) {}

TEST_P(ObfuscatedFileUtilTest, TestQuotaOnTruncation) {}

TEST_P(ObfuscatedFileUtilTest, TestEnsureFileExists) {}

TEST_P(ObfuscatedFileUtilTest, TestDirectoryOps) {}

TEST_P(ObfuscatedFileUtilTest, TestReadDirectory) {}

TEST_P(ObfuscatedFileUtilTest, TestReadRootWithSlash) {}

TEST_P(ObfuscatedFileUtilTest, TestReadRootWithEmptyString) {}

TEST_P(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) {}

// TODO(crbug.com/40511450): Remove this test once last_access_time has
// been removed after PPAPI has been deprecated. Fuchsia does not support touch,
// which breaks this test that relies on it. Since PPAPI is being deprecated,
// this test is excluded from the Fuchsia build.
// See https://crbug.com/1077456 for details.
#if !BUILDFLAG(IS_FUCHSIA)
TEST_P(ObfuscatedFileUtilTest, TestTouch) {}
#endif  // !BUILDFLAG(IS_FUCHSIA)

TEST_P(ObfuscatedFileUtilTest, TestPathQuotas) {}

TEST_P(ObfuscatedFileUtilTest, TestCopyOrMoveFileNotFound) {}

TEST_P(ObfuscatedFileUtilTest, TestCopyOrMoveFileSuccess) {}

TEST_P(ObfuscatedFileUtilTest, TestCopyPathQuotas) {}

TEST_P(ObfuscatedFileUtilTest, TestMovePathQuotasWithRename) {}

TEST_P(ObfuscatedFileUtilTest, TestMovePathQuotasWithoutRename) {}

TEST_P(ObfuscatedFileUtilTest, TestCopyInForeignFile) {}

TEST_P(ObfuscatedFileUtilTest, TestEnumerator) {}

TEST_P(ObfuscatedFileUtilTest, TestStorageKeyEnumerator) {}

TEST_P(ObfuscatedFileUtilTest, TestRevokeUsageCache) {}

TEST_P(ObfuscatedFileUtilTest, TestInconsistency) {}

TEST_P(ObfuscatedFileUtilTest, TestIncompleteDirectoryReading) {}

TEST_P(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) {}

TEST_P(ObfuscatedFileUtilTest, TestDirectoryTimestampForDeletion) {}

TEST_P(ObfuscatedFileUtilTest, TestDirectoryTimestampForCopyAndMove) {}

TEST_P(ObfuscatedFileUtilTest, TestFileEnumeratorTimestamp) {}

TEST_P(ObfuscatedFileUtilTest, TestQuotaOnCopyFile) {}

TEST_P(ObfuscatedFileUtilTest, TestQuotaOnMoveFile) {}

TEST_P(ObfuscatedFileUtilTest, TestQuotaOnRemove) {}

TEST_P(ObfuscatedFileUtilTest, TestQuotaOnOpen) {}

TEST_P(ObfuscatedFileUtilTest, MaybeDropDatabasesAliveCase) {}

TEST_P(ObfuscatedFileUtilTest, MaybeDropDatabasesAlreadyDeletedCase) {}

TEST_P(ObfuscatedFileUtilTest, DestroyDirectoryDatabase_Isolated) {}

TEST_P(ObfuscatedFileUtilTest, GetDirectoryDatabase_Isolated) {}

TEST_P(ObfuscatedFileUtilTest, OpenPathInNonDirectory) {}

TEST_P(ObfuscatedFileUtilTest, CreateDirectory_NotADirectoryInRecursive) {}

TEST_P(ObfuscatedFileUtilTest, DeleteDirectoryForBucketAndType) {}

TEST_P(ObfuscatedFileUtilTest, DeleteDirectoryForBucketAndType_DeleteAll) {}

}  // namespace storage