1368 {
1369 final PlatformViewsController platformViewsController = new PlatformViewsController();
1370
1371 final int platformViewId = 0;
1372 assertNull(platformViewsController.getPlatformViewById(platformViewId));
1373
1374 final PlatformViewFactory viewFactory = mock(PlatformViewFactory.class);
1375 final PlatformView platformView = mock(PlatformView.class);
1376 final View androidView = mock(View.class);
1377 when(platformView.getView()).thenReturn(androidView);
1378 when(viewFactory.create(
any(),
eq(platformViewId),
any())).thenReturn(platformView);
1379
1380 platformViewsController.getRegistry().registerViewFactory("testType", viewFactory);
1381
1382 final FlutterJNI jni = new FlutterJNI();
1383 jni.attachToNative();
1384
1385 final FlutterView flutterView = attach(jni, platformViewsController);
1386
1387 jni.onFirstFrame();
1388
1389
1390 createPlatformView(jni, platformViewsController, platformViewId, "testType", true);
1391
1392
1393
1394 platformViewsController.createOverlaySurface();
1395 platformViewsController.onDisplayOverlaySurface(platformViewId, 0, 0, 10, 10);
1396
1397
1398 assertEquals(flutterView.getChildCount(), 3);
1399
1400 FlutterImageView imageView = flutterView.getCurrentImageSurface();
1401
1402
1403 assertTrue(imageView != null);
1404 assertTrue(flutterView.indexOfChild(imageView) != -1);
1405
1406
1407 assertTrue(platformViewsController.getOverlayLayerViews().size() != 0);
1408 PlatformOverlayView overlayView = platformViewsController.getOverlayLayerViews().get(0);
1409 assertTrue(overlayView != null);
1410 assertTrue(flutterView.indexOfChild(overlayView) != -1);
1411
1412
1413
1414
1415 platformViewsController.onBeginFrame();
1416 platformViewsController.onEndFrame();
1417
1418
1419 jni.onFirstFrame();
1420
1421 assertEquals(null, flutterView.getCurrentImageSurface());
1422
1423
1424 assertTrue(flutterView.indexOfChild(imageView) == -1);
1425
1426
1427 assertTrue(flutterView.indexOfChild(overlayView) == -1);
1428 }