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

Commit c29057a

Browse files
committed
[a11y] Simplify EmbedderA11yTest tests
Add breadcrumbs to make it easier to jump between the Dart fixture side and the embedder side of the EmbedderA11yTest.A11yTreeIsConsistent unittest.
1 parent cac56b2 commit c29057a

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
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: 24 additions & 24 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,7 +188,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
188188
};
189189
notify_semantics_enabled_latch.Wait();
190190

191-
// Prepare to NotifyAccessibilityFeatures call
191+
// Prepare notifyAccessibilityFeatures callback.
192192
fml::AutoResetWaitableEvent notify_features_latch;
193193
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
194194
Dart_Handle exception = nullptr;
@@ -198,7 +198,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
198198
notify_features_latch.Signal();
199199
};
200200

201-
// Enable semantics. Wait for NotifySemanticsEnabled(true).
201+
// 2: Enable semantics. Wait for notifySemanticsEnabled(true).
202202
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
203203
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
204204
Dart_Handle exception = nullptr;
@@ -211,10 +211,10 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
211211
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
212212
notify_semantics_enabled_latch_2.Wait();
213213

214-
// Wait for initial accessibility features (reduce_motion == false)
214+
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
215215
notify_features_latch.Wait();
216216

217-
// Set accessibility features: (reduce_motion == true)
217+
// 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
218218
fml::AutoResetWaitableEvent notify_features_latch_2;
219219
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
220220
Dart_Handle exception = nullptr;
@@ -228,12 +228,12 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
228228
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
229229
notify_features_latch_2.Wait();
230230

231-
// Wait for UpdateSemantics callback on platform (current) thread.
231+
// 5: Wait for UpdateSemantics callback on platform (current) thread.
232232
signal_native_latch.Wait();
233233
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
234234
semantics_update_latch.Wait();
235235

236-
// Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
236+
// 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
237237
fml::AutoResetWaitableEvent notify_semantics_action_latch;
238238
notify_semantics_action_callback = [&](Dart_NativeArguments args) {
239239
Dart_Handle exception = nullptr;
@@ -257,7 +257,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
257257
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
258258
notify_semantics_action_latch.Wait();
259259

260-
// Disable semantics. Wait for NotifySemanticsEnabled(false).
260+
// 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
261261
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
262262
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
263263
Dart_Handle exception = nullptr;
@@ -353,7 +353,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
353353
auto engine = builder.LaunchEngine();
354354
ASSERT_TRUE(engine.is_valid());
355355

356-
// Wait for initial NotifySemanticsEnabled(false).
356+
// 1: Wait for initial notifySemanticsEnabled(false).
357357
fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
358358
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
359359
Dart_Handle exception = nullptr;
@@ -364,7 +364,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
364364
};
365365
notify_semantics_enabled_latch.Wait();
366366

367-
// Prepare to NotifyAccessibilityFeatures call
367+
// Prepare notifyAccessibilityFeatures callback.
368368
fml::AutoResetWaitableEvent notify_features_latch;
369369
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
370370
Dart_Handle exception = nullptr;
@@ -374,7 +374,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
374374
notify_features_latch.Signal();
375375
};
376376

377-
// Enable semantics. Wait for NotifySemanticsEnabled(true).
377+
// 2: Enable semantics. Wait for notifySemanticsEnabled(true).
378378
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
379379
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
380380
Dart_Handle exception = nullptr;
@@ -387,10 +387,10 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
387387
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
388388
notify_semantics_enabled_latch_2.Wait();
389389

390-
// Wait for initial accessibility features (reduce_motion == false)
390+
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
391391
notify_features_latch.Wait();
392392

393-
// Set accessibility features: (reduce_motion == true)
393+
// 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
394394
fml::AutoResetWaitableEvent notify_features_latch_2;
395395
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
396396
Dart_Handle exception = nullptr;
@@ -404,12 +404,12 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
404404
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
405405
notify_features_latch_2.Wait();
406406

407-
// Wait for UpdateSemantics callback on platform (current) thread.
407+
// 5: Wait for UpdateSemantics callback on platform (current) thread.
408408
signal_native_latch.Wait();
409409
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
410410
semantics_update_latch.Wait();
411411

412-
// Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
412+
// 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
413413
fml::AutoResetWaitableEvent notify_semantics_action_latch;
414414
notify_semantics_action_callback = [&](Dart_NativeArguments args) {
415415
Dart_Handle exception = nullptr;
@@ -433,7 +433,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingUnstableCallbacks) {
433433
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
434434
notify_semantics_action_latch.Wait();
435435

436-
// Disable semantics. Wait for NotifySemanticsEnabled(false).
436+
// 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
437437
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
438438
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
439439
Dart_Handle exception = nullptr;
@@ -546,7 +546,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
546546
auto engine = builder.LaunchEngine();
547547
ASSERT_TRUE(engine.is_valid());
548548

549-
// Wait for initial NotifySemanticsEnabled(false).
549+
// 1: Wait for initial notifySemanticsEnabled(false).
550550
fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
551551
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
552552
Dart_Handle exception = nullptr;
@@ -557,7 +557,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
557557
};
558558
notify_semantics_enabled_latch.Wait();
559559

560-
// Prepare to NotifyAccessibilityFeatures call
560+
// Prepare notifyAccessibilityFeatures callback.
561561
fml::AutoResetWaitableEvent notify_features_latch;
562562
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
563563
Dart_Handle exception = nullptr;
@@ -567,7 +567,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
567567
notify_features_latch.Signal();
568568
};
569569

570-
// Enable semantics. Wait for NotifySemanticsEnabled(true).
570+
// 2: Enable semantics. Wait for notifySemanticsEnabled(true).
571571
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
572572
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
573573
Dart_Handle exception = nullptr;
@@ -580,10 +580,10 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
580580
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
581581
notify_semantics_enabled_latch_2.Wait();
582582

583-
// Wait for initial accessibility features (reduce_motion == false)
583+
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
584584
notify_features_latch.Wait();
585585

586-
// Set accessibility features: (reduce_motion == true)
586+
// 4: Wait for notifyAccessibilityFeatures (reduce_motion == true)
587587
fml::AutoResetWaitableEvent notify_features_latch_2;
588588
notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
589589
Dart_Handle exception = nullptr;
@@ -597,7 +597,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
597597
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
598598
notify_features_latch_2.Wait();
599599

600-
// Wait for UpdateSemantics callback on platform (current) thread.
600+
// 5: Wait for UpdateSemantics callback on platform (current) thread.
601601
signal_native_latch.Wait();
602602
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
603603
semantics_node_latch.Wait();
@@ -607,7 +607,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
607607
ASSERT_EQ(1, action_count);
608608
ASSERT_EQ(1, action_batch_end_count);
609609

610-
// Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
610+
// 6: Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
611611
fml::AutoResetWaitableEvent notify_semantics_action_latch;
612612
notify_semantics_action_callback = [&](Dart_NativeArguments args) {
613613
Dart_Handle exception = nullptr;
@@ -631,7 +631,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
631631
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
632632
notify_semantics_action_latch.Wait();
633633

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

0 commit comments

Comments
 (0)