chromium/content/browser/file_system_access/file_system_access_watcher_manager_unittest.cc

// Copyright 2023 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_watcher_manager.h"

#include <list>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/run_until.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/test/test_timeouts.h"
#include "build/buildflag.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/file_system_access/file_system_access_change_source.h"
#include "content/browser/file_system_access/file_system_access_manager_impl.h"
#include "content/browser/file_system_access/file_system_access_watch_scope.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_web_contents_factory.h"
#include "content/test/test_web_contents.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_url.h"
#include "storage/browser/quota/quota_manager_proxy.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_context.h"
#include "storage/common/file_system/file_system_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.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_error.mojom-shared.h"

namespace content {

Change;
Observation;
ChangeInfo;
ChangeType;
FilePathType;

namespace {

constexpr char kTestMountPoint[] =;

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
void SpinEventLoopForABit() {}

bool ReportsModifiedPathForLocalObservations() {}

bool ReportsChangeInfoForLocalObservations() {}

#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA) &&
        // !BUILDFLAG(IS_IOS)

// Accumulates changes it receives from the given `observation`.
class ChangeAccumulator {};

// Trivial implementation of a change source which allows tests to signal
// changes.
class FakeChangeSource : public FileSystemAccessChangeSource {};

}  // namespace

class FileSystemAccessWatcherManagerTest : public testing::Test {};

// Watching the local file system is not supported on Android or Fuchsia.
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
TEST_F(FileSystemAccessWatcherManagerTest, BasicRegistration) {}
#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_FUCHSIA) &&
        // !BUILDFLAG(IS_IOS)

TEST_F(FileSystemAccessWatcherManagerTest, BasicRegistrationUnownedSource) {}

TEST_F(FileSystemAccessWatcherManagerTest, UnownedSource) {}

TEST_F(FileSystemAccessWatcherManagerTest, SourceFailsInitialization) {}

TEST_F(FileSystemAccessWatcherManagerTest, IgnoreSwapFileChanges) {}

TEST_F(FileSystemAccessWatcherManagerTest, RemoveObservation) {}

TEST_F(FileSystemAccessWatcherManagerTest, ObserveBucketFS) {}

TEST_F(FileSystemAccessWatcherManagerTest, UnsupportedScope) {}

// TODO(crbug.com/321980367): Add tests covering more edge cases regarding
// overlapping scopes.
TEST_F(FileSystemAccessWatcherManagerTest, OverlappingSourceScopes) {}

TEST_F(FileSystemAccessWatcherManagerTest,
       OverlappingObservationScopesForBucketFileSystem) {}

TEST_F(FileSystemAccessWatcherManagerTest,
       OnlyReceiveChangesWhenSourceAndObservationUrlsMatchForLocalFileSystem) {}

TEST_F(FileSystemAccessWatcherManagerTest, ErroredChange) {}

TEST_F(FileSystemAccessWatcherManagerTest,
       ErroredChangeOnBucketFileSystemWhenSourceHasLargerScopeThanObservation) {}

TEST_F(FileSystemAccessWatcherManagerTest, ChangeAtRelativePath) {}

TEST_F(FileSystemAccessWatcherManagerTest, ChangeType) {}

// TODO(crbug.com/321980129): Consider parameterizing these tests once
// observing changes to other backends is supported.

TEST_F(FileSystemAccessWatcherManagerTest, WatchLocalDirectory) {}

// TODO(crbug.com/41490258): Failing on Windows. Re-enable this test.
TEST_F(FileSystemAccessWatcherManagerTest,
       DISABLED_WatchLocalDirectoryNonRecursivelyDoesNotSeeRecursiveChanges) {}

TEST_F(FileSystemAccessWatcherManagerTest, WatchLocalDirectoryRecursively) {}

TEST_F(FileSystemAccessWatcherManagerTest, WatchLocalFile) {}

TEST_F(FileSystemAccessWatcherManagerTest,
       WatchLocalFileWithMultipleObservations) {}

TEST_F(FileSystemAccessWatcherManagerTest, OutOfScope) {}

}  // namespace content