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  (fml::RefPtr<flutter::PlatformMessage> message, int responseId),
22  (override));
23 
24  MOCK_METHOD(void,
26  (int responseId, std::unique_ptr<fml::Mapping> data),
27  (override));
28 
29  MOCK_METHOD(void,
31  (std::vector<uint8_t> buffer, std::vector<std::string> strings),
32  (override));
33 
34  MOCK_METHOD(void,
36  (std::vector<uint8_t> actions_buffer,
37  std::vector<std::string> strings),
38  (override));
39 
40  MOCK_METHOD(void, FlutterViewOnFirstFrame, (), (override));
41 
42  MOCK_METHOD(void, FlutterViewOnPreEngineRestart, (), (override));
43 
44  MOCK_METHOD(void,
46  (JavaWeakGlobalRef surface_texture, int textureId),
47  (override));
48 
49  MOCK_METHOD(void,
51  (JavaWeakGlobalRef surface_texture),
52  (override));
53 
54  MOCK_METHOD(void,
56  (JavaWeakGlobalRef surface_texture, SkMatrix& transform),
57  (override));
58 
59  MOCK_METHOD(void,
61  (JavaWeakGlobalRef surface_texture),
62  (override));
63 
64  MOCK_METHOD(void,
66  (int view_id,
67  int x,
68  int y,
69  int width,
70  int height,
71  int viewWidth,
72  int viewHeight,
73  MutatorsStack mutators_stack),
74  (override));
75 
76  MOCK_METHOD(void,
78  (int surface_id, int x, int y, int width, int height),
79  (override));
80 
81  MOCK_METHOD(void, FlutterViewBeginFrame, (), (override));
82 
83  MOCK_METHOD(void, FlutterViewEndFrame, (), (override));
84 
85  MOCK_METHOD(std::unique_ptr<PlatformViewAndroidJNI::OverlayMetadata>,
87  (),
88  (override));
89 
90  MOCK_METHOD(void, FlutterViewDestroyOverlaySurfaces, (), (override));
91 
92  MOCK_METHOD(std::unique_ptr<std::vector<std::string>>,
94  (std::vector<std::string> supported_locales_data),
95  (override));
96 
97  MOCK_METHOD(double, GetDisplayRefreshRate, (), (override));
98 };
99 
100 } // namespace flutter
101 
102 #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 std::unique_ptr< std::vector< std::string > > FlutterViewComputePlatformResolvedLocale(std::vector< std::string > supported_locales_data)=0
Computes the locale Android would select.
std::nullptr_t JavaWeakGlobalRef
virtual void SurfaceTextureDetachFromGLContext(JavaWeakGlobalRef surface_texture)=0
Detaches a SurfaceTexture from the OpenGL ES context.
virtual void FlutterViewDestroyOverlaySurfaces()=0
Destroys the overlay surfaces.
virtual void FlutterViewOnPreEngineRestart()=0
Indicates that a hot restart is about to happen.
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 FlutterViewHandlePlatformMessage(fml::RefPtr< flutter::PlatformMessage > message, int responseId)=0
Sends a platform message. The message may be empty.
virtual void FlutterViewBeginFrame()=0
Initiates a frame if using hybrid composition.
virtual void FlutterViewEndFrame()=0
Indicates that the current frame ended. It&#39;s used to clean up state.
MOCK_METHOD(void, FlutterViewHandlePlatformMessage,(fml::RefPtr< flutter::PlatformMessage > message, int responseId),(override))
virtual double GetDisplayRefreshRate()=0
int32_t height
virtual void SurfaceTextureUpdateTexImage(JavaWeakGlobalRef surface_texture)=0
Updates the texture image to the most recent frame from the image stream.
int32_t width
virtual void FlutterViewUpdateSemantics(std::vector< uint8_t > buffer, std::vector< std::string > strings)=0
Sends semantics tree updates.
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.
virtual void SurfaceTextureAttachToGLContext(JavaWeakGlobalRef surface_texture, int textureId)=0
Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread...
virtual void FlutterViewOnFirstFrame()=0
Indicates that FlutterView should start painting pixels.
virtual void SurfaceTextureGetTransformMatrix(JavaWeakGlobalRef surface_texture, SkMatrix &transform)=0
Gets the transform matrix from the SurfaceTexture. Then, it updates the transform matrix...