chromium/content/browser/file_system_access/file_system_access_file_writer_impl_browsertest.cc

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

#include "base/containers/contains.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "components/services/quarantine/test_support.h"
#include "content/browser/file_system_access/file_system_access_manager_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/file_system_chooser_test_helpers.h"
#include "content/shell/browser/shell.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#include "ui/shell_dialogs/select_file_dialog_factory.h"
#include "ui/shell_dialogs/select_file_policy.h"

#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif

namespace content {

// This browser test implements end-to-end tests for
// FileSystemAccessFileWriterImpl.
class FileSystemAccessFileWriterBrowserTest : public ContentBrowserTest {};

IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       ContentsWrittenToSwapFileFirst) {}

IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       KeepExistingDataHasPreviousContent) {}

IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       CreateWriterNoKeepExistingWithEmptyFile) {}

IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       EachWriterHasUniqueSwapFile) {}

IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       EachWriterHasUniqueSwapFileRacy) {}

IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       EachWriterHasUniqueSwapFileRacyKeepExistingData) {}

IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       WriteOffsetAndSeekInSameWritable) {}

// Ideally this would be tested by WPTs, but the location of the swap file is
// not specified and not easily accessible.
IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       CannotCreateWritableToSwapFile) {}

// TODO(crbug.com/40639570): Files are only quarantined on windows in
// browsertests unfortunately. Change this when more platforms are enabled.
#if BUILDFLAG(IS_WIN)
#define MAYBE_FileAnnotated
#else
#define MAYBE_FileAnnotated
#endif  // BUILDFLAG(IS_WIN)
IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       MAYBE_FileAnnotated) {}

#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_WIN)
IN_PROC_BROWSER_TEST_F(FileSystemAccessFileWriterBrowserTest,
                       RespectOSPermissions) {}
#endif  // BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_WIN)

}  // namespace content