Flutter Engine
flutter_runner_test Namespace Reference

Classes

class  AccessibilityBridgeTest
 
class  AccessibilityBridgeTestDelegate
 
class  FlutterRunnerProductConfigurationTest
 
class  MockSemanticsManager
 

Functions

 TEST_F (AccessibilityBridgeTest, RegistersViewRef)
 
 TEST_F (AccessibilityBridgeTest, EnableDisable)
 
 TEST_F (AccessibilityBridgeTest, RequestAnnounce)
 
 TEST_F (AccessibilityBridgeTest, PopulatesIsKeyboardKeyAttribute)
 
 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, PopulatesToggledState)
 
 TEST_F (AccessibilityBridgeTest, ApplyViewPixelRatioToRoot)
 
 TEST_F (AccessibilityBridgeTest, DoesNotPopulatesHiddenState)
 
 TEST_F (AccessibilityBridgeTest, PopulatesActions)
 
 TEST_F (AccessibilityBridgeTest, TruncatesLargeLabel)
 
 TEST_F (AccessibilityBridgeTest, TruncatesLargeToolTip)
 
 TEST_F (AccessibilityBridgeTest, TruncatesLargeValue)
 
 TEST_F (AccessibilityBridgeTest, SplitsLargeUpdates)
 
 TEST_F (AccessibilityBridgeTest, HandlesCycles)
 
 TEST_F (AccessibilityBridgeTest, BatchesLargeMessages)
 
 TEST_F (AccessibilityBridgeTest, HitTest)
 
 TEST_F (AccessibilityBridgeTest, HitTestWithPixelRatio)
 
 TEST_F (AccessibilityBridgeTest, HitTestUnfocusableChild)
 
 TEST_F (AccessibilityBridgeTest, HitTestOverlapping)
 
 TEST_F (AccessibilityBridgeTest, Actions)
 
 TEST_F (AccessibilityBridgeTest, InspectData)
 
 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)
 

Function Documentation

