diff --git a/shell/platform/windows/accessibility_bridge_delegate_win32_unittests.cc b/shell/platform/windows/accessibility_bridge_delegate_win32_unittests.cc index 67baa9a74a059..8afc6351de42d 100644 --- a/shell/platform/windows/accessibility_bridge_delegate_win32_unittests.cc +++ b/shell/platform/windows/accessibility_bridge_delegate_win32_unittests.cc @@ -163,6 +163,36 @@ void ExpectWinEventFromAXEvent(int32_t node_id, } // namespace +TEST(AccessibilityBridgeDelegateWin32, GetParent) { + auto window_binding_handler = + std::make_unique<::testing::NiceMock>(); + FlutterWindowsView view(std::move(window_binding_handler)); + view.SetEngine(GetTestEngine()); + view.OnUpdateSemanticsEnabled(true); + + auto bridge = view.GetEngine()->accessibility_bridge().lock(); + PopulateAXTree(bridge); + + auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock(); + auto node1_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock(); + EXPECT_EQ(node0_delegate->GetNativeViewAccessible(), + node1_delegate->GetParent()); +} + +TEST(AccessibilityBridgeDelegateWin32, GetParentOnRootRetunsNullptr) { + auto window_binding_handler = + std::make_unique<::testing::NiceMock>(); + FlutterWindowsView view(std::move(window_binding_handler)); + view.SetEngine(GetTestEngine()); + view.OnUpdateSemanticsEnabled(true); + + auto bridge = view.GetEngine()->accessibility_bridge().lock(); + PopulateAXTree(bridge); + + auto node0_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock(); + ASSERT_TRUE(node0_delegate->GetParent() == nullptr); +} + TEST(AccessibilityBridgeDelegateWin32, NodeDelegateHasUniqueId) { auto window_binding_handler = std::make_unique<::testing::NiceMock>(); diff --git a/shell/platform/windows/flutter_platform_node_delegate_win32.cc b/shell/platform/windows/flutter_platform_node_delegate_win32.cc index 75d904fb0ae62..eb0d4769e7f9d 100644 --- a/shell/platform/windows/flutter_platform_node_delegate_win32.cc +++ b/shell/platform/windows/flutter_platform_node_delegate_win32.cc @@ -37,31 +37,6 @@ FlutterPlatformNodeDelegateWin32::GetNativeViewAccessible() { return ax_platform_node_->GetNativeViewAccessible(); } -// |FlutterPlatformNodeDelegate| -gfx::NativeViewAccessible FlutterPlatformNodeDelegateWin32::GetParent() { - gfx::NativeViewAccessible parent = FlutterPlatformNodeDelegate::GetParent(); - if (parent) { - return parent; - } - assert(engine_); - FlutterWindowsView* view = engine_->view(); - if (!view) { - return nullptr; - } - HWND hwnd = view->GetPlatformWindow(); - if (!hwnd) { - return nullptr; - } - - IAccessible* iaccessible_parent; - if (SUCCEEDED(::AccessibleObjectFromWindow( - hwnd, OBJID_WINDOW, IID_IAccessible, - reinterpret_cast(&iaccessible_parent)))) { - return iaccessible_parent; - } - return nullptr; -} - // |FlutterPlatformNodeDelegate| gfx::Rect FlutterPlatformNodeDelegateWin32::GetBoundsRect( const ui::AXCoordinateSystem coordinate_system, diff --git a/shell/platform/windows/flutter_platform_node_delegate_win32.h b/shell/platform/windows/flutter_platform_node_delegate_win32.h index f42c2baa4c87d..2b36f7aff460d 100644 --- a/shell/platform/windows/flutter_platform_node_delegate_win32.h +++ b/shell/platform/windows/flutter_platform_node_delegate_win32.h @@ -29,9 +29,6 @@ class FlutterPlatformNodeDelegateWin32 : public FlutterPlatformNodeDelegate { // |ui::AXPlatformNodeDelegate| gfx::NativeViewAccessible GetNativeViewAccessible() override; - // |FlutterPlatformNodeDelegate| - gfx::NativeViewAccessible GetParent() override; - // |FlutterPlatformNodeDelegate| gfx::Rect GetBoundsRect( const ui::AXCoordinateSystem coordinate_system,