Flutter Engine
 
Loading...
Searching...
No Matches
flutter::testing::MockLayer Class Reference

#include <mock_layer.h>

Inheritance diagram for flutter::testing::MockLayer:
flutter::Layer flutter::testing::MockCacheableLayer

Public Member Functions

 MockLayer (const DlPath &path, DlPaint paint=DlPaint())
 
void Preroll (PrerollContext *context) override
 
void Paint (PaintContext &context) const override
 
const MutatorsStackparent_mutators ()
 
const DlMatrixparent_matrix ()
 
const DlRectparent_cull_rect ()
 
bool IsReplacing (DiffContext *context, const Layer *layer) const override
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
const MockLayeras_mock_layer () const override
 
bool parent_has_platform_view ()
 
bool parent_has_texture_layer ()
 
bool fake_has_platform_view ()
 
bool fake_reads_surface ()
 
bool fake_opacity_compatible ()
 
bool fake_has_texture_layer ()
 
MockLayerset_parent_has_platform_view (bool flag)
 
MockLayerset_parent_has_texture_layer (bool flag)
 
MockLayerset_fake_has_platform_view (bool flag)
 
MockLayerset_fake_reads_surface (bool flag)
 
MockLayerset_fake_opacity_compatible (bool flag)
 
MockLayerset_fake_has_texture_layer (bool flag)
 
void set_expected_paint_matrix (const DlMatrix &matrix)
 
- Public Member Functions inherited from flutter::Layer
 Layer ()
 
virtual ~Layer ()
 
void AssignOldLayer (Layer *old_layer)
 
virtual void PreservePaintRegion (DiffContext *context)
 
virtual void PaintChildren (PaintContext &context) const
 
bool subtree_has_platform_view () const
 
void set_subtree_has_platform_view (bool value)
 
const DlRectpaint_bounds () const
 
void set_paint_bounds (const DlRect &paint_bounds)
 
bool is_empty () const
 
bool needs_painting (PaintContext &context) const
 
uint64_t original_layer_id () const
 
uint64_t unique_id () const
 
virtual RasterCacheKeyID caching_key_id () const
 
virtual const ContainerLayeras_container_layer () const
 
virtual const DisplayListLayeras_display_list_layer () const
 
virtual const TextureLayeras_texture_layer () const
 
virtual const PerformanceOverlayLayeras_performance_overlay_layer () const
 

Static Public Member Functions

static std::shared_ptr< MockLayerMake (const DlPath &path, DlPaint paint=DlPaint())
 
static std::shared_ptr< MockLayerMakeOpacityCompatible (const DlPath &path)
 

Additional Inherited Members

- Static Public Attributes inherited from flutter::Layer
static constexpr int kSaveLayerRenderFlags
 
static constexpr int kRasterCacheRenderFlags
 

Detailed Description

Definition at line 26 of file mock_layer.h.

Constructor & Destructor Documentation

◆ MockLayer()

flutter::testing::MockLayer::MockLayer ( const DlPath path,
DlPaint  paint = DlPaint() 
)
explicit

Definition at line 17 of file mock_layer.cc.

18 : fake_paint_path_(path), fake_paint_(std::move(paint)) {}
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
Definition switch_defs.h:52

Member Function Documentation

◆ as_mock_layer()

const MockLayer * flutter::testing::MockLayer::as_mock_layer ( ) const
inlineoverridevirtual

Reimplemented from flutter::Layer.

Definition at line 50 of file mock_layer.h.

50{ return this; }

◆ Diff()

void flutter::testing::MockLayer::Diff ( DiffContext context,
const Layer old_layer 
)
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 29 of file mock_layer.cc.

29 {
30 DiffContext::AutoSubtreeRestore subtree(context);
31 context->AddLayerBounds(fake_paint_path_.GetBounds());
32 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
33}
DlRect GetBounds() const override
Definition dl_path.cc:245

References flutter::DiffContext::AddLayerBounds(), flutter::DiffContext::CurrentSubtreeRegion(), flutter::DlPath::GetBounds(), and flutter::DiffContext::SetLayerPaintRegion().

◆ fake_has_platform_view()

bool flutter::testing::MockLayer::fake_has_platform_view ( )
inline

Definition at line 60 of file mock_layer.h.

60{ return mock_flags_ & kFakeHasPlatformView; }

Referenced by Preroll().

◆ fake_has_texture_layer()

bool flutter::testing::MockLayer::fake_has_texture_layer ( )
inline

