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
10#include "gmock/gmock.h"
11
12namespace flutter {
13namespace testing {
14
16 public:
18 virtual ~MockTextureRegistry() = default;
19};
20
22 public:
24 : weak_factory_(this),
25 texture_registry_(std::make_shared<MockTextureRegistry>()) {}
26 virtual ~MockSnapshotDelegate() = default;
27
28 MOCK_METHOD(std::unique_ptr<GpuImageResult>,
30 (sk_sp<DisplayList>, const SkImageInfo&),
31 (override));
32 MOCK_METHOD(std::shared_ptr<TextureRegistry>,
34 (),
35 (override));
36 MOCK_METHOD(GrDirectContext*, GetGrContext, (), (override));
39 (sk_sp<DisplayList>,
40 DlISize,
41 std::function<void(sk_sp<DlImage>)>),
42 (override));
43 MOCK_METHOD(sk_sp<DlImage>,
45 (sk_sp<DisplayList>, DlISize),
46 (override));
47 MOCK_METHOD(sk_sp<SkImage>,
49 (sk_sp<SkImage>),
50 (override));
53 (const std::shared_ptr<impeller::RuntimeStage>&),
54 (override));
55 MOCK_METHOD(bool, MakeRenderContextCurrent, (), (override));
56
58 return weak_factory_.GetWeakPtr();
59 }
60
61 std::shared_ptr<MockTextureRegistry> GetMockTextureRegistry() {
62 return texture_registry_;
63 }
64
65 private:
67 std::shared_ptr<MockTextureRegistry> texture_registry_;
68};
69
70class MockDlImage : public DlImage {
71 public:
72 MOCK_METHOD(DlISize, GetSize, (), (const, override));
73 MOCK_METHOD(sk_sp<SkImage>, skia_image, (), (const, override));
74 MOCK_METHOD(bool, isOpaque, (), (const, override));
75 MOCK_METHOD(bool, isTextureBacked, (), (const, override));
76 MOCK_METHOD(std::shared_ptr<impeller::Texture>,
78 (),
79 (const, override));
80 MOCK_METHOD(size_t, GetApproximateByteSize, (), (const, override));
81 MOCK_METHOD(bool, isUIThreadSafe, (), (const, override));
82};
83
84} // namespace testing
85} // namespace flutter
86
87#endif // FLUTTER_LIB_UI_PAINTING_TESTING_MOCKS_H_
Represents an image whose allocation is (usually) resident on device memory.
Definition dl_image.h:32
virtual size_t GetApproximateByteSize() const =0
virtual DlISize GetSize() const =0
virtual bool isTextureBacked() const =0
virtual bool isOpaque() const =0
If the pixel format of this image ignores alpha, this returns true. This method might conservatively ...
virtual std::shared_ptr< impeller::Texture > impeller_texture() const =0
If this display list image is meant to be used by the Impeller backend, an Impeller texture instance....
virtual bool isUIThreadSafe() const =0
If the underlying platform image held by this object has no threading requirements for the release of...
virtual sk_sp< SkImage > skia_image() const =0
If this display list image is meant to be used by the Skia backend, an SkImage instance....
virtual bool MakeRenderContextCurrent()=0
virtual void MakeRasterSnapshot(sk_sp< DisplayList > display_list, DlISize picture_size, std::function< void(sk_sp< DlImage >)> callback)=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 sk_sp< DlImage > MakeRasterSnapshotSync(sk_sp< DisplayList > display_list, DlISize picture_size)=0
virtual sk_sp< SkImage > ConvertToRasterImage(sk_sp< SkImage > image)=0
virtual GrDirectContext * GetGrContext()=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(size_t, GetApproximateByteSize,(),(const, override))
MOCK_METHOD(bool, isOpaque,(),(const, override))
MOCK_METHOD(std::shared_ptr< impeller::Texture >, impeller_texture,(),(const, override))
MOCK_METHOD(sk_sp< SkImage >, skia_image,(),(const, override))
MOCK_METHOD(bool, isTextureBacked,(),(const, override))
MOCK_METHOD(bool, isUIThreadSafe,(),(const, override))
MOCK_METHOD(DlISize, GetSize,(),(const, override))
MOCK_METHOD(void, CacheRuntimeStage,(const std::shared_ptr< impeller::RuntimeStage > &),(override))
MOCK_METHOD(bool, MakeRenderContextCurrent,(),(override))
MOCK_METHOD(std::shared_ptr< TextureRegistry >, GetTextureRegistry,(),(override))
MOCK_METHOD(GrDirectContext *, GetGrContext,(),(override))
MOCK_METHOD(std::unique_ptr< GpuImageResult >, MakeSkiaGpuImage,(sk_sp< DisplayList >, const SkImageInfo &),(override))
MOCK_METHOD(void, MakeRasterSnapshot,(sk_sp< DisplayList >, DlISize, std::function< void(sk_sp< DlImage >)>),(override))
std::shared_ptr< MockTextureRegistry > GetMockTextureRegistry()
Definition mocks.h:61
MOCK_METHOD(sk_sp< SkImage >, ConvertToRasterImage,(sk_sp< SkImage >),(override))
MOCK_METHOD(sk_sp< DlImage >, MakeRasterSnapshotSync,(sk_sp< DisplayList >, DlISize),(override))
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > GetWeakPtr()
Definition mocks.h:57
Definition ref_ptr.h:261