1402 {
1403 final PlatformViewsController platformViewsController = new PlatformViewsController();
1404
1405 final int platformViewId = 0;
1406 assertNull(platformViewsController.getPlatformViewById(platformViewId));
1407
1408 final PlatformViewFactory viewFactory = mock(PlatformViewFactory.class);
1409 final PlatformView platformView = mock(PlatformView.class);
1410 final View androidView = mock(View.class);
1411 when(platformView.getView()).thenReturn(androidView);
1412 when(viewFactory.create(
any(),
eq(platformViewId),
any())).thenReturn(platformView);
1413
1414 platformViewsController.getRegistry().registerViewFactory("testType", viewFactory);
1415
1416 final FlutterJNI jni = new FlutterJNI();
1417 jni.attachToNative();
1418
1419 final FlutterView flutterView = attach(jni, platformViewsController);
1420
1421 jni.onFirstFrame();
1422
1423
1424 createPlatformView(jni, platformViewsController, platformViewId, "testType", true);
1425
1426
1427
1428 platformViewsController.createOverlaySurface();
1429 platformViewsController.onDisplayOverlaySurface(platformViewId, 0, 0, 10, 10);
1430
1431
1432 assertEquals(flutterView.getChildCount(), 3);
1433
1434 FlutterImageView imageView = flutterView.getCurrentImageSurface();
1435
1436
1437 assertTrue(imageView != null);
1438 assertTrue(flutterView.indexOfChild(imageView) != -1);
1439
1440
1441 assertTrue(platformViewsController.getOverlayLayerViews().size() != 0);
1442 PlatformOverlayView overlayView = platformViewsController.getOverlayLayerViews().get(0);
1443 assertTrue(overlayView != null);
1444 assertTrue(flutterView.indexOfChild(overlayView) != -1);
1445
1446
1447
1448
1449 platformViewsController.onBeginFrame();
1450 platformViewsController.onEndFrame();
1451
1452
1453 jni.onFirstFrame();
1454
1455 assertEquals(null, flutterView.getCurrentImageSurface());
1456
1457
1458 assertTrue(flutterView.indexOfChild(imageView) == -1);
1459
1460
1461 assertTrue(flutterView.indexOfChild(overlayView) == -1);
1462 }