Flutter Engine
jni_mock.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_SHELL_PLATFORM_ANDROID_JNI_MOCK_H_
6 #define FLUTTER_SHELL_PLATFORM_ANDROID_JNI_MOCK_H_
7 
8 #include "flutter/shell/platform/android/jni/platform_view_android_jni.h"
9 #include "gmock/gmock.h"
10 
11 namespace flutter {
12 
13 //------------------------------------------------------------------------------
14 /// Mock for |PlatformViewAndroidJNI|. This implementation can be used in unit
15 /// tests without requiring the Android toolchain.
16 ///
17 class JNIMock final : public PlatformViewAndroidJNI {
18  public:
19  MOCK_METHOD(void,
21  (std::unique_ptr<flutter::PlatformMessage> message,
22  int responseId),
23  (override));
24 
25  MOCK_METHOD(void,
27  (int responseId, std::unique_ptr<fml::Mapping> data),
28  (override));
29 
30  MOCK_METHOD(void,
32  (std::vector<uint8_t> buffer,
33  std::vector<std::string> strings,
34  std::vector<std::vector<uint8_t>> string_attribute_args),
35  (override));
36 
37  MOCK_METHOD(void,
39  (std::vector<uint8_t> actions_buffer,
40  std::vector<std::string> strings),
41  (override));
42 
43  MOCK_METHOD(void, FlutterViewOnFirstFrame, (), (override));
44 
45  MOCK_METHOD(void, FlutterViewOnPreEngineRestart, (), (override));
46 
47  MOCK_METHOD(void,
49  (JavaLocalRef surface_texture, int textureId),
50  (override));
51 
52  MOCK_METHOD(void,
54  (JavaLocalRef surface_texture),
55  (override));
56 
57  MOCK_METHOD(void,
59  (JavaLocalRef surface_texture, SkMatrix& transform),
60  (override));
61 
62  MOCK_METHOD(void,
64  (JavaLocalRef surface_texture),
65  (override));
66 
67  MOCK_METHOD(void,
69  (int view_id,
70  int x,
71  int y,
72  int width,
73  int height,
74  int viewWidth,
75  int viewHeight,
76  MutatorsStack mutators_stack),
77  (override));
78 
79  MOCK_METHOD(void,
81  (int surface_id, int x, int y, int width, int height),
82  (override));
83 
84  MOCK_METHOD(void, FlutterViewBeginFrame, (), (override));
85 
86  MOCK_METHOD(void, FlutterViewEndFrame, (), (override));
87 
88  MOCK_METHOD(std::unique_ptr<PlatformViewAndroidJNI::OverlayMetadata>,
90  (),
91  (override));
92 
93  MOCK_METHOD(void, FlutterViewDestroyOverlaySurfaces, (), (override));
94 
95  MOCK_METHOD(std::unique_ptr<std::vector<std::string>>,
97  (std::vector<std::string> supported_locales_data),
98  (override));
99 
100  MOCK_METHOD(double, GetDisplayRefreshRate, (), (override));
101 
102  MOCK_METHOD(bool,
104  (int loading_unit_id),
105  (override));
106 };
107 
108 } // namespace flutter
109 
110 #endif // FLUTTER_SHELL_PLATFORM_ANDROID_JNI_MOCK_H_
virtual std::unique_ptr< PlatformViewAndroidJNI::OverlayMetadata > FlutterViewCreateOverlaySurface()=0
Instantiates an overlay surface in hybrid composition and provides the necessary metadata to operate ...
virtual void FlutterViewUpdateSemantics(std::vector< uint8_t > buffer, std::vector< std::string > strings, std::vector< std::vector< uint8_t >> string_attribute_args)=0
Sends semantics tree updates.
virtual std::unique_ptr< std::vector< std::string > > FlutterViewComputePlatformResolvedLocale(std::vector< std::string > supported_locales_data)=0
Computes the locale Android would select.
virtual void FlutterViewDestroyOverlaySurfaces()=0
Destroys the overlay surfaces.
virtual void FlutterViewOnPreEngineRestart()=0
Indicates that a hot restart is about to happen.
virtual void SurfaceTextureDetachFromGLContext(JavaLocalRef surface_texture)=0
Detaches a SurfaceTexture from the OpenGL ES context.
virtual void FlutterViewDisplayOverlaySurface(int surface_id, int x, int y, int width, int height)=0
Positions and sizes an overlay surface in hybrid composition.
virtual void FlutterViewOnDisplayPlatformView(int view_id, int x, int y, int width, int height, int viewWidth, int viewHeight, MutatorsStack mutators_stack)=0
Positions and sizes a platform view if using hybrid composition.
virtual void FlutterViewBeginFrame()=0
Initiates a frame if using hybrid composition.
virtual bool RequestDartDeferredLibrary(int loading_unit_id)=0
virtual void SurfaceTextureGetTransformMatrix(JavaLocalRef surface_texture, SkMatrix &transform)=0
Gets the transform matrix from the SurfaceTexture. Then, it updates the transform matrix...
virtual void FlutterViewEndFrame()=0
Indicates that the current frame ended. It&#39;s used to clean up state.
virtual double GetDisplayRefreshRate()=0
int32_t width
int32_t height
virtual void FlutterViewHandlePlatformMessage(std::unique_ptr< flutter::PlatformMessage > message, int responseId)=0
Sends a platform message. The message may be empty.
virtual void FlutterViewHandlePlatformMessageResponse(int responseId, std::unique_ptr< fml::Mapping > data)=0
Responds to a platform message. The data may be a nullptr.
virtual void FlutterViewUpdateCustomAccessibilityActions(std::vector< uint8_t > actions_buffer, std::vector< std::string > strings)=0
Sends new custom accessibility events.
static const uint8_t buffer[]
MOCK_METHOD(void, FlutterViewHandlePlatformMessage,(std::unique_ptr< flutter::PlatformMessage > message, int responseId),(override))
std::nullptr_t JavaLocalRef
virtual void SurfaceTextureUpdateTexImage(JavaLocalRef surface_texture)=0
Updates the texture image to the most recent frame from the image stream.
virtual void FlutterViewOnFirstFrame()=0
Indicates that FlutterView should start painting pixels.
virtual void SurfaceTextureAttachToGLContext(JavaLocalRef surface_texture, int textureId)=0
Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread...