Flutter Engine
 
Loading...
Searching...
No Matches
embedded_view_params_unittests.cc
Go to the documentation of this file.
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
7#include "gtest/gtest.h"
8
9namespace flutter {
10namespace testing {
11
12TEST(EmbeddedViewParams, GetBoundingRectAfterMutationsWithNoMutations) {
13 MutatorsStack stack;
14 DlMatrix matrix;
15
16 EmbeddedViewParams params(matrix, DlSize(1, 1), stack);
17 EXPECT_EQ(params.finalBoundingRect(), DlRect::MakeXYWH(0, 0, 1, 1));
18}
19
20TEST(EmbeddedViewParams, GetBoundingRectAfterMutationsWithScale) {
21 MutatorsStack stack;
22 DlMatrix matrix = DlMatrix::MakeScale({2, 2, 1});
23 stack.PushTransform(matrix);
24
25 EmbeddedViewParams params(matrix, DlSize(1, 1), stack);
26 EXPECT_EQ(params.finalBoundingRect(), DlRect::MakeXYWH(0, 0, 2, 2));
27}
28
29TEST(EmbeddedViewParams, GetBoundingRectAfterMutationsWithTranslate) {
30 MutatorsStack stack;
31 DlMatrix matrix = DlMatrix::MakeTranslation({1, 1});
32 stack.PushTransform(matrix);
33
34 EmbeddedViewParams params(matrix, DlSize(1, 1), stack);
35 EXPECT_EQ(params.finalBoundingRect(), DlRect::MakeXYWH(1, 1, 1, 1));
36}
37
38TEST(EmbeddedViewParams, GetBoundingRectAfterMutationsWithRotation90) {
39 MutatorsStack stack;
41 stack.PushTransform(matrix);
42
43 EmbeddedViewParams params(matrix, DlSize(1, 1), stack);
44 EXPECT_EQ(params.finalBoundingRect(), DlRect::MakeXYWH(-1, 0, 1, 1));
45}
46
47TEST(EmbeddedViewParams, GetBoundingRectAfterMutationsWithRotation45) {
48 MutatorsStack stack;
50 stack.PushTransform(matrix);
51
52 EmbeddedViewParams params(matrix, DlSize(1, 1), stack);
53 EXPECT_EQ(params.finalBoundingRect(),
54 DlRect::MakeXYWH(-sqrt(2) / 2, 0, sqrt(2), sqrt(2)));
55}
56
58 GetBoundingRectAfterMutationsWithTranslateScaleAndRotation) {
59 DlMatrix matrix = DlMatrix::MakeTranslation({2, 2}) *
60 DlMatrix::MakeScale({3, 3, 1}) *
62
63 MutatorsStack stack;
64 stack.PushTransform(matrix);
65
66 EmbeddedViewParams params(matrix, DlSize(1, 1), stack);
67 EXPECT_EQ(params.finalBoundingRect(), DlRect::MakeXYWH(-1, 2, 3, 3));
68}
69
70} // namespace testing
71} // namespace flutter
void PushTransform(const DlMatrix &matrix)
const EmbeddedViewParams * params
TEST(NativeAssetsManagerTest, NoAvailableAssets)
impeller::Degrees DlDegrees
impeller::Size DlSize
A 4x4 matrix using column-major storage.
Definition matrix.h:37
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition matrix.h:95
static Matrix MakeRotationZ(Radians r)
Definition matrix.h:223
static constexpr Matrix MakeScale(const Vector3 &s)
Definition matrix.h:104
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
Definition rect.h:136