diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index 1f7a850b07135..fcd51e7cddf83 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -122,7 +122,10 @@ source_set("flutter_windows_source") { public_configs = [ ":relative_angle_headers" ] - defines = [ "FLUTTER_ENGINE_NO_PROTOTYPES" ] + defines = [ + "FLUTTER_ENGINE_NO_PROTOTYPES", + "FLUTTER_ENGINE_USE_UIA", + ] public_deps = [ "//flutter/fml:string_conversion", @@ -227,6 +230,8 @@ executable("flutter_windows_unittests") { public_configs = [ "//flutter:config" ] + defines = [ "FLUTTER_ENGINE_USE_UIA" ] + deps = [ ":flutter_windows_fixtures", ":flutter_windows_headers", diff --git a/shell/platform/windows/testing/mock_window.h b/shell/platform/windows/testing/mock_window.h index f25732ee63617..22429cf32a18f 100644 --- a/shell/platform/windows/testing/mock_window.h +++ b/shell/platform/windows/testing/mock_window.h @@ -67,6 +67,8 @@ class MockWindow : public Window { MOCK_METHOD0(GetAxFragmentRootDelegate, ui::AXFragmentRootDelegateWin*()); + MOCK_METHOD3(OnGetObject, LRESULT(UINT, WPARAM, LPARAM)); + void CallOnImeComposition(UINT const message, WPARAM const wparam, LPARAM const lparam); diff --git a/shell/platform/windows/window.h b/shell/platform/windows/window.h index 1ad35e68e2b86..632e140979575 100644 --- a/shell/platform/windows/window.h +++ b/shell/platform/windows/window.h @@ -141,9 +141,9 @@ class Window : public KeyboardManager::WindowDelegate { // // The primary use of this function is to supply Windows with wrapped // semantics objects for use by Windows accessibility. - LRESULT OnGetObject(UINT const message, - WPARAM const wparam, - LPARAM const lparam); + virtual LRESULT OnGetObject(UINT const message, + WPARAM const wparam, + LPARAM const lparam); // Called when IME composing begins. virtual void OnComposeBegin() = 0; diff --git a/shell/platform/windows/window_unittests.cc b/shell/platform/windows/window_unittests.cc index 82fbede827fe2..251ef3f217f1f 100644 --- a/shell/platform/windows/window_unittests.cc +++ b/shell/platform/windows/window_unittests.cc @@ -360,5 +360,23 @@ TEST(MockWindow, UnknownPointerTypeSkipsDirectManipulation) { window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0); } +// Test that the root UIA object is queried by WM_GETOBJECT. +TEST(MockWindow, GetObjectUia) { + MockWindow window; + bool uia_called = false; + ON_CALL(window, OnGetObject) + .WillByDefault(Invoke([&uia_called](UINT msg, WPARAM wpar, LPARAM lpar) { +#ifdef FLUTTER_ENGINE_USE_UIA + uia_called = true; +#endif // FLUTTER_ENGINE_USE_UIA + return static_cast(0); + })); + EXPECT_CALL(window, OnGetObject).Times(1); + + window.InjectWindowMessage(WM_GETOBJECT, 0, UiaRootObjectId); + + EXPECT_TRUE(uia_called); +} + } // namespace testing } // namespace flutter