Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
mocks.h
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
5#ifndef FLUTTER_LIB_UI_PAINTING_TESTING_MOCKS_H_
6#define FLUTTER_LIB_UI_PAINTING_TESTING_MOCKS_H_
7
11#include "gmock/gmock.h"
12#if IMPELLER_SUPPORTS_RENDERING
13#include "impeller/core/texture.h" // nogncheck
15#endif
16
17namespace flutter {
18namespace testing {
19
21 public:
23 virtual ~MockTextureRegistry() = default;
24};
25
27 public:
29 : weak_factory_(this),
30 texture_registry_(std::make_shared<MockTextureRegistry>()) {}
31 virtual ~MockSnapshotDelegate() = default;
32
33 MOCK_METHOD(std::unique_ptr<GpuImageResult>,
35 (sk_sp<DisplayList>, const SkImageInfo&),
36 (override));
37 MOCK_METHOD(std::shared_ptr<TextureRegistry>,
39 (),
40 (override));
41 MOCK_METHOD(GrDirectContext*, GetGrContext, (), (override));
44 (sk_sp<DisplayList>,
45 DlISize,
46 std::function<void(sk_sp<SkImage>)>,
47 SnapshotPixelFormat target_format),
48 (override));
49 MOCK_METHOD(sk_sp<SkImage>,
51 (sk_sp<DisplayList>, DlISize, SnapshotPixelFormat),
52 (override));
55 (sk_sp<DisplayList>,
56 DlISize,
57 std::function<void(std::shared_ptr<impeller::Texture>)>,
58 SnapshotPixelFormat target_format),
59 (override));
60 MOCK_METHOD(std::shared_ptr<impeller::Texture>,
62 (sk_sp<DisplayList>, DlISize, SnapshotPixelFormat),
63 (override));
64 MOCK_METHOD(sk_sp<SkImage>,
66 (sk_sp<SkImage>),
67 (override));
68 MOCK_METHOD(sk_sp<SkImage>,
70 (sk_sp<SkImage>, SnapshotPixelFormat),
71 (override));
72 MOCK_METHOD(std::shared_ptr<impeller::Texture>,
74 (sk_sp<SkImage>, SnapshotPixelFormat),
75 (override));
78 (const std::shared_ptr<impeller::RuntimeStage>&),
79 (override));
80 MOCK_METHOD(bool, MakeRenderContextCurrent, (), (override));
81
83 return weak_factory_.GetWeakPtr();
84 }
85
86 std::shared_ptr<MockTextureRegistry> GetMockTextureRegistry() {
87 return texture_registry_;
88 }
89
90 private:
92 std::shared_ptr<MockTextureRegistry> texture_registry_;
93};
94
95#if IMPELLER_SUPPORTS_RENDERING
96class MockDlImage : public impeller::DlImageImpeller {
97 public:
98 MOCK_METHOD(DlISize, GetSize, (), (const, override));
99 MOCK_METHOD(bool, isOpaque, (), (const, override));
100 MOCK_METHOD(size_t, GetApproximateByteSize, (), (const, override));
101 MOCK_METHOD(bool, isUIThreadSafe, (), (const, override));
102 MOCK_METHOD(DlImage::Type, GetImageType, (), (const, override));
103 MOCK_METHOD(DlColorSpace, GetColorSpace, (), (const, override));
104 MOCK_METHOD(const DlImageSkia*, asSkiaImage, (), (const, override));
105 MOCK_METHOD(std::shared_ptr<impeller::Texture>,
106 GetImpellerTexture,
107 (const std::shared_ptr<impeller::Context>&),
108 (const, override));
109};
110#endif
111
112} // namespace testing
113} // namespace flutter
114
115#endif // FLUTTER_LIB_UI_PAINTING_TESTING_MOCKS_H_
Type
The backend type of this image.
Definition dl_image.h:44
virtual bool MakeRenderContextCurrent()=0
virtual sk_sp< SkImage > MakeSkiaTextureImage(sk_sp< SkImage > image, SnapshotPixelFormat pixel_format)=0
virtual std::shared_ptr< TextureRegistry > GetTextureRegistry()=0
Gets the registry of external textures currently in use by the rasterizer. These textures may be upda...
virtual void MakeSkiaSnapshot(sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(sk_sp< SkImage >)> callback, SnapshotPixelFormat pixel_format)=0
virtual std::shared_ptr< impeller::Texture > MakeImpellerTextureImage(sk_sp< SkImage > image, SnapshotPixelFormat pixel_format)=0
virtual std::shared_ptr< impeller::Texture > MakeImpellerSnapshotSync(sk_sp< DisplayList > display_list, DlISize picture_size, SnapshotPixelFormat pixel_format)=0
virtual sk_sp< SkImage > ConvertToRasterImage(sk_sp< SkImage > image)=0
virtual GrDirectContext * GetGrContext()=0
virtual void MakeImpellerSnapshot(sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(std::shared_ptr< impeller::Texture >)> callback, SnapshotPixelFormat pixel_format)=0
virtual sk_sp< SkImage > MakeSkiaSnapshotSync(sk_sp< DisplayList > display_list, DlISize picture_size, SnapshotPixelFormat pixel_format)=0
virtual std::unique_ptr< GpuImageResult > MakeSkiaGpuImage(sk_sp< DisplayList > display_list, const SkImageInfo &image_info)=0
Attempts to create a GrBackendTexture for the specified DisplayList. May result in a raster bitmap if...
virtual void CacheRuntimeStage(const std::shared_ptr< impeller::RuntimeStage > &runtime_stage)=0
MOCK_METHOD(void, CacheRuntimeStage,(const std::shared_ptr< impeller::RuntimeStage > &),(override))
MOCK_METHOD(bool, MakeRenderContextCurrent,(),(override))
MOCK_METHOD(std::shared_ptr< impeller::Texture >, MakeImpellerSnapshotSync,(sk_sp< DisplayList >, DlISize, SnapshotPixelFormat),(override))
MOCK_METHOD(sk_sp< SkImage >, MakeSkiaTextureImage,(sk_sp< SkImage >, SnapshotPixelFormat),(override))
MOCK_METHOD(std::shared_ptr< TextureRegistry >, GetTextureRegistry,(),(override))
MOCK_METHOD(sk_sp< SkImage >, MakeSkiaSnapshotSync,(sk_sp< DisplayList >, DlISize, SnapshotPixelFormat),(override))
MOCK_METHOD(GrDirectContext *, GetGrContext,(),(override))
MOCK_METHOD(std::unique_ptr< GpuImageResult >, MakeSkiaGpuImage,(sk_sp< DisplayList >, const SkImageInfo &),(override))
std::shared_ptr< MockTextureRegistry > GetMockTextureRegistry()
Definition mocks.h:86
MOCK_METHOD(sk_sp< SkImage >, ConvertToRasterImage,(sk_sp< SkImage >),(override))
MOCK_METHOD(void, MakeImpellerSnapshot,(sk_sp< DisplayList >, DlISize, std::function< void(std::shared_ptr< impeller::Texture >)>, SnapshotPixelFormat target_format),(override))
MOCK_METHOD(void, MakeSkiaSnapshot,(sk_sp< DisplayList >, DlISize, std::function< void(sk_sp< SkImage >)>, SnapshotPixelFormat target_format),(override))
MOCK_METHOD(std::shared_ptr< impeller::Texture >, MakeImpellerTextureImage,(sk_sp< SkImage >, SnapshotPixelFormat),(override))
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > GetWeakPtr()
Definition mocks.h:82
DlColorSpace
Definition dl_color.h:13
Definition ref_ptr.h:261