◆ 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 ( 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() [7/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() [8/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() [9/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() [10/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() [11/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
RegistersViewRef   
)

Definition at line 142 of file accessibility_bridge_unittest.cc.

142  {
143  EXPECT_TRUE(semantics_manager_.RegisterViewCalled());
144 }

◆ TEST_F() [12/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
EnableDisable   
)

Definition at line 146 of file accessibility_bridge_unittest.cc.

146  {
147  EXPECT_FALSE(accessibility_delegate_.enabled());
148  std::unique_ptr<fuchsia::accessibility::semantics::SemanticListener> listener(
149  accessibility_bridge_.release());
150  listener->OnSemanticsModeChanged(true, nullptr);
151  EXPECT_TRUE(accessibility_delegate_.enabled());
152 }

◆ TEST_F() [13/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
RequestAnnounce   
)

Definition at line 154 of file accessibility_bridge_unittest.cc.

154  {
155  accessibility_bridge_->RequestAnnounce("message");
156  RunLoopUntilIdle();
157 
158  auto& last_events = semantics_manager_.GetLastEvents();
159  ASSERT_EQ(last_events.size(), 1u);
160  ASSERT_TRUE(last_events[0].is_announce());
161  EXPECT_EQ(last_events[0].announce().message(), "message");
162 }

◆ TEST_F() [14/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesIsKeyboardKeyAttribute   
)

Definition at line 164 of file accessibility_bridge_unittest.cc.

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

164  {
166  node0.id = 0;
167  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsKeyboardKey);
168 
169  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
170  RunLoopUntilIdle();
171 
172  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
173  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
174  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
175  EXPECT_TRUE(fuchsia_node.has_attributes());
176  EXPECT_TRUE(fuchsia_node.attributes().is_keyboard_key());
177 }

◆ TEST_F() [15/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
UpdatesNodeRoles   
)

Definition at line 179 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::flags, flutter::SemanticsNode::id, flutter::kHasCheckedState, flutter::kHasToggledState, flutter::kIsButton, flutter::kIsHeader, flutter::kIsImage, flutter::kIsInMutuallyExclusiveGroup, flutter::kIsLink, flutter::kIsSlider, flutter::kIsTextField, and node.

179  {
181 
183  node0.id = 0;
184  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kIsButton);
185  node0.childrenInTraversalOrder = {1, 2, 3, 4, 5, 6, 7, 8};
186  node0.childrenInHitTestOrder = {1, 2, 3, 4, 5, 6, 7, 8};
187  updates.emplace(0, node0);
188 
190  node1.id = 1;
191  node1.flags |= static_cast<int>(flutter::SemanticsFlags::kIsHeader);
192  node1.childrenInTraversalOrder = {};
193  node1.childrenInHitTestOrder = {};
194  updates.emplace(1, node1);
195 
197  node2.id = 2;
198  node2.flags |= static_cast<int>(flutter::SemanticsFlags::kIsImage);
199  node2.childrenInTraversalOrder = {};
200  node2.childrenInHitTestOrder = {};
201  updates.emplace(2, node2);
202 
204  node3.id = 3;
205  node3.flags |= static_cast<int>(flutter::SemanticsFlags::kIsTextField);
206  node3.childrenInTraversalOrder = {};
207  node3.childrenInHitTestOrder = {};
208  updates.emplace(3, node3);
209 
211  node4.childrenInTraversalOrder = {};
212  node4.childrenInHitTestOrder = {};
213  node4.id = 4;
214  node4.flags |= static_cast<int>(flutter::SemanticsFlags::kIsSlider);
215  updates.emplace(4, node4);
216 
218  node5.childrenInTraversalOrder = {};
219  node5.childrenInHitTestOrder = {};
220  node5.id = 5;
221  node5.flags |= static_cast<int>(flutter::SemanticsFlags::kIsLink);
222  updates.emplace(5, node5);
223 
225  node6.childrenInTraversalOrder = {};
226  node6.childrenInHitTestOrder = {};
227  node6.id = 6;
228  node6.flags |= static_cast<int>(flutter::SemanticsFlags::kHasCheckedState);
229  node6.flags |=
231  updates.emplace(6, node6);
232 
234  node7.childrenInTraversalOrder = {};
235  node7.childrenInHitTestOrder = {};
236  node7.id = 7;
237  node7.flags |= static_cast<int>(flutter::SemanticsFlags::kHasCheckedState);
238  updates.emplace(7, node7);
239 
241  node8.childrenInTraversalOrder = {};
242  node8.childrenInHitTestOrder = {};
243  node8.id = 8;
244  node8.flags |= static_cast<int>(flutter::SemanticsFlags::kHasToggledState);
245  updates.emplace(7, node8);
246 
247  accessibility_bridge_->AddSemanticsNodeUpdate(std::move(updates), 1.f);
248  RunLoopUntilIdle();
249 
250  std::unordered_map<uint32_t, fuchsia::accessibility::semantics::Role>
251  roles_by_node_id = {
252  {0u, fuchsia::accessibility::semantics::Role::BUTTON},
253  {1u, fuchsia::accessibility::semantics::Role::HEADER},
254  {2u, fuchsia::accessibility::semantics::Role::IMAGE},
255  {3u, fuchsia::accessibility::semantics::Role::TEXT_FIELD},
256  {4u, fuchsia::accessibility::semantics::Role::SLIDER},
257  {5u, fuchsia::accessibility::semantics::Role::LINK},
258  {6u, fuchsia::accessibility::semantics::Role::RADIO_BUTTON},
259  {7u, fuchsia::accessibility::semantics::Role::CHECK_BOX},
260  {8u, fuchsia::accessibility::semantics::Role::TOGGLE_SWITCH}};
261 
262  EXPECT_EQ(0, semantics_manager_.DeleteCount());
263  EXPECT_EQ(1, semantics_manager_.UpdateCount());
264  EXPECT_EQ(1, semantics_manager_.CommitCount());
265  EXPECT_EQ(8u, semantics_manager_.LastUpdatedNodes().size());
266  for (const auto& node : semantics_manager_.LastUpdatedNodes()) {
267  ExpectNodeHasRole(node, roles_by_node_id);
268  }
269 
270  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
271  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
272 }
std::vector< int32_t > childrenInHitTestOrder
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::vector< int32_t > childrenInTraversalOrder
const FlutterSemanticsNode * node
Definition: fl_view.cc:83

◆ TEST_F() [16/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
DeletesChildrenTransitively   
)

Definition at line 274 of file accessibility_bridge_unittest.cc.

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

274  {
275  // Test that when a node is deleted, so are its transitive children.
277  node2.id = 2;
278 
280  node1.id = 1;
281  node1.childrenInTraversalOrder = {2};
282  node1.childrenInHitTestOrder = {2};
283 
285  node0.id = 0;
286  node0.childrenInTraversalOrder = {1};
287  node0.childrenInHitTestOrder = {1};
288 
289  accessibility_bridge_->AddSemanticsNodeUpdate(
290  {
291  {0, node0},
292  {1, node1},
293  {2, node2},
294  },
295  1.f);
296  RunLoopUntilIdle();
297 
298  EXPECT_EQ(0, semantics_manager_.DeleteCount());
299  EXPECT_EQ(1, semantics_manager_.UpdateCount());
300  EXPECT_EQ(1, semantics_manager_.CommitCount());
301  EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size());
302  EXPECT_EQ(0U, semantics_manager_.LastDeletedNodeIds().size());
303  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
304  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
305 
306  // Remove the children
307  node0.childrenInTraversalOrder.clear();
308  node0.childrenInHitTestOrder.clear();
309  accessibility_bridge_->AddSemanticsNodeUpdate(
310  {
311  {0, node0},
312  },
313  1.f);
314  RunLoopUntilIdle();
315 
316  EXPECT_EQ(1, semantics_manager_.DeleteCount());
317  EXPECT_EQ(2, semantics_manager_.UpdateCount());
318  EXPECT_EQ(2, semantics_manager_.CommitCount());
319  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
320  ASSERT_EQ(std::vector<uint32_t>({1, 2}),
321  semantics_manager_.LastDeletedNodeIds());
322  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
323  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
324 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [17/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleButton   
)

Definition at line 326 of file accessibility_bridge_unittest.cc.

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

326  {
328  node0.id = 0;
329  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsButton);
330 
331  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
332  RunLoopUntilIdle();
333 
334  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
335  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
336  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
337  EXPECT_TRUE(fuchsia_node.has_role());
338  EXPECT_EQ(fuchsia_node.role(),
339  fuchsia::accessibility::semantics::Role::BUTTON);
340 }

◆ TEST_F() [18/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleImage   
)

Definition at line 342 of file accessibility_bridge_unittest.cc.

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

342  {
344  node0.id = 0;
345  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsImage);
346 
347  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
348  RunLoopUntilIdle();
349 
350  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
351  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
352  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
353  EXPECT_TRUE(fuchsia_node.has_role());
354  EXPECT_EQ(fuchsia_node.role(),
355  fuchsia::accessibility::semantics::Role::IMAGE);
356 }

◆ TEST_F() [19/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleSlider   
)

Definition at line 358 of file accessibility_bridge_unittest.cc.

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

358  {
360  node0.id = 0;
361  node0.actions |= static_cast<int>(flutter::SemanticsAction::kIncrease);
362 
363  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
364  RunLoopUntilIdle();
365 
366  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
367  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
368  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
369  EXPECT_TRUE(fuchsia_node.has_role());
370  EXPECT_EQ(fuchsia_node.role(),
371  fuchsia::accessibility::semantics::Role::SLIDER);
372 }

◆ TEST_F() [20/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleHeader   
)

Definition at line 374 of file accessibility_bridge_unittest.cc.

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

374  {
376  node0.id = 0;
377  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsHeader);
378 
379  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
380  RunLoopUntilIdle();
381 
382  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
383  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
384  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
385  EXPECT_TRUE(fuchsia_node.has_role());
386  EXPECT_EQ(fuchsia_node.role(),
387  fuchsia::accessibility::semantics::Role::HEADER);
388 }

