Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.embedding.engine.RenderingComponentTest Class Reference

Public Member Functions

void flutterUiDisplayListenersCanRemoveThemselvesWhenInvoked ()
 
void flutterUiDisplayListenersAddedAfterFirstFrameAreAutomaticallyInvoked ()
 
void flutterUiDisplayListenersAddedAfterFlutterUiDisappearsAreNotInvoked ()
 

Detailed Description

Definition at line 19 of file RenderingComponentTest.java.

Member Function Documentation

◆ flutterUiDisplayListenersAddedAfterFirstFrameAreAutomaticallyInvoked()

void io.flutter.embedding.engine.RenderingComponentTest.flutterUiDisplayListenersAddedAfterFirstFrameAreAutomaticallyInvoked ( )
inline

Definition at line 55 of file RenderingComponentTest.java.

55 {
56 // Setup test.
57 FlutterJNI flutterJNI = new FlutterJNI();
58 FlutterRenderer flutterRenderer = new FlutterRenderer(flutterJNI);
59
60 FlutterUiDisplayListener listener = mock(FlutterUiDisplayListener.class);
61
62 // Pretend we are the native side and tell FlutterJNI that Flutter has rendered a frame.
63 flutterJNI.onFirstFrame();
64
65 // Execute behavior under test.
66 flutterRenderer.addIsDisplayingFlutterUiListener(listener);
67
68 // Verify results.
69 verify(listener, times(1)).onFlutterUiDisplayed();
70 }
static SkISize times(const SkISize &size, float factor)

◆ flutterUiDisplayListenersAddedAfterFlutterUiDisappearsAreNotInvoked()

void io.flutter.embedding.engine.RenderingComponentTest.flutterUiDisplayListenersAddedAfterFlutterUiDisappearsAreNotInvoked ( )
inline

Definition at line 73 of file RenderingComponentTest.java.

73 {
74 // Setup test.
75 FlutterJNI flutterJNI = new FlutterJNI();
76 FlutterRenderer flutterRenderer = new FlutterRenderer(flutterJNI);
77
78 FlutterUiDisplayListener listener = mock(FlutterUiDisplayListener.class);
79
80 // Pretend we are the native side and tell FlutterJNI that Flutter has rendered a frame.
81 flutterJNI.onFirstFrame();
82
83 // Pretend that rendering has stopped.
84 flutterJNI.onRenderingStopped();
85
86 // Execute behavior under test.
87 flutterRenderer.addIsDisplayingFlutterUiListener(listener);
88
89 // Verify results.
90 verify(listener, never()).onFlutterUiDisplayed();
91 }

◆ flutterUiDisplayListenersCanRemoveThemselvesWhenInvoked()

void io.flutter.embedding.engine.RenderingComponentTest.flutterUiDisplayListenersCanRemoveThemselvesWhenInvoked ( )
inline

Definition at line 21 of file RenderingComponentTest.java.

21 {
22 // Setup test.
23 FlutterJNI flutterJNI = new FlutterJNI();
24 FlutterRenderer flutterRenderer = new FlutterRenderer(flutterJNI);
25
26 AtomicInteger listenerInvocationCount = new AtomicInteger(0);
27 FlutterUiDisplayListener listener =
28 new FlutterUiDisplayListener() {
29 @Override
30 public void onFlutterUiDisplayed() {
31 // This is the behavior we're testing, but we also verify that this method
32 // was invoked to ensure that this test behavior executed.
33 flutterRenderer.removeIsDisplayingFlutterUiListener(this);
34
35 // Track the invocation to ensure this method is called once, and only once.
36 listenerInvocationCount.incrementAndGet();
37 }
38
39 @Override
40 public void onFlutterUiNoLongerDisplayed() {}
41 };
42 flutterRenderer.addIsDisplayingFlutterUiListener(listener);
43
44 // Execute behavior under test.
45 // Pretend we are the native side and tell FlutterJNI that Flutter has rendered a frame.
46 flutterJNI.onFirstFrame();
47
48 // Verify results.
49 // If we got to this point without an exception, and if our listener was called one time,
50 // then the behavior under test is correct.
51 assertEquals(1, listenerInvocationCount.get());
52 }

The documentation for this class was generated from the following file: