chromium/chrome/browser/pdf/pdf_viewer_stream_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 "chrome/browser/pdf/pdf_viewer_stream_manager.h"

#include <memory>

#include "base/memory/weak_ptr.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/pdf/pdf_test_util.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/mock_navigation_handle.h"
#include "content/public/test/navigation_simulator.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#include "pdf/pdf_features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/loader/transferrable_url_loader.mojom.h"
#include "url/gurl.h"

namespace pdf {

namespace {

NiceMock;
Return;

constexpr char kOriginalUrl1[] =;
constexpr char kOriginalUrl2[] =;

}  // namespace

class PdfViewerStreamManagerTest : public ChromeRenderViewHostTestHarness {};

// Verify adding and getting an `extensions::StreamContainer`.
TEST_F(PdfViewerStreamManagerTest, AddAndGetStreamContainer) {}

// Verify adding an `extensions::StreamContainer` under the same frame tree node
// ID replaces the original unclaimed `extensions::StreamContainer`.
TEST_F(PdfViewerStreamManagerTest,
       AddStreamContainerSameFrameTreeNodeIdUnclaimed) {}

// Verify getting a `StreamContainer` with a non-matching URL returns nullptr;
TEST_F(PdfViewerStreamManagerTest, AddAndGetStreamInvalidURL) {}

// Verify adding multiple `extensions::StreamContainer`s for different
// FrameTreeNodes at once.
TEST_F(PdfViewerStreamManagerTest, AddMultipleStreamContainers) {}

// `PdfViewerStreamManager::IsPdfExtensionHost()` should correctly identify the
// PDF extension hosts.
TEST_F(PdfViewerStreamManagerTest, IsPdfExtensionHost) {}

// `PdfViewerStreamManager::IsPdfContentHost()` should correctly identify the
// PDF content hosts.
TEST_F(PdfViewerStreamManagerTest, IsPdfContentHost) {}

// If multiple `extensions::StreamContainer`s exist, then deleting one stream
// shouldn't delete the other stream.
TEST_F(PdfViewerStreamManagerTest, DeleteWithMultipleStreamContainers) {}

// Verify that unclaimed stream infos can be deleted.
TEST_F(PdfViewerStreamManagerTest, DeleteUnclaimedStreamInfo) {}

// If the embedder render frame is deleted, the stream should be deleted.
TEST_F(PdfViewerStreamManagerTest, RenderFrameDeletedWithClaimedStream) {}

TEST_F(PdfViewerStreamManagerTest, RenderFrameDeletedWithUnclaimedStream) {}

// If the `content::RenderFrameHost` for the stream changes, then the stream
// should be deleted.
TEST_F(PdfViewerStreamManagerTest, EmbedderRenderFrameHostChanged) {}

// If the PDF extension host changes to a different host, the stream should be
// deleted.
TEST_F(PdfViewerStreamManagerTest, ExtensionRenderFrameHostChanged) {}

// If the PDF content host changes to a different host, the stream should be
// deleted.
TEST_F(PdfViewerStreamManagerTest, ContentRenderFrameHostChanged) {}

// If the `content::RenderFrameHost` for the stream is deleted, then the stream
// should be deleted.
TEST_F(PdfViewerStreamManagerTest, EmbedderFrameDeleted) {}

// If the PDF extension frame is deleted, the stream should be deleted.
TEST_F(PdfViewerStreamManagerTest, ExtensionFrameDeleted) {}

// If the PDF content frame is deleted, the stream should be deleted.
TEST_F(PdfViewerStreamManagerTest, ContentFrameDeleted) {}

// Starting the navigation for the content host should set the content host
// frame tree node ID.
TEST_F(PdfViewerStreamManagerTest,
       DidStartNavigationSetContentHostFrameTreeNodeId) {}

// `PdfViewerStreamManager` should register a subresource
// override if the navigation handle is for a PDF content frame.
TEST_F(PdfViewerStreamManagerTest, ReadyToCommitNavigationSubresourceOverride) {}

// `PdfViewerStreamManager` should be able to handle registering multiple
// subresource override for multiple PDF streams.
TEST_F(PdfViewerStreamManagerTest,
       ReadyToCommitNavigationSubresourceOverrideMultipleStreams) {}

// The initial load should claim the stream.
TEST_F(PdfViewerStreamManagerTest, ReadyToCommitNavigationClaimAndReplace) {}

}  // namespace pdf