Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.embedding.engine.FlutterJNITest Class Reference

Public Member Functions

void itAllowsFirstFrameListenersToRemoveThemselvesInline ()
 
void computePlatformResolvedLocaleCallsLocalizationPluginProperly ()
 
void onDisplayPlatformView_callsPlatformViewsController ()
 
void onDisplayOverlaySurface_callsPlatformViewsController ()
 
void onBeginFrame_callsPlatformViewsController ()
 
void onEndFrame_callsPlatformViewsController ()
 
void createOverlaySurface_callsPlatformViewsController ()
 
void invokePlatformMessageResponseCallback_wantsDirectBuffer ()
 
void setRefreshRateFPS_callsUpdateRefreshRate ()
 

Detailed Description

Definition at line 33 of file FlutterJNITest.java.

Member Function Documentation

◆ computePlatformResolvedLocaleCallsLocalizationPluginProperly()

void io.flutter.embedding.engine.FlutterJNITest.computePlatformResolvedLocaleCallsLocalizationPluginProperly ( )
inline

Definition at line 68 of file FlutterJNITest.java.

68 {
69 // --- Test Setup ---
70 FlutterJNI flutterJNI = new FlutterJNI();
71
72 Context context = mock(Context.class);
73 Resources resources = mock(Resources.class);
74 Configuration config = mock(Configuration.class);
75 DartExecutor dartExecutor = mock(DartExecutor.class);
76 LocaleList localeList =
77 new LocaleList(new Locale("es", "MX"), new Locale("zh", "CN"), new Locale("en", "US"));
78 when(context.getResources()).thenReturn(resources);
79 when(resources.getConfiguration()).thenReturn(config);
80 when(config.getLocales()).thenReturn(localeList);
81
82 flutterJNI.setLocalizationPlugin(
83 new LocalizationPlugin(context, new LocalizationChannel(dartExecutor)));
84 String[] supportedLocales =
85 new String[] {
86 "fr", "FR", "",
87 "zh", "", "",
88 "en", "CA", ""
89 };
90 String[] result = flutterJNI.computePlatformResolvedLocale(supportedLocales);
91 assertEquals(result.length, 3);
92 assertEquals(result[0], "zh");
93 assertEquals(result[1], "");
94 assertEquals(result[2], "");
95
96 supportedLocales =
97 new String[] {
98 "fr", "FR", "",
99 "ar", "", "",
100 "en", "CA", ""
101 };
102 result = flutterJNI.computePlatformResolvedLocale(supportedLocales);
103 assertEquals(result.length, 3);
104 assertEquals(result[0], "en");
105 assertEquals(result[1], "CA");
106 assertEquals(result[2], "");
107
108 supportedLocales =
109 new String[] {
110 "fr", "FR", "",
111 "ar", "", "",
112 "en", "US", ""
113 };
114 result = flutterJNI.computePlatformResolvedLocale(supportedLocales);
115 assertEquals(result.length, 3);
116 assertEquals(result[0], "en");
117 assertEquals(result[1], "US");
118 assertEquals(result[2], "");
119
120 supportedLocales =
121 new String[] {
122 "ar", "", "",
123 "es", "MX", "",
124 "en", "US", ""
125 };
126 result = flutterJNI.computePlatformResolvedLocale(supportedLocales);
127 assertEquals(result.length, 3);
128 assertEquals(result[0], "es");
129 assertEquals(result[1], "MX");
130 assertEquals(result[2], "");
131
132 // Empty supportedLocales.
133 supportedLocales = new String[] {};
134 result = flutterJNI.computePlatformResolvedLocale(supportedLocales);
135 assertEquals(result.length, 0);
136
137 // Empty preferredLocales.
138 supportedLocales =
139 new String[] {
140 "fr", "FR", "",
141 "zh", "", "",
142 "en", "CA", ""
143 };
144 localeList = new LocaleList();
145 when(config.getLocales()).thenReturn(localeList);
146 result = flutterJNI.computePlatformResolvedLocale(supportedLocales);
147 // The first locale is default.
148 assertEquals(result.length, 3);
149 assertEquals(result[0], "fr");
150 assertEquals(result[1], "FR");
151 assertEquals(result[2], "");
152 }
GAsyncResult * result

◆ createOverlaySurface_callsPlatformViewsController()

void io.flutter.embedding.engine.FlutterJNITest.createOverlaySurface_callsPlatformViewsController ( )
inline

Definition at line 231 of file FlutterJNITest.java.

231 {
232 PlatformViewsController platformViewsController = mock(PlatformViewsController.class);
233
234 FlutterJNI flutterJNI = new FlutterJNI();
235 flutterJNI.setPlatformViewsController(platformViewsController);
236
237 // --- Execute Test ---
238 flutterJNI.createOverlaySurface();
239
240 // --- Verify Results ---
241 verify(platformViewsController, times(1)).createOverlaySurface();
242 }
static SkISize times(const SkISize &size, float factor)

◆ invokePlatformMessageResponseCallback_wantsDirectBuffer()

void io.flutter.embedding.engine.FlutterJNITest.invokePlatformMessageResponseCallback_wantsDirectBuffer ( )
inline

Definition at line 245 of file FlutterJNITest.java.

245 {
246 FlutterJNI flutterJNI = new FlutterJNI();
247 ByteBuffer buffer = ByteBuffer.allocate(4);
248 flutterJNI.invokePlatformMessageResponseCallback(0, buffer, buffer.position());
249 }
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ itAllowsFirstFrameListenersToRemoveThemselvesInline()