◆ TEST_F() [21/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesCheckedState   
)

Definition at line 390 of file accessibility_bridge_unittest.cc.

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

390  {
392  node0.id = 0;
393  // HasCheckedState = true
394  // IsChecked = true
395  // IsSelected = false
396  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kHasCheckedState);
397  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kIsChecked);
398  node0.value = "value";
399 
400  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
401  RunLoopUntilIdle();
402 
403  EXPECT_EQ(0, semantics_manager_.DeleteCount());
404  EXPECT_EQ(1, semantics_manager_.UpdateCount());
405  EXPECT_EQ(1, semantics_manager_.CommitCount());
406  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
407  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
408  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
409  EXPECT_TRUE(fuchsia_node.has_states());
410  const auto& states = fuchsia_node.states();
411  EXPECT_TRUE(states.has_checked_state());
412  EXPECT_EQ(states.checked_state(),
413  fuchsia::accessibility::semantics::CheckedState::CHECKED);
414  EXPECT_TRUE(states.has_selected());
415  EXPECT_FALSE(states.selected());
416  EXPECT_TRUE(states.has_value());
417  EXPECT_EQ(states.value(), node0.value);
418 
419  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
420  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
421 }

◆ TEST_F() [22/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesSelectedState   
)

Definition at line 423 of file accessibility_bridge_unittest.cc.

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

423  {
425  node0.id = 0;
426  // HasCheckedState = false
427  // IsChecked = false
428  // IsSelected = true
429  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsSelected);
430 
431  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
432  RunLoopUntilIdle();
433 
434  EXPECT_EQ(0, semantics_manager_.DeleteCount());
435  EXPECT_EQ(1, semantics_manager_.UpdateCount());
436  EXPECT_EQ(1, semantics_manager_.CommitCount());
437  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
438  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
439  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
440  EXPECT_TRUE(fuchsia_node.has_states());
441  const auto& states = fuchsia_node.states();
442  EXPECT_TRUE(states.has_checked_state());
443  EXPECT_EQ(states.checked_state(),
444  fuchsia::accessibility::semantics::CheckedState::NONE);
445  EXPECT_TRUE(states.has_selected());
446  EXPECT_TRUE(states.selected());
447 
448  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
449  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
450 }

◆ TEST_F() [23/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesToggledState   
)

Definition at line 452 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::flags, flutter::SemanticsNode::id, flutter::kHasToggledState, and flutter::kIsToggled.

452  {
454  node0.id = 0;
455  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kHasToggledState);
456  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kIsToggled);
457 
458  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
459  RunLoopUntilIdle();
460 
461  EXPECT_EQ(0, semantics_manager_.DeleteCount());
462  EXPECT_EQ(1, semantics_manager_.UpdateCount());
463  EXPECT_EQ(1, semantics_manager_.CommitCount());
464  EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
465  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
466  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
467  EXPECT_TRUE(fuchsia_node.has_states());
468  const auto& states = fuchsia_node.states();
469  EXPECT_TRUE(states.has_toggled_state());
470  EXPECT_EQ(states.toggled_state(),
471  fuchsia::accessibility::semantics::ToggledState::ON);
472 
473  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
474  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
475 }

◆ TEST_F() [24/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
ApplyViewPixelRatioToRoot   
)

Definition at line 477 of file accessibility_bridge_unittest.cc.

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

477  {
479  node0.id = 0;
480  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsSelected);
481 
482  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.25f);
483  RunLoopUntilIdle();
484  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
485  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
486  EXPECT_EQ(fuchsia_node.transform().matrix[0], 0.8f);
487  EXPECT_EQ(fuchsia_node.transform().matrix[5], 0.8f);
488  EXPECT_EQ(fuchsia_node.transform().matrix[10], 1.f);
489 }

◆ TEST_F() [25/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
DoesNotPopulatesHiddenState   
)

Definition at line 491 of file accessibility_bridge_unittest.cc.

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