Definition at line 68 of file mock_layer.h.

68{ return mock_flags_ & kFakeHasTextureLayer; }

Referenced by Preroll().

◆ fake_opacity_compatible()

bool flutter::testing::MockLayer::fake_opacity_compatible ( )
inline

Definition at line 64 of file mock_layer.h.

64 {
65 return mock_flags_ & kFakeOpacityCompatible;
66 }

Referenced by Preroll().

◆ fake_reads_surface()

bool flutter::testing::MockLayer::fake_reads_surface ( )
inline

Definition at line 62 of file mock_layer.h.

62{ return mock_flags_ & kFakeReadsSurface; }

Referenced by Preroll().

◆ IsReplacing()

bool flutter::testing::MockLayer::IsReplacing ( DiffContext context,
const Layer layer 
) const
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 20 of file mock_layer.cc.

20 {
21 // Similar to PictureLayer, only return true for identical mock layers;
22 // That way ContainerLayer::DiffChildren can properly detect mock layer
23 // insertion
24 auto mock_layer = layer->as_mock_layer();
25 return mock_layer && mock_layer->fake_paint_ == fake_paint_ &&
26 mock_layer->fake_paint_path_ == fake_paint_path_;
27}

References flutter::Layer::as_mock_layer().

◆ Make()

static std::shared_ptr< MockLayer > flutter::testing::MockLayer::Make ( const DlPath path,
DlPaint  paint = DlPaint() 
)
inlinestatic

Definition at line 30 of file mock_layer.h.

31 {
32 return std::make_shared<MockLayer>(path, std::move(paint));
33 }

References flutter::path.

Referenced by flutter::testing::TEST(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ MakeOpacityCompatible()

static std::shared_ptr< MockLayer > flutter::testing::MockLayer::MakeOpacityCompatible ( const DlPath path)
inlinestatic

Definition at line 35 of file mock_layer.h.

35 {
36 auto mock_layer = std::make_shared<MockLayer>(path, DlPaint());
37 mock_layer->set_fake_opacity_compatible(true);
38 return mock_layer;
39 }
flutter::DlPaint DlPaint

References flutter::path.

Referenced by flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

◆ Paint()

void flutter::testing::MockLayer::Paint ( PaintContext context) const
overridevirtual

Implements flutter::Layer.

Definition at line 54 of file mock_layer.cc.

54 {
55 FML_DCHECK(needs_painting(context));
56
57 if (expected_paint_matrix_.has_value()) {
58 EXPECT_EQ(context.canvas->GetMatrix(), expected_paint_matrix_.value());
59 }
60
61 DlPaint paint = fake_paint_;
62 context.state_stack.fill(paint);
63 context.canvas->DrawPath(fake_paint_path_, paint);
64}
bool needs_painting(PaintContext &context) const
Definition layer.h:218
#define FML_DCHECK(condition)
Definition logging.h:122

References flutter::PaintContext::canvas, flutter::DlCanvas::DrawPath(), flutter::LayerStateStack::fill(), FML_DCHECK, flutter::DlCanvas::GetMatrix(), flutter::Layer::needs_painting(), and flutter::PaintContext::state_stack.

◆ parent_cull_rect()

const DlRect & flutter::testing::MockLayer::parent_cull_rect ( )
inline

Definition at line 46 of file mock_layer.h.

46{ return parent_cull_rect_; }

◆ parent_has_platform_view()

bool flutter::testing::MockLayer::parent_has_platform_view ( )
inline

Definition at line 52 of file mock_layer.h.

52 {
53 return mock_flags_ & kParentHasPlatformView;
54 }

◆ parent_has_texture_layer()

bool flutter::testing::MockLayer::parent_has_texture_layer ( )
inline

Definition at line 56 of file mock_layer.h.

56 {
57 return mock_flags_ & kParentHasTextureLayer;
58 }

◆ parent_matrix()

const DlMatrix & flutter::testing::MockLayer::parent_matrix ( )
inline

Definition at line 45 of file mock_layer.h.

45{ return parent_matrix_; }

◆ parent_mutators()

const MutatorsStack & flutter::testing::MockLayer::parent_mutators ( )
inline

Definition at line 44 of file mock_layer.h.

44{ return parent_mutators_; }

◆ Preroll()

void flutter::testing::MockLayer::Preroll ( PrerollContext context)
overridevirtual

Implements flutter::Layer.

Definition at line 35 of file mock_layer.cc.

35 {
36 context->state_stack.fill(&parent_mutators_);
37 parent_matrix_ = context->state_stack.matrix();
38 parent_cull_rect_ = context->state_stack.local_cull_rect();
39
40 set_parent_has_platform_view(context->has_platform_view);
41 set_parent_has_texture_layer(context->has_texture_layer);
42
43 context->has_platform_view = fake_has_platform_view();
44 context->has_texture_layer = fake_has_texture_layer();
45 set_paint_bounds(fake_paint_path_.GetBounds());
46 if (fake_reads_surface()) {
47 context->surface_needs_readback = true;
48 }
50 context->renderable_state_flags = LayerStateStack::kCallerCanApplyOpacity;
51 }
52}
void set_paint_bounds(const DlRect &paint_bounds)
Definition layer.h:209
static constexpr int kCallerCanApplyOpacity
MockLayer & set_parent_has_platform_view(bool flag)
Definition mock_layer.h:70
MockLayer & set_parent_has_texture_layer(bool flag)
Definition mock_layer.h:76