void io.flutter.embedding.engine.FlutterJNITest.itAllowsFirstFrameListenersToRemoveThemselvesInline ( )
inline

Definition at line 35 of file FlutterJNITest.java.

35 {
36 // --- Test Setup ---
37 FlutterJNI flutterJNI = new FlutterJNI();
38
39 AtomicInteger callbackInvocationCount = new AtomicInteger(0);
40 FlutterUiDisplayListener callback =
41 new FlutterUiDisplayListener() {
42 @Override
43 public void onFlutterUiDisplayed() {
44 callbackInvocationCount.incrementAndGet();
45 flutterJNI.removeIsDisplayingFlutterUiListener(this);
46 }
47
48 @Override
49 public void onFlutterUiNoLongerDisplayed() {}
50 };
51 flutterJNI.addIsDisplayingFlutterUiListener(callback);
52
53 // --- Execute Test ---
54 flutterJNI.onFirstFrame();
55
56 // --- Verify Results ---
57 assertEquals(1, callbackInvocationCount.get());
58
59 // --- Execute Test ---
60 // The callback removed itself from the listener list. A second call doesn't call the callback.
61 flutterJNI.onFirstFrame();
62
63 // --- Verify Results ---
64 assertEquals(1, callbackInvocationCount.get());
65 }
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ onBeginFrame_callsPlatformViewsController()

void io.flutter.embedding.engine.FlutterJNITest.onBeginFrame_callsPlatformViewsController ( )
inline

Definition at line 201 of file FlutterJNITest.java.

201 {
202 PlatformViewsController platformViewsController = mock(PlatformViewsController.class);
203
204 // --- Test Setup ---
205 FlutterJNI flutterJNI = new FlutterJNI();
206 flutterJNI.setPlatformViewsController(platformViewsController);
207
208 // --- Execute Test ---
209 flutterJNI.onBeginFrame();
210
211 // --- Verify Results ---
212 verify(platformViewsController, times(1)).onBeginFrame();
213 }

◆ onDisplayOverlaySurface_callsPlatformViewsController()

void io.flutter.embedding.engine.FlutterJNITest.onDisplayOverlaySurface_callsPlatformViewsController ( )
inline

Definition at line 185 of file FlutterJNITest.java.

185 {
186 PlatformViewsController platformViewsController = mock(PlatformViewsController.class);
187
188 FlutterJNI flutterJNI = new FlutterJNI();
189 flutterJNI.setPlatformViewsController(platformViewsController);
190
191 // --- Execute Test ---
192 flutterJNI.onDisplayOverlaySurface(
193 /*id=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200);
194
195 // --- Verify Results ---
196 verify(platformViewsController, times(1))
197 .onDisplayOverlaySurface(/*id=*/ 1, /*x=*/ 10, /*y=*/ 20, /*width=*/ 100, /*height=*/ 200);
198 }

◆ onDisplayPlatformView_callsPlatformViewsController()

void io.flutter.embedding.engine.FlutterJNITest.onDisplayPlatformView_callsPlatformViewsController ( )
inline

Definition at line 154 of file FlutterJNITest.java.

154 {
155 PlatformViewsController platformViewsController = mock(PlatformViewsController.class);
156
157 FlutterJNI flutterJNI = new FlutterJNI();
158 flutterJNI.setPlatformViewsController(platformViewsController);
159 FlutterMutatorsStack stack = new FlutterMutatorsStack();
160 // --- Execute Test ---
161 flutterJNI.onDisplayPlatformView(
162 /*viewId=*/ 1,
163 /*x=*/ 10,
164 /*y=*/ 20,
165 /*width=*/ 100,
166 /*height=*/ 200,
167 /*viewWidth=*/ 100,
168 /*viewHeight=*/ 200,
169 /*mutatorsStack=*/ stack);
170
171 // --- Verify Results ---
172 verify(platformViewsController, times(1))
173 .onDisplayPlatformView(
174 /*viewId=*/ 1,
175 /*x=*/ 10,
176 /*y=*/ 20,
177 /*width=*/ 100,
178 /*height=*/ 200,
179 /*viewWidth=*/ 100,
180 /*viewHeight=*/ 200,
181 /*mutatorsStack=*/ stack);
182 }

◆ onEndFrame_callsPlatformViewsController()

void io.flutter.embedding.engine.FlutterJNITest.onEndFrame_callsPlatformViewsController ( )
inline

Definition at line 216 of file FlutterJNITest.java.

216 {
217 PlatformViewsController platformViewsController = mock(PlatformViewsController.class);
218
219 // --- Test Setup ---
220 FlutterJNI flutterJNI = new FlutterJNI();
221 flutterJNI.setPlatformViewsController(platformViewsController);
222
223 // --- Execute Test ---
224 flutterJNI.onEndFrame();
225
226 // --- Verify Results ---
227 verify(platformViewsController, times(1)).onEndFrame();
228 }

◆ setRefreshRateFPS_callsUpdateRefreshRate()

void io.flutter.embedding.engine.FlutterJNITest.setRefreshRateFPS_callsUpdateRefreshRate ( )
inline

Definition at line 252 of file FlutterJNITest.java.

252 {
253 FlutterJNI flutterJNI = spy(new FlutterJNI());
254 // --- Execute Test ---
255 flutterJNI.setRefreshRateFPS(120.0f);
256 // --- Verify Results ---
257 verify(flutterJNI, times(1)).updateRefreshRate();
258 }

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