491  {
492  // Flutter's notion of a hidden node is different from Fuchsia's hidden node.
493  // This test make sures that this state does not get sent.
495  node0.id = 0;
496  // HasCheckedState = false
497  // IsChecked = false
498  // IsSelected = false
499  // IsHidden = true
500  node0.flags = static_cast<int>(flutter::SemanticsFlags::kIsHidden);
501 
502  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
503  RunLoopUntilIdle();
504 
505  EXPECT_EQ(0, semantics_manager_.DeleteCount());
506  EXPECT_EQ(1, semantics_manager_.UpdateCount());
507  EXPECT_EQ(1, semantics_manager_.CommitCount());
508  EXPECT_EQ(1u, semantics_manager_.LastUpdatedNodes().size());
509  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
510  EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
511  EXPECT_TRUE(fuchsia_node.has_states());
512  const auto& states = fuchsia_node.states();
513  EXPECT_TRUE(states.has_checked_state());
514  EXPECT_EQ(states.checked_state(),
515  fuchsia::accessibility::semantics::CheckedState::NONE);
516  EXPECT_TRUE(states.has_selected());
517  EXPECT_FALSE(states.selected());
518  EXPECT_FALSE(states.has_hidden());
519 
520  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
521  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
522 }

◆ TEST_F() [26/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesActions   
)

Definition at line 524 of file accessibility_bridge_unittest.cc.

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

524  {
526  node0.id = 0;
527  node0.actions |= static_cast<int>(flutter::SemanticsAction::kTap);
528  node0.actions |= static_cast<int>(flutter::SemanticsAction::kLongPress);
529  node0.actions |= static_cast<int>(flutter::SemanticsAction::kShowOnScreen);
530  node0.actions |= static_cast<int>(flutter::SemanticsAction::kIncrease);
531  node0.actions |= static_cast<int>(flutter::SemanticsAction::kDecrease);
532 
533  accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
534  RunLoopUntilIdle();
535 
536  EXPECT_EQ(0, semantics_manager_.DeleteCount());
537  EXPECT_EQ(1, semantics_manager_.UpdateCount());
538  EXPECT_EQ(1, semantics_manager_.CommitCount());
539  EXPECT_EQ(1u, semantics_manager_.LastUpdatedNodes().size());
540  const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
541  EXPECT_EQ(fuchsia_node.actions().size(), 5u);
542  EXPECT_EQ(fuchsia_node.actions().at(0u),
543  fuchsia::accessibility::semantics::Action::DEFAULT);
544  EXPECT_EQ(fuchsia_node.actions().at(1u),
545  fuchsia::accessibility::semantics::Action::SECONDARY);
546  EXPECT_EQ(fuchsia_node.actions().at(2u),
547  fuchsia::accessibility::semantics::Action::SHOW_ON_SCREEN);
548  EXPECT_EQ(fuchsia_node.actions().at(3u),
549  fuchsia::accessibility::semantics::Action::INCREMENT);
550  EXPECT_EQ(fuchsia_node.actions().at(4u),
551  fuchsia::accessibility::semantics::Action::DECREMENT);
552 }

◆ TEST_F() [27/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
TruncatesLargeLabel   
)

Definition at line 554 of file accessibility_bridge_unittest.cc.

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

554  {
555  // Test that labels which are too long are truncated.
557  node0.id = 0;
558 
560  node1.id = 1;
561 
562  flutter::SemanticsNode bad_node;
563  bad_node.id = 2;
564  bad_node.label =
565  std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE + 1, '2');
566 
567  node0.childrenInTraversalOrder = {1, 2};
568  node0.childrenInHitTestOrder = {1, 2};
569 
570  accessibility_bridge_->AddSemanticsNodeUpdate(
571  {
572  {0, node0},
573  {1, node1},
574  {2, bad_node},
575  },
576  1.f);
577  RunLoopUntilIdle();
578 
579  // Nothing to delete, but we should have broken
580  EXPECT_EQ(0, semantics_manager_.DeleteCount());
581  EXPECT_EQ(1, semantics_manager_.UpdateCount());
582  EXPECT_EQ(1, semantics_manager_.CommitCount());
583  EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size());
584  auto trimmed_node =
585  std::find_if(semantics_manager_.LastUpdatedNodes().begin(),
586  semantics_manager_.LastUpdatedNodes().end(),
587  [id = static_cast<uint32_t>(bad_node.id)](
588  fuchsia::accessibility::semantics::Node const& node) {
589  return node.node_id() == id;
590  });
591  ASSERT_NE(trimmed_node, semantics_manager_.LastUpdatedNodes().end());
592  ASSERT_TRUE(trimmed_node->has_attributes());
593  EXPECT_EQ(
594  trimmed_node->attributes().label(),
595  std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE, '2'));
596  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
597  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
598 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
const FlutterSemanticsNode * node
Definition: fl_view.cc:83
int32_t id

◆ TEST_F() [28/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
TruncatesLargeToolTip   
)

Definition at line 600 of file accessibility_bridge_unittest.cc.

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

600  {
601  // Test that tooltips which are too long are truncated.
603  node0.id = 0;
604 
606  node1.id = 1;
607 
608  flutter::SemanticsNode bad_node;
609  bad_node.id = 2;
610  bad_node.tooltip =
611  std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE + 1, '2');
612 
613  node0.childrenInTraversalOrder = {1, 2};
614  node0.childrenInHitTestOrder = {1, 2};
615 
616  accessibility_bridge_->AddSemanticsNodeUpdate(
617  {
618  {0, node0},
619  {1, node1},
620  {2, bad_node},
621  },
622  1.f);
623  RunLoopUntilIdle();
624 
625  // Nothing to delete, but we should have broken
626  EXPECT_EQ(0, semantics_manager_.DeleteCount());
627  EXPECT_EQ(1, semantics_manager_.UpdateCount());
628  EXPECT_EQ(1, semantics_manager_.CommitCount());
629  EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size());
630  auto trimmed_node =
631  std::find_if(semantics_manager_.LastUpdatedNodes().begin(),
632  semantics_manager_.LastUpdatedNodes().end(),
633  [id = static_cast<uint32_t>(bad_node.id)](
634  fuchsia::accessibility::semantics::Node const& node) {
635  return node.node_id() == id;
636  });
637  ASSERT_NE(trimmed_node, semantics_manager_.LastUpdatedNodes().end());
638  ASSERT_TRUE(trimmed_node->has_attributes());
639  EXPECT_EQ(
640  trimmed_node->attributes().secondary_label(),
641  std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE, '2'));
642  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
643  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
644 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
const FlutterSemanticsNode * node
Definition: fl_view.cc:83
int32_t id

