[Impeller] added tests for matrices (flutter/engine#47754)

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
gaaclarke
2023-11-07 11:39:40 -08:00
committed by GitHub
parent 0e3bce76a0
commit aab5af3615
4 changed files with 32 additions and 1 deletions

View File

@@ -148,6 +148,7 @@
../../../flutter/impeller/fixtures
../../../flutter/impeller/geometry/README.md
../../../flutter/impeller/geometry/geometry_unittests.cc
../../../flutter/impeller/geometry/matrix_unittests.cc
../../../flutter/impeller/geometry/rect_unittests.cc
../../../flutter/impeller/golden_tests/README.md
../../../flutter/impeller/golden_tests_harvester/.dart_tool

View File

@@ -61,6 +61,7 @@ impeller_component("geometry_unittests") {
testonly = true
sources = [
"geometry_unittests.cc",
"matrix_unittests.cc",
"rect_unittests.cc",
]

View File

@@ -39,7 +39,8 @@ inline ::testing::AssertionResult MatrixNear(impeller::Matrix a,
&& NumberNear(a.m[15], b.m[15]);
return equal ? ::testing::AssertionSuccess()
: ::testing::AssertionFailure() << "Matrixes are not equal.";
: ::testing::AssertionFailure()
<< "Matrixes are not equal " << a << " " << b;
}
inline ::testing::AssertionResult QuaternionNear(impeller::Quaternion a,

View File

@@ -0,0 +1,28 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gtest/gtest.h"
#include "flutter/impeller/geometry/matrix.h"
#include "flutter/impeller/geometry/geometry_asserts.h"
namespace impeller {
namespace testing {
TEST(MatrixTest, Multiply) {
Matrix x(0.0, 0.0, 0.0, 1.0, //
1.0, 0.0, 0.0, 1.0, //
0.0, 1.0, 0.0, 1.0, //
1.0, 1.0, 0.0, 1.0);
Matrix translate = Matrix::MakeTranslation({10, 20, 0});
Matrix result = translate * x;
EXPECT_TRUE(MatrixNear(result, Matrix(10.0, 20.0, 0.0, 1.0, //
11.0, 20.0, 0.0, 1.0, //
10.0, 21.0, 0.0, 1.0, //
11.0, 21.0, 0.0, 1.0)));
}
} // namespace testing
} // namespace impeller