From ed86837855e5a6efda638f84993f926937ab3b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= <737941+loic-sharma@users.noreply.github.com> Date: Thu, 29 Sep 2022 09:41:13 -0700 Subject: [PATCH] Fix the `AXPlatformNodeWinTest.IAccessibleHitTest` test (flutter/engine#36490) --- .../ax/platform/ax_platform_node_win_unittest.cc | 4 ++-- .../accessibility/ax/platform/test_ax_node_wrapper.cc | 5 +++++ .../accessibility/ax/platform/test_ax_node_wrapper.h | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/third_party/accessibility/ax/platform/ax_platform_node_win_unittest.cc b/engine/src/flutter/third_party/accessibility/ax/platform/ax_platform_node_win_unittest.cc index 6cd3740a2a..90d5e40156 100644 --- a/engine/src/flutter/third_party/accessibility/ax/platform/ax_platform_node_win_unittest.cc +++ b/engine/src/flutter/third_party/accessibility/ax/platform/ax_platform_node_win_unittest.cc @@ -271,6 +271,7 @@ void AXPlatformNodeWinTest::TearDown() { ax_fragment_root_.reset(nullptr); DestroyTree(); TestAXNodeWrapper::SetGlobalIsWebContent(false); + TestAXNodeWrapper::ClearHitTestResults(); ASSERT_EQ(0U, AXPlatformNodeBase::GetInstanceCountForTesting()); } @@ -446,8 +447,7 @@ TEST_F(AXPlatformNodeWinTest, IAccessibleDetachedObject) { EXPECT_EQ(E_FAIL, root_obj->get_accName(SELF, name2.Receive())); } -// TODO(cbracken): Flaky https://github.com/flutter/flutter/issues/98302 -TEST_F(AXPlatformNodeWinTest, DISABLED_IAccessibleHitTest) { +TEST_F(AXPlatformNodeWinTest, IAccessibleHitTest) { AXNodeData root; root.id = 1; root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40); diff --git a/engine/src/flutter/third_party/accessibility/ax/platform/test_ax_node_wrapper.cc b/engine/src/flutter/third_party/accessibility/ax/platform/test_ax_node_wrapper.cc index 6ed39a7bbc..7270b83911 100644 --- a/engine/src/flutter/third_party/accessibility/ax/platform/test_ax_node_wrapper.cc +++ b/engine/src/flutter/third_party/accessibility/ax/platform/test_ax_node_wrapper.cc @@ -119,6 +119,11 @@ void TestAXNodeWrapper::SetHitTestResult(AXNode::AXID src_node_id, g_hit_test_result[src_node_id] = dst_node_id; } +// static +void TestAXNodeWrapper::ClearHitTestResults() { + g_hit_test_result.clear(); +} + TestAXNodeWrapper::~TestAXNodeWrapper() { platform_node_->Destroy(); } diff --git a/engine/src/flutter/third_party/accessibility/ax/platform/test_ax_node_wrapper.h b/engine/src/flutter/third_party/accessibility/ax/platform/test_ax_node_wrapper.h index fc0581c12f..c2e9c208da 100644 --- a/engine/src/flutter/third_party/accessibility/ax/platform/test_ax_node_wrapper.h +++ b/engine/src/flutter/third_party/accessibility/ax/platform/test_ax_node_wrapper.h @@ -56,6 +56,9 @@ class TestAXNodeWrapper : public AXPlatformNodeDelegateBase { static void SetHitTestResult(AXNode::AXID src_node_id, AXNode::AXID dst_node_id); + // Remove all hit test overrides added by SetHitTestResult. + static void ClearHitTestResults(); + ~TestAXNodeWrapper() override; AXPlatformNode* ax_platform_node() const { return platform_node_; }