◆ TEST_F() [29/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
TruncatesLargeValue   
)

Definition at line 646 of file accessibility_bridge_unittest.cc.

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

646  {
647  // Test that values which are too long are truncated.
649  node0.id = 0;
650 
652  node1.id = 1;
653 
654  flutter::SemanticsNode bad_node;
655  bad_node.id = 2;
656  bad_node.value =
657  std::string(fuchsia::accessibility::semantics::MAX_VALUE_SIZE + 1, '2');
658 
659  node0.childrenInTraversalOrder = {1, 2};
660  node0.childrenInHitTestOrder = {1, 2};
661 
662  accessibility_bridge_->AddSemanticsNodeUpdate(
663  {
664  {0, node0},
665  {1, node1},
666  {2, bad_node},
667  },
668  1.f);
669  RunLoopUntilIdle();
670 
671  EXPECT_EQ(0, semantics_manager_.DeleteCount());
672  EXPECT_EQ(1, semantics_manager_.UpdateCount());
673  EXPECT_EQ(1, semantics_manager_.CommitCount());
674  EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size());
675  auto trimmed_node =
676  std::find_if(semantics_manager_.LastUpdatedNodes().begin(),
677  semantics_manager_.LastUpdatedNodes().end(),
678  [id = static_cast<uint32_t>(bad_node.id)](
679  fuchsia::accessibility::semantics::Node const& node) {
680  return node.node_id() == id;
681  });
682  ASSERT_NE(trimmed_node, semantics_manager_.LastUpdatedNodes().end());
683  ASSERT_TRUE(trimmed_node->has_states());
684  EXPECT_EQ(
685  trimmed_node->states().value(),
686  std::string(fuchsia::accessibility::semantics::MAX_VALUE_SIZE, '2'));
687  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
688  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
689 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
const FlutterSemanticsNode * node
Definition: fl_view.cc:83
int32_t id

◆ TEST_F() [30/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
SplitsLargeUpdates   
)

Definition at line 691 of file accessibility_bridge_unittest.cc.

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

691  {
692  // Test that labels which are too long are truncated.
694  node0.id = 0;
695 
697  node1.id = 1;
698  node1.label =
699  std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE, '1');
700 
702  node2.id = 2;
703  node2.label = "2";
704 
706  node3.id = 3;
707  node3.label = "3";
708 
710  node4.id = 4;
711  node4.value =
712  std::string(fuchsia::accessibility::semantics::MAX_VALUE_SIZE, '4');
713 
714  node0.childrenInTraversalOrder = {1, 2};
715  node0.childrenInHitTestOrder = {1, 2};
716  node1.childrenInTraversalOrder = {3, 4};
717  node1.childrenInHitTestOrder = {3, 4};
718 
719  accessibility_bridge_->AddSemanticsNodeUpdate(
720  {
721  {0, node0},
722  {1, node1},
723  {2, node2},
724  {3, node3},
725  {4, node4},
726  },
727  1.f);
728  RunLoopUntilIdle();
729 
730  // Nothing to delete, but we should have broken into groups (4, 3, 2), (1, 0)
731  EXPECT_EQ(0, semantics_manager_.DeleteCount());
732  EXPECT_EQ(2, semantics_manager_.UpdateCount());
733  EXPECT_EQ(1, semantics_manager_.CommitCount());
734  EXPECT_EQ(2U, semantics_manager_.LastUpdatedNodes().size());
735  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
736  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
737 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [31/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HandlesCycles   
)

Definition at line 739 of file accessibility_bridge_unittest.cc.

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

