5#include "flutter/flow/testing/mock_layer.h"
7#include "flutter/flow/testing/layer_test.h"
8#include "flutter/fml/macros.h"
9#include "flutter/testing/mock_canvas.h"
19 auto layer = std::make_shared<MockLayer>(
path,
DlPaint());
21 EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
22 "needs_painting\\(context\\)");
26 auto layer = std::make_shared<MockLayer>(
SkPath(),
DlPaint());
28 layer->Preroll(preroll_context());
29 EXPECT_EQ(layer->paint_bounds(),
SkPath().getBounds());
31 EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
32 "needs_painting\\(context\\)");
43 const SkRect device_cull_rect = combined_matrix.
mapRect(local_cull_rect);
44 const bool parent_has_platform_view =
true;
45 auto layer = std::make_shared<MockLayer>(
path,
paint);
47 preroll_context()->state_stack.set_preroll_delegate(device_cull_rect,
49 auto mutator = preroll_context()->state_stack.save();
50 mutator.transform(scale_matrix);
51 preroll_context()->has_platform_view = parent_has_platform_view;
52 layer->Preroll(preroll_context());
53 EXPECT_EQ(preroll_context()->has_platform_view,
false);
54 EXPECT_EQ(layer->paint_bounds(),
path.getBounds());
55 EXPECT_TRUE(layer->needs_painting(paint_context()));
56 EXPECT_EQ(layer->parent_mutators(), std::vector{Mutator(scale_matrix)});
57 EXPECT_EQ(layer->parent_matrix(), combined_matrix);
58 EXPECT_EQ(layer->parent_cull_rect(), local_cull_rect);
59 EXPECT_EQ(layer->parent_has_platform_view(), parent_has_platform_view);
61 layer->Paint(paint_context());
62 EXPECT_EQ(mock_canvas().draw_calls(),
68 auto layer = std::make_shared<MockLayer>(
SkPath(),
DlPaint());
69 layer->set_fake_has_platform_view(
true);
70 EXPECT_EQ(preroll_context()->has_platform_view,
false);
72 layer->Preroll(preroll_context());
73 EXPECT_EQ(preroll_context()->has_platform_view,
true);
77 auto layer = std::make_shared<MockLayer>(
SkPath(),
DlPaint());
78 layer->set_fake_has_platform_view(
true);
79 EXPECT_EQ(preroll_context()->has_platform_view,
false);
81 layer->Preroll(preroll_context());
82 EXPECT_EQ(preroll_context()->has_platform_view,
true);
87 PrerollContext* context = preroll_context();
89 auto mock1 = std::make_shared<MockLayer>(
path1);
90 mock1->Preroll(context);
91 EXPECT_EQ(context->renderable_state_flags, 0);
94 mock2->Preroll(context);
95 EXPECT_EQ(context->renderable_state_flags,
100 auto mock_layer = std::make_shared<MockLayer>(
SkPath());
102 EXPECT_EQ(mock_layer->parent_has_platform_view(),
false);
103 mock_layer->set_parent_has_platform_view(
true);
104 EXPECT_EQ(mock_layer->parent_has_platform_view(),
true);
106 EXPECT_EQ(mock_layer->parent_has_texture_layer(),
false);
107 mock_layer->set_parent_has_texture_layer(
true);
108 EXPECT_EQ(mock_layer->parent_has_texture_layer(),
true);
110 EXPECT_EQ(mock_layer->fake_has_platform_view(),
false);
111 mock_layer->set_fake_has_platform_view(
true);
112 EXPECT_EQ(mock_layer->fake_has_platform_view(),
true);
114 EXPECT_EQ(mock_layer->fake_reads_surface(),
false);
115 mock_layer->set_fake_reads_surface(
true);
116 EXPECT_EQ(mock_layer->fake_reads_surface(),
true);
118 EXPECT_EQ(mock_layer->fake_opacity_compatible(),
false);
119 mock_layer->set_fake_opacity_compatible(
true);
120 EXPECT_EQ(mock_layer->fake_opacity_compatible(),
true);
122 EXPECT_EQ(mock_layer->fake_has_texture_layer(),
false);
123 mock_layer->set_fake_has_texture_layer(
true);
124 EXPECT_EQ(mock_layer->fake_has_texture_layer(),
true);
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
static constexpr int kCallerCanApplyOpacity
static std::shared_ptr< MockLayer > MakeOpacityCompatible(const SkPath &path)
TEST_F(DisplayListTest, Defaults)
LayerTestBase<::testing::Test > LayerTest
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
static constexpr SkRect MakeWH(float w, float h)
static constexpr DlColor kBlue()
#define EXPECT_TRUE(handle)