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

Commit 86e8893

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 4972e08 commit 86e8893

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
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: 15 additions & 17 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;

0 commit comments

Comments
 (0)