From 8239650625db3290b04e41921cb100bbd4d095bf Mon Sep 17 00:00:00 2001 From: utzcoz Date: Wed, 22 Dec 2021 00:13:12 +0800 Subject: [PATCH 1/2] Bump Robolectric to 4.7.3 Signed-off-by: utzcoz --- shell/platform/android/test/README.md | 2 +- shell/platform/android/test_runner/build.gradle | 2 +- .../test_runner/src/main/resources/robolectric.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/android/test/README.md b/shell/platform/android/test/README.md index b5e4dce6dcc5c..ef203e012cefe 100644 --- a/shell/platform/android/test/README.md +++ b/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.6.1 +All Java code in the engine should now be able to be tested with Robolectric 4.7.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/shell/platform/android/test_runner/build.gradle b/shell/platform/android/test_runner/build.gradle index bb9a1fc781375..bc69251a8c897 100644 --- a/shell/platform/android/test_runner/build.gradle +++ b/shell/platform/android/test_runner/build.gradle @@ -44,7 +44,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.6.1" + testImplementation "org.robolectric:robolectric:4.7.3" testImplementation "junit:junit:4.13" def mockitoVersion = "4.1.0" diff --git a/shell/platform/android/test_runner/src/main/resources/robolectric.properties b/shell/platform/android/test_runner/src/main/resources/robolectric.properties index 28a4ed295fa79..ffcbe2dd23944 100644 --- a/shell/platform/android/test_runner/src/main/resources/robolectric.properties +++ b/shell/platform/android/test_runner/src/main/resources/robolectric.properties @@ -1 +1 @@ -sdk=30 +sdk=31 From ed64f71815f03daf431016217e216368aa851fa6 Mon Sep 17 00:00:00 2001 From: utzcoz Date: Sun, 26 Dec 2021 01:38:04 +0800 Subject: [PATCH 2/2] Restrict SingleViewPresentationTest under SDK 31 Looks like https://android.googlesource.com/platform/frameworks/base/+/f3aefb28029f5eb05835a61e86bf660cc72da432%5E%21/core/java/android/app/Presentation.java added at Android 12 breaks flutter's hook to cache IMM instance for Presentation. Before it is fixed, we should restrict SingleViewPresentationTest to ensure that it will not run with SDK 31 to avoid failures. Signed-off-by: utzcoz --- .../plugin/platform/SingleViewPresentationTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/test/io/flutter/plugin/platform/SingleViewPresentationTest.java b/shell/platform/android/test/io/flutter/plugin/platform/SingleViewPresentationTest.java index 67c03004653af..1aa4953c387ab 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/SingleViewPresentationTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/SingleViewPresentationTest.java @@ -1,5 +1,8 @@ package io.flutter.plugin.platform; +import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; +import static android.os.Build.VERSION_CODES.P; +import static android.os.Build.VERSION_CODES.R; import static junit.framework.Assert.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -18,9 +21,10 @@ @Config(manifest = Config.NONE) @RunWith(RobolectricTestRunner.class) -@TargetApi(28) +@TargetApi(P) public class SingleViewPresentationTest { @Test + @Config(minSdk = JELLY_BEAN_MR1, maxSdk = R) public void returnsOuterContextInputMethodManager() { // There's a bug in Android Q caused by the IMM being instanced per display. // https://github.com/flutter/flutter/issues/38375. We need the context returned by @@ -51,6 +55,7 @@ public void returnsOuterContextInputMethodManager() { } @Test + @Config(minSdk = JELLY_BEAN_MR1, maxSdk = R) public void returnsOuterContextInputMethodManager_createDisplayContext() { // The IMM should also persist across display contexts created from the base context.