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

Commit 2705bcb

Browse files
authored
Revert "Re-landing Robolectric 4.8.1 (#34272)" (#37019)
This reverts commit c7c21e5.
1 parent 25133f1 commit 2705bcb

File tree

4 files changed

+6
-75
lines changed

4 files changed

+6
-75
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: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
import static org.mockito.Mockito.*;
88
import static org.robolectric.Shadows.shadowOf;
99

10-
import android.app.Presentation;
1110
import android.content.Context;
1211
import android.content.MutableContextWrapper;
1312
import android.content.res.AssetManager;
14-
import android.graphics.Canvas;
1513
import android.graphics.SurfaceTexture;
1614
import android.util.SparseArray;
1715
import android.view.MotionEvent;
@@ -55,8 +53,6 @@
5553
import org.robolectric.annotation.Config;
5654
import org.robolectric.annotation.Implementation;
5755
import org.robolectric.annotation.Implements;
58-
import org.robolectric.shadows.ShadowDialog;
59-
import org.robolectric.shadows.ShadowSurface;
6056
import org.robolectric.shadows.ShadowSurfaceView;
6157

6258
@Config(manifest = Config.NONE)
@@ -509,8 +505,7 @@ public void createHybridPlatformViewMessage_throwsIfViewIsNull() {
509505
}
510506

511507
@Test
512-
@Config(
513-
shadows = {ShadowFlutterJNI.class, ShadowPlatformTaskQueue.class, ShadowPresentation.class})
508+
@Config(shadows = {ShadowFlutterJNI.class, ShadowPlatformTaskQueue.class})
514509
public void onDetachedFromJNI_clearsPlatformViewContext() {
515510
PlatformViewsController platformViewsController = new PlatformViewsController();
516511

@@ -541,8 +536,7 @@ public void onDetachedFromJNI_clearsPlatformViewContext() {
541536
}
542537

543538
@Test
544-
@Config(
545-
shadows = {ShadowFlutterJNI.class, ShadowPlatformTaskQueue.class, ShadowPresentation.class})
539+
@Config(shadows = {ShadowFlutterJNI.class, ShadowPlatformTaskQueue.class})
546540
public void onPreEngineRestart_clearsPlatformViewContext() {
547541
PlatformViewsController platformViewsController = new PlatformViewsController();
548542

@@ -746,12 +740,7 @@ public void disposeAndroidView_hybridComposition() {
746740
}
747741

748742
@Test
749-
@Config(
750-
shadows = {
751-
ShadowFlutterJNI.class,
752-
ShadowReleasedSurface.class,
753-
ShadowPlatformTaskQueue.class
754-
})
743+
@Config(shadows = {ShadowFlutterJNI.class, ShadowPlatformTaskQueue.class})
755744
public void disposeNullAndroidView() {
756745
PlatformViewsController platformViewsController = new PlatformViewsController();
757746

@@ -771,20 +760,6 @@ public void disposeNullAndroidView() {
771760
attach(jni, platformViewsController);
772761

773762
// Simulate create call from the framework.
774-
// Before Robolectric 4.8, Surface#lockHardwareCanvas will throw exception at
775-
// PlatformViewWrapper#setTexture, because Robolectric doesn't support to shadow
776-
// Surface#lockHardwareCanvas, and it uses real Android logic with native pointer address is 0.
777-
// This failure will ensure embeddedView's parent is null, because
778-
// PlatformViewsController#createForTextureLayer will fail because of previous mentioned error,
779-
// and PlatformViewsController#createForTextureLayer will not add embeddedView to wrapperView.
780-
// So this test can pass. From Robolectric 4.8, it supports to shadow Surface#lockHardwareCanvas
781-
// and it can pass with default true valid value, and
782-
// PlatformViewsController#createForTextureLayer will run correctly and add embeddedView to
783-
// wrapperView, and initializePlatformViewIfNeeded will fail because embeddedView's parent is
784-
// not null. So adding a new shadow class called ShadowReleasedSurface to simulate previous
785-
// Surface#lockHardwareCanvas failure to ensure this test can work with Robolectric 4.8 and
786-
// later versions. But it is just a workaround, the root cause is this test case depends on
787-
// just-failure behavior of Surface#lockHardwareCanvas in old Robolectric.
788763
createPlatformView(
789764
jni, platformViewsController, platformViewId, "testType", /* hybrid=*/ false);
790765
platformViewsController.initializePlatformViewIfNeeded(platformViewId);
@@ -1413,50 +1388,6 @@ public void dispatch(Runnable runnable) {
14131388
}
14141389
}
14151390

1416-
/**
1417-
* The shadow class of {@link Surface} to simulate released surface.
1418-
*
1419-
* <p>This shadow class's usage is restricted, not for normal purpose.
1420-
*/
1421-
@Implements(Surface.class)
1422-
public static class ShadowReleasedSurface extends ShadowSurface {
1423-
public ShadowReleasedSurface() {}
1424-
1425-
@Implementation
1426-
@Override
1427-
protected Canvas lockHardwareCanvas() {
1428-
throw new IllegalStateException("Surface has already been released.");
1429-
}
1430-
}
1431-
1432-
/**
1433-
* The shadow class of {@link Presentation} to simulate Presentation showing logic.
1434-
*
1435-
* <p>Robolectric doesn't support VirtualDisplay creating correctly now, so this shadow class is
1436-
* used to simulate custom logic for Presentation.
1437-
*/
1438-
@Implements(Presentation.class)
1439-
public static class ShadowPresentation extends ShadowDialog {
1440-
private boolean isShowing = false;
1441-
1442-
public ShadowPresentation() {}
1443-
1444-
@Implementation
1445-
protected void show() {
1446-
isShowing = true;
1447-
}
1448-
1449-
@Implementation
1450-
protected void dismiss() {
1451-
isShowing = false;
1452-
}
1453-
1454-
@Implementation
1455-
protected boolean isShowing() {
1456-
return isShowing;
1457-
}
1458-
}
1459-
14601391
@Implements(FlutterJNI.class)
14611392
public static class ShadowFlutterJNI {
14621393
private static SparseArray<ByteBuffer> replies = new SparseArray<>();

shell/platform/android/test_runner/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ android {
7070
testImplementation "androidx.test:core:1.4.0"
7171
testImplementation "com.google.android.play:core:1.8.0"
7272
testImplementation "com.ibm.icu:icu4j:69.1"
73-
testImplementation "org.robolectric:robolectric:4.8.1"
73+
testImplementation "org.robolectric:robolectric:4.7.3"
7474
testImplementation "junit:junit:4.13.2"
7575
testImplementation "androidx.test.ext:junit:1.1.4-alpha07"
7676

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)