Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5cf8df7

Browse files
committed
[a11y] Add breadcrumbs in unittests comments
Add breadcrumbs to make it easier to jump between the Dart fixture side and the embedder side of the EmbedderA11yTest.A11yTreeIsConsistent unittest.
1 parent 0a81b0c commit 5cf8df7

File tree

2 files changed

+52
-58
lines changed

2 files changed

+52
-58
lines changed

shell/platform/embedder/fixtures/main.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,23 @@ Future<SemanticsActionData> get semanticsAction {
124124

125125
@pragma('vm:entry-point')
126126
void a11y_main() async {
127-
// Return initial state (semantics disabled).
127+
// 1: Return initial state (semantics disabled).
128128
notifySemanticsEnabled(PlatformDispatcher.instance.semanticsEnabled);
129129

130-
// Await semantics enabled from embedder.
130+
// 2: Await semantics enabled from embedder.
131131
await semanticsChanged;
132132
notifySemanticsEnabled(PlatformDispatcher.instance.semanticsEnabled);
133133

134-
// Return initial state of accessibility features.
134+
// 3: Return initial state of accessibility features.
135135
notifyAccessibilityFeatures(
136136
PlatformDispatcher.instance.accessibilityFeatures.reduceMotion);
137137

138-
// Await accessibility features changed from embedder.
138+
// 4: Await accessibility features changed from embedder.
139139
await accessibilityFeaturesChanged;
140140
notifyAccessibilityFeatures(
141141
PlatformDispatcher.instance.accessibilityFeatures.reduceMotion);
142142

143-
// Fire semantics update.
143+
// 5: Fire semantics update.
144144
final SemanticsUpdateBuilder builder = SemanticsUpdateBuilder()
145145
..updateNode(
146146
id: 42,
@@ -284,15 +284,15 @@ void a11y_main() async {
284284

285285
signalNativeTest();
286286

287-
// Await semantics action from embedder.
287+
// 6: Await semantics action from embedder.
288288
final SemanticsActionData data = await semanticsAction;
289289
final List<int> actionArgs = <int>[
290290
data.args!.getInt8(0),
291291
data.args!.getInt8(1)
292292
];
293293
notifySemanticsAction(data.id, data.action.index, actionArgs);
294294

295-
// Await semantics disabled from embedder.
295+
// 7: Await semantics disabled from embedder.
296296
await semanticsChanged;
297297
notifySemanticsEnabled(PlatformDispatcher.instance.semanticsEnabled);
298298
}

shell/platform/embedder/tests/embedder_a11y_unittests.cc

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
177177
auto engine = builder.LaunchEngine();
178178
ASSERT_TRUE(engine.is_valid());
179179

180-
// Wait for initial NotifySemanticsEnabled(false).
180+
// 1: Wait for initial notifySemanticsEnabled(false).
181181
fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
182182
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
183183
Dart_Handle exception = nullptr;
@@ -188,17 +188,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
188188
};
189189
notify_semantics_enabled_latch.Wait();
190190

191-
// Prepare to NotifyAccessibilityFeatures call
192-
fml::AutoResetWaitableEvent notify_features_latch;
193-
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
194-
Dart_Handle exception = nullptr;
195-
bool enabled =
196-
::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
197-
ASSERT_FALSE(enabled);
198-
notify_features_latch.Signal();
199-
};
200-
201-
// Enable semantics. Wait for NotifySemanticsEnabled(true).
191+
// 2: Enable semantics. Wait for notifySemanticsEnabled(true).
202192
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
203193
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
204194
Dart_Handle exception = nullptr;
@@ -211,10 +201,18 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
211201
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
212202
notify_semantics_enabled_latch_2.Wait();
213203

214-
// Wait for initial accessibility features (reduce_motion == false)
204+
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
205+
fml::AutoResetWaitableEvent notify_features_latch;
206+
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
207+
Dart_Handle exception = nullptr;
208+
bool enabled =
209+
::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
210+
ASSERT_FALSE(enabled);
211+
notify_features_latch.Signal();
212+
};
215213
notify_features_latch.Wait();
216214

217-
// Set accessibility features: (reduce_motion == true)
215+
// 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
218216
fml::AutoResetWaitableEvent notify_features_latch_2;
219217
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
220218
Dart_Handle exception = nullptr;
@@ -228,12 +226,12 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
228226
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
229227
notify_features_latch_2.Wait();
230228

231-
// Wait for UpdateSemantics callback on platform (current) thread.
229+
// 5: Wait for UpdateSemantics callback on platform (current) thread.
232230
signal_native_latch.Wait();
233231
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
234232
semantics_update_latch.Wait();
235233

236-
// Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
234+
// 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
237235
fml::AutoResetWaitableEvent notify_semantics_action_latch;
238236
notify_semantics_action_callback = [&](Dart_NativeArguments args) {
239237
Dart_Handle exception = nullptr;
@@ -257,7 +255,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
257255
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
258256
notify_semantics_action_latch.Wait();
259257

260-
// Disable semantics. Wait for NotifySemanticsEnabled(false).
258+
// 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
261259
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
262260
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
263261
Dart_Handle exception = nullptr;
@@ -353,7 +351,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
353351
auto engine = builder.LaunchEngine();
354352
ASSERT_TRUE(engine.is_valid());
355353

356-
// Wait for initial NotifySemanticsEnabled(false).
354+
// 1: Wait for initial notifySemanticsEnabled(false).
357355
fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
358356
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
359357
Dart_Handle exception = nullptr;
@@ -364,17 +362,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
364362
};
365363
notify_semantics_enabled_latch.Wait();
366364

