28 {
29
30
31
32
33
34
35
36
37
38
39
40 final FlutterSurfaceView surfaceView =
41 spy(new FlutterSurfaceView(ApplicationProvider.getApplicationContext()));
42
43 FlutterJNI fakeFlutterJNI = mock(FlutterJNI.class);
45
46 SurfaceHolder fakeSurfaceHolder = mock(SurfaceHolder.class);
47 Surface fakeSurface = mock(Surface.class);
48 when(surfaceView.getHolder()).thenReturn(fakeSurfaceHolder);
49 when(fakeSurfaceHolder.getSurface()).thenReturn(fakeSurface);
50 when(surfaceView.isSurfaceAvailableForRendering()).thenReturn(true);
51 when(surfaceView.getWindowToken()).thenReturn(mock(
android.os.IBinder.class));
52
53
54 surfaceView.attachToRenderer(flutterRenderer);
55
56
57 verify(fakeFlutterJNI,
times(1)).onSurfaceCreated(
any(Surface.class));
58
59
60 surfaceView.detachFromRenderer();
61
62
63 verify(fakeFlutterJNI,
times(1)).onSurfaceDestroyed();
64
65
66 surfaceView.attachToRenderer(flutterRenderer);
67
68
69 verify(fakeFlutterJNI, never()).onSurfaceWindowChanged(
any(Surface.class));
70 verify(fakeFlutterJNI,
times(2)).onSurfaceCreated(
any(Surface.class));
71 }
static SkISize times(const SkISize &size, float factor)
SIT bool any(const Vec< 1, T > &x)