chromium/content/browser/file_system_access/file_system_access_observer_observation_unittest.cc

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

#include <iterator>
#include <memory>

#include "base/cancelable_callback.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/memory/weak_ptr.h"
#include "base/test/test_future.h"
#include "base/test/test_timeouts.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/file_system_access/file_path_watcher/file_path_watcher.h"
#include "content/browser/file_system_access/file_system_access_directory_handle_impl.h"
#include "content/browser/file_system_access/file_system_access_file_handle_impl.h"
#include "content/browser/file_system_access/file_system_access_manager_impl.h"
#include "content/browser/file_system_access/file_system_access_watcher_manager.h"
#include "content/browser/file_system_access/fixed_file_system_access_permission_grant.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_renderer_host.h"
#include "content/test/test_web_contents.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "storage/browser/file_system/file_system_url.h"
#include "storage/browser/quota/quota_manager_proxy.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/mojom/file_system_access/file_system_access_observer_host.mojom.h"

namespace content {

ChangeInfo;
ChangeType;
FilePathType;

MojoChangeType;
MojoFilePathType;

namespace {

// A struct equivalent to `blink::mojom::FileSystemAccessChangePtr` but can be
// used in gtest matchers.
struct MojoChangeInfo {};

// Implementation of an observation (blink::mojom::FileSystemAccessObserver).
// Collects the changes it receives so that it can be verified against expected
// changes.
class FakeObservation : public blink::mojom::FileSystemAccessObserver {};

// Wraps an observer remote
// (mojo::Remote<blink::mojom::FileSystemAccessObserverHost>).
class FakeObserver {};

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

}  // namespace

class FileSystemAccessObserverObservationTest
    : public RenderViewHostTestHarness {};

TEST_F(FileSystemAccessObserverObservationTest,
       NoChangesAfterAnErrorIsReported) {}

TEST_F(FileSystemAccessObserverObservationTest,
       AnErrorDestroysTheCorrectObservation) {}

TEST_F(FileSystemAccessObserverObservationTest, ReceivedEventsInBFCache) {}

TEST_F(FileSystemAccessObserverObservationTest, ReceivedErrorsInBFCache) {}

}  // namespace content