chromium/content/browser/file_system_access/file_system_access_file_writer_impl_unittest.cc

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

#include "content/browser/file_system_access/file_system_access_file_writer_impl.h"

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

#include "base/containers/contains.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/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/types/expected.h"
#include "components/services/storage/public/cpp/buckets/bucket_info.h"
#include "components/services/storage/public/cpp/buckets/bucket_locator.h"
#include "content/browser/file_system_access/file_system_access_lock_manager.h"
#include "content/browser/file_system_access/fixed_file_system_access_permission_grant.h"
#include "content/browser/file_system_access/mock_file_system_access_permission_context.h"
#include "content/public/test/browser_task_environment.h"
#include "mojo/public/cpp/system/data_pipe_producer.h"
#include "mojo/public/cpp/system/string_data_source.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "storage/browser/file_system/file_stream_reader.h"
#include "storage/browser/quota/quota_manager_proxy.h"
#include "storage/browser/test/async_file_test_helper.h"
#include "storage/browser/test/mock_quota_manager.h"
#include "storage/browser/test/mock_quota_manager_proxy.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "storage/browser/test/quota_manager_proxy_sync.h"
#include "storage/browser/test/test_file_system_backend.h"
#include "storage/browser/test/test_file_system_context.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/file_system_access/file_system_access_directory_handle.mojom.h"
#include "third_party/blink/public/mojom/file_system_access/file_system_access_manager.mojom.h"
#include "url/gurl.h"

FileSystemAccessStatus;
FileSystemURL;

_;
AllOf;
Eq;
Field;

namespace content {

namespace {

class MockQuarantine : public quarantine::mojom::Quarantine {};

// File System Backend that can notify whenever a FileSystemOperation is
// created. This lets tests simulate race conditions between file operations and
// other work.
class TestFileSystemBackend : public storage::TestFileSystemBackend {};

}  // namespace

class FileSystemAccessFileWriterImplTest : public testing::Test {};

TEST_F(FileSystemAccessFileWriterImplTest, WriteValidEmptyString) {}

TEST_F(FileSystemAccessFileWriterImplTest, WriteValidNonEmpty) {}

TEST_F(FileSystemAccessFileWriterImplTest, WriteWithOffsetInFile) {}

TEST_F(FileSystemAccessFileWriterImplTest, WriteWithOffsetPastFile) {}

TEST_F(FileSystemAccessFileWriterImplTest, TruncateShrink) {}

TEST_F(FileSystemAccessFileWriterImplTest, TruncateGrow) {}

TEST_F(FileSystemAccessFileWriterImplTest, WriterDestroyedAfterClose) {}

TEST_F(FileSystemAccessFileWriterImplTest, WriterDestroyedAfterAbort) {}

// TODO(crbug.com/40266589): Add more tests, particularly for error
// conditions.

class FileSystemAccessSandboxedFileWriterImplTest
    : public FileSystemAccessFileWriterImplTest {};

TEST_F(FileSystemAccessSandboxedFileWriterImplTest, SkipQuarantine) {}

TEST_F(FileSystemAccessSandboxedFileWriterImplTest, QuotaError) {}

class FileSystemAccessFileWriterAfterWriteChecksTest
    : public FileSystemAccessFileWriterImplTest {};

TEST_F(FileSystemAccessFileWriterAfterWriteChecksTest, Allow) {}

TEST_F(FileSystemAccessFileWriterAfterWriteChecksTest, Block) {}

TEST_F(FileSystemAccessFileWriterAfterWriteChecksTest,
       HandleCloseDuringCheckOK) {}

TEST_F(FileSystemAccessFileWriterAfterWriteChecksTest,
       HandleCloseDuringCheckNotOK) {}

TEST_F(FileSystemAccessFileWriterAfterWriteChecksTest,
       DestructDuringMoveQuarantines) {}

}  // namespace content