367-
// Prepare to NotifyAccessibilityFeatures call
368-
fml::AutoResetWaitableEvent notify_features_latch;
369-
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
370-
Dart_Handle exception = nullptr;
371-
bool enabled =
372-
::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
373-
ASSERT_FALSE(enabled);
374-
notify_features_latch.Signal();
375-
};
376-
377-
// Enable semantics. Wait for NotifySemanticsEnabled(true).
365+
// 2: Enable semantics. Wait for notifySemanticsEnabled(true).
378366
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
379367
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
380368
Dart_Handle exception = nullptr;
@@ -387,10 +375,18 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
387375
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
388376
notify_semantics_enabled_latch_2.Wait();
389377

390-
// Wait for initial accessibility features (reduce_motion == false)
378+
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
379+
fml::AutoResetWaitableEvent notify_features_latch;
380+
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
381+
Dart_Handle exception = nullptr;
382+
bool enabled =
383+
::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
384+
ASSERT_FALSE(enabled);
385+
notify_features_latch.Signal();
386+
};
391387
notify_features_latch.Wait();
392388

393-
// Set accessibility features: (reduce_motion == true)
389+
// 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
394390
fml::AutoResetWaitableEvent notify_features_latch_2;
395391
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
396392
Dart_Handle exception = nullptr;
@@ -404,12 +400,12 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
404400
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
405401
notify_features_latch_2.Wait();
406402

407-
// Wait for UpdateSemantics callback on platform (current) thread.
403+
// 5: Wait for UpdateSemantics callback on platform (current) thread.
408404
signal_native_latch.Wait();
409405
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
410406
semantics_update_latch.Wait();
411407

412-
// Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
408+
// 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
413409
fml::AutoResetWaitableEvent notify_semantics_action_latch;
414410
notify_semantics_action_callback = [&](Dart_NativeArguments args) {
415411
Dart_Handle exception = nullptr;
@@ -433,7 +429,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
433429
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
434430
notify_semantics_action_latch.Wait();
435431

436-
// Disable semantics. Wait for NotifySemanticsEnabled(false).
432+
// 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
437433
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
438434
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
439435
Dart_Handle exception = nullptr;
@@ -546,7 +542,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
546542
auto engine = builder.LaunchEngine();
547543
ASSERT_TRUE(engine.is_valid());
548544

549-
// Wait for initial NotifySemanticsEnabled(false).
545+
// 1: Wait for initial notifySemanticsEnabled(false).
550546
fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
551547
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
552548
Dart_Handle exception = nullptr;
@@ -557,17 +553,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
557553
};
558554
notify_semantics_enabled_latch.Wait();
559555

560-
// Prepare to NotifyAccessibilityFeatures call
561-
fml::AutoResetWaitableEvent notify_features_latch;
562-
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
563-
Dart_Handle exception = nullptr;
564-
bool enabled =
565-
::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
566-
ASSERT_FALSE(enabled);
567-
notify_features_latch.Signal();
568-
};
569-
570-
// Enable semantics. Wait for NotifySemanticsEnabled(true).
556+
// 2: Enable semantics. Wait for notifySemanticsEnabled(true).
571557
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
572558
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
573559
Dart_Handle exception = nullptr;
@@ -580,10 +566,18 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
580566
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
581567
notify_semantics_enabled_latch_2.Wait();
582568

583-
// Wait for initial accessibility features (reduce_motion == false)
569+
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
570+
fml::AutoResetWaitableEvent notify_features_latch;
571+
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
572+
Dart_Handle exception = nullptr;
573+
bool enabled =
574+
::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
575+
ASSERT_FALSE(enabled);
576+
notify_features_latch.Signal();
577+
};
584578
notify_features_latch.Wait();
585579

586-
// Set accessibility features: (reduce_motion == true)
580+
// 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
587581
fml::AutoResetWaitableEvent notify_features_latch_2;
588582
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
589583
Dart_Handle exception = nullptr;
@@ -597,7 +591,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
597591
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
598592
notify_features_latch_2.Wait();
599593

600-
// Wait for UpdateSemantics callback on platform (current) thread.
594+
// 5: Wait for UpdateSemantics callback on platform (current) thread.
601595
signal_native_latch.Wait();
602596
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
603597
semantics_node_latch.Wait();
@@ -607,7 +601,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
607601
ASSERT_EQ(1, action_count);
608602
ASSERT_EQ(1, action_batch_end_count);
609603

610-
// Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
604+
// 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
611605
fml::AutoResetWaitableEvent notify_semantics_action_latch;
612606
notify_semantics_action_callback = [&](Dart_NativeArguments args) {
613607
Dart_Handle exception = nullptr;
@@ -631,7 +625,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
631625
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
632626
notify_semantics_action_latch.Wait();
633627

634-
// Disable semantics. Wait for NotifySemanticsEnabled(false).
628+
// 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
635629
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
636630
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
637631
Dart_Handle exception = nullptr;

0 commit comments

Comments
 (0)