[a11y] Use DartConverter for embedder a11y tests (#40993)

No semantic change. This just simplifies converting Dart arguments to
C++ types, making it more consistent with the rest of the codebase.

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I signed the [CLA].
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
diff --git a/shell/platform/embedder/tests/embedder_a11y_unittests.cc b/shell/platform/embedder/tests/embedder_a11y_unittests.cc
index 4c64169..a682016e 100644
--- a/shell/platform/embedder/tests/embedder_a11y_unittests.cc
+++ b/shell/platform/embedder/tests/embedder_a11y_unittests.cc
@@ -15,6 +15,10 @@
 #include "flutter/shell/platform/embedder/embedder.h"
 #include "flutter/shell/platform/embedder/tests/embedder_config_builder.h"
 #include "flutter/testing/testing.h"
+#include "third_party/tonic/converter/dart_converter.h"
+
+#include "gmock/gmock.h"  // For EXPECT_THAT and matchers
+#include "gtest/gtest.h"
 
 // CREATE_NATIVE_ENTRY is leaky by design
 // NOLINTBEGIN(clang-analyzer-core.StackAddressEscape)
@@ -23,6 +27,7 @@
 namespace testing {
 
 using EmbedderA11yTest = testing::EmbedderTest;
+using ::testing::ElementsAre;
 
 constexpr static char kTooltip[] = "tooltip";
 
@@ -175,9 +180,9 @@
   // Wait for initial NotifySemanticsEnabled(false).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_semantics_enabled_latch.Signal();
   };
@@ -186,9 +191,9 @@
   // Prepare to NotifyAccessibilityFeatures call
   fml::AutoResetWaitableEvent notify_features_latch;
   notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_features_latch.Signal();
   };
@@ -196,9 +201,9 @@
   // Enable semantics. Wait for NotifySemanticsEnabled(true).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = false;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_TRUE(enabled);
     notify_semantics_enabled_latch_2.Signal();
   };
@@ -212,9 +217,9 @@
   // Set accessibility features: (reduce_motion == true)
   fml::AutoResetWaitableEvent notify_features_latch_2;
   notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
-    bool enabled = false;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_TRUE(enabled);
     notify_features_latch_2.Signal();
   };
@@ -231,24 +236,19 @@
   // Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
   fml::AutoResetWaitableEvent notify_semantics_action_latch;
   notify_semantics_action_callback = [&](Dart_NativeArguments args) {
-    int64_t node_id = 0;
-    Dart_GetNativeIntegerArgument(args, 0, &node_id);
+    Dart_Handle exception = nullptr;
+    int64_t node_id =
+        ::tonic::DartConverter<int64_t>::FromArguments(args, 0, exception);
     ASSERT_EQ(42, node_id);
 
-    int64_t action_id;
-    auto handle = Dart_GetNativeIntegerArgument(args, 1, &action_id);
-    ASSERT_FALSE(Dart_IsError(handle));
+    int64_t action_id =
+        ::tonic::DartConverter<int64_t>::FromArguments(args, 1, exception);
     ASSERT_EQ(static_cast<int32_t>(flutter::SemanticsAction::kTap), action_id);
 
-    Dart_Handle semantic_args = Dart_GetNativeArgument(args, 2);
-    int64_t data;
-    Dart_Handle dart_int = Dart_ListGetAt(semantic_args, 0);
-    Dart_IntegerToInt64(dart_int, &data);
-    ASSERT_EQ(2, data);
-
-    dart_int = Dart_ListGetAt(semantic_args, 1);
-    Dart_IntegerToInt64(dart_int, &data);
-    ASSERT_EQ(1, data);
+    std::vector<int64_t> semantic_args =
+        ::tonic::DartConverter<std::vector<int64_t>>::FromArguments(args, 2,
+                                                                    exception);
+    ASSERT_THAT(semantic_args, ElementsAre(2, 1));
     notify_semantics_action_latch.Signal();
   };
   std::vector<uint8_t> bytes({2, 1});
@@ -260,8 +260,9 @@
   // Disable semantics. Wait for NotifySemanticsEnabled(false).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    Dart_GetNativeBooleanArgument(args, 0, &enabled);
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_semantics_enabled_latch_3.Signal();
   };
@@ -355,9 +356,9 @@
   // Wait for initial NotifySemanticsEnabled(false).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_semantics_enabled_latch.Signal();
   };
@@ -366,9 +367,9 @@
   // Prepare to NotifyAccessibilityFeatures call
   fml::AutoResetWaitableEvent notify_features_latch;
   notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_features_latch.Signal();
   };
@@ -376,9 +377,9 @@
   // Enable semantics. Wait for NotifySemanticsEnabled(true).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = false;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_TRUE(enabled);
     notify_semantics_enabled_latch_2.Signal();
   };
@@ -392,9 +393,9 @@
   // Set accessibility features: (reduce_motion == true)
   fml::AutoResetWaitableEvent notify_features_latch_2;
   notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
-    bool enabled = false;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_TRUE(enabled);
     notify_features_latch_2.Signal();
   };
