7
7
import static org .mockito .Mockito .*;
8
8
import static org .robolectric .Shadows .shadowOf ;
9
9
10
- import android .app .Presentation ;
11
10
import android .content .Context ;
12
11
import android .content .MutableContextWrapper ;
13
12
import android .content .res .AssetManager ;
14
- import android .graphics .Canvas ;
15
13
import android .graphics .SurfaceTexture ;
16
14
import android .util .SparseArray ;
17
15
import android .view .MotionEvent ;
55
53
import org .robolectric .annotation .Config ;
56
54
import org .robolectric .annotation .Implementation ;
57
55
import org .robolectric .annotation .Implements ;
58
- import org .robolectric .shadows .ShadowDialog ;
59
- import org .robolectric .shadows .ShadowSurface ;
60
56
import org .robolectric .shadows .ShadowSurfaceView ;
61
57
62
58
@ Config (manifest = Config .NONE )
@@ -509,8 +505,7 @@ public void createHybridPlatformViewMessage_throwsIfViewIsNull() {
509
505
}
510
506
511
507
@ Test
512
- @ Config (
513
- shadows = {ShadowFlutterJNI .class , ShadowPlatformTaskQueue .class , ShadowPresentation .class })
508
+ @ Config (shadows = {ShadowFlutterJNI .class , ShadowPlatformTaskQueue .class })
514
509
public void onDetachedFromJNI_clearsPlatformViewContext () {
515
510
PlatformViewsController platformViewsController = new PlatformViewsController ();
516
511
@@ -541,8 +536,7 @@ public void onDetachedFromJNI_clearsPlatformViewContext() {
541
536
}
542
537
543
538
@ Test
544
- @ Config (
545
- shadows = {ShadowFlutterJNI .class , ShadowPlatformTaskQueue .class , ShadowPresentation .class })
539
+ @ Config (shadows = {ShadowFlutterJNI .class , ShadowPlatformTaskQueue .class })
546
540
public void onPreEngineRestart_clearsPlatformViewContext () {
547
541
PlatformViewsController platformViewsController = new PlatformViewsController ();
548
542
@@ -746,12 +740,7 @@ public void disposeAndroidView_hybridComposition() {
746
740
}
747
741
748
742
@ Test
749
- @ Config (
750
- shadows = {
751
- ShadowFlutterJNI .class ,
752
- ShadowReleasedSurface .class ,
753
- ShadowPlatformTaskQueue .class
754
- })
743
+ @ Config (shadows = {ShadowFlutterJNI .class , ShadowPlatformTaskQueue .class })
755
744
public void disposeNullAndroidView () {
756
745
PlatformViewsController platformViewsController = new PlatformViewsController ();
757
746
@@ -771,20 +760,6 @@ public void disposeNullAndroidView() {
771
760
attach (jni , platformViewsController );
772
761
773
762
// 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.
788
763
createPlatformView (
789
764
jni , platformViewsController , platformViewId , "testType" , /* hybrid=*/ false );
790
765
platformViewsController .initializePlatformViewIfNeeded (platformViewId );
@@ -1413,50 +1388,6 @@ public void dispatch(Runnable runnable) {
1413
1388
}
1414
1389
}
1415
1390
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
-
1460
1391
@ Implements (FlutterJNI .class )
1461
1392
public static class ShadowFlutterJNI {
1462
1393
private static SparseArray <ByteBuffer > replies = new SparseArray <>();
0 commit comments