739  {
740  // Test that cycles don't cause fatal error.
742  node0.id = 0;
743  node0.childrenInTraversalOrder.push_back(0);
744  node0.childrenInHitTestOrder.push_back(0);
745  accessibility_bridge_->AddSemanticsNodeUpdate(
746  {
747  {0, node0},
748  },
749  1.f);
750  RunLoopUntilIdle();
751 
752  EXPECT_EQ(0, semantics_manager_.DeleteCount());
753  EXPECT_EQ(1, semantics_manager_.UpdateCount());
754  EXPECT_EQ(1, semantics_manager_.CommitCount());
755  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
756  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
757 
758  node0.childrenInTraversalOrder = {0, 1};
759  node0.childrenInHitTestOrder = {0, 1};
761  node1.id = 1;
762  node1.childrenInTraversalOrder = {0};
763  node1.childrenInHitTestOrder = {0};
764  accessibility_bridge_->AddSemanticsNodeUpdate(
765  {
766  {0, node0},
767  {1, node1},
768  },
769  1.f);
770  RunLoopUntilIdle();
771 
772  EXPECT_EQ(0, semantics_manager_.DeleteCount());
773  EXPECT_EQ(2, semantics_manager_.UpdateCount());
774  EXPECT_EQ(2, semantics_manager_.CommitCount());
775  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
776  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
777 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [32/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
BatchesLargeMessages   
)

Definition at line 779 of file accessibility_bridge_unittest.cc.

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

779  {
780  // Tests that messages get batched appropriately.
782  node0.id = 0;
783 
785 
786  const int32_t child_nodes = 100;
787  const int32_t leaf_nodes = 100;
788  for (int32_t i = 1; i < child_nodes + 1; i++) {
790  node.id = i;
791  node0.childrenInTraversalOrder.push_back(i);
792  node0.childrenInHitTestOrder.push_back(i);
793  for (int32_t j = 0; j < leaf_nodes; j++) {
794  flutter::SemanticsNode leaf_node;
795  int id = (i * child_nodes) + ((j + 1) * leaf_nodes);
796  leaf_node.id = id;
797  leaf_node.label = "A relatively simple label";
798  node.childrenInTraversalOrder.push_back(id);
799  node.childrenInHitTestOrder.push_back(id);
800  update.insert(std::make_pair(id, std::move(leaf_node)));
801  }
802  update.insert(std::make_pair(i, std::move(node)));
803  }
804 
805  update.insert(std::make_pair(0, std::move(node0)));
806  accessibility_bridge_->AddSemanticsNodeUpdate(update, 1.f);
807  RunLoopUntilIdle();
808 
809  EXPECT_EQ(0, semantics_manager_.DeleteCount());
810  EXPECT_TRUE(6 <= semantics_manager_.UpdateCount() &&
811  semantics_manager_.UpdateCount() <= 10);
812  EXPECT_EQ(1, semantics_manager_.CommitCount());
813  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
814  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
815 
816  int next_update_count = semantics_manager_.UpdateCount() + 1;
817  // Remove the children
818  node0.childrenInTraversalOrder.clear();
819  node0.childrenInHitTestOrder.clear();
820  accessibility_bridge_->AddSemanticsNodeUpdate(
821  {
822  {0, node0},
823  },
824  1.f);
825  RunLoopUntilIdle();
826 
827  EXPECT_EQ(1, semantics_manager_.DeleteCount());
828  EXPECT_EQ(next_update_count, semantics_manager_.UpdateCount());
829  EXPECT_EQ(2, semantics_manager_.CommitCount());
830  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
831  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
832 }
std::vector< int32_t > childrenInHitTestOrder
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::vector< int32_t > childrenInTraversalOrder
const FlutterSemanticsNode * node
Definition: fl_view.cc:83
int32_t id

◆ TEST_F() [33/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTest   
)

Definition at line 834 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::actions, callback, flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::flags, flutter::SemanticsNode::id, flutter::kIsFocusable, flutter::SemanticsNode::label, flutter::SemanticsNode::platformViewId, flutter::SemanticsNode::rect, and flutter::SemanticsNode::transform.

834  {
836  node0.id = 0;
837  node0.rect.setLTRB(0, 0, 100, 100);
838  node0.flags |= static_cast<int32_t>(flutter::SemanticsFlags::kIsFocusable);
839 
841  node1.id = 1;
842  node1.rect.setLTRB(10, 10, 20, 20);
843  // Setting platform view id ensures this node is considered focusable.
844  node1.platformViewId = 1u;
845 
847  node2.id = 2;
848  node2.rect.setLTRB(25, 10, 45, 20);
849  // Setting label ensures this node is considered focusable.
850  node2.label = "label";
851 
853  node3.id = 3;
854  node3.rect.setLTRB(10, 25, 20, 45);
855  // Setting actions to a nonzero value ensures this node is considered
856  // focusable.
857  node3.actions = 1u;
858 
860  node4.id = 4;
861  node4.rect.setLTRB(10, 10, 20, 20);
862  node4.transform.setTranslate(20, 20, 0);
863  node4.flags |= static_cast<int32_t>(flutter::SemanticsFlags::kIsFocusable);
864 
865  node0.childrenInTraversalOrder = {1, 2, 3, 4};
866  node0.childrenInHitTestOrder = {1, 2, 3, 4};
867 
868  accessibility_bridge_->AddSemanticsNodeUpdate(
869  {
870  {0, node0},
871  {1, node1},
872  {2, node2},
873  {3, node3},
874  {4, node4},
875  },
876  1.f);
877  RunLoopUntilIdle();
878 
879  uint32_t hit_node_id;
880  auto callback = [&hit_node_id](fuchsia::accessibility::semantics::Hit hit) {
881  EXPECT_TRUE(hit.has_node_id());
882  hit_node_id = hit.node_id();
883  };
884 
885  // Nodes are:
886  // ----------
887  // | 1 2 |
888  // | 3 4 |
889  // ----------
890 
891  accessibility_bridge_->HitTest({1, 1}, callback);
892  EXPECT_EQ(hit_node_id, 0u);
893  accessibility_bridge_->HitTest({15, 15}, callback);
894  EXPECT_EQ(hit_node_id, 1u);
895  accessibility_bridge_->HitTest({30, 15}, callback);
896  EXPECT_EQ(hit_node_id, 2u);
897  accessibility_bridge_->HitTest({15, 30}, callback);
898  EXPECT_EQ(hit_node_id, 3u);
899  accessibility_bridge_->HitTest({30, 30}, callback);
900  EXPECT_EQ(hit_node_id, 4u);
901 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ TEST_F() [34/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTestWithPixelRatio   
)

Definition at line 903 of file accessibility_bridge_unittest.cc.

References callback, flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::flags, flutter::SemanticsNode::id, flutter::kIsFocusable, flutter::SemanticsNode::platformViewId, and flutter::SemanticsNode::rect.

903  {
905  node0.id = 0;
906  node0.rect.setLTRB(0, 0, 100, 100);
907  node0.flags |= static_cast<int32_t>(flutter::SemanticsFlags::kIsFocusable);
908 
910  node1.id = 1;
911  node1.rect.setLTRB(10, 10, 20, 20);
912  // Setting platform view id ensures this node is considered focusable.
913  node1.platformViewId = 1u;
914 
915  node0.childrenInTraversalOrder = {1};
916  node0.childrenInHitTestOrder = {1};
917 
918  accessibility_bridge_->AddSemanticsNodeUpdate(
919  {
920  {0, node0},
921  {1, node1},
922  },
923  // Pick a very small pixel ratio so that a point within the bounds of
924  // the node's root-space coordinates will be well outside the "screen"
925  // bounds of the node.
926  .1f);
927  RunLoopUntilIdle();
928 
929  uint32_t hit_node_id;
930  auto callback = [&hit_node_id](fuchsia::accessibility::semantics::Hit hit) {
931  EXPECT_TRUE(hit.has_node_id());
932  hit_node_id = hit.node_id();
933  };
934  accessibility_bridge_->HitTest({15, 15}, callback);
935  EXPECT_EQ(hit_node_id, 0u);
936 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ TEST_F() [35/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTestUnfocusableChild   
)

Definition at line 938 of file accessibility_bridge_unittest.cc.

References callback, flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::flags, flutter::SemanticsNode::id, flutter::kIsFocusable, and flutter::SemanticsNode::rect.

938  {
940  node0.id = 0;
941  node0.rect.setLTRB(0, 0, 100, 100);
942 
944  node1.id = 1;
945  node1.rect.setLTRB(10, 10, 60, 60);
946 
948  node2.id = 2;
949  node2.rect.setLTRB(50, 50, 100, 100);
950  node2.flags |= static_cast<int32_t>(flutter::SemanticsFlags::kIsFocusable);
951 
952  node0.childrenInTraversalOrder = {1, 2};
953  node0.childrenInHitTestOrder = {1, 2};
954 
955  accessibility_bridge_->AddSemanticsNodeUpdate(
956  {
957  {0, node0},
958  {1, node1},
959  {2, node2},
960  },
961  1.f);
962  RunLoopUntilIdle();
963 
964  uint32_t hit_node_id;
965  auto callback = [&hit_node_id](fuchsia::accessibility::semantics::Hit hit) {
966  EXPECT_TRUE(hit.has_node_id());
967  hit_node_id = hit.node_id();
968  };
969 
970  accessibility_bridge_->HitTest({55, 55}, callback);
971  EXPECT_EQ(hit_node_id, 2u);
972 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ TEST_F() [36/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTestOverlapping   
)

Definition at line 974 of file accessibility_bridge_unittest.cc.

References callback, flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::flags, flutter::SemanticsNode::id, flutter::kIsFocusable, and flutter::SemanticsNode::rect.

974  {
975  // Tests that the first node in hit test order wins, even if a later node
976  // would be able to receive the hit.
978  node0.id = 0;
979  node0.rect.setLTRB(0, 0, 100, 100);
980  node0.flags |= static_cast<int32_t>(flutter::SemanticsFlags::kIsFocusable);
981 
983  node1.id = 1;
984  node1.rect.setLTRB(0, 0, 100, 100);
985  node1.flags |= static_cast<int32_t>(flutter::SemanticsFlags::kIsFocusable);
986 
988  node2.id = 2;
989  node2.rect.setLTRB(25, 10, 45, 20);
990  node2.flags |= static_cast<int32_t>(flutter::SemanticsFlags::kIsFocusable);
991 
992  node0.childrenInTraversalOrder = {1, 2};
993  node0.childrenInHitTestOrder = {2, 1};
994 
995  accessibility_bridge_->AddSemanticsNodeUpdate(
996  {
997  {0, node0},
998  {1, node1},
999  {2, node2},
1000  },
1001  1.f);
1002  RunLoopUntilIdle();
1003 
1004  uint32_t hit_node_id;
1005  auto callback = [&hit_node_id](fuchsia::accessibility::semantics::Hit hit) {
1006  EXPECT_TRUE(hit.has_node_id());
1007  hit_node_id = hit.node_id();
1008  };
1009 
1010  accessibility_bridge_->HitTest({30, 15}, callback);
1011  EXPECT_EQ(hit_node_id, 2u);
1012 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ TEST_F() [37/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
Actions   
)

Definition at line 1014 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.

1014  {
1015  flutter::SemanticsNode node0;
1016  node0.id = 0;
1017 
1018  flutter::SemanticsNode node1;
1019  node1.id = 1;
1020 
1021  node0.childrenInTraversalOrder = {1};
1022  node0.childrenInHitTestOrder = {1};
1023 
1024  accessibility_bridge_->AddSemanticsNodeUpdate(
1025  {
1026  {0, node0},
1027  {1, node1},
1028  },
1029  1.f);
1030  RunLoopUntilIdle();
1031 
1032  auto handled_callback = [](bool handled) { EXPECT_TRUE(handled); };
1033  auto unhandled_callback = [](bool handled) { EXPECT_FALSE(handled); };
1034 
1035  accessibility_bridge_->OnAccessibilityActionRequested(
1036  0u, fuchsia::accessibility::semantics::Action::DEFAULT, handled_callback);
1037  EXPECT_EQ(accessibility_delegate_.actions.size(), 1u);
1038  EXPECT_EQ(accessibility_delegate_.actions.back(),
1039  std::make_pair(0, flutter::SemanticsAction::kTap));
1040 
1041  accessibility_bridge_->OnAccessibilityActionRequested(
1042  0u, fuchsia::accessibility::semantics::Action::SECONDARY,
1043  handled_callback);
1044  EXPECT_EQ(accessibility_delegate_.actions.size(), 2u);
1045  EXPECT_EQ(accessibility_delegate_.actions.back(),
1046  std::make_pair(0, flutter::SemanticsAction::kLongPress));
1047 
1048  accessibility_bridge_->OnAccessibilityActionRequested(
1049  0u, fuchsia::accessibility::semantics::Action::SET_FOCUS,
1050  unhandled_callback);
1051  EXPECT_EQ(accessibility_delegate_.actions.size(), 2u);
1052 
1053  accessibility_bridge_->OnAccessibilityActionRequested(
1054  0u, fuchsia::accessibility::semantics::Action::SET_VALUE,
1055  unhandled_callback);
1056  EXPECT_EQ(accessibility_delegate_.actions.size(), 2u);
1057 
1058  accessibility_bridge_->OnAccessibilityActionRequested(
1059  0u, fuchsia::accessibility::semantics::Action::SHOW_ON_SCREEN,
1060  handled_callback);
1061  EXPECT_EQ(accessibility_delegate_.actions.size(), 3u);
1062  EXPECT_EQ(accessibility_delegate_.actions.back(),
1063  std::make_pair(0, flutter::SemanticsAction::kShowOnScreen));
1064 
1065  accessibility_bridge_->OnAccessibilityActionRequested(
1066  2u, fuchsia::accessibility::semantics::Action::DEFAULT,
1067  unhandled_callback);
1068  EXPECT_EQ(accessibility_delegate_.actions.size(), 3u);
1069 
1070  accessibility_bridge_->OnAccessibilityActionRequested(
1071  0u, fuchsia::accessibility::semantics::Action::INCREMENT,
1072  handled_callback);
1073  EXPECT_EQ(accessibility_delegate_.actions.size(), 4u);
1074  EXPECT_EQ(accessibility_delegate_.actions.back(),
1075  std::make_pair(0, flutter::SemanticsAction::kIncrease));
1076 
1077  accessibility_bridge_->OnAccessibilityActionRequested(
1078  0u, fuchsia::accessibility::semantics::Action::DECREMENT,
1079  handled_callback);
1080  EXPECT_EQ(accessibility_delegate_.actions.size(), 5u);
1081  EXPECT_EQ(accessibility_delegate_.actions.back(),
1082  std::make_pair(0, flutter::SemanticsAction::kDecrease));
1083 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder

◆ TEST_F() [38/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
InspectData   
)

Definition at line 1086 of file accessibility_bridge_unittest.cc.

References flutter::SemanticsNode::childrenInHitTestOrder, flutter::SemanticsNode::childrenInTraversalOrder, flutter::SemanticsNode::flags, flutter::SemanticsNode::hint, flutter::SemanticsNode::id, flutter::kIsButton, flutter::kIsHeader, flutter::SemanticsNode::label, name, flutter::SemanticsNode::rect, result, and flutter::SemanticsNode::value.

1086  {
1088  flutter::SemanticsNode node0;
1089  node0.id = 0;
1090  node0.label = "node0";
1091  node0.hint = "node0_hint";
1092  node0.value = "value";
1093  node0.flags |= static_cast<int>(flutter::SemanticsFlags::kIsButton);
1094  node0.childrenInTraversalOrder = {1};
1095  node0.childrenInHitTestOrder = {1};
1096  node0.rect.setLTRB(0, 0, 100, 100);
1097  updates.emplace(0, node0);
1098 
1099  flutter::SemanticsNode node1;
1100  node1.id = 1;
1101  node1.flags |= static_cast<int>(flutter::SemanticsFlags::kIsHeader);
1102  node1.childrenInTraversalOrder = {};
1103  node1.childrenInHitTestOrder = {};
1104  updates.emplace(1, node1);
1105 
1106  accessibility_bridge_->AddSemanticsNodeUpdate(std::move(updates), 1.f);
1107  RunLoopUntilIdle();
1108 
1109  fpromise::result<inspect::Hierarchy> hierarchy;
1110  ASSERT_FALSE(hierarchy.is_ok());
1111  RunPromiseToCompletion(
1112  inspect::ReadFromInspector(*inspector_)
1113  .then([&hierarchy](fpromise::result<inspect::Hierarchy>& result) {
1114  hierarchy = std::move(result);
1115  }));
1116  ASSERT_TRUE(hierarchy.is_ok());
1117 
1118  auto tree_inspect_hierarchy = hierarchy.value().GetByPath({"test_node"});
1119  ASSERT_NE(tree_inspect_hierarchy, nullptr);
1120  // TODO(http://fxbug.dev/75841): Rewrite flutter engine accessibility bridge
1121  // tests using inspect matchers. The checks bellow verify that the tree was
1122  // built, and that it matches the format of the input tree. This will be
1123  // updated in the future when test matchers are available to verify individual
1124  // property values.
1125  const auto& root = tree_inspect_hierarchy->children();
1126  ASSERT_EQ(root.size(), 1u);
1127  EXPECT_EQ(root[0].name(), "semantic_tree_root");
1128  const auto& child = root[0].children();
1129  ASSERT_EQ(child.size(), 1u);
1130  EXPECT_EQ(child[0].name(), "node_1");
1131 }
std::vector< int32_t > childrenInHitTestOrder
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
GAsyncResult * result
std::vector< int32_t > childrenInTraversalOrder
const char * name
Definition: fuchsia.cc:50