Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 04dba37

Browse files
authored
[Impeller] added tests for matrices (#47754)
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 5f5288f commit 04dba37

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

ci/licenses_golden/excluded_files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
../../../flutter/impeller/fixtures
149149
../../../flutter/impeller/geometry/README.md
150150
../../../flutter/impeller/geometry/geometry_unittests.cc
151+
../../../flutter/impeller/geometry/matrix_unittests.cc
151152
../../../flutter/impeller/geometry/rect_unittests.cc
152153
../../../flutter/impeller/golden_tests/README.md
153154
../../../flutter/impeller/golden_tests_harvester/.dart_tool

impeller/geometry/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impeller_component("geometry_unittests") {
6161
testonly = true
6262
sources = [
6363
"geometry_unittests.cc",
64+
"matrix_unittests.cc",
6465
"rect_unittests.cc",
6566
]
6667

impeller/geometry/geometry_asserts.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ inline ::testing::AssertionResult MatrixNear(impeller::Matrix a,
3939
&& NumberNear(a.m[15], b.m[15]);
4040

4141
return equal ? ::testing::AssertionSuccess()
42-
: ::testing::AssertionFailure() << "Matrixes are not equal.";
42+
: ::testing::AssertionFailure()
43+
<< "Matrixes are not equal " << a << " " << b;
4344
}
4445

4546
inline ::testing::AssertionResult QuaternionNear(impeller::Quaternion a,

impeller/geometry/matrix_unittests.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "gtest/gtest.h"
6+
7+
#include "flutter/impeller/geometry/matrix.h"
8+
9+
#include "flutter/impeller/geometry/geometry_asserts.h"
10+
11+
namespace impeller {
12+
namespace testing {
13+
14+
TEST(MatrixTest, Multiply) {
15+
Matrix x(0.0, 0.0, 0.0, 1.0, //
16+
1.0, 0.0, 0.0, 1.0, //
17+
0.0, 1.0, 0.0, 1.0, //
18+
1.0, 1.0, 0.0, 1.0);
19+
Matrix translate = Matrix::MakeTranslation({10, 20, 0});
20+
Matrix result = translate * x;
21+
EXPECT_TRUE(MatrixNear(result, Matrix(10.0, 20.0, 0.0, 1.0, //
22+
11.0, 20.0, 0.0, 1.0, //
23+
10.0, 21.0, 0.0, 1.0, //
24+
11.0, 21.0, 0.0, 1.0)));
25+
}
26+
27+
} // namespace testing
28+
} // namespace impeller

0 commit comments

Comments
 (0)