1010import android .content .Context ;
1111import android .content .MutableContextWrapper ;
1212import android .content .res .AssetManager ;
13- import android .graphics .Canvas ;
1413import android .graphics .SurfaceTexture ;
1514import android .util .SparseArray ;
1615import android .view .MotionEvent ;
5453import org .robolectric .annotation .Config ;
5554import org .robolectric .annotation .Implementation ;
5655import org .robolectric .annotation .Implements ;
57- import org .robolectric .shadows .ShadowSurface ;
5856import 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 <>();
0 commit comments