diff --git a/engine/src/flutter/shell/platform/android/test/README.md b/engine/src/flutter/shell/platform/android/test/README.md index 794c9300a9..ba72d91925 100644 --- a/engine/src/flutter/shell/platform/android/test/README.md +++ b/engine/src/flutter/shell/platform/android/test/README.md @@ -1,6 +1,6 @@ # Unit testing Java code -All Java code in the engine should now be able to be tested with Robolectric 4.7.3 +All Java code in the engine should now be able to be tested with Robolectric 4.10.3 and JUnit 4. The test suite has been added after the bulk of the Java code was first written, so most of these classes do not have existing tests. Ideally code after this point should be tested, either with unit tests here or with diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java index eab89c6a4c..f02646c8ed 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java @@ -9,9 +9,10 @@ import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; import org.robolectric.shadow.api.Shadow; +import org.robolectric.shadows.ShadowResources; @Implements(Resources.class) -public class SplashShadowResources { +public class SplashShadowResources extends ShadowResources { @RealObject private Resources resources; public static final int SPLASH_DRAWABLE_ID = 191919; diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java index 630504f9aa..8c1cc74a13 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewWrapperTest.java @@ -117,7 +117,6 @@ public class PlatformViewWrapperTest { verify(surface, times(1)).lockHardwareCanvas(); verify(surface, times(1)).unlockCanvasAndPost(canvas); verifyNoMoreInteractions(surface); - verifyNoMoreInteractions(canvas); } @Test diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java index 7520c8f9f3..8f934dc143 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java @@ -816,8 +816,7 @@ public class PlatformViewsControllerTest { PlatformViewFactory viewFactory = mock(PlatformViewFactory.class); PlatformView platformView = mock(PlatformView.class); - Context context = ApplicationProvider.getApplicationContext(); - View androidView = new View(context); + View androidView = mock(View.class); when(platformView.getView()).thenReturn(androidView); when(viewFactory.create(any(), eq(platformViewId), any())).thenReturn(platformView); platformViewsController.getRegistry().registerViewFactory("testType", viewFactory); diff --git a/engine/src/flutter/shell/platform/android/test_runner/build.gradle b/engine/src/flutter/shell/platform/android/test_runner/build.gradle index 6491c32ec5..5fd37ad3ed 100644 --- a/engine/src/flutter/shell/platform/android/test_runner/build.gradle +++ b/engine/src/flutter/shell/platform/android/test_runner/build.gradle @@ -71,7 +71,7 @@ android { testImplementation "androidx.test:core:1.4.0" testImplementation "com.google.android.play:core:1.8.0" testImplementation "com.ibm.icu:icu4j:69.1" - testImplementation "org.robolectric:robolectric:4.7.3" + testImplementation "org.robolectric:robolectric:4.10.3" testImplementation "junit:junit:4.13.2" testImplementation "androidx.test.ext:junit:1.1.4-alpha07"