chromium/ui/gfx/geometry/transform_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/354829279): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "ui/gfx/geometry/transform.h"

#include <stddef.h>

#include <algorithm>
#include <limits>
#include <numbers>
#include <optional>
#include <ostream>

#include "base/numerics/angle_conversions.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/axis_transform2d.h"
#include "ui/gfx/geometry/box_f.h"
#include "ui/gfx/geometry/decomposed_transform.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/test/geometry_util.h"
#include "ui/gfx/geometry/vector3d_f.h"

namespace gfx {

namespace {

#define STATIC_ROW0_EQ(a, b, c, d, transform)

#define STATIC_ROW1_EQ(a, b, c, d, transform)

#define STATIC_ROW2_EQ(a, b, c, d, transform)

#define STATIC_ROW3_EQ(a, b, c, d, transform)

#define EXPECT_ROW0_EQ(a, b, c, d, transform)

#define EXPECT_ROW1_EQ(a, b, c, d, transform)

#define EXPECT_ROW2_EQ(a, b, c, d, transform)

#define EXPECT_ROW3_EQ(a, b, c, d, transform)

// Checking float values for equality close to zero is not robust using
// EXPECT_FLOAT_EQ (see gtest documentation). So, to verify rotation matrices,
// we must use a looser absolute error threshold in some places.
#define EXPECT_ROW0_NEAR(a, b, c, d, transform, errorThreshold)

#define EXPECT_ROW1_NEAR(a, b, c, d, transform, errorThreshold)

#define EXPECT_ROW2_NEAR(a, b, c, d, transform, errorThreshold)

bool PointsAreNearlyEqual(const PointF& lhs, const PointF& rhs) {}

bool PointsAreNearlyEqual(const Point3F& lhs, const Point3F& rhs) {}

bool MatricesAreNearlyEqual(const Transform& lhs, const Transform& rhs) {}

Transform GetTestMatrix1() {}

Transform GetTestMatrix2() {}

Transform ApproxIdentityMatrix(double error) {}

constexpr double kErrorThreshold =;

// This test is to make it easier to understand the order of operations.
TEST(XFormTest, PrePostOperations) {}

// This test mostly overlaps with other tests, but similar to the above test,
// this test may help understand how accumulated transforms are equivalent to
// multiple mapping operations e.g. MapPoint().
TEST(XFormTest, BasicOperations) {}

TEST(XFormTest, Equality) {}

TEST(XFormTest, ConcatTranslate) {}

TEST(XFormTest, ConcatScale) {}

TEST(XFormTest, ConcatRotate) {}

TEST(XFormTest, ConcatSelf) {}

TEST(XFormTest, Translate) {}

TEST(XFormTest, Scale) {}

TEST(XFormTest, SetRotate) {}

// 2D tests
TEST(XFormTest, ConcatTranslate2D) {}

TEST(XFormTest, ConcatScale2D) {}

TEST(XFormTest, ConcatRotate2D) {}

TEST(XFormTest, SetTranslate2D) {}

TEST(XFormTest, SetScale2D) {}

TEST(XFormTest, SetRotate2D) {}

TEST(XFormTest, MapPointWithExtremePerspective) {}

TEST(XFormTest, BlendTranslate) {}

TEST(XFormTest, BlendRotate) {}

TEST(XFormTest, CanBlend180DegreeRotation) {}

TEST(XFormTest, BlendScale) {}

TEST(XFormTest, BlendSkew) {}

TEST(XFormTest, ExtrapolateSkew) {}

TEST(XFormTest, BlendPerspective) {}

TEST(XFormTest, BlendIdentity) {}

TEST(XFormTest, CannotBlendSingularMatrix) {}

TEST(XFormTest, VerifyBlendForTranslation) {}

TEST(XFormTest, VerifyBlendForScale) {}

TEST(XFormTest, VerifyBlendForSkew) {}

TEST(XFormTest, BlendForRotationAboutX) {}

TEST(XFormTest, BlendForRotationAboutY) {}

TEST(XFormTest, BlendForRotationAboutZ) {}

TEST(XFormTest, BlendForCompositeTransform) {}

TEST(XFormTest, Blend2dXFlip) {}

TEST(XFormTest, Blend2dRotationDirection) {}

gfx::DecomposedTransform GetRotationDecomp(double x,
                                           double y,
                                           double z,
                                           double w) {}

const double kCos30deg =;
const double kSin30deg =;

TEST(XFormTest, QuaternionFromRotationMatrix) {}

TEST(XFormTest, QuaternionToRotationMatrixTest) {}

TEST(XFormTest, QuaternionInterpolation) {}

TEST(XFormTest, ComposeIdentity) {}

TEST(XFormTest, DecomposeTranslateRotateScale) {}

TEST(XFormTest, DecomposeScaleTransform) {}

TEST(XFormTest, Decompose2d) {}

double ComputeDecompRecompError(const Transform& transform) {}

TEST(XFormTest, DecomposeAndCompose) {}

TEST(XFormTest, IsIdentityOr2dTranslation) {}

TEST(XFormTest, IntegerTranslation) {}

TEST(XFormTest, Integer2dTranslation) {}

TEST(XFormTest, Inverse) {}

TEST(XFormTest, verifyBackfaceVisibilityBasicCases) {}

TEST(XFormTest, verifyBackfaceVisibilityForPerspective) {}

TEST(XFormTest, verifyDefaultConstructorCreatesIdentityMatrix) {}

TEST(XFormTest, verifyCopyConstructor) {}

// ColMajor() and RowMajor() are tested in GetTestMatrix1() and
// GetTestTransform2().

TEST(XFormTest, GetColMajor) {}

TEST(XFormTest, Affine) {}

TEST(XFormTest, MakeTranslation) {}

TEST(XFormTest, MakeScale) {}

TEST(XFormTest, MakeRotation) {}

TEST(XFormTest, ColMajorF) {}

TEST(XFormTest, FromQuaternion) {}

TEST(XFormTest, verifyAssignmentOperator) {}

TEST(XFormTest, verifyEqualsBooleanOperator) {}

TEST(XFormTest, verifyMultiplyOperator) {}

TEST(XFormTest, verifyMultiplyAndAssignOperator) {}

TEST(XFormTest, PreConcat) {}

TEST(XFormTest, verifyMakeIdentiy) {}

TEST(XFormTest, verifyTranslate) {}

TEST(XFormTest, verifyPostTranslate) {}

TEST(XFormTest, verifyTranslate3d) {}

TEST(XFormTest, verifyPostTranslate3d) {}

TEST(XFormTest, verifyScale) {}

TEST(XFormTest, verifyScale3d) {}

TEST(XFormTest, verifyPostScale3d) {}

TEST(XFormTest, Rotate) {}

TEST(XFormTest, RotateAboutXAxis) {}

TEST(XFormTest, RotateAboutYAxis) {}

TEST(XFormTest, RotateAboutZAxis) {}

TEST(XFormTest, RotateAboutForAlignedAxes) {}

TEST(XFormTest, verifyRotateAboutForArbitraryAxis) {}

TEST(XFormTest, verifyRotateAboutForDegenerateAxis) {}

TEST(XFormTest, verifySkew) {}

TEST(XFormTest, verifyPerspectiveDepth) {}

TEST(XFormTest, verifyHasPerspective) {}

TEST(XFormTest, verifyIsInvertible) {}

TEST(XFormTest, verifyIsIdentity) {}

TEST(XFormTest, verifyIsIdentityOrTranslation) {}

TEST(XFormTest, ApproximatelyIdentityOrTranslation) {}

TEST(XFormTest, RoundToIdentityOrIntegerTranslation) {}

TEST(XFormTest, verifyIsScaleOrTranslation) {}

TEST(XFormTest, To2dScale) {}

TEST(XFormTest, Flatten) {}

TEST(XFormTest, IsFlat) {}

TEST(XFormTest, Preserves2dAffine) {}

// Another implementation of Preserves2dAxisAlignment that isn't as fast,
// good for testing the faster implementation.
static bool EmpiricallyPreserves2dAxisAlignment(const Transform& transform) {}

TEST(XFormTest, Preserves2dAxisAlignment) {}

TEST(XFormTest, To2dTranslation) {}

TEST(XFormTest, To3dTranslation) {}

TEST(XFormTest, MapRect) {}

TEST(XFormTest, MapIntRect) {}

TEST(XFormTest, TransformRectReverse) {}

TEST(XFormTest, InverseMapIntRect) {}

TEST(XFormTest, MapQuad) {}

TEST(XFormTest, MapBox) {}

TEST(XFormTest, Round2dTranslationComponents) {}

TEST(XFormTest, BackFaceVisiblilityTolerance) {}

TEST(XFormTest, TransformVector4) {}

TEST(XFormTest, Make90NRotation) {}

TEST(XFormTest, Rotate90NDegrees) {}

TEST(XFormTest, MapPoint) {}

TEST(XFormTest, InverseMapPoint) {}

TEST(XFormTest, MapVector) {}

TEST(XFormTest, PreConcatAxisTransform2d) {}

TEST(XFormTest, PostConcatAxisTransform2d) {}

TEST(XFormTest, ClampOutput) {}

constexpr float kProjectionClampedBigNumber =;

// This test also demonstrates the relationship between ProjectPoint() and
// MapPoint().
TEST(XFormTest, ProjectPoint) {}

TEST(XFormTest, ProjectQuad) {}

TEST(XFormTest, ToString) {}

TEST(XFormTest, Is2dProportionalUpscaleAndOr2dTranslation) {}

TEST(XFormTest, Creates3d) {}

TEST(XFormTest, ApplyTransformOrigin) {}

TEST(XFormTest, Zoom) {}

TEST(XFormTest, ApproximatelyEqual) {}

}  // namespace

}  // namespace gfx