chromium/pdf/pdf_ink_module_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 "pdf/pdf_ink_module.h"

#include <set>
#include <string_view>
#include <vector>

#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/containers/to_vector.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "pdf/ink/ink_affine_transform.h"
#include "pdf/ink/ink_brush.h"
#include "pdf/pdf_features.h"
#include "pdf/pdf_ink_brush.h"
#include "pdf/pdf_ink_transform.h"
#include "pdf/test/mouse_event_builder.h"
#include "pdf/test/pdf_ink_test_helpers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d_f.h"

_;
ElementsAre;
ElementsAreArray;
InSequence;
Pair;
SizeIs;

namespace chrome_pdf {

namespace {

// Constants to support a layout of 2 pages, arranged vertically with a small
// gap between them.
constexpr gfx::RectF kVerticalLayout2Pages[] =;

// Some commonly used points in relation to `kVerticalLayout2Pages`.
constexpr gfx::PointF kTwoPageVerticalLayoutPointOutsidePages(10.0f, 0.0f);
constexpr gfx::PointF kTwoPageVerticalLayoutPoint1InsidePage0(10.0f, 10.0f);
constexpr gfx::PointF kTwoPageVerticalLayoutPoint2InsidePage0(15.0f, 15.0f);
constexpr gfx::PointF kTwoPageVerticalLayoutPoint3InsidePage0(20.0f, 15.0f);
constexpr gfx::PointF kTwoPageVerticalLayoutPoint1InsidePage1(10.0f, 75.0f);
constexpr gfx::PointF kTwoPageVerticalLayoutPoint2InsidePage1(15.0f, 80.0f);
constexpr gfx::PointF kTwoPageVerticalLayoutPoint3InsidePage1(20.0f, 80.0f);

// The inputs for a stroke that starts in first page, leaves the bounds of that
// page, but then moves back into the page results in one stroke with two
// segments.
constexpr gfx::PointF kTwoPageVerticalLayoutPageExitAndReentryPoints[] =;
// The two segments created by the inputs above.
constexpr gfx::PointF kTwoPageVerticalLayoutPageExitAndReentrySegment1[] =;
constexpr gfx::PointF kTwoPageVerticalLayoutPageExitAndReentrySegment2[] =;

class FakeClient : public PdfInkModule::Client {};

class PdfInkModuleTest : public testing::Test {};

TEST_F(PdfInkModuleTest, UnknownMessage) {}

// Verify that a set eraser message sets the annotation brush to an eraser.
TEST_F(PdfInkModuleTest, HandleSetAnnotationBrushMessageEraser) {}

// Verify that a set pen message sets the annotation brush to a pen, with the
// given params.
TEST_F(PdfInkModuleTest, HandleSetAnnotationBrushMessagePen) {}

// Verify that a set highlighter message sets the annotation brush to a
// highlighter, with the given params.
TEST_F(PdfInkModuleTest, HandleSetAnnotationBrushMessageHighlighter) {}

// Verify that brushes with zero color values can be set as the annotation
// brush.
TEST_F(PdfInkModuleTest, HandleSetAnnotationBrushMessageColorZero) {}

TEST_F(PdfInkModuleTest, HandleSetAnnotationModeMessage) {}

TEST_F(PdfInkModuleTest, MaybeSetCursorWhenTogglingAnnotationMode) {}

TEST_F(PdfInkModuleTest, MaybeSetCursorWhenChangingBrushes) {}

TEST_F(PdfInkModuleTest, MaybeSetCursorWhenChangingZoom) {}

class PdfInkModuleStrokeTest : public PdfInkModuleTest {};

TEST_F(PdfInkModuleStrokeTest, NoAnnotationIfNotEnabled) {}

TEST_F(PdfInkModuleStrokeTest, AnnotationIfEnabled) {}

TEST_F(PdfInkModuleStrokeTest, CanonicalAnnotationPoints) {}

TEST_F(PdfInkModuleStrokeTest, DrawRenderTransform) {}

TEST_F(PdfInkModuleStrokeTest, InvalidationsFromStroke) {}

TEST_F(PdfInkModuleStrokeTest, StrokeOutsidePage) {}

TEST_F(PdfInkModuleStrokeTest, StrokeInsidePages) {}

TEST_F(PdfInkModuleStrokeTest, StrokeAcrossPages) {}

TEST_F(PdfInkModuleStrokeTest, StrokePageExitAndReentry) {}

TEST_F(PdfInkModuleStrokeTest, StrokePageExitAndReentryWithQuickMoves) {}

TEST_F(PdfInkModuleStrokeTest, EraseStroke) {}

TEST_F(PdfInkModuleStrokeTest, EraseOnPageWithoutStrokes) {}

TEST_F(PdfInkModuleStrokeTest, EraseStrokeEntirelyOffPage) {}

TEST_F(PdfInkModuleStrokeTest, EraseStrokeErasesTwoStrokes) {}

TEST_F(PdfInkModuleStrokeTest, EraseStrokesAcrossTwoPages) {}

TEST_F(PdfInkModuleStrokeTest, EraseStrokePageExitAndReentry) {}

class PdfInkModuleUndoRedoTest : public PdfInkModuleStrokeTest {};

TEST_F(PdfInkModuleUndoRedoTest, UndoRedoEmpty) {}

TEST_F(PdfInkModuleUndoRedoTest, UndoRedoBasic) {}

TEST_F(PdfInkModuleUndoRedoTest, UndoRedoAnnotationModeDisabled) {}

TEST_F(PdfInkModuleUndoRedoTest, UndoRedoBetweenDraws) {}

TEST_F(PdfInkModuleUndoRedoTest, UndoRedoOnTwoPages) {}

}  // namespace

}  // namespace chrome_pdf