0

[PDF Ink Signatures] Make test support functions broadly accessible

Move some test support functions out of pdf_ink_transform_unittest.cc
and into pdf/ink/ink_affine_transform.h, so that they can be used by
other test files.

Low-Coverage-Reason: TRIVIAL_CHANGE Function moves, and the uncovered function is only executed for test failures
Change-Id: If5affff3fcd58b0df2893a4c316e8f50feb9de4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5632106
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1315603}
This commit is contained in:
Alan Screen
2024-06-17 00:56:49 +00:00
committed by Chromium LUCI CQ
parent dc49d33ec3
commit 699dcda066
4 changed files with 30 additions and 12 deletions

@ -23,6 +23,7 @@ source_set("interface") {
visibility = [ "//pdf/*" ]
sources = [
"ink_affine_transform.cc",
"ink_affine_transform.h",
"ink_brush.h",
"ink_brush_behavior.h",

@ -0,0 +1,22 @@
// 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/ink/ink_affine_transform.h"
#include <ostream>
namespace chrome_pdf {
bool operator==(const InkAffineTransform& lhs, const InkAffineTransform& rhs) {
return lhs.a == rhs.a && lhs.b == rhs.b && lhs.c == rhs.c && lhs.d == rhs.d &&
lhs.e == rhs.e && lhs.f == rhs.f;
}
void PrintTo(const InkAffineTransform& transform, std::ostream* os) {
*os << "[ " << transform.a << ", " << transform.b << ", " << transform.c
<< ", " << transform.d << ", " << transform.e << ", " << transform.f
<< " ]";
}
} // namespace chrome_pdf

@ -5,6 +5,8 @@
#ifndef PDF_INK_INK_AFFINE_TRANSFORM_H_
#define PDF_INK_INK_AFFINE_TRANSFORM_H_
#include <iosfwd>
namespace chrome_pdf {
// NOTE: This is the equivalent to the following 3x3 matrix:
@ -23,6 +25,11 @@ struct InkAffineTransform {
float f;
};
bool operator==(const InkAffineTransform& lhs, const InkAffineTransform& rhs);
// Supports pretty-printing transforms for test failures.
void PrintTo(const InkAffineTransform& transform, std::ostream* os);
} // namespace chrome_pdf
#endif // PDF_INK_INK_AFFINE_TRANSFORM_H_

@ -72,18 +72,6 @@ struct InputOutputPair {
} // namespace
bool operator==(const InkAffineTransform& lhs, const InkAffineTransform& rhs) {
return lhs.a == rhs.a && lhs.b == rhs.b && lhs.c == rhs.c && lhs.d == rhs.d &&
lhs.e == rhs.e && lhs.f == rhs.f;
}
// Supports pretty-printing transforms for test failures.
void PrintTo(const InkAffineTransform& transform, std::ostream* os) {
*os << base::StringPrintf("[ %f, %f, %f, %f, %f, %f ]", transform.a,
transform.b, transform.c, transform.d, transform.e,
transform.f);
}
TEST(PdfInkTransformTest, EventPositionToCanonicalPositionIdentity) {
constexpr auto kInputsAndOutputs = std::to_array<InputOutputPair>({
InputOutputPair{kInputPositionTopLeft, kCanonicalPositionTopLeft},