[PDF Ink Signatures] Move CreateInputBatch() to pdf_ink_test_helpers.h
This is a follow-up to a https://crrev.com/1362665, to move the helper function to create ink::StrokeInputBatch to pdf_ink_test_helper.h, so other tests can use it with PdfInkInputData. Change-Id: I4d9d78f0f698ca889fee735d60df03fa02b423a3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5906265 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Alan Screen <awscreen@chromium.org> Cr-Commit-Position: refs/heads/main@{#1363890}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e07d8c1faf
commit
c410524063
@ -14,7 +14,6 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/time/time.h"
|
||||
#include "pdf/pdf_ink_brush.h"
|
||||
#include "pdf/pdf_ink_conversions.h"
|
||||
#include "pdf/pdfium/pdfium_engine.h"
|
||||
#include "pdf/pdfium/pdfium_engine_exports.h"
|
||||
#include "pdf/pdfium/pdfium_page.h"
|
||||
@ -78,19 +77,6 @@ constexpr auto kBasicInputs = std::to_array<PdfInkInputData>({
|
||||
{{125.878f, 53.2194f}, base::Seconds(0.985401f)},
|
||||
});
|
||||
|
||||
std::optional<ink::StrokeInputBatch> CreateInputBatch(
|
||||
base::span<const PdfInkInputData> inputs) {
|
||||
ink::StrokeInputBatch input_batch;
|
||||
for (const auto& input : inputs) {
|
||||
auto result = input_batch.Append(CreateInkStrokeInput(
|
||||
ink::StrokeInput::ToolType::kMouse, input.position, input.time));
|
||||
if (!result.ok()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
return input_batch;
|
||||
}
|
||||
|
||||
base::FilePath GetReferenceFilePath(std::string_view test_filename) {
|
||||
return base::FilePath(FILE_PATH_LITERAL("pdfium_ink"))
|
||||
.AppendASCII(test_filename);
|
||||
@ -142,7 +128,8 @@ TEST_P(PDFiumInkWriterTest, Basic) {
|
||||
auto brush =
|
||||
std::make_unique<PdfInkBrush>(PdfInkBrush::Type::kPen, kBasicBrushParams);
|
||||
|
||||
std::optional<ink::StrokeInputBatch> inputs = CreateInputBatch(kBasicInputs);
|
||||
std::optional<ink::StrokeInputBatch> inputs =
|
||||
CreateInkInputBatch(kBasicInputs);
|
||||
ASSERT_TRUE(inputs.has_value());
|
||||
ink::Stroke stroke(brush->GetInkBrush(), inputs.value());
|
||||
ASSERT_TRUE(WriteStrokeToPage(page, stroke));
|
||||
|
@ -8,9 +8,23 @@
|
||||
#include <utility>
|
||||
|
||||
#include "base/values.h"
|
||||
#include "pdf/pdf_ink_conversions.h"
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
std::optional<ink::StrokeInputBatch> CreateInkInputBatch(
|
||||
base::span<const PdfInkInputData> inputs) {
|
||||
ink::StrokeInputBatch input_batch;
|
||||
for (const auto& input : inputs) {
|
||||
auto result = input_batch.Append(CreateInkStrokeInput(
|
||||
ink::StrokeInput::ToolType::kMouse, input.position, input.time));
|
||||
if (!result.ok()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
return input_batch;
|
||||
}
|
||||
|
||||
base::Value::Dict CreateSetAnnotationBrushMessageForTesting(
|
||||
const std::string& type,
|
||||
double size,
|
||||
|
@ -5,12 +5,15 @@
|
||||
#ifndef PDF_TEST_PDF_INK_TEST_HELPERS_H_
|
||||
#define PDF_TEST_PDF_INK_TEST_HELPERS_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/values.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "third_party/ink/src/ink/geometry/affine_transform.h"
|
||||
#include "third_party/ink/src/ink/strokes/input/stroke_input_batch.h"
|
||||
#include "ui/gfx/geometry/point_f.h"
|
||||
|
||||
namespace chrome_pdf {
|
||||
@ -30,6 +33,10 @@ struct PdfInkInputData {
|
||||
base::TimeDelta time;
|
||||
};
|
||||
|
||||
// Generates an ink::StrokeInputBatch. Treats `inputs` as mouse inputs.
|
||||
std::optional<ink::StrokeInputBatch> CreateInkInputBatch(
|
||||
base::span<const PdfInkInputData> inputs);
|
||||
|
||||
base::Value::Dict CreateSetAnnotationModeMessageForTesting(bool enable);
|
||||
|
||||
base::Value::Dict CreateSetAnnotationBrushMessageForTesting(
|
||||
|
Reference in New Issue
Block a user