Flutter Engine
flutter_runner_test Namespace Reference

Classes

class  AccessibilityBridgeTest
 
class  AccessibilityBridgeTestDelegate
 
class  FlutterRunnerProductConfigurationTest
 
class  MockSemanticsManager
 
class  SessionConnectionTest
 
class  VsyncWaiterTest
 

Functions

 TEST_F (AccessibilityBridgeTest, RegistersViewRef)
 
 TEST_F (AccessibilityBridgeTest, EnableDisable)
 
 TEST_F (AccessibilityBridgeTest, UpdatesNodeRoles)
 
 TEST_F (AccessibilityBridgeTest, DeletesChildrenTransitively)
 
 TEST_F (AccessibilityBridgeTest, PopulatesRoleButton)
 
 TEST_F (AccessibilityBridgeTest, PopulatesRoleImage)
 
 TEST_F (AccessibilityBridgeTest, PopulatesRoleSlider)
 
 TEST_F (AccessibilityBridgeTest, PopulatesRoleHeader)
 
 TEST_F (AccessibilityBridgeTest, PopulatesCheckedState)
 
 TEST_F (AccessibilityBridgeTest, PopulatesSelectedState)
 
 TEST_F (AccessibilityBridgeTest, ApplyViewPixelRatioToRoot)
 
 TEST_F (AccessibilityBridgeTest, DoesNotPopulatesHiddenState)
 
 TEST_F (AccessibilityBridgeTest, PopulatesActions)
 
 TEST_F (AccessibilityBridgeTest, TruncatesLargeLabel)
 
 TEST_F (AccessibilityBridgeTest, TruncatesLargeValue)
 
 TEST_F (AccessibilityBridgeTest, SplitsLargeUpdates)
 
 TEST_F (AccessibilityBridgeTest, HandlesCycles)
 
 TEST_F (AccessibilityBridgeTest, BatchesLargeMessages)
 
 TEST_F (AccessibilityBridgeTest, HitTest)
 
 TEST_F (AccessibilityBridgeTest, HitTestOverlapping)
 
 TEST_F (AccessibilityBridgeTest, Actions)
 
 TEST_F (FlutterRunnerProductConfigurationTest, ValidVsyncOffset)
 
 TEST_F (FlutterRunnerProductConfigurationTest, InvalidJsonString)
 
 TEST_F (FlutterRunnerProductConfigurationTest, EmptyJsonString)
 
 TEST_F (FlutterRunnerProductConfigurationTest, EmptyVsyncOffset)
 
 TEST_F (FlutterRunnerProductConfigurationTest, NegativeVsyncOffset)
 
 TEST_F (FlutterRunnerProductConfigurationTest, NonIntegerVsyncOffset)
 
 TEST_F (FlutterRunnerProductConfigurationTest, ValidMaxFramesInFlight)
 
 TEST_F (FlutterRunnerProductConfigurationTest, MissingMaxFramesInFlight)
 
 TEST_F (FlutterRunnerProductConfigurationTest, ValidInterceptAllInput)
 
 TEST_F (FlutterRunnerProductConfigurationTest, MissingInterceptAllInput)
 
 TEST_F (SessionConnectionTest, SimplePresentTest)
 
 TEST_F (SessionConnectionTest, BatchedPresentTest)
 
static fml::TimePoint TimePointFromInt (int i)
 
static fml::TimeDelta TimeDeltaFromInt (int i)
 
static int TimePointToInt (fml::TimePoint time)
 
 TEST (CalculateNextLatchPointTest, PresentAsSoonAsPossible)
 
 TEST (CalculateNextLatchPointTest, LongFrameBuildTime)
 
 TEST (CalculateNextLatchPointTest, DelayedPresentRequestWithLongFrameBuildTime)
 
 TEST (CalculateNextLatchPointTest, LastLastPointTargetedLate)
 
 TEST (CalculateNextLatchPointTest, SteadyState_OnTimeFrames)
 
 TEST (CalculateNextLatchPointTest, SteadyState_LongFrameBuildTimes)
 
 TEST (CalculateNextLatchPointTest, SteadyState_LateLastLatchPointTargeted)
 
 TEST (CalculateNextLatchPointTest, SteadyState_DelayedPresentRequestWithLongFrameBuildTime)
 
 TEST (CalculateNextLatchPointTest, SteadyState_FuzzyLatchPointsBeforeTarget)
 
 TEST (CalculateNextLatchPointTest, SteadyState_FuzzyLatchPointsAfterTarget)
 
static fuchsia::scenic::scheduling::PresentationInfo CreatePresentationInfo (zx_time_t latch_point, zx_time_t presentation_time)
 
 TEST (VsyncRecorderTest, DefaultVsyncInfoValues_AreReasonable)
 
 TEST (VsyncRecorderTest, DefaultLastPresentationTime_IsReasonable)
 
 TEST (VsyncRecorderTest, SinglePresentationInfo_IsUpdatedCorrectly)
 
 TEST (VsyncRecorderTest, MultiplePresentationInfos_AreUpdatedCorrectly)
 
 TEST (VsyncRecorderTest, FramePresentedInfo_IsUpdatedCorrectly)
 
 TEST_F (VsyncWaiterTest, AwaitVsync)
 
 TEST_F (VsyncWaiterTest, SnapToNextPhaseOverlapsWithNow)
 
 TEST_F (VsyncWaiterTest, SnapToNextPhaseAfterNow)
 
 TEST_F (VsyncWaiterTest, SnapToNextPhaseAfterNowMultiJump)
 
 TEST_F (VsyncWaiterTest, SnapToNextPhaseAfterNowMultiJumpAccountForCeils)
 

Function Documentation

◆ CreatePresentationInfo()

static fuchsia::scenic::scheduling::PresentationInfo flutter_runner_test::CreatePresentationInfo ( zx_time_t  latch_point,
zx_time_t  presentation_time 
)
static

Definition at line 20 of file vsync_recorder_unittests.cc.

Referenced by TEST().

22  {
23  fuchsia::scenic::scheduling::PresentationInfo info;
24 
25  info.set_latch_point(latch_point);
26  info.set_presentation_time(presentation_time);
27  return info;
28 }

◆ TEST() [1/15]

flutter_runner_test::TEST ( VsyncRecorderTest  ,
DefaultVsyncInfoValues_AreReasonable   
)

Definition at line 33 of file vsync_recorder_unittests.cc.

References fml::TimePoint::FromEpochDelta(), fml::TimeDelta::FromMilliseconds(), fml::TimeDelta::FromNanoseconds(), flutter_runner::VsyncRecorder::GetCurrentVsyncInfo(), flutter_runner::VsyncRecorder::GetInstance(), flutter_runner::VsyncInfo::presentation_interval, and flutter_runner::VsyncInfo::presentation_time.

