From 2eae74883a1a133b2a90ab3028b2c59d9171149b Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 19 Oct 2023 14:52:20 -0700 Subject: [PATCH] [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 --- .../macos/framework/Source/AccessibilityBridgeMacTest.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacTest.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacTest.mm index 536a62dcea..f499e80dc6 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacTest.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacTest.mm @@ -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]; }