chromium/third_party/blink/renderer/core/annotation/annotation_agent_container_impl_test.cc

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

#include "third_party/blink/renderer/core/annotation/annotation_agent_container_impl.h"

#include <gtest/gtest.h>

#include "base/run_loop.h"
#include "base/test/bind.h"
#include "components/shared_highlighting/core/common/shared_highlighting_metrics.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/mojom/annotation/annotation.mojom-blink.h"
#include "third_party/blink/renderer/core/annotation/annotation_agent_impl.h"
#include "third_party/blink/renderer/core/annotation/annotation_test_utils.h"
#include "third_party/blink/renderer/core/editing/finder/async_find_buffer.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/iterators/text_iterator.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"

namespace blink {

class AnnotationAgentContainerImplTest : public SimTest {};

// Ensure containers aren't supplementing a document until they're requested.
TEST_F(AnnotationAgentContainerImplTest, IsConstructedLazily) {}

// Test that binding the mojo interface creates a new container.
TEST_F(AnnotationAgentContainerImplTest, BindingCreatesContainer) {}

// Test that navigating to a new document breaks the binding on the old
// document's container.
TEST_F(AnnotationAgentContainerImplTest, NavigationBreaksBinding) {}

// Test that navigating to a new document installs a new container.
TEST_F(AnnotationAgentContainerImplTest, NavigationReplacesContainer) {}

// Test that the container can create an unbound agent.
TEST_F(AnnotationAgentContainerImplTest, CreateUnboundAgent) {}

// Test that the container can create a bound agent. It should automatically
// perform attachment at creation time.
TEST_F(AnnotationAgentContainerImplTest, CreateBoundAgent) {}

// Test that creating an agent in a document that hasn't yet completed parsing
// will cause agents to defer attachment and attempt it when the document
// finishes parsing.
TEST_F(AnnotationAgentContainerImplTest, DeferAttachmentUntilFinishedParsing) {}

// Test that an agent removing itself also removes it from its container.
TEST_F(AnnotationAgentContainerImplTest, ManuallyRemoveAgent) {}

// Test that navigating to a new document causes the agents to be disconnected
// from their hosts.
TEST_F(AnnotationAgentContainerImplTest, NavigationRemovesBoundAgents) {}

// Test that a detached document's container is no longer accessible.
TEST_F(AnnotationAgentContainerImplTest,
       DetachedDocumentContainerBecomesInaccessible) {}

// When the document has no selection, calling CreateAgentFromSelection must
// not create an agent and it must return empty null bindings back to the
// caller.
TEST_F(AnnotationAgentContainerImplTest,
       CreateAgentFromSelectionWithNoSelection) {}

// CreateAgentFromSelection must create an agent and return a selector for the
// selected text and bindings to the agent. It should also attach the agent to
// show the highlight.
TEST_F(AnnotationAgentContainerImplTest,
       CreateAgentFromSelectionWithCollapsedSelection) {}

// CreateAgentFromSelection should synchronously return a preemptively generated
// result if one is available.
TEST_F(AnnotationAgentContainerImplTest,
       CreateAgentFromSelectionWithPreemptiveGeneration) {}

// When the document has a collapsed selection, calling
// CreateAgentFromSelection must not create an agent and it must return empty
// null bindings back to the caller.
TEST_F(AnnotationAgentContainerImplTest, CreateAgentFromSelection) {}

// Test that an in-progress, asynchronous generation is canceled gracefully if
// a new document is navigated.
TEST_F(AnnotationAgentContainerImplTest, ShutdownDocumentWhileGenerating) {}

}  // namespace blink