33  {
34  VsyncInfo vsync_info = VsyncRecorder::GetInstance().GetCurrentVsyncInfo();
35 
36  EXPECT_GE(vsync_info.presentation_time,
38 
39  EXPECT_GE(vsync_info.presentation_interval,
41 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
fml::TimeDelta presentation_interval
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition: time_point.h:36
fml::TimePoint presentation_time
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition: time_delta.h:46

◆ TEST() [2/15]

flutter_runner_test::TEST ( VsyncRecorderTest  ,
DefaultLastPresentationTime_IsReasonable   
)

Definition at line 43 of file vsync_recorder_unittests.cc.

References flutter_runner::VsyncRecorder::GetInstance(), flutter_runner::VsyncRecorder::GetLastPresentationTime(), and fml::TimePoint::Now().

43  {
44  fml::TimePoint last_presentation_time =
45  VsyncRecorder::GetInstance().GetLastPresentationTime();
46 
47  EXPECT_LE(last_presentation_time, fml::TimePoint::Now());
48 }
static TimePoint Now()
Definition: time_point.cc:26

◆ TEST() [3/15]

flutter_runner_test::TEST ( VsyncRecorderTest  ,
SinglePresentationInfo_IsUpdatedCorrectly   
)

Definition at line 50 of file vsync_recorder_unittests.cc.

References CreatePresentationInfo(), fml::TimePoint::FromEpochDelta(), fml::TimeDelta::FromMilliseconds(), fml::TimeDelta::FromNanoseconds(), flutter_runner::VsyncRecorder::GetCurrentVsyncInfo(), flutter_runner::VsyncRecorder::GetInstance(), flutter_runner::VsyncInfo::presentation_interval, flutter_runner::VsyncInfo::presentation_time, and flutter_runner::VsyncRecorder::UpdateNextPresentationInfo().

50  {
51  std::vector<fuchsia::scenic::scheduling::PresentationInfo>
52  future_presentations = {};
53 
54  // Update the |vsync_info|.
55  future_presentations.push_back(
56  CreatePresentationInfo(/*latch_point=*/5, /*presentation_time=*/10));
57  VsyncRecorder::GetInstance().UpdateNextPresentationInfo(
58  {.future_presentations = std::move(future_presentations),
59  .remaining_presents_in_flight_allowed = 1});
60 
61  // Check that |vsync_info| was correctly updated.
62  VsyncInfo vsync_info = VsyncRecorder::GetInstance().GetCurrentVsyncInfo();
63  EXPECT_EQ(
64  vsync_info.presentation_time,
66 
67  EXPECT_GE(vsync_info.presentation_interval,
69 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
fml::TimeDelta presentation_interval
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition: time_point.h:36
fml::TimePoint presentation_time
static fuchsia::scenic::scheduling::PresentationInfo CreatePresentationInfo(zx_time_t latch_point, zx_time_t presentation_time)
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition: time_delta.h:46

◆ TEST() [4/15]

flutter_runner_test::TEST ( VsyncRecorderTest  ,
MultiplePresentationInfos_AreUpdatedCorrectly   
)

Definition at line 71 of file vsync_recorder_unittests.cc.

References CreatePresentationInfo(), fml::TimePoint::FromEpochDelta(), fml::TimeDelta::FromMilliseconds(), fml::TimeDelta::FromNanoseconds(), flutter_runner::VsyncRecorder::GetCurrentVsyncInfo(), flutter_runner::VsyncRecorder::GetInstance(), flutter_runner::VsyncInfo::presentation_interval, flutter_runner::VsyncInfo::presentation_time, and flutter_runner::VsyncRecorder::UpdateNextPresentationInfo().

71  {
72  std::vector<fuchsia::scenic::scheduling::PresentationInfo>
73  future_presentations = {};
74 
75  // Update the |vsync_info|.
76  future_presentations.push_back(
77  CreatePresentationInfo(/*latch_point=*/15, /*presentation_time=*/20));
78  future_presentations.push_back(
79  CreatePresentationInfo(/*latch_point=*/25, /*presentation_time=*/30));
80  VsyncRecorder::GetInstance().UpdateNextPresentationInfo(
81  {.future_presentations = std::move(future_presentations),
82  .remaining_presents_in_flight_allowed = 1});
83 
84  // Check that |vsync_info| was correctly updated with the first time.
85  VsyncInfo vsync_info = VsyncRecorder::GetInstance().GetCurrentVsyncInfo();
86  EXPECT_EQ(
87  vsync_info.presentation_time,
89  EXPECT_GE(vsync_info.presentation_interval,
91 
92  // Clear and re-try with more future times!
93  future_presentations.clear();
94  future_presentations.push_back(
95  CreatePresentationInfo(/*latch_point=*/15, /*presentation_time=*/20));
96  future_presentations.push_back(
97  CreatePresentationInfo(/*latch_point=*/25, /*presentation_time=*/30));
98  future_presentations.push_back(
99  CreatePresentationInfo(/*latch_point=*/35, /*presentation_time=*/40));
100  future_presentations.push_back(
101  CreatePresentationInfo(/*latch_point=*/45, /*presentation_time=*/50));
102  VsyncRecorder::GetInstance().UpdateNextPresentationInfo(
103  {.future_presentations = std::move(future_presentations),
104  .remaining_presents_in_flight_allowed = 1});
105 
106  // Check that |vsync_info| was correctly updated with the first time.
107  vsync_info = VsyncRecorder::GetInstance().GetCurrentVsyncInfo();
108  EXPECT_EQ(
109  vsync_info.presentation_time,
111  EXPECT_GE(vsync_info.presentation_interval,
113 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
fml::TimeDelta presentation_interval
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition: time_point.h:36
fml::TimePoint presentation_time
static fuchsia::scenic::scheduling::PresentationInfo CreatePresentationInfo(zx_time_t latch_point, zx_time_t presentation_time)
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition: time_delta.h:46

◆ TEST() [5/15]

flutter_runner_test::TEST ( VsyncRecorderTest  ,
FramePresentedInfo_IsUpdatedCorrectly   
)

Definition at line 115 of file vsync_recorder_unittests.cc.

References fml::TimePoint::FromEpochDelta(), fml::TimeDelta::FromNanoseconds(), flutter_runner::VsyncRecorder::GetInstance(), and flutter_runner::VsyncRecorder::UpdateFramePresentedInfo().

115  {
116  int64_t time1 = 10;
117  int64_t time2 = 30;
118  int64_t time3 = 35;
119 
120  VsyncRecorder::GetInstance().UpdateFramePresentedInfo(zx::time(time1));
121 
122  EXPECT_EQ(
123  VsyncRecorder::GetInstance().GetLastPresentationTime(),
125 
126  VsyncRecorder::GetInstance().UpdateFramePresentedInfo(zx::time(time2));
127  VsyncRecorder::GetInstance().UpdateFramePresentedInfo(zx::time(time3));
128 
129  EXPECT_EQ(
130  VsyncRecorder::GetInstance().GetLastPresentationTime(),
132 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition: time_point.h:36

◆ TEST() [6/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
PresentAsSoonAsPossible   
)

Definition at line 120 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

120  {
121  fml::TimePoint present_requested_time = TimePointFromInt(0);
123  fml::TimePoint last_latch_point_targeted = TimePointFromInt(0);
124  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(0);
125  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
126  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
127  future_presentation_infos = {};
128 
129  // Assertions about given values.
130  EXPECT_GE(now, present_requested_time);
131  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
132  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
133 
134  fml::TimePoint calculated_latch_point =
135  SessionConnection::CalculateNextLatchPoint(
136  present_requested_time, now, last_latch_point_targeted,
137  flutter_frame_build_time, vsync_interval, future_presentation_infos);
138 
139  EXPECT_GE(TimePointToInt(calculated_latch_point), TimePointToInt(now));
140  EXPECT_LE(TimePointToInt(calculated_latch_point),
141  TimePointToInt(now + vsync_interval));
142 
143  EXPECT_GE(TimePointToInt(calculated_latch_point),
144  TimePointToInt(present_requested_time + flutter_frame_build_time));
145  EXPECT_GE(TimePointToInt(calculated_latch_point),
146  TimePointToInt(last_latch_point_targeted));
147 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [7/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
LongFrameBuildTime   
)

Definition at line 149 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

149  {
150  fml::TimePoint present_requested_time = TimePointFromInt(500);
151  fml::TimePoint now = TimePointFromInt(600);
152  fml::TimePoint last_latch_point_targeted = TimePointFromInt(0);
153  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(2500);
154  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
155  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
156  future_presentation_infos = {};
157 
158  // Assertions about given values.
159  EXPECT_GE(now, present_requested_time);
160  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
161  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
162 
163  EXPECT_GT(flutter_frame_build_time, vsync_interval);
164 
165  fml::TimePoint calculated_latch_point =
166  SessionConnection::CalculateNextLatchPoint(
167  present_requested_time, now, last_latch_point_targeted,
168  flutter_frame_build_time, vsync_interval, future_presentation_infos);
169 
170  EXPECT_GE(TimePointToInt(calculated_latch_point),
171  TimePointToInt(now + (vsync_interval * 2)));
172  EXPECT_LE(TimePointToInt(calculated_latch_point),
173  TimePointToInt(now + (vsync_interval * 3)));
174 
175  EXPECT_GE(TimePointToInt(calculated_latch_point),
176  TimePointToInt(present_requested_time + flutter_frame_build_time));
177  EXPECT_GE(TimePointToInt(calculated_latch_point),
178  TimePointToInt(last_latch_point_targeted));
179 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [8/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
DelayedPresentRequestWithLongFrameBuildTime   
)

Definition at line 181 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

181  {
182  fml::TimePoint present_requested_time = TimePointFromInt(0);
183  fml::TimePoint now = TimePointFromInt(1500);
184  fml::TimePoint last_latch_point_targeted = TimePointFromInt(0);
185  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(2000);
186  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
187  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
188  future_presentation_infos = {};
189 
190  // Assertions about given values.
191  EXPECT_GE(now, present_requested_time);
192  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
193  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
194 
195  EXPECT_GT(flutter_frame_build_time, vsync_interval);
196  EXPECT_GT(now, present_requested_time + vsync_interval);
197 
198  fml::TimePoint calculated_latch_point =
199  SessionConnection::CalculateNextLatchPoint(
200  present_requested_time, now, last_latch_point_targeted,
201  flutter_frame_build_time, vsync_interval, future_presentation_infos);
202 
203  EXPECT_GE(TimePointToInt(calculated_latch_point), TimePointToInt(now));
204  EXPECT_LE(TimePointToInt(calculated_latch_point),
205  TimePointToInt(now + vsync_interval));
206 
207  EXPECT_GE(TimePointToInt(calculated_latch_point),
208  TimePointToInt(present_requested_time + flutter_frame_build_time));
209  EXPECT_GE(TimePointToInt(calculated_latch_point),
210  TimePointToInt(last_latch_point_targeted));
211 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [9/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
LastLastPointTargetedLate   
)

Definition at line 213 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

213  {
214  fml::TimePoint present_requested_time = TimePointFromInt(2000);
215  fml::TimePoint now = TimePointFromInt(2000);
216  fml::TimePoint last_latch_point_targeted = TimePointFromInt(2600);
217  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
218  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
219  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
220  future_presentation_infos = {};
221 
222  // Assertions about given values.
223  EXPECT_GE(now, present_requested_time);
224  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
225  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
226 
227  EXPECT_GT(last_latch_point_targeted, present_requested_time);
228 
229  fml::TimePoint calculated_latch_point =
230  SessionConnection::CalculateNextLatchPoint(
231  present_requested_time, now, last_latch_point_targeted,
232  flutter_frame_build_time, vsync_interval, future_presentation_infos);
233 
234  EXPECT_GE(TimePointToInt(calculated_latch_point),
235  TimePointToInt(now + vsync_interval));
236  EXPECT_LE(TimePointToInt(calculated_latch_point),
237  TimePointToInt(now + (vsync_interval * 2)));
238 
239  EXPECT_GE(TimePointToInt(calculated_latch_point),
240  TimePointToInt(present_requested_time + flutter_frame_build_time));
241  EXPECT_GE(TimePointToInt(calculated_latch_point),
242  TimePointToInt(last_latch_point_targeted));
243 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [10/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
SteadyState_OnTimeFrames   
)

Definition at line 249 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

249  {
250  fml::TimePoint present_requested_time = TimePointFromInt(5000);
251  fml::TimePoint now = TimePointFromInt(5000);
252  fml::TimePoint last_latch_point_targeted = TimePointFromInt(4500);
253  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
254  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
255  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
256  future_presentation_infos = {
257  {TimePointFromInt(3500), TimePointFromInt(4000)},
258  {TimePointFromInt(4500), TimePointFromInt(5000)},
259  {TimePointFromInt(5500), TimePointFromInt(6000)},
260  {TimePointFromInt(6500), TimePointFromInt(7000)},
261  {TimePointFromInt(7500), TimePointFromInt(8000)},
262  };
263 
264  // Assertions about given values.
265  EXPECT_GE(now, present_requested_time);
266  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
267  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
268 
269  fml::TimePoint calculated_latch_point =
270  SessionConnection::CalculateNextLatchPoint(
271  present_requested_time, now, last_latch_point_targeted,
272  flutter_frame_build_time, vsync_interval, future_presentation_infos);
273 
274  EXPECT_GE(TimePointToInt(calculated_latch_point),
275  TimePointToInt(now + vsync_interval));
276  EXPECT_LE(TimePointToInt(calculated_latch_point),
277  TimePointToInt(now + (vsync_interval * 2)));
278  EXPECT_EQ(TimePointToInt(calculated_latch_point), 6500);
279 
280  EXPECT_GE(TimePointToInt(calculated_latch_point),
281  TimePointToInt(present_requested_time + flutter_frame_build_time));
282  EXPECT_GE(TimePointToInt(calculated_latch_point),
283  TimePointToInt(last_latch_point_targeted));
284 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [11/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
SteadyState_LongFrameBuildTimes   
)

Definition at line 286 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

286  {
287  fml::TimePoint present_requested_time = TimePointFromInt(5000);
288  fml::TimePoint now = TimePointFromInt(5000);
289  fml::TimePoint last_latch_point_targeted = TimePointFromInt(4500);
290  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(2000);
291  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
292  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
293  future_presentation_infos = {
294  {TimePointFromInt(3500), TimePointFromInt(4000)},
295  {TimePointFromInt(4500), TimePointFromInt(5000)},
296  {TimePointFromInt(5500), TimePointFromInt(6000)},
297  {TimePointFromInt(6500), TimePointFromInt(7000)},
298  {TimePointFromInt(7500), TimePointFromInt(8000)},
299  };
300 
301  // Assertions about given values.
302  EXPECT_GE(now, present_requested_time);
303  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
304  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
305 
306  EXPECT_GT(flutter_frame_build_time, vsync_interval);
307 
308  fml::TimePoint calculated_latch_point =
309  SessionConnection::CalculateNextLatchPoint(
310  present_requested_time, now, last_latch_point_targeted,
311  flutter_frame_build_time, vsync_interval, future_presentation_infos);
312 
313  EXPECT_GE(TimePointToInt(calculated_latch_point),
314  TimePointToInt(now + (vsync_interval * 2)));
315  EXPECT_LE(TimePointToInt(calculated_latch_point),
316  TimePointToInt(now + (vsync_interval * 3)));
317  EXPECT_EQ(TimePointToInt(calculated_latch_point), 7500);
318 
319  EXPECT_GE(TimePointToInt(calculated_latch_point),
320  TimePointToInt(present_requested_time + flutter_frame_build_time));
321  EXPECT_GE(TimePointToInt(calculated_latch_point),
322  TimePointToInt(last_latch_point_targeted));
323 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [12/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
SteadyState_LateLastLatchPointTargeted   
)

Definition at line 325 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

325  {
326  fml::TimePoint present_requested_time = TimePointFromInt(5000);
327  fml::TimePoint now = TimePointFromInt(5000);
328  fml::TimePoint last_latch_point_targeted = TimePointFromInt(6500);
329  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
330  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
331  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
332  future_presentation_infos = {
333  {TimePointFromInt(4500), TimePointFromInt(5000)},
334  {TimePointFromInt(5500), TimePointFromInt(6000)},
335  {TimePointFromInt(6500), TimePointFromInt(7000)},
336  {TimePointFromInt(7500), TimePointFromInt(8000)},
337  {TimePointFromInt(8500), TimePointFromInt(9000)},
338  };
339 
340  // Assertions about given values.
341  EXPECT_GE(now, present_requested_time);
342  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
343  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
344 
345  EXPECT_GT(last_latch_point_targeted, now + vsync_interval);
346 
347  fml::TimePoint calculated_latch_point =
348  SessionConnection::CalculateNextLatchPoint(
349  present_requested_time, now, last_latch_point_targeted,
350  flutter_frame_build_time, vsync_interval, future_presentation_infos);
351 
352  EXPECT_GE(TimePointToInt(calculated_latch_point),
353  TimePointToInt(now + vsync_interval));
354  EXPECT_LE(TimePointToInt(calculated_latch_point),
355  TimePointToInt(now + (vsync_interval * 2)));
356  EXPECT_EQ(TimePointToInt(calculated_latch_point), 6500);
357 
358  EXPECT_GE(TimePointToInt(calculated_latch_point),
359  TimePointToInt(present_requested_time + flutter_frame_build_time));
360  EXPECT_GE(TimePointToInt(calculated_latch_point),
361  TimePointToInt(last_latch_point_targeted));
362 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [13/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
SteadyState_DelayedPresentRequestWithLongFrameBuildTime   
)

Definition at line 364 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

365  {
366  fml::TimePoint present_requested_time = TimePointFromInt(4000);
367  fml::TimePoint now = TimePointFromInt(5500);
368  fml::TimePoint last_latch_point_targeted = TimePointFromInt(3500);
369  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(2000);
370  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
371  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
372  future_presentation_infos = {
373  {TimePointFromInt(4500), TimePointFromInt(5000)},
374  {TimePointFromInt(5500), TimePointFromInt(6000)},
375  {TimePointFromInt(6500), TimePointFromInt(7000)},
376  };
377 
378  // Assertions about given values.
379  EXPECT_GE(now, present_requested_time);
380  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
381  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
382 
383  EXPECT_GT(flutter_frame_build_time, vsync_interval);
384  EXPECT_GT(now, present_requested_time + vsync_interval);
385 
386  fml::TimePoint calculated_latch_point =
387  SessionConnection::CalculateNextLatchPoint(
388  present_requested_time, now, last_latch_point_targeted,
389  flutter_frame_build_time, vsync_interval, future_presentation_infos);
390 
391  EXPECT_GE(TimePointToInt(calculated_latch_point),
392  TimePointToInt(now + vsync_interval));
393  EXPECT_LE(TimePointToInt(calculated_latch_point),
394  TimePointToInt(now + (vsync_interval * 2)));
395  EXPECT_EQ(TimePointToInt(calculated_latch_point), 6500);
396 
397  EXPECT_GE(TimePointToInt(calculated_latch_point),
398  TimePointToInt(present_requested_time + flutter_frame_build_time));
399  EXPECT_GE(TimePointToInt(calculated_latch_point),
400  TimePointToInt(last_latch_point_targeted));
401 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [14/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
SteadyState_FuzzyLatchPointsBeforeTarget   
)

Definition at line 403 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

403  {
404  fml::TimePoint present_requested_time = TimePointFromInt(4000);
405  fml::TimePoint now = TimePointFromInt(4000);
406  fml::TimePoint last_latch_point_targeted = TimePointFromInt(5490);
407  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
408  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
409  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
410  future_presentation_infos = {
411  {TimePointFromInt(4510), TimePointFromInt(5000)},
412  {TimePointFromInt(5557), TimePointFromInt(6000)},
413  {TimePointFromInt(6482), TimePointFromInt(7000)},
414  {TimePointFromInt(7356), TimePointFromInt(8000)},
415  };
416 
417  // Assertions about given values.
418  EXPECT_GE(now, present_requested_time);
419  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
420  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
421 
422  fml::TimePoint calculated_latch_point =
423  SessionConnection::CalculateNextLatchPoint(
424  present_requested_time, now, last_latch_point_targeted,
425  flutter_frame_build_time, vsync_interval, future_presentation_infos);
426 
427  EXPECT_GE(TimePointToInt(calculated_latch_point),
428  TimePointToInt(now + vsync_interval));
429  EXPECT_LE(TimePointToInt(calculated_latch_point),
430  TimePointToInt(now + (vsync_interval * 2)));
431  EXPECT_EQ(TimePointToInt(calculated_latch_point), 5557);
432 
433  EXPECT_GE(TimePointToInt(calculated_latch_point),
434  TimePointToInt(present_requested_time + flutter_frame_build_time));
435  EXPECT_GE(TimePointToInt(calculated_latch_point),
436  TimePointToInt(last_latch_point_targeted));
437 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST() [15/15]

flutter_runner_test::TEST ( CalculateNextLatchPointTest  ,
SteadyState_FuzzyLatchPointsAfterTarget   
)

Definition at line 439 of file session_connection_unittests.cc.

References flutter_runner::SessionConnection::CalculateNextLatchPoint(), TimeDeltaFromInt(), TimePointFromInt(), and TimePointToInt().

439  {
440  fml::TimePoint present_requested_time = TimePointFromInt(4000);
441  fml::TimePoint now = TimePointFromInt(4000);
442  fml::TimePoint last_latch_point_targeted = TimePointFromInt(5557);
443  fml::TimeDelta flutter_frame_build_time = TimeDeltaFromInt(1000);
444  fml::TimeDelta vsync_interval = TimeDeltaFromInt(1000);
445  std::deque<std::pair<fml::TimePoint, fml::TimePoint>>
446  future_presentation_infos = {
447  {TimePointFromInt(4510), TimePointFromInt(5000)},
448  {TimePointFromInt(5490), TimePointFromInt(6000)},
449  {TimePointFromInt(6482), TimePointFromInt(7000)},
450  {TimePointFromInt(7356), TimePointFromInt(8000)},
451  };
452 
453  // Assertions about given values.
454  EXPECT_GE(now, present_requested_time);
455  EXPECT_GE(flutter_frame_build_time, TimeDeltaFromInt(0));
456  EXPECT_GT(vsync_interval, TimeDeltaFromInt(0));
457 
458  fml::TimePoint calculated_latch_point =
459  SessionConnection::CalculateNextLatchPoint(
460  present_requested_time, now, last_latch_point_targeted,
461  flutter_frame_build_time, vsync_interval, future_presentation_infos);
462 
463  EXPECT_GE(TimePointToInt(calculated_latch_point),
464  TimePointToInt(now + (vsync_interval * 2)));
465  EXPECT_LE(TimePointToInt(calculated_latch_point),
466  TimePointToInt(now + (vsync_interval * 3)));
467  EXPECT_EQ(TimePointToInt(calculated_latch_point), 6482);
468 
469  EXPECT_GE(TimePointToInt(calculated_latch_point),
470  TimePointToInt(present_requested_time + flutter_frame_build_time));
471  EXPECT_GE(TimePointToInt(calculated_latch_point),
472  TimePointToInt(last_latch_point_targeted));
473 }
static int TimePointToInt(fml::TimePoint time)
static fml::TimeDelta TimeDeltaFromInt(int i)
static fml::TimePoint TimePointFromInt(int i)

◆ TEST_F() [1/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
ValidVsyncOffset   
)

Definition at line 16 of file flutter_runner_product_configuration_unittests.cc.

References fml::TimeDelta::FromMicroseconds(), and flutter_runner::FlutterRunnerProductConfiguration::get_vsync_offset().

16  {
17  const std::string json_string = "{ \"vsync_offset_in_us\" : 9000 } ";
18  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(9000);
19 
20  FlutterRunnerProductConfiguration product_config =
22  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
23 }
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43

◆ TEST_F() [2/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
InvalidJsonString   
)

Definition at line 25 of file flutter_runner_product_configuration_unittests.cc.

References fml::TimeDelta::FromMicroseconds(), and flutter_runner::FlutterRunnerProductConfiguration::get_vsync_offset().

25  {
26  const std::string json_string = "{ \"invalid json string\" }}} ";
27  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(0);
28 
29  FlutterRunnerProductConfiguration product_config =
31  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
32 }
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43

◆ TEST_F() [3/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
EmptyJsonString   
)

Definition at line 34 of file flutter_runner_product_configuration_unittests.cc.

References fml::TimeDelta::FromMicroseconds(), and flutter_runner::FlutterRunnerProductConfiguration::get_vsync_offset().

34  {
35  const std::string json_string = "";
36  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(0);
37 
38  FlutterRunnerProductConfiguration product_config =
40  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
41 }
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43

◆ TEST_F() [4/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
EmptyVsyncOffset   
)

Definition at line 43 of file flutter_runner_product_configuration_unittests.cc.

References fml::TimeDelta::FromMicroseconds(), and flutter_runner::FlutterRunnerProductConfiguration::get_vsync_offset().

43  {
44  const std::string json_string = "{ \"vsync_offset_in_us\" : } ";
45  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(0);
46 
47  FlutterRunnerProductConfiguration product_config =
49  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
50 }
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43

◆ TEST_F() [5/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
NegativeVsyncOffset   
)

Definition at line 52 of file flutter_runner_product_configuration_unittests.cc.

References fml::TimeDelta::FromMicroseconds(), and flutter_runner::FlutterRunnerProductConfiguration::get_vsync_offset().

52  {
53  const std::string json_string = "{ \"vsync_offset_in_us\" : -15410 } ";
54  const fml::TimeDelta expected_offset =
56 
57  FlutterRunnerProductConfiguration product_config =
59  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
60 }
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43

◆ TEST_F() [6/38]

flutter_runner_test::TEST_F ( VsyncWaiterTest  ,
AwaitVsync   
)

Definition at line 54 of file vsync_waiter_unittests.cc.

References flutter_runner::CreateFMLTaskRunner(), flutter_runner_test::VsyncWaiterTest::CreateVsyncWaiter(), fml::TimeDelta::FromMilliseconds(), fml::AutoResetWaitableEvent::Signal(), flutter_runner_test::VsyncWaiterTest::SignalVsyncEvent(), and fml::AutoResetWaitableEvent::WaitWithTimeout().

54  {
55  std::array<std::unique_ptr<flutter_runner::Thread>, 3> threads;
56 
57  for (auto& thread : threads) {
58  thread.reset(new flutter_runner::Thread());
59  }
60 
61  async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
62 
63  const flutter::TaskRunners task_runners(
64  "VsyncWaiterTests", // Dart thread labels
66  async_get_default_dispatcher()), // platform
67  flutter_runner::CreateFMLTaskRunner(threads[0]->dispatcher()), // raster
68  flutter_runner::CreateFMLTaskRunner(threads[1]->dispatcher()), // ui
69  flutter_runner::CreateFMLTaskRunner(threads[2]->dispatcher()) // io
70  );
71 
72  auto vsync_waiter = CreateVsyncWaiter(std::move(task_runners));
73 
75  vsync_waiter->AsyncWaitForVsync(
76  [&latch](fml::TimePoint frame_start_time,
77  fml::TimePoint frame_target_time) { latch.Signal(); });
78  SignalVsyncEvent();
79 
80  bool did_timeout =
82 
83  // False indicates we were signalled rather than timed out
84  EXPECT_FALSE(did_timeout);
85 
86  vsync_waiter.reset();
87  for (const auto& thread : threads) {
88  thread->Quit();
89  }
90 }
fml::RefPtr< fml::TaskRunner > CreateFMLTaskRunner(async_dispatcher_t *dispatcher)
bool WaitWithTimeout(TimeDelta timeout)
std::function< std::unique_ptr< VsyncWaiter >()> CreateVsyncWaiter
static constexpr TimeDelta FromMilliseconds(int64_t millis)
Definition: time_delta.h:46

◆ TEST_F() [7/38]

flutter_runner_test::TEST_F ( SessionConnectionTest  ,
SimplePresentTest   
)

Definition at line 61 of file session_connection_unittests.cc.

References FML_CHECK, and flutter_runner::SessionConnection::Present().

61  {
62  fml::closure on_session_error_callback = []() { FML_CHECK(false); };
63 
64  uint64_t num_presents_handled = 0;
65  on_frame_presented_event on_frame_presented_callback =
66  [&num_presents_handled](
67  fuchsia::scenic::scheduling::FramePresentedInfo info) {
68  num_presents_handled += info.presentation_infos.size();
69  };
70 
71  flutter_runner::SessionConnection session_connection(
72  "debug label", std::move(session_), on_session_error_callback,
73  on_frame_presented_callback, vsync_event_.get(), 3);
74 
75  for (int i = 0; i < 200; ++i) {
76  session_connection.Present();
77  std::this_thread::sleep_for(std::chrono::milliseconds(10));
78  }
79 
80  EXPECT_GT(num_presents_handled, 0u);
81 }
std::function< void()> closure
Definition: closure.h:14
#define FML_CHECK(condition)
Definition: logging.h:68
std::function< void(fuchsia::scenic::scheduling::FramePresentedInfo)> on_frame_presented_event

◆ TEST_F() [8/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
NonIntegerVsyncOffset   
)

Definition at line 62 of file flutter_runner_product_configuration_unittests.cc.

References fml::TimeDelta::FromMicroseconds(), and flutter_runner::FlutterRunnerProductConfiguration::get_vsync_offset().

62  {
63  const std::string json_string = "{ \"vsync_offset_in_us\" : 3.14159 } ";
64  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(0);
65 
66  FlutterRunnerProductConfiguration product_config =
68  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
69 }
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43

◆ TEST_F() [9/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
ValidMaxFramesInFlight   
)

Definition at line 71 of file flutter_runner_product_configuration_unittests.cc.

References flutter_runner::FlutterRunnerProductConfiguration::get_max_frames_in_flight().

71  {
72  const std::string json_string = "{ \"max_frames_in_flight\" : 5 } ";
73  const uint64_t expected_max_frames_in_flight = 5;
74 
75  FlutterRunnerProductConfiguration product_config =
77  EXPECT_EQ(product_config.get_max_frames_in_flight(),
78  expected_max_frames_in_flight);
79 }

◆ TEST_F() [10/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
MissingMaxFramesInFlight   
)

Definition at line 81 of file flutter_runner_product_configuration_unittests.cc.

References flutter_runner::FlutterRunnerProductConfiguration::get_max_frames_in_flight().

81  {
82  const std::string json_string = "{ \"max_frames_in_flight\" : } ";
83  const uint64_t minimum_reasonable_max_frames_in_flight = 1;
84 
85  FlutterRunnerProductConfiguration product_config =
87  EXPECT_GE(product_config.get_max_frames_in_flight(),
88  minimum_reasonable_max_frames_in_flight);
89 }

◆ TEST_F() [11/38]

flutter_runner_test::TEST_F ( SessionConnectionTest  ,
BatchedPresentTest   
)

Definition at line 83 of file session_connection_unittests.cc.

References FML_CHECK, and flutter_runner::SessionConnection::Present().

83  {
84  fml::closure on_session_error_callback = []() { FML_CHECK(false); };
85 
86  uint64_t num_presents_handled = 0;
87  on_frame_presented_event on_frame_presented_callback =
88  [&num_presents_handled](
89  fuchsia::scenic::scheduling::FramePresentedInfo info) {
90  num_presents_handled += info.presentation_infos.size();
91  };
92 
93  flutter_runner::SessionConnection session_connection(
94  "debug label", std::move(session_), on_session_error_callback,
95  on_frame_presented_callback, vsync_event_.get(), 3);
96 
97  for (int i = 0; i < 200; ++i) {
98  session_connection.Present();
99  if (i % 10 == 9) {
100  std::this_thread::sleep_for(std::chrono::milliseconds(20));
101  }
102  }
103 
104  EXPECT_GT(num_presents_handled, 0u);
105 }
std::function< void()> closure
Definition: closure.h:14
#define FML_CHECK(condition)
Definition: logging.h:68
std::function< void(fuchsia::scenic::scheduling::FramePresentedInfo)> on_frame_presented_event

◆ TEST_F() [12/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
ValidInterceptAllInput   
)

Definition at line 91 of file flutter_runner_product_configuration_unittests.cc.

References flutter_runner::FlutterRunnerProductConfiguration::get_intercept_all_input().

91  {
92  const std::string json_string = "{ \"intercept_all_input\" : true } ";
93  const uint64_t expected_intercept_all_input = true;
94 
95  FlutterRunnerProductConfiguration product_config =
97 
98  EXPECT_EQ(expected_intercept_all_input,
99  product_config.get_intercept_all_input());
100 }

◆ TEST_F() [13/38]

flutter_runner_test::TEST_F ( VsyncWaiterTest  ,
SnapToNextPhaseOverlapsWithNow   
)

Definition at line 92 of file vsync_waiter_unittests.cc.

References fml::TimeDelta::FromNanoseconds(), fml::TimePoint::Now(), and flutter_runner::VsyncWaiter::SnapToNextPhase().

92  {
93  const auto now = fml::TimePoint::Now();
94  const auto last_presentation_time = now - fml::TimeDelta::FromNanoseconds(10);
95  const auto delta = fml::TimeDelta::FromNanoseconds(10);
96  const auto next_vsync = flutter_runner::VsyncWaiter::SnapToNextPhase(
97  now, last_presentation_time, delta);
98 
99  EXPECT_EQ(now + delta, next_vsync);
100 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
static TimePoint Now()
Definition: time_point.cc:26

◆ TEST_F() [14/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
RegistersViewRef   
)

Definition at line 94 of file accessibility_bridge_unittest.cc.

94  {
95  EXPECT_TRUE(semantics_manager_.RegisterViewCalled());
96 }

◆ TEST_F() [15/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
EnableDisable   
)

Definition at line 98 of file accessibility_bridge_unittest.cc.

98  {
99  EXPECT_FALSE(accessibility_delegate_.enabled());
100  std::unique_ptr<fuchsia::accessibility::semantics::SemanticListener> listener(
101  accessibility_bridge_.release());
102  listener->OnSemanticsModeChanged(true, nullptr);
103  EXPECT_TRUE(accessibility_delegate_.enabled());
104 }

◆ TEST_F() [16/38]

flutter_runner_test::TEST_F ( VsyncWaiterTest  ,
SnapToNextPhaseAfterNow   
)

Definition at line 102 of file vsync_waiter_unittests.cc.

References fml::TimeDelta::FromNanoseconds(), fml::TimePoint::Now(), and flutter_runner::VsyncWaiter::SnapToNextPhase().

102  {
103  const auto now = fml::TimePoint::Now();
104  const auto last_presentation_time = now - fml::TimeDelta::FromNanoseconds(9);
105  const auto delta = fml::TimeDelta::FromNanoseconds(10);
106  const auto next_vsync = flutter_runner::VsyncWaiter::SnapToNextPhase(
107  now, last_presentation_time, delta);
108 
109  // math here: 10 - 9 = 1
110  EXPECT_EQ(now + fml::TimeDelta::FromNanoseconds(1), next_vsync);
111 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
static TimePoint Now()
Definition: time_point.cc:26

◆ TEST_F() [17/38]

flutter_runner_test::TEST_F ( FlutterRunnerProductConfigurationTest  ,
MissingInterceptAllInput   
)

Definition at line 102 of file flutter_runner_product_configuration_unittests.cc.

References flutter_runner::FlutterRunnerProductConfiguration::get_intercept_all_input().

102  {
103  const std::string json_string = "{ \"intercept_all_input\" : } ";
104  const uint64_t expected_intercept_all_input = false;
105 
106  FlutterRunnerProductConfiguration product_config =
108 
109  EXPECT_EQ(expected_intercept_all_input,
110  product_config.get_intercept_all_input());
111 }

◆ TEST_F() [18/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
UpdatesNodeRoles   
)

Definition at line 106 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::flags, flutter::SemanticsNode::id, flutter::kIsButton, flutter::kIsHeader, flutter::kIsImage, flutter::kIsSlider, and flutter::kIsTextField.

106  {
108 
110  node0.id = 0;
111  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kIsButton);
112  node0.childrenInTraversalOrder = {1, 2, 3, 4};
113  node0.childrenInHitTestOrder = {1, 2, 3, 4};
114  updates.emplace(0, node0);
115 
117  node1.id = 1;
118  node1.flags |= static_cast<int>(flutter::SemanticsFlags::kIsHeader);
119  node1.childrenInTraversalOrder = {};
120  node1.childrenInHitTestOrder = {};
121  updates.emplace(1, node1);
122 
124  node2.id = 2;
125  node2.flags |= static_cast<int>(flutter::SemanticsFlags::kIsImage);
126  node2.childrenInTraversalOrder = {};
127  node2.childrenInHitTestOrder = {};
128  updates.emplace(2, node2);
129 
131  node3.id = 3;
132  node3.flags |= static_cast<int>(flutter::SemanticsFlags::kIsTextField);
133  node3.childrenInTraversalOrder = {};
134  node3.childrenInHitTestOrder = {};
135  updates.emplace(3, node3);
136 
138  node4.childrenInTraversalOrder = {};
139  node4.childrenInHitTestOrder = {};
140  node4.id = 4;
141  node4.flags |= static_cast<int>(flutter::SemanticsFlags::kIsSlider);
142  updates.emplace(4, node4);
143 
144  accessibility_bridge_->AddSemanticsNodeUpdate(std::move(updates), 1.f);
145  RunLoopUntilIdle();
146 
147  std::unordered_map<uint32_t, fuchsia::accessibility::semantics::Role>
148  roles_by_node_id = {
149  {0u, fuchsia::accessibility::semantics::Role::BUTTON},
150  {1u, fuchsia::accessibility::semantics::Role::HEADER},
151  {2u, fuchsia::accessibility::semantics::Role::IMAGE},
152  {3u, fuchsia::accessibility::semantics::Role::TEXT_FIELD},
153  {4u, fuchsia::accessibility::semantics::Role::SLIDER}};
154 
155  EXPECT_EQ(0, semantics_manager_.DeleteCount());
156  EXPECT_EQ(1, semantics_manager_.UpdateCount());
157  EXPECT_EQ(1, semantics_manager_.CommitCount());
158  EXPECT_EQ(5U, semantics_manager_.LastUpdatedNodes().size());
159  for (const auto& node : semantics_manager_.LastUpdatedNodes()) {
160  ExpectNodeHasRole(node, roles_by_node_id);
161  }
162 
163  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
164  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
165 }
std::vector< int32_t > childrenInHitTestOrder
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [19/38]

flutter_runner_test::TEST_F ( VsyncWaiterTest  ,
SnapToNextPhaseAfterNowMultiJump   
)

Definition at line 113 of file vsync_waiter_unittests.cc.

References fml::TimeDelta::FromNanoseconds(), fml::TimePoint::Now(), and flutter_runner::VsyncWaiter::SnapToNextPhase().

113  {
114  const auto now = fml::TimePoint::Now();
115  const auto last_presentation_time = now - fml::TimeDelta::FromNanoseconds(34);
116  const auto delta = fml::TimeDelta::FromNanoseconds(10);
117  const auto next_vsync = flutter_runner::VsyncWaiter::SnapToNextPhase(
118  now, last_presentation_time, delta);
119 
120  // zeroes: -34, -24, -14, -4, 6, ...
121  EXPECT_EQ(now + fml::TimeDelta::FromNanoseconds(6), next_vsync);
122 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
static TimePoint Now()
Definition: time_point.cc:26

◆ TEST_F() [20/38]

flutter_runner_test::TEST_F ( VsyncWaiterTest  ,
SnapToNextPhaseAfterNowMultiJumpAccountForCeils   
)

Definition at line 124 of file vsync_waiter_unittests.cc.

References fml::TimeDelta::FromNanoseconds(), fml::TimePoint::Now(), and flutter_runner::VsyncWaiter::SnapToNextPhase().

124  {
125  const auto now = fml::TimePoint::Now();
126  const auto last_presentation_time = now - fml::TimeDelta::FromNanoseconds(20);
127  const auto delta = fml::TimeDelta::FromNanoseconds(16);
128  const auto next_vsync = flutter_runner::VsyncWaiter::SnapToNextPhase(
129  now, last_presentation_time, delta);
130 
131  // zeroes: -20, -4, 12, 28, ...
132  EXPECT_EQ(now + fml::TimeDelta::FromNanoseconds(12), next_vsync);
133 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
static TimePoint Now()
Definition: time_point.cc:26

◆ TEST_F() [21/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
DeletesChildrenTransitively   
)

Definition at line 167 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, and flutter::SemanticsNode::id.

167  {
168  // Test that when a node is deleted, so are its transitive children.
170  node2.id = 2;
171 
173  node1.id = 1;
174  node1.childrenInTraversalOrder = {2};
175  node1.childrenInHitTestOrder = {2};
176 
178  node0.id = 0;
179  node0.childrenInTraversalOrder = {1};
180  node0.childrenInHitTestOrder = {1};
181 
182  accessibility_bridge_->AddSemanticsNodeUpdate(
183  {
184  {0, node0},
185  {1, node1},
186  {2, node2},
187  },
188  1.f);
189  RunLoopUntilIdle();
190 
191  EXPECT_EQ(0, semantics_manager_.DeleteCount());
192  EXPECT_EQ(1, semantics_manager_.UpdateCount());
193  EXPECT_EQ(1, semantics_manager_.CommitCount());
194  EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size());
195  EXPECT_EQ(0U, semantics_manager_.LastDeletedNodeIds().size());
196  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
197  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
198 
199  // Remove the children
200  node0.childrenInTraversalOrder.clear();
201  node0.childrenInHitTestOrder.clear();
202  accessibility_bridge_->AddSemanticsNodeUpdate(
203  {
204  {0, node0},
205  },
206  1.f);
207  RunLoopUntilIdle();
208 
209  EXPECT_EQ(1, semantics_manager_.DeleteCount());
210  EXPECT_EQ(2, semantics_manager_.UpdateCount());
211  EXPECT_EQ(2, semantics_manager_.CommitCount());
212  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
213  ASSERT_EQ(std::vector<uint32_t>({1, 2}),
214  semantics_manager_.LastDeletedNodeIds());
215  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
216  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
217 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [22/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleButton   
)

Definition at line 219 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::flags, flutter::SemanticsNode::id, and flutter::kIsButton.

219  {
221  node0.id = 0;
222  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsButton);
223 
224  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
225  RunLoopUntilIdle();
226 
227  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
228  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
229  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
230  EXPECT_TRUE(fuchsia_node.has_role());
231  EXPECT_EQ(fuchsia_node.role(),
232  fuchsia::accessibility::semantics::Role::BUTTON);
233 }

◆ TEST_F() [23/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleImage   
)

Definition at line 235 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::flags, flutter::SemanticsNode::id, and flutter::kIsImage.

235  {
237  node0.id = 0;
238  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsImage);
239 
240  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
241  RunLoopUntilIdle();
242 
243  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
244  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
245  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
246  EXPECT_TRUE(fuchsia_node.has_role());
247  EXPECT_EQ(fuchsia_node.role(),
248  fuchsia::accessibility::semantics::Role::IMAGE);
249 }

◆ TEST_F() [24/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleSlider   
)

Definition at line 251 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::actions, flutter::SemanticsNode::id, and flutter::kIncrease.

251  {
253  node0.id = 0;
254  node0.actions |= static_cast<int>(flutter::SemanticsAction::kIncrease);
255 
256  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
257  RunLoopUntilIdle();
258 
259  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
260  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
261  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
262  EXPECT_TRUE(fuchsia_node.has_role());
263  EXPECT_EQ(fuchsia_node.role(),
264  fuchsia::accessibility::semantics::Role::SLIDER);
265 }

◆ TEST_F() [25/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleHeader   
)

Definition at line 267 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::flags, flutter::SemanticsNode::id, and flutter::kIsHeader.

267  {
269  node0.id = 0;
270  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsHeader);
271 
272  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
273  RunLoopUntilIdle();
274 
275  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
276  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
277  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
278  EXPECT_TRUE(fuchsia_node.has_role());
279  EXPECT_EQ(fuchsia_node.role(),
280  fuchsia::accessibility::semantics::Role::HEADER);
281 }

◆ TEST_F() [26/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesCheckedState   
)

Definition at line 283 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::flags, flutter::SemanticsNode::id, flutter::kHasCheckedState, flutter::kIsChecked, and flutter::SemanticsNode::value.

283  {
285  node0.id = 0;
286  // HasCheckedState = true
287  // IsChecked = true
288  // IsSelected = false
289  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kHasCheckedState);
290  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kIsChecked);
291  node0.value = "value";
292 
293  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
294  RunLoopUntilIdle();
295 
296  EXPECT_EQ(0, semantics_manager_.DeleteCount());
297  EXPECT_EQ(1, semantics_manager_.UpdateCount());
298  EXPECT_EQ(1, semantics_manager_.CommitCount());
299  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
300  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
301  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
302  EXPECT_TRUE(fuchsia_node.has_states());
303  const auto& states = fuchsia_node.states();
304  EXPECT_TRUE(states.has_checked_state());
305  EXPECT_EQ(states.checked_state(),
306  fuchsia::accessibility::semantics::CheckedState::CHECKED);
307  EXPECT_TRUE(states.has_selected());
308  EXPECT_FALSE(states.selected());
309  EXPECT_TRUE(states.has_value());
310  EXPECT_EQ(states.value(), node0.value);
311 
312  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
313  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
314 }

◆ TEST_F() [27/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesSelectedState   
)

Definition at line 316 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::flags, flutter::SemanticsNode::id, and flutter::kIsSelected.

316  {
318  node0.id = 0;
319  // HasCheckedState = false
320  // IsChecked = false
321  // IsSelected = true
322  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsSelected);
323 
324  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
325  RunLoopUntilIdle();
326 
327  EXPECT_EQ(0, semantics_manager_.DeleteCount());
328  EXPECT_EQ(1, semantics_manager_.UpdateCount());
329  EXPECT_EQ(1, semantics_manager_.CommitCount());
330  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
331  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
332  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
333  EXPECT_TRUE(fuchsia_node.has_states());
334  const auto& states = fuchsia_node.states();
335  EXPECT_TRUE(states.has_checked_state());
336  EXPECT_EQ(states.checked_state(),
337  fuchsia::accessibility::semantics::CheckedState::NONE);
338  EXPECT_TRUE(states.has_selected());
339  EXPECT_TRUE(states.selected());
340 
341  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
342  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
343 }

◆ TEST_F() [28/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
ApplyViewPixelRatioToRoot   
)

Definition at line 345 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::flags, flutter::SemanticsNode::id, and flutter::kIsSelected.

345  {
347  node0.id = 0;
348  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsSelected);
349 
350  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.25f);
351  RunLoopUntilIdle();
352  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
353  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
354  EXPECT_EQ(fuchsia_node.transform().matrix[0], 0.8f);
355  EXPECT_EQ(fuchsia_node.transform().matrix[5], 0.8f);
356  EXPECT_EQ(fuchsia_node.transform().matrix[10], 1.f);
357 }

◆ TEST_F() [29/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
DoesNotPopulatesHiddenState   
)

Definition at line 359 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::flags, flutter::SemanticsNode::id, and flutter::kIsHidden.

359  {
360  // Flutter's notion of a hidden node is different from Fuchsia's hidden node.
361  // This test make sures that this state does not get sent.
363  node0.id = 0;
364  // HasCheckedState = false
365  // IsChecked = false
366  // IsSelected = false
367  // IsHidden = true
368  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsHidden);
369 
370  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
371  RunLoopUntilIdle();
372 
373  EXPECT_EQ(0, semantics_manager_.DeleteCount());
374  EXPECT_EQ(1, semantics_manager_.UpdateCount());
375  EXPECT_EQ(1, semantics_manager_.CommitCount());
376  EXPECT_EQ(1u, semantics_manager_.LastUpdatedNodes().size());
377  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
378  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
379  EXPECT_TRUE(fuchsia_node.has_states());
380  const auto& states = fuchsia_node.states();
381  EXPECT_TRUE(states.has_checked_state());
382  EXPECT_EQ(states.checked_state(),
383  fuchsia::accessibility::semantics::CheckedState::NONE);
384  EXPECT_TRUE(states.has_selected());
385  EXPECT_FALSE(states.selected());
386  EXPECT_FALSE(states.has_hidden());
387 
388  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
389  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
390 }

◆ TEST_F() [30/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesActions   
)

Definition at line 392 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::actions, flutter::SemanticsNode::id, flutter::kDecrease, flutter::kIncrease, flutter::kLongPress, flutter::kShowOnScreen, and flutter::kTap.

392  {
394  node0.id = 0;
395  node0.actions |= static_cast<int>(flutter::SemanticsAction::kTap);
396  node0.actions |= static_cast<int>(flutter::SemanticsAction::kLongPress);
397  node0.actions |= static_cast<int>(flutter::SemanticsAction::kShowOnScreen);
398  node0.actions |= static_cast<int>(flutter::SemanticsAction::kIncrease);
399  node0.actions |= static_cast<int>(flutter::SemanticsAction::kDecrease);
400 
401  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
402  RunLoopUntilIdle();
403 
404  EXPECT_EQ(0, semantics_manager_.DeleteCount());
405  EXPECT_EQ(1, semantics_manager_.UpdateCount());
406  EXPECT_EQ(1, semantics_manager_.CommitCount());
407  EXPECT_EQ(1u, semantics_manager_.LastUpdatedNodes().size());
408  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
409  EXPECT_EQ(fuchsia_node.actions().size(), 5u);
410  EXPECT_EQ(fuchsia_node.actions().at(0u),
411  fuchsia::accessibility::semantics::Action::DEFAULT);
412  EXPECT_EQ(fuchsia_node.actions().at(1u),
413  fuchsia::accessibility::semantics::Action::SECONDARY);
414  EXPECT_EQ(fuchsia_node.actions().at(2u),
415  fuchsia::accessibility::semantics::Action::SHOW_ON_SCREEN);
416  EXPECT_EQ(fuchsia_node.actions().at(3u),
417  fuchsia::accessibility::semantics::Action::INCREMENT);
418  EXPECT_EQ(fuchsia_node.actions().at(4u),
419  fuchsia::accessibility::semantics::Action::DECREMENT);
420 }

◆ TEST_F() [31/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
TruncatesLargeLabel   
)

Definition at line 422 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, id, flutter::SemanticsNode::id, and flutter::SemanticsNode::label.

422  {
423  // Test that labels which are too long are truncated.
425  node0.id = 0;
426 
428  node1.id = 1;
429 
430  flutter::SemanticsNode bad_node;
431  bad_node.id = 2;
432  bad_node.label =
433  std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE + 1, '2');
434 
435  node0.childrenInTraversalOrder = {1, 2};
436  node0.childrenInHitTestOrder = {1, 2};
437 
438  accessibility_bridge_->AddSemanticsNodeUpdate(
439  {
440  {0, node0},
441  {1, node1},
442  {2, bad_node},
443  },
444  1.f);
445  RunLoopUntilIdle();
446 
447  // Nothing to delete, but we should have broken
448  EXPECT_EQ(0, semantics_manager_.DeleteCount());
449  EXPECT_EQ(1, semantics_manager_.UpdateCount());
450  EXPECT_EQ(1, semantics_manager_.CommitCount());
451  EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size());
452  auto trimmed_node =
453  std::find_if(semantics_manager_.LastUpdatedNodes().begin(),
454  semantics_manager_.LastUpdatedNodes().end(),
455  [id = static_cast<uint32_t>(bad_node.id)](
456  fuchsia::accessibility::semantics::Node const& node) {
457  return node.node_id() == id;
458  });
459  ASSERT_NE(trimmed_node, semantics_manager_.LastUpdatedNodes().end());
460  ASSERT_TRUE(trimmed_node->has_attributes());
461  EXPECT_EQ(
462  trimmed_node->attributes().label(),
463  std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE, '2'));
464  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
465  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
466 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
int32_t id

◆ TEST_F() [32/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
TruncatesLargeValue   
)

Definition at line 468 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, id, flutter::SemanticsNode::id, and flutter::SemanticsNode::value.

468  {
469  // Test that values which are too long are truncated.
471  node0.id = 0;
472 
474  node1.id = 1;
475 
476  flutter::SemanticsNode bad_node;
477  bad_node.id = 2;
478  bad_node.value =
479  std::string(fuchsia::accessibility::semantics::MAX_VALUE_SIZE + 1, '2');
480 
481  node0.childrenInTraversalOrder = {1, 2};
482  node0.childrenInHitTestOrder = {1, 2};
483 
484  accessibility_bridge_->AddSemanticsNodeUpdate(
485  {
486  {0, node0},
487  {1, node1},
488  {2, bad_node},
489  },
490  1.f);
491  RunLoopUntilIdle();
492 
493  EXPECT_EQ(0, semantics_manager_.DeleteCount());
494  EXPECT_EQ(1, semantics_manager_.UpdateCount());
495  EXPECT_EQ(1, semantics_manager_.CommitCount());
496  EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size());
497  auto trimmed_node =
498  std::find_if(semantics_manager_.LastUpdatedNodes().begin(),
499  semantics_manager_.LastUpdatedNodes().end(),
500  [id = static_cast<uint32_t>(bad_node.id)](
501  fuchsia::accessibility::semantics::Node const& node) {
502  return node.node_id() == id;
503  });
504  ASSERT_NE(trimmed_node, semantics_manager_.LastUpdatedNodes().end());
505  ASSERT_TRUE(trimmed_node->has_states());
506  EXPECT_EQ(
507  trimmed_node->states().value(),
508  std::string(fuchsia::accessibility::semantics::MAX_VALUE_SIZE, '2'));
509  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
510  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
511 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
int32_t id

◆ TEST_F() [33/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
SplitsLargeUpdates   
)

Definition at line 513 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::id, flutter::SemanticsNode::label, and flutter::SemanticsNode::value.

513  {
514  // Test that labels which are too long are truncated.
516  node0.id = 0;
517 
519  node1.id = 1;
520  node1.label =
521  std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE, '1');
522 
524  node2.id = 2;
525  node2.label = "2";
526 
528  node3.id = 3;
529  node3.label = "3";
530 
532  node4.id = 4;
533  node4.value =
534  std::string(fuchsia::accessibility::semantics::MAX_VALUE_SIZE, '4');
535 
536  node0.childrenInTraversalOrder = {1, 2};
537  node0.childrenInHitTestOrder = {1, 2};
538  node1.childrenInTraversalOrder = {3, 4};
539  node1.childrenInHitTestOrder = {3, 4};
540 
541  accessibility_bridge_->AddSemanticsNodeUpdate(
542  {
543  {0, node0},
544  {1, node1},
545  {2, node2},
546  {3, node3},
547  {4, node4},
548  },
549  1.f);
550  RunLoopUntilIdle();
551 
552  // Nothing to delete, but we should have broken into groups (4, 3, 2), (1, 0)
553  EXPECT_EQ(0, semantics_manager_.DeleteCount());
554  EXPECT_EQ(2, semantics_manager_.UpdateCount());
555  EXPECT_EQ(1, semantics_manager_.CommitCount());
556  EXPECT_EQ(2U, semantics_manager_.LastUpdatedNodes().size());
557  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
558  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
559 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [34/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HandlesCycles   
)

Definition at line 561 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, and flutter::SemanticsNode::id.

561  {
562  // Test that cycles don't cause fatal error.
564  node0.id = 0;
565  node0.childrenInTraversalOrder.push_back(0);
566  node0.childrenInHitTestOrder.push_back(0);
567  accessibility_bridge_->AddSemanticsNodeUpdate(
568  {
569  {0, node0},
570  },
571  1.f);
572  RunLoopUntilIdle();
573 
574  EXPECT_EQ(0, semantics_manager_.DeleteCount());
575  EXPECT_EQ(1, semantics_manager_.UpdateCount());
576  EXPECT_EQ(1, semantics_manager_.CommitCount());
577  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
578  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
579 
580  node0.childrenInTraversalOrder = {0, 1};
581  node0.childrenInHitTestOrder = {0, 1};
583  node1.id = 1;
584  node1.childrenInTraversalOrder = {0};
585  node1.childrenInHitTestOrder = {0};
586  accessibility_bridge_->AddSemanticsNodeUpdate(
587  {
588  {0, node0},
589  {1, node1},
590  },
591  1.f);
592  RunLoopUntilIdle();
593 
594  EXPECT_EQ(0, semantics_manager_.DeleteCount());
595  EXPECT_EQ(2, semantics_manager_.UpdateCount());
596  EXPECT_EQ(2, semantics_manager_.CommitCount());
597  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
598  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
599 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [35/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
BatchesLargeMessages   
)

Definition at line 601 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, id, flutter::SemanticsNode::id, and flutter::SemanticsNode::label.

601  {
602  // Tests that messages get batched appropriately.
604  node0.id = 0;
605 
607 
608  const int32_t child_nodes = 100;
609  const int32_t leaf_nodes = 100;
610  for (int32_t i = 1; i < child_nodes + 1; i++) {
612  node.id = i;
613  node0.childrenInTraversalOrder.push_back(i);
614  node0.childrenInHitTestOrder.push_back(i);
615  for (int32_t j = 0; j < leaf_nodes; j++) {
616  flutter::SemanticsNode leaf_node;
617  int id = (i * child_nodes) + ((j + 1) * leaf_nodes);
618  leaf_node.id = id;
619  leaf_node.label = "A relatively simple label";
620  node.childrenInTraversalOrder.push_back(id);
621  node.childrenInHitTestOrder.push_back(id);
622  update.insert(std::make_pair(id, std::move(leaf_node)));
623  }
624  update.insert(std::make_pair(i, std::move(node)));
625  }
626 
627  update.insert(std::make_pair(0, std::move(node0)));
628  accessibility_bridge_->AddSemanticsNodeUpdate(update, 1.f);
629  RunLoopUntilIdle();
630 
631  EXPECT_EQ(0, semantics_manager_.DeleteCount());
632  EXPECT_TRUE(6 <= semantics_manager_.UpdateCount() &&
633  semantics_manager_.UpdateCount() <= 10);
634  EXPECT_EQ(1, semantics_manager_.CommitCount());
635  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
636  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
637 
638  int next_update_count = semantics_manager_.UpdateCount() + 1;
639  // Remove the children
640  node0.childrenInTraversalOrder.clear();
641  node0.childrenInHitTestOrder.clear();
642  accessibility_bridge_->AddSemanticsNodeUpdate(
643  {
644  {0, node0},
645  },
646  1.f);
647  RunLoopUntilIdle();
648 
649  EXPECT_EQ(1, semantics_manager_.DeleteCount());
650  EXPECT_EQ(next_update_count, semantics_manager_.UpdateCount());
651  EXPECT_EQ(2, semantics_manager_.CommitCount());
652  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
653  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
654 }
std::vector< int32_t > childrenInHitTestOrder
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::vector< int32_t > childrenInTraversalOrder
int32_t id

◆ TEST_F() [36/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTest   
)

Definition at line 656 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::id, flutter::SemanticsNode::rect, and flutter::SemanticsNode::transform.

656  {
658  node0.id = 0;
659  node0.rect.setLTRB(0, 0, 100, 100);
660 
662  node1.id = 1;
663  node1.rect.setLTRB(10, 10, 20, 20);
664 
666  node2.id = 2;
667  node2.rect.setLTRB(25, 10, 45, 20);
668 
670  node3.id = 3;
671  node3.rect.setLTRB(10, 25, 20, 45);
672 
674  node4.id = 4;
675  node4.rect.setLTRB(10, 10, 20, 20);
676  node4.transform.setTranslate(20, 20, 0);
677 
678  node0.childrenInTraversalOrder = {1, 2, 3, 4};
679  node0.childrenInHitTestOrder = {1, 2, 3, 4};
680 
681  accessibility_bridge_->AddSemanticsNodeUpdate(
682  {
683  {0, node0},
684  {1, node1},
685  {2, node2},
686  {3, node3},
687  {4, node4},
688  },
689  1.f);
690  RunLoopUntilIdle();
691 
692  uint32_t hit_node_id;
693  auto callback = [&hit_node_id](fuchsia::accessibility::semantics::Hit hit) {
694  EXPECT_TRUE(hit.has_node_id());
695  hit_node_id = hit.node_id();
696  };
697 
698  // Nodes are:
699  // ----------
700  // | 1 2 |
701  // | 3 4 |
702  // ----------
703 
704  accessibility_bridge_->HitTest({1, 1}, callback);
705  EXPECT_EQ(hit_node_id, 0u);
706  accessibility_bridge_->HitTest({15, 15}, callback);
707  EXPECT_EQ(hit_node_id, 1u);
708  accessibility_bridge_->HitTest({30, 15}, callback);
709  EXPECT_EQ(hit_node_id, 2u);
710  accessibility_bridge_->HitTest({15, 30}, callback);
711  EXPECT_EQ(hit_node_id, 3u);
712  accessibility_bridge_->HitTest({30, 30}, callback);
713  EXPECT_EQ(hit_node_id, 4u);
714 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [37/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTestOverlapping   
)

Definition at line 716 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::id, and flutter::SemanticsNode::rect.

716  {
717  // Tests that the first node in hit test order wins, even if a later node
718  // would be able to recieve the hit.
720  node0.id = 0;
721  node0.rect.setLTRB(0, 0, 100, 100);
722 
724  node1.id = 1;
725  node1.rect.setLTRB(0, 0, 100, 100);
726 
728  node2.id = 2;
729  node2.rect.setLTRB(25, 10, 45, 20);
730 
731  node0.childrenInTraversalOrder = {1, 2};
732  node0.childrenInHitTestOrder = {2, 1};
733 
734  accessibility_bridge_->AddSemanticsNodeUpdate(
735  {
736  {0, node0},
737  {1, node1},
738  {2, node2},
739  },
740  1.f);
741  RunLoopUntilIdle();
742 
743  uint32_t hit_node_id;
744  auto callback = [&hit_node_id](fuchsia::accessibility::semantics::Hit hit) {
745  EXPECT_TRUE(hit.has_node_id());
746  hit_node_id = hit.node_id();
747  };
748 
749  accessibility_bridge_->HitTest({30, 15}, callback);
750  EXPECT_EQ(hit_node_id, 2u);
751 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [38/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
Actions   
)

Definition at line 753 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::id, flutter::kDecrease, flutter::kIncrease, flutter::kLongPress, flutter::kShowOnScreen, and flutter::kTap.

753  {
755  node0.id = 0;
756 
758  node1.id = 1;
759 
760  node0.childrenInTraversalOrder = {1};
761  node0.childrenInHitTestOrder = {1};
762 
763  accessibility_bridge_->AddSemanticsNodeUpdate(
764  {
765  {0, node0},
766  {1, node1},
767  },
768  1.f);
769  RunLoopUntilIdle();
770 
771  auto handled_callback = [](bool handled) { EXPECT_TRUE(handled); };
772  auto unhandled_callback = [](bool handled) { EXPECT_FALSE(handled); };
773 
774  accessibility_bridge_->OnAccessibilityActionRequested(
775  0u, fuchsia::accessibility::semantics::Action::DEFAULT, handled_callback);
776  EXPECT_EQ(accessibility_delegate_.actions.size(), 1u);
777  EXPECT_EQ(accessibility_delegate_.actions.back(),
778  std::make_pair(0, flutter::SemanticsAction::kTap));
779 
780  accessibility_bridge_->OnAccessibilityActionRequested(
781  0u, fuchsia::accessibility::semantics::Action::SECONDARY,
782  handled_callback);
783  EXPECT_EQ(accessibility_delegate_.actions.size(), 2u);
784  EXPECT_EQ(accessibility_delegate_.actions.back(),
785  std::make_pair(0, flutter::SemanticsAction::kLongPress));
786 
787  accessibility_bridge_->OnAccessibilityActionRequested(
788  0u, fuchsia::accessibility::semantics::Action::SET_FOCUS,
789  unhandled_callback);
790  EXPECT_EQ(accessibility_delegate_.actions.size(), 2u);
791 
792  accessibility_bridge_->OnAccessibilityActionRequested(
793  0u, fuchsia::accessibility::semantics::Action::SET_VALUE,
794  unhandled_callback);
795  EXPECT_EQ(accessibility_delegate_.actions.size(), 2u);
796 
797  accessibility_bridge_->OnAccessibilityActionRequested(
798  0u, fuchsia::accessibility::semantics::Action::SHOW_ON_SCREEN,
799  handled_callback);
800  EXPECT_EQ(accessibility_delegate_.actions.size(), 3u);
801  EXPECT_EQ(accessibility_delegate_.actions.back(),
802  std::make_pair(0, flutter::SemanticsAction::kShowOnScreen));
803 
804  accessibility_bridge_->OnAccessibilityActionRequested(
805  2u, fuchsia::accessibility::semantics::Action::DEFAULT,
806  unhandled_callback);
807  EXPECT_EQ(accessibility_delegate_.actions.size(), 3u);
808 
809  accessibility_bridge_->OnAccessibilityActionRequested(
810  0u, fuchsia::accessibility::semantics::Action::INCREMENT,
811  handled_callback);
812  EXPECT_EQ(accessibility_delegate_.actions.size(), 4u);
813  EXPECT_EQ(accessibility_delegate_.actions.back(),
814  std::make_pair(0, flutter::SemanticsAction::kIncrease));
815 
816  accessibility_bridge_->OnAccessibilityActionRequested(
817  0u, fuchsia::accessibility::semantics::Action::DECREMENT,
818  handled_callback);
819  EXPECT_EQ(accessibility_delegate_.actions.size(), 5u);
820  EXPECT_EQ(accessibility_delegate_.actions.back(),
821  std::make_pair(0, flutter::SemanticsAction::kDecrease));
822 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TimeDeltaFromInt()

static fml::TimeDelta flutter_runner_test::TimeDeltaFromInt ( int  i)
static

Definition at line 110 of file session_connection_unittests.cc.

References fml::TimeDelta::FromNanoseconds().

Referenced by TEST().

110  {
112 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ TimePointFromInt()

static fml::TimePoint flutter_runner_test::TimePointFromInt ( int  i)
static

Definition at line 107 of file session_connection_unittests.cc.

References fml::TimePoint::FromEpochDelta(), and fml::TimeDelta::FromNanoseconds().

Referenced by TEST().

107  {
109 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40
static constexpr TimePoint FromEpochDelta(TimeDelta ticks)
Definition: time_point.h:36

◆ TimePointToInt()

static int flutter_runner_test::TimePointToInt ( fml::TimePoint  time)
static

Definition at line 113 of file session_connection_unittests.cc.

References fml::TimePoint::ToEpochDelta(), and fml::TimeDelta::ToNanoseconds().

Referenced by TEST().

113  {
114  return time.ToEpochDelta().ToNanoseconds();
115 }
TimeDelta ToEpochDelta() const
Definition: time_point.h:40
constexpr int64_t ToNanoseconds() const
Definition: time_delta.h:61