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 141 of file accessibility_bridge_unittest.cc.

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

◆ TEST_F() [12/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
EnableDisable   
)

Definition at line 145 of file accessibility_bridge_unittest.cc.

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

◆ TEST_F() [13/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
RequestAnnounce   
)

Definition at line 153 of file accessibility_bridge_unittest.cc.

References message.

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

◆ TEST_F() [14/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesIsKeyboardKeyAttribute   
)

Definition at line 163 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [15/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
UpdatesNodeRoles   
)

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

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

◆ TEST_F() [16/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
DeletesChildrenTransitively   
)

Definition at line 273 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [17/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleButton   
)

Definition at line 325 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [18/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleImage   
)

Definition at line 341 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [19/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleSlider   
)

Definition at line 357 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [20/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesRoleHeader   
)

Definition at line 373 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [21/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesCheckedState   
)

Definition at line 389 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [22/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesSelectedState   
)

Definition at line 422 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [23/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesToggledState   
)

Definition at line 451 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [24/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
ApplyViewPixelRatioToRoot   
)

Definition at line 476 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [25/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
DoesNotPopulatesHiddenState   
)

Definition at line 490 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [26/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
PopulatesActions   
)

Definition at line 523 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [27/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
TruncatesLargeLabel   
)

Definition at line 553 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [28/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
TruncatesLargeToolTip   
)

Definition at line 599 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [29/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
TruncatesLargeValue   
)

Definition at line 645 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [30/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
SplitsLargeUpdates   
)

Definition at line 690 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [31/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HandlesCycles   
)

Definition at line 738 of file accessibility_bridge_unittest.cc.

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

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

◆ TEST_F() [32/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
BatchesLargeMessages   
)

Definition at line 778 of file accessibility_bridge_unittest.cc.

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

778  {
779  // Tests that messages get batched appropriately.
781  node0.id = 0;
782 
784 
785  const int32_t child_nodes = 100;
786  const int32_t leaf_nodes = 100;
787  for (int32_t i = 1; i < child_nodes + 1; i++) {
789  node.id = i;
790  node0.childrenInTraversalOrder.push_back(i);
791  node0.childrenInHitTestOrder.push_back(i);
792  for (int32_t j = 0; j < leaf_nodes; j++) {
793  flutter::SemanticsNode leaf_node;
794  int id = (i * child_nodes) + ((j + 1) * leaf_nodes);
795  leaf_node.id = id;
796  leaf_node.label = "A relatively simple label";
797  node.childrenInTraversalOrder.push_back(id);
798  node.childrenInHitTestOrder.push_back(id);
799  update.insert(std::make_pair(id, std::move(leaf_node)));
800  }
801  update.insert(std::make_pair(i, std::move(node)));
802  }
803 
804  update.insert(std::make_pair(0, std::move(node0)));
805 
806  // Make the semantics manager hold answering to this commit to test the flow
807  // control. This means the second update will not be pushed until the first
808  // one has processed.
809  semantics_manager_.SetShouldHoldCommitResponse(true);
810  accessibility_bridge_->AddSemanticsNodeUpdate(update, 1.f);
811  RunLoopUntilIdle();
812 
813  EXPECT_EQ(0, semantics_manager_.DeleteCount());
814 
815  EXPECT_TRUE(6 <= semantics_manager_.UpdateCount() &&
816  semantics_manager_.UpdateCount() <= 12);
817  EXPECT_EQ(1, semantics_manager_.CommitCount());
818  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
819  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
820 
821  int next_update_count = semantics_manager_.UpdateCount() + 1;
822  // Remove the children
823  node0.childrenInTraversalOrder.clear();
824  node0.childrenInHitTestOrder.clear();
825  accessibility_bridge_->AddSemanticsNodeUpdate(
826  {
827  {0, node0},
828  },
829  1.f);
830  RunLoopUntilIdle();
831 
832  // Should still be 0, because the commit was not answered yet.
833  EXPECT_EQ(0, semantics_manager_.DeleteCount());
834 
835  semantics_manager_.InvokeCommitCallback();
836  RunLoopUntilIdle();
837 
838  EXPECT_EQ(1, semantics_manager_.DeleteCount());
839  EXPECT_EQ(next_update_count, semantics_manager_.UpdateCount());
840  EXPECT_EQ(2, semantics_manager_.CommitCount());
841  EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
842  EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
843 }
std::vector< int32_t > childrenInHitTestOrder
std::unordered_map< int32_t, SemanticsNode > SemanticsNodeUpdates
std::vector< int32_t > childrenInTraversalOrder
int32_t id
G_BEGIN_DECLS const FlutterSemanticsNode * node

◆ TEST_F() [33/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTest   
)

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

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

◆ TEST_F() [34/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTestWithPixelRatio   
)

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

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

◆ TEST_F() [35/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTestUnfocusableChild   
)

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

949  {
951  node0.id = 0;
952  node0.rect.setLTRB(0, 0, 100, 100);
953 
955  node1.id = 1;
956  node1.rect.setLTRB(10, 10, 60, 60);
957 
959  node2.id = 2;
960  node2.rect.setLTRB(50, 50, 100, 100);
961  node2.flags |= static_cast<int32_t>(flutter::SemanticsFlags::kIsFocusable);
962 
963  node0.childrenInTraversalOrder = {1, 2};
964  node0.childrenInHitTestOrder = {1, 2};
965 
966  accessibility_bridge_->AddSemanticsNodeUpdate(
967  {
968  {0, node0},
969  {1, node1},
970  {2, node2},
971  },
972  1.f);
973  RunLoopUntilIdle();
974 
975  uint32_t hit_node_id;
976  auto callback = [&hit_node_id](fuchsia::accessibility::semantics::Hit hit) {
977  EXPECT_TRUE(hit.has_node_id());
978  hit_node_id = hit.node_id();
979  };
980 
981  accessibility_bridge_->HitTest({55, 55}, callback);
982  EXPECT_EQ(hit_node_id, 2u);
983 }
std::vector< int32_t > childrenInHitTestOrder
std::vector< int32_t > childrenInTraversalOrder
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ TEST_F() [36/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
HitTestOverlapping   
)

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

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

◆ TEST_F() [37/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
Actions   
)

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

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

◆ TEST_F() [38/38]

flutter_runner_test::TEST_F ( AccessibilityBridgeTest  ,
InspectData   
)

Definition at line 1097 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, flutter::name, flutter::SemanticsNode::rect, result, and flutter::SemanticsNode::value.

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