diff --git a/shell/platform/android/test/io/flutter/embedding/android/FlutterFragmentTest.java b/shell/platform/android/test/io/flutter/embedding/android/FlutterFragmentTest.java index 4b6c223530d30..06b30a99e024e 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/FlutterFragmentTest.java +++ b/shell/platform/android/test/io/flutter/embedding/android/FlutterFragmentTest.java @@ -284,8 +284,11 @@ public void itReturnsExclusiveAppComponent() { } @SuppressWarnings("deprecation") - // Robolectric.setupActivity - // TODO(reidbaker): https://github.com/flutter/flutter/issues/133151 + private FragmentActivity getMockFragmentActivity() { + // TODO(reidbaker): https://github.com/flutter/flutter/issues/133151 + return Robolectric.setupActivity(FragmentActivity.class); + } + @Test public void itDelegatesOnBackPressedAutomaticallyWhenEnabled() { // We need to mock FlutterJNI to avoid triggering native code. @@ -300,7 +303,7 @@ public void itDelegatesOnBackPressedAutomaticallyWhenEnabled() { FlutterFragment.withCachedEngine("my_cached_engine") .shouldAutomaticallyHandleOnBackPressed(true) .build(); - FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class); + FragmentActivity activity = getMockFragmentActivity(); activity .getSupportFragmentManager() .beginTransaction() @@ -337,7 +340,7 @@ public void itHandlesPopSystemNavigationAutomaticallyWhenEnabled() { FlutterFragment.withCachedEngine("my_cached_engine") .shouldAutomaticallyHandleOnBackPressed(true) .build(); - FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class); + FragmentActivity activity = getMockFragmentActivity(); activity .getSupportFragmentManager() .beginTransaction()