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

[a11y] Improve EmbedderA11yTest, fixture comments #40995

Merged
merged 1 commit into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions shell/platform/embedder/fixtures/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,23 @@ Future<SemanticsActionData> get semanticsAction {

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

// Await semantics enabled from embedder.
// 2: Await semantics enabled from embedder.
await semanticsChanged;
notifySemanticsEnabled(PlatformDispatcher.instance.semanticsEnabled);

// Return initial state of accessibility features.
// 3: Return initial state of accessibility features.
notifyAccessibilityFeatures(
PlatformDispatcher.instance.accessibilityFeatures.reduceMotion);

// Await accessibility features changed from embedder.
// 4: Await accessibility features changed from embedder.
await accessibilityFeaturesChanged;
notifyAccessibilityFeatures(
PlatformDispatcher.instance.accessibilityFeatures.reduceMotion);

// Fire semantics update.
// 5: Fire semantics update.
final SemanticsUpdateBuilder builder = SemanticsUpdateBuilder()
..updateNode(
id: 42,
Expand Down Expand Up @@ -284,15 +284,15 @@ void a11y_main() async {

signalNativeTest();

// Await semantics action from embedder.
// 6: Await semantics action from embedder.
final SemanticsActionData data = await semanticsAction;
final List<int> actionArgs = <int>[
data.args!.getInt8(0),
data.args!.getInt8(1)
];
notifySemanticsAction(data.id, data.action.index, actionArgs);

// Await semantics disabled from embedder.
// 7: Await semantics disabled from embedder.
await semanticsChanged;
notifySemanticsEnabled(PlatformDispatcher.instance.semanticsEnabled);
}
Expand Down
48 changes: 24 additions & 24 deletions shell/platform/embedder/tests/embedder_a11y_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
auto engine = builder.LaunchEngine();
ASSERT_TRUE(engine.is_valid());

// Wait for initial NotifySemanticsEnabled(false).
// 1: Wait for initial notifySemanticsEnabled(false).
fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
Dart_Handle exception = nullptr;
Expand All @@ -188,7 +188,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistent) {
};
notify_semantics_enabled_latch.Wait();

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

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

// Wait for initial accessibility features (reduce_motion == false)
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
notify_features_latch.Wait();

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

// Wait for UpdateSemantics callback on platform (current) thread.
// 5: Wait for UpdateSemantics callback on platform (current) thread.
signal_native_latch.Wait();
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
semantics_update_latch.Wait();

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

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

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

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

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

// Wait for initial accessibility features (reduce_motion == false)
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
notify_features_latch.Wait();

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

// Wait for UpdateSemantics callback on platform (current) thread.
// 5: Wait for UpdateSemantics callback on platform (current) thread.
signal_native_latch.Wait();
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
semantics_update_latch.Wait();

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

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

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

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

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

// Wait for initial accessibility features (reduce_motion == false)
// 3: Wait for notifyAccessibilityFeatures (reduce_motion == false)
notify_features_latch.Wait();

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

// Wait for UpdateSemantics callback on platform (current) thread.
// 5: Wait for UpdateSemantics callback on platform (current) thread.
signal_native_latch.Wait();
fml::MessageLoop::GetCurrent().RunExpiredTasksNow();
semantics_node_latch.Wait();
Expand All @@ -607,7 +607,7 @@ TEST_F(EmbedderA11yTest, A11yTreeIsConsistentUsingLegacyCallbacks) {
ASSERT_EQ(1, action_count);
ASSERT_EQ(1, action_batch_end_count);

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

// Disable semantics. Wait for NotifySemanticsEnabled(false).
// 7: Disable semantics. Wait for NotifySemanticsEnabled(false).
fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
Dart_Handle exception = nullptr;
Expand Down