Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
io.flutter.view.VsyncWaiterTest Class Reference

Public Member Functions

void setUp ()
 
void itSetsFpsBelowApi17 ()
 
void itSetsFpsWhenDisplayManagerUpdates ()
 
void itSetsFpsWhenDisplayManagerDoesNotUpdate ()
 

Detailed Description

Definition at line 30 of file VsyncWaiterTest.java.

Member Function Documentation

◆ itSetsFpsBelowApi17()

void io.flutter.view.VsyncWaiterTest.itSetsFpsBelowApi17 ( )
inline

Definition at line 37 of file VsyncWaiterTest.java.

37 {
38 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
39 VsyncWaiter waiter = VsyncWaiter.getInstance(10.0f, mockFlutterJNI);
40 verify(mockFlutterJNI, times(1)).setRefreshRateFPS(10.0f);
41
42 waiter.init();
43
44 ArgumentCaptor<FlutterJNI.AsyncWaitForVsyncDelegate> delegateCaptor =
45 ArgumentCaptor.forClass(FlutterJNI.AsyncWaitForVsyncDelegate.class);
46 verify(mockFlutterJNI, times(1)).setAsyncWaitForVsyncDelegate(delegateCaptor.capture());
47 delegateCaptor.getValue().asyncWaitForVsync(1);
48 shadowOf(Looper.getMainLooper()).idle();
49 verify(mockFlutterJNI, times(1)).onVsync(anyLong(), eq(1000000000l / 10l), eq(1l));
50 }
static SkISize times(const SkISize &size, float factor)
static bool eq(const SkM44 &a, const SkM44 &b, float tol)
Definition M44Test.cpp:18

◆ itSetsFpsWhenDisplayManagerDoesNotUpdate()

void io.flutter.view.VsyncWaiterTest.itSetsFpsWhenDisplayManagerDoesNotUpdate ( )
inline

Definition at line 88 of file VsyncWaiterTest.java.

88 {
89 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
90 DisplayManager mockDisplayManager = mock(DisplayManager.class);
91 Display mockDisplay = mock(Display.class);
92 when(mockDisplayManager.getDisplay(Display.DEFAULT_DISPLAY)).thenReturn(mockDisplay);
93 when(mockDisplay.getRefreshRate()).thenReturn(90.0f);
94
95 VsyncWaiter waiter = VsyncWaiter.getInstance(mockDisplayManager, mockFlutterJNI);
96 verify(mockDisplayManager, times(1)).registerDisplayListener(any(), isNull());
97
98 verify(mockFlutterJNI, times(1)).setRefreshRateFPS(90.0f);
99 }
SIT bool any(const Vec< 1, T > &x)
Definition SkVx.h:530

◆ itSetsFpsWhenDisplayManagerUpdates()

void io.flutter.view.VsyncWaiterTest.itSetsFpsWhenDisplayManagerUpdates ( )
inline

Definition at line 53 of file VsyncWaiterTest.java.

53 {
54 FlutterJNI mockFlutterJNI = mock(FlutterJNI.class);
55 DisplayManager mockDisplayManager = mock(DisplayManager.class);
56 Display mockDisplay = mock(Display.class);
57 ArgumentCaptor<VsyncWaiter.DisplayListener> displayListenerCaptor =
58 ArgumentCaptor.forClass(VsyncWaiter.DisplayListener.class);
59 when(mockDisplayManager.getDisplay(Display.DEFAULT_DISPLAY)).thenReturn(mockDisplay);
60
61 VsyncWaiter waiter = VsyncWaiter.getInstance(mockDisplayManager, mockFlutterJNI);
62 verify(mockDisplayManager, times(1))
63 .registerDisplayListener(displayListenerCaptor.capture(), isNull());
64
65 when(mockDisplay.getRefreshRate()).thenReturn(90.0f);
66 displayListenerCaptor.getValue().onDisplayChanged(Display.DEFAULT_DISPLAY);
67 verify(mockFlutterJNI, times(1)).setRefreshRateFPS(90.0f);
68
69 waiter.init();
70
71 ArgumentCaptor<FlutterJNI.AsyncWaitForVsyncDelegate> delegateCaptor =
72 ArgumentCaptor.forClass(FlutterJNI.AsyncWaitForVsyncDelegate.class);
73 verify(mockFlutterJNI, times(1)).setAsyncWaitForVsyncDelegate(delegateCaptor.capture());
74 delegateCaptor.getValue().asyncWaitForVsync(1);
75 shadowOf(Looper.getMainLooper()).idle();
76 verify(mockFlutterJNI, times(1)).onVsync(anyLong(), eq(1000000000l / 90l), eq(1l));
77
78 when(mockDisplay.getRefreshRate()).thenReturn(60.0f);
79 displayListenerCaptor.getValue().onDisplayChanged(Display.DEFAULT_DISPLAY);
80 verify(mockFlutterJNI, times(1)).setRefreshRateFPS(60.0f);
81
82 delegateCaptor.getValue().asyncWaitForVsync(1);
83 shadowOf(Looper.getMainLooper()).idle();
84 verify(mockFlutterJNI, times(1)).onVsync(anyLong(), eq(1000000000l / 60l), eq(1l));
85 }

◆ setUp()

void io.flutter.view.VsyncWaiterTest.setUp ( )
inline

Definition at line 32 of file VsyncWaiterTest.java.

32 {
33 VsyncWaiter.reset();
34 }

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