[macOS] Fail early when no a11y notification (flutter/engine#47129)

In the SendsAccessibilityCreateNotificationToWindowOfFlutterView test in AccessibilityBridgeMacTest, we look for an accessibility notification by name in a map stored in the test accessibility bridge. If there is no such notification, bail out immediately.

Previously we got a crash since we called `second` to retrieve the value associated with the map entry we find, without actually checking that we'd actually found an entry.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Chris Bracken
2023-10-19 14:52:20 -07:00
committed by GitHub
parent ab1cafa36c
commit 2eae74883a

View File

@@ -105,10 +105,10 @@ TEST(AccessibilityBridgeMacTest, SendsAccessibilityCreateNotificationToWindowOfF
bridge->OnAccessibilityEvent(targeted_event);
EXPECT_EQ(bridge->actual_notifications.size(), 1u);
EXPECT_EQ(
bridge->actual_notifications.find([NSAccessibilityCreatedNotification UTF8String])->second,
expectedTarget);
ASSERT_EQ(bridge->actual_notifications.size(), 1u);
auto target = bridge->actual_notifications.find([NSAccessibilityCreatedNotification UTF8String]);
ASSERT_NE(target, bridge->actual_notifications.end());
EXPECT_EQ(target->second, expectedTarget);
[engine shutDownEngine];
}