Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit cc06e5a

Browse files
Revert "Bump Robolectric to 4.8.1 (#33024)" (#34263)
This reverts commit 2857531.
1 parent 7b7ebdf commit cc06e5a

File tree

4 files changed

+5
-41
lines changed

4 files changed

+5
-41
lines changed

shell/platform/android/test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Unit testing Java code
22

3-
All Java code in the engine should now be able to be tested with Robolectric 4.8.1
3+
All Java code in the engine should now be able to be tested with Robolectric 4.7.3
44
and JUnit 4. The test suite has been added after the bulk of the Java code was
55
first written, so most of these classes do not have existing tests. Ideally code
66
after this point should be tested, either with unit tests here or with

shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import android.content.Context;
1111
import android.content.MutableContextWrapper;
1212
import android.content.res.AssetManager;
13-
import android.graphics.Canvas;
1413
import android.graphics.SurfaceTexture;
1514
import android.util.SparseArray;
1615
import android.view.MotionEvent;
@@ -54,7 +53,6 @@
5453
import org.robolectric.annotation.Config;
5554
import org.robolectric.annotation.Implementation;
5655
import org.robolectric.annotation.Implements;
57-
import org.robolectric.shadows.ShadowSurface;
5856
import org.robolectric.shadows.ShadowSurfaceView;
5957

6058
@Config(manifest = Config.NONE)
@@ -649,12 +647,7 @@ public void disposeAndroidView__hybridComposition() {
649647
}
650648

651649
@Test
652-
@Config(
653-
shadows = {
654-
ShadowFlutterJNI.class,
655-
ShadowReleasedSurface.class,
656-
ShadowPlatformTaskQueue.class
657-
})
650+
@Config(shadows = {ShadowFlutterJNI.class, ShadowPlatformTaskQueue.class})
658651
public void disposeNullAndroidView() {
659652
PlatformViewsController platformViewsController = new PlatformViewsController();
660653

@@ -674,20 +667,6 @@ public void disposeNullAndroidView() {
674667
attach(jni, platformViewsController);
675668

676669
// Simulate create call from the framework.
677-
// Before Robolectric 4.8, Surface#lockHardwareCanvas will throw exception at
678-
// PlatformViewWrapper#setTexture, because Robolectric doesn't support to shadow
679-
// Surface#lockHardwareCanvas, and it uses real Android logic with native pointer address is 0.
680-
// This failure will ensure embeddedView's parent is null, because
681-
// PlatformViewsController#createForTextureLayer will fail because of previous mentioned error,
682-
// and PlatformViewsController#createForTextureLayer will not add embeddedView to wrapperView.
683-
// So this test can pass. From Robolectric 4.8, it supports to shadow Surface#lockHardwareCanvas
684-
// and it can pass with default true valid value, and
685-
// PlatformViewsController#createForTextureLayer will run correctly and add embeddedView to
686-
// wrapperView, and initializePlatformViewIfNeeded will fail because embeddedView's parent is
687-
// not null. So adding a new shadow class called ShadowReleasedSurface to simulate previous
688-
// Surface#lockHardwareCanvas failure to ensure this test can work with Robolectric 4.8 and
689-
// later versions. But it is just a workaround, the root cause is this test case depends on
690-
// just-failure behavior of Surface#lockHardwareCanvas in old Robolectric.
691670
createPlatformView(
692671
jni, platformViewsController, platformViewId, "testType", /* hybrid=*/ false);
693672
platformViewsController.initializePlatformViewIfNeeded(platformViewId);
@@ -1316,22 +1295,6 @@ public void dispatch(Runnable runnable) {
13161295
}
13171296
}
13181297

1319-
/**
1320-
* The shadow class of {@link Surface} to simulate released surface.
1321-
*
1322-
* <p>This shadow class's usage is restricted, not for normal purpose.
1323-
*/
1324-
@Implements(Surface.class)
1325-
public static class ShadowReleasedSurface extends ShadowSurface {
1326-
public ShadowReleasedSurface() {}
1327-
1328-
@Implementation
1329-
@Override
1330-
protected Canvas lockHardwareCanvas() {
1331-
throw new IllegalStateException("Surface has already been released.");
1332-
}
1333-
}
1334-
13351298
@Implements(FlutterJNI.class)
13361299
public static class ShadowFlutterJNI {
13371300
private static SparseArray<ByteBuffer> replies = new SparseArray<>();

shell/platform/android/test_runner/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ android {
6969
implementation files(project.property("flutter_jar"))
7070
testImplementation "androidx.test:core:1.4.0"
7171
testImplementation "com.google.android.play:core:1.8.0"
72-
testImplementation "org.robolectric:robolectric:4.8.1"
72+
testImplementation "com.ibm.icu:icu4j:69.1"
73+
testImplementation "org.robolectric:robolectric:4.7.3"
7374
testImplementation "junit:junit:4.13"
7475
testImplementation "androidx.test.ext:junit:1.1.3"
7576

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sdk=32
1+
sdk=31
22
shadows=io.flutter.CustomShadowContextImpl

0 commit comments

Comments
 (0)