From 4220821a5e9e976eb35c7f4c928fa641e66875d2 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 9 Feb 2023 10:22:10 -0500 Subject: [PATCH 1/6] Enable UIA --- shell/platform/windows/BUILD.gn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index 1f7a850b07135..e3fd536956d1b 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", From 84767a123654f1f2b8128acee812bb98b6489a31 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 9 Feb 2023 10:39:58 -0500 Subject: [PATCH 2/6] Unit test getobject --- shell/platform/windows/BUILD.gn | 2 ++ shell/platform/windows/testing/mock_window.h | 2 ++ shell/platform/windows/window.h | 6 +++--- shell/platform/windows/window_unittests.cc | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index e3fd536956d1b..751e3f721f93c 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -243,6 +243,8 @@ executable("flutter_windows_unittests") { "//flutter/third_party/tonic", "//third_party/rapidjson", ] + + defines = [ "FLUTTER_ENGINE_USE_UIA "] } shared_library("flutter_windows_glfw") { 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..1fb24e8891132 100644 --- a/shell/platform/windows/window_unittests.cc +++ b/shell/platform/windows/window_unittests.cc @@ -360,5 +360,22 @@ 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 From fa8b39cf2ed9866d0965886d6bc8a31bcce16da8 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 9 Feb 2023 11:52:04 -0500 Subject: [PATCH 3/6] Formatting --- shell/platform/windows/window_unittests.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/platform/windows/window_unittests.cc b/shell/platform/windows/window_unittests.cc index 1fb24e8891132..251ef3f217f1f 100644 --- a/shell/platform/windows/window_unittests.cc +++ b/shell/platform/windows/window_unittests.cc @@ -364,12 +364,13 @@ TEST(MockWindow, UnknownPointerTypeSkipsDirectManipulation) { TEST(MockWindow, GetObjectUia) { MockWindow window; bool uia_called = false; - ON_CALL(window, OnGetObject).WillByDefault(Invoke([&uia_called](UINT msg, WPARAM wpar, LPARAM lpar){ + ON_CALL(window, OnGetObject) + .WillByDefault(Invoke([&uia_called](UINT msg, WPARAM wpar, LPARAM lpar) { #ifdef FLUTTER_ENGINE_USE_UIA - uia_called = true; + uia_called = true; #endif // FLUTTER_ENGINE_USE_UIA - return static_cast(0); - })); + return static_cast(0); + })); EXPECT_CALL(window, OnGetObject).Times(1); window.InjectWindowMessage(WM_GETOBJECT, 0, UiaRootObjectId); From 5fe6cf5282557c7e497b5ad2254237a43ff8b9cd Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 9 Feb 2023 12:36:53 -0500 Subject: [PATCH 4/6] Formatting --- shell/platform/windows/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index 751e3f721f93c..026a7e0e3ea40 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -244,7 +244,7 @@ executable("flutter_windows_unittests") { "//third_party/rapidjson", ] - defines = [ "FLUTTER_ENGINE_USE_UIA "] + defines = [ "FLUTTER_ENGINE_USE_UIA" ] } shared_library("flutter_windows_glfw") { From 98fac8025e1caaf24e659ccdf848033abb36b060 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 9 Feb 2023 12:47:10 -0500 Subject: [PATCH 5/6] Formatting --- shell/platform/windows/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index 026a7e0e3ea40..b411ef8d959a2 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -229,6 +229,8 @@ executable("flutter_windows_unittests") { [ "//flutter/shell/platform/common:desktop_library_implementation" ] public_configs = [ "//flutter:config" ] + + defines = [ "FLUTTER_ENGINE_USE_UIA" ] deps = [ ":flutter_windows_fixtures", @@ -243,8 +245,6 @@ executable("flutter_windows_unittests") { "//flutter/third_party/tonic", "//third_party/rapidjson", ] - - defines = [ "FLUTTER_ENGINE_USE_UIA" ] } shared_library("flutter_windows_glfw") { From 54f47af14c624d73f70b937bddff6514960f3cc3 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 9 Feb 2023 14:06:06 -0500 Subject: [PATCH 6/6] Formatting --- shell/platform/windows/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index b411ef8d959a2..fcd51e7cddf83 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -229,7 +229,7 @@ executable("flutter_windows_unittests") { [ "//flutter/shell/platform/common:desktop_library_implementation" ] public_configs = [ "//flutter:config" ] - + defines = [ "FLUTTER_ENGINE_USE_UIA" ] deps = [