@@ -237,6 +237,47 @@ public void itThrowsExceptionIfCachedEngineDoesNotExist() {
237
237
// Expect IllegalStateException.
238
238
}
239
239
240
+ // Bug: b/271100292
241
+ @ Test
242
+ public void flutterEngineGroupGetsInitialRouteFromIntent () {
243
+ // ---- Test setup ----
244
+ FlutterLoader mockFlutterLoader = mock (FlutterLoader .class );
245
+ Activity mockActivity = mock (Activity .class );
246
+ Intent mockIntent = mock (Intent .class );
247
+ when (mockFlutterLoader .findAppBundlePath ()).thenReturn ("default_flutter_assets/path" );
248
+ FlutterInjector .setInstance (
249
+ new FlutterInjector .Builder ().setFlutterLoader (mockFlutterLoader ).build ());
250
+ FlutterEngineGroup flutterEngineGroup = mock (FlutterEngineGroup .class );
251
+ FlutterEngineGroupCache .getInstance ().put ("my_flutter_engine_group" , flutterEngineGroup );
252
+
253
+ List <String > entryPointArgs = new ArrayList <>();
254
+ entryPointArgs .add ("entrypoint-arg" );
255
+
256
+ // Adjust fake host to request cached engine group.
257
+ when (mockHost .getInitialRoute ()).thenReturn (null );
258
+ when (mockHost .getCachedEngineGroupId ()).thenReturn ("my_flutter_engine_group" );
259
+ when (mockHost .provideFlutterEngine (any (Context .class ))).thenReturn (null );
260
+ when (mockHost .shouldAttachEngineToActivity ()).thenReturn (false );
261
+ when (mockHost .getDartEntrypointArgs ()).thenReturn (entryPointArgs );
262
+ when (mockHost .shouldHandleDeeplinking ()).thenReturn (true );
263
+ when (mockHost .getActivity ()).thenReturn (mockActivity );
264
+ when (mockActivity .getIntent ()).thenReturn (mockIntent );
265
+ when (mockIntent .getData ()).thenReturn (Uri .parse ("foo://example.com/initial_route" ));
266
+
267
+ // Create the real object that we're testing.
268
+ FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate (mockHost );
269
+
270
+ // --- Execute the behavior under test ---
271
+ // The FlutterEngine is obtained in onAttach().
272
+ delegate .onAttach (ctx );
273
+
274
+ DartExecutor .DartEntrypoint entrypoint = new DartExecutor .DartEntrypoint ("/fake/path" , "main" );
275
+ ArgumentCaptor <FlutterEngineGroup .Options > optionsCaptor =
276
+ ArgumentCaptor .forClass (FlutterEngineGroup .Options .class );
277
+ verify (flutterEngineGroup , times (1 )).createAndRunEngine (optionsCaptor .capture ());
278
+ assertEquals ("/initial_route" , optionsCaptor .getValue ().getInitialRoute ());
279
+ }
280
+
240
281
@ Test
241
282
public void itUsesNewEngineInGroupWhenProvided () {
242
283
// ---- Test setup ----
0 commit comments