@@ -411,24 +412,19 @@
   // Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
   fml::AutoResetWaitableEvent notify_semantics_action_latch;
   notify_semantics_action_callback = [&](Dart_NativeArguments args) {
-    int64_t node_id = 0;
-    Dart_GetNativeIntegerArgument(args, 0, &node_id);
+    Dart_Handle exception = nullptr;
+    int64_t node_id =
+        ::tonic::DartConverter<int64_t>::FromArguments(args, 0, exception);
     ASSERT_EQ(42, node_id);
 
-    int64_t action_id;
-    auto handle = Dart_GetNativeIntegerArgument(args, 1, &action_id);
-    ASSERT_FALSE(Dart_IsError(handle));
+    int64_t action_id =
+        ::tonic::DartConverter<int64_t>::FromArguments(args, 1, exception);
     ASSERT_EQ(static_cast<int32_t>(flutter::SemanticsAction::kTap), action_id);
 
-    Dart_Handle semantic_args = Dart_GetNativeArgument(args, 2);
-    int64_t data;
-    Dart_Handle dart_int = Dart_ListGetAt(semantic_args, 0);
-    Dart_IntegerToInt64(dart_int, &data);
-    ASSERT_EQ(2, data);
-
-    dart_int = Dart_ListGetAt(semantic_args, 1);
-    Dart_IntegerToInt64(dart_int, &data);
-    ASSERT_EQ(1, data);
+    std::vector<int64_t> semantic_args =
+        ::tonic::DartConverter<std::vector<int64_t>>::FromArguments(args, 2,
+                                                                    exception);
+    ASSERT_THAT(semantic_args, ElementsAre(2, 1));
     notify_semantics_action_latch.Signal();
   };
   std::vector<uint8_t> bytes({2, 1});
@@ -440,8 +436,9 @@
   // Disable semantics. Wait for NotifySemanticsEnabled(false).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    Dart_GetNativeBooleanArgument(args, 0, &enabled);
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_semantics_enabled_latch_3.Signal();
   };
@@ -552,9 +549,9 @@
   // Wait for initial NotifySemanticsEnabled(false).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_semantics_enabled_latch.Signal();
   };
@@ -563,9 +560,9 @@
   // Prepare to NotifyAccessibilityFeatures call
   fml::AutoResetWaitableEvent notify_features_latch;
   notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_features_latch.Signal();
   };
@@ -573,9 +570,9 @@
   // Enable semantics. Wait for NotifySemanticsEnabled(true).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch_2;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = false;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_TRUE(enabled);
     notify_semantics_enabled_latch_2.Signal();
   };
@@ -589,9 +586,9 @@
   // Set accessibility features: (reduce_motion == true)
   fml::AutoResetWaitableEvent notify_features_latch_2;
   notify_accessibility_features_callback = [&](Dart_NativeArguments args) {
-    bool enabled = false;
-    auto handle = Dart_GetNativeBooleanArgument(args, 0, &enabled);
-    ASSERT_FALSE(Dart_IsError(handle));
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_TRUE(enabled);
     notify_features_latch_2.Signal();
   };
@@ -613,24 +610,19 @@
   // Dispatch a tap to semantics node 42. Wait for NotifySemanticsAction.
   fml::AutoResetWaitableEvent notify_semantics_action_latch;
   notify_semantics_action_callback = [&](Dart_NativeArguments args) {
-    int64_t node_id = 0;
-    Dart_GetNativeIntegerArgument(args, 0, &node_id);
+    Dart_Handle exception = nullptr;
+    int64_t node_id =
+        ::tonic::DartConverter<int64_t>::FromArguments(args, 0, exception);
     ASSERT_EQ(42, node_id);
 
-    int64_t action_id;
-    auto handle = Dart_GetNativeIntegerArgument(args, 1, &action_id);
-    ASSERT_FALSE(Dart_IsError(handle));
+    int64_t action_id =
+        ::tonic::DartConverter<int64_t>::FromArguments(args, 1, exception);
     ASSERT_EQ(static_cast<int32_t>(flutter::SemanticsAction::kTap), action_id);
 
-    Dart_Handle semantic_args = Dart_GetNativeArgument(args, 2);
-    int64_t data;
-    Dart_Handle dart_int = Dart_ListGetAt(semantic_args, 0);
-    Dart_IntegerToInt64(dart_int, &data);
-    ASSERT_EQ(2, data);
-
-    dart_int = Dart_ListGetAt(semantic_args, 1);
-    Dart_IntegerToInt64(dart_int, &data);
-    ASSERT_EQ(1, data);
+    std::vector<int64_t> semantic_args =
+        ::tonic::DartConverter<std::vector<int64_t>>::FromArguments(args, 2,
+                                                                    exception);
+    ASSERT_THAT(semantic_args, ElementsAre(2, 1));
     notify_semantics_action_latch.Signal();
   };
   std::vector<uint8_t> bytes({2, 1});
@@ -642,8 +634,9 @@
   // Disable semantics. Wait for NotifySemanticsEnabled(false).
   fml::AutoResetWaitableEvent notify_semantics_enabled_latch_3;
   notify_semantics_enabled_callback = [&](Dart_NativeArguments args) {
-    bool enabled = true;
-    Dart_GetNativeBooleanArgument(args, 0, &enabled);
+    Dart_Handle exception = nullptr;
+    bool enabled =
+        ::tonic::DartConverter<bool>::FromArguments(args, 0, exception);
     ASSERT_FALSE(enabled);
     notify_semantics_enabled_latch_3.Signal();
   };