190 {
191
192 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
193 when(mockFlutterJNI.isAttached()).thenReturn(true);
194
195 PlatformViewsController platformViewsController = mock(PlatformViewsController.class);
196
197 ArgumentCaptor<
FlutterEngine.EngineLifecycleListener> engineLifecycleListenerArgumentCaptor =
198 ArgumentCaptor.forClass(
FlutterEngine.EngineLifecycleListener.class);
199
200
202 ctx,
203 mock(FlutterLoader.class),
204 mockFlutterJNI,
205 platformViewsController,
206 new String[] {},
207 false);
208
209
210 verify(mockFlutterJNI)
211 .addEngineLifecycleListener(engineLifecycleListenerArgumentCaptor.capture());
212 FlutterEngine.EngineLifecycleListener engineLifecycleListener =
213 engineLifecycleListenerArgumentCaptor.getValue();
214 assertNotNull(engineLifecycleListener);
215
216
217 engineLifecycleListener.onPreEngineRestart();
218
219
220
221 verify(platformViewsController,
times(1)).onPreEngineRestart();
222 }