References fake_has_platform_view(), fake_has_texture_layer(), fake_opacity_compatible(), fake_reads_surface(), flutter::LayerStateStack::fill(), flutter::DlPath::GetBounds(), flutter::PrerollContext::has_platform_view, flutter::PrerollContext::has_texture_layer, flutter::LayerStateStack::kCallerCanApplyOpacity, flutter::LayerStateStack::local_cull_rect(), flutter::LayerStateStack::matrix(), flutter::PrerollContext::renderable_state_flags, flutter::Layer::set_paint_bounds(), set_parent_has_platform_view(), set_parent_has_texture_layer(), flutter::PrerollContext::state_stack, and flutter::PrerollContext::surface_needs_readback.

Referenced by flutter::testing::MockCacheableLayer::Preroll().

◆ set_expected_paint_matrix()

void flutter::testing::MockLayer::set_expected_paint_matrix ( const DlMatrix matrix)
inline

Definition at line 106 of file mock_layer.h.

106 {
107 expected_paint_matrix_ = matrix;
108 }

◆ set_fake_has_platform_view()

MockLayer & flutter::testing::MockLayer::set_fake_has_platform_view ( bool  flag)
inline

Definition at line 82 of file mock_layer.h.

82 {
83 flag ? (mock_flags_ |= kFakeHasPlatformView)
84 : (mock_flags_ &= ~(kFakeHasPlatformView));
85 return *this;
86 }

◆ set_fake_has_texture_layer()

MockLayer & flutter::testing::MockLayer::set_fake_has_texture_layer ( bool  flag)
inline

Definition at line 100 of file mock_layer.h.

100 {
101 flag ? (mock_flags_ |= kFakeHasTextureLayer)
102 : (mock_flags_ &= ~(kFakeHasTextureLayer));
103 return *this;
104 }

◆ set_fake_opacity_compatible()

MockLayer & flutter::testing::MockLayer::set_fake_opacity_compatible ( bool  flag)
inline

Definition at line 94 of file mock_layer.h.

94 {
95 flag ? (mock_flags_ |= kFakeOpacityCompatible)
96 : (mock_flags_ &= ~(kFakeOpacityCompatible));
97 return *this;
98 }

◆ set_fake_reads_surface()

MockLayer & flutter::testing::MockLayer::set_fake_reads_surface ( bool  flag)
inline

Definition at line 88 of file mock_layer.h.

88 {
89 flag ? (mock_flags_ |= kFakeReadsSurface)
90 : (mock_flags_ &= ~(kFakeReadsSurface));
91 return *this;
92 }

◆ set_parent_has_platform_view()

MockLayer & flutter::testing::MockLayer::set_parent_has_platform_view ( bool  flag)
inline

Definition at line 70 of file mock_layer.h.

70 {
71 flag ? (mock_flags_ |= kParentHasPlatformView)
72 : (mock_flags_ &= ~(kParentHasPlatformView));
73 return *this;
74 }

Referenced by Preroll().

◆ set_parent_has_texture_layer()

MockLayer & flutter::testing::MockLayer::set_parent_has_texture_layer ( bool  flag)
inline

Definition at line 76 of file mock_layer.h.

76 {
77 flag ? (mock_flags_ |= kParentHasTextureLayer)
78 : (mock_flags_ &= ~(kParentHasTextureLayer));
79 return *this;
80 }

Referenced by Preroll().


The documentation for this class was generated from the following files: