Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit de841f6

Browse files
Enable UIA in Window (#39513)
* Enable UIA * Unit test getobject * Formatting * Formatting * Formatting * Formatting
1 parent 24bde68 commit de841f6

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

shell/platform/windows/BUILD.gn

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ source_set("flutter_windows_source") {
122122

123123
public_configs = [ ":relative_angle_headers" ]
124124

125-
defines = [ "FLUTTER_ENGINE_NO_PROTOTYPES" ]
125+
defines = [
126+
"FLUTTER_ENGINE_NO_PROTOTYPES",
127+
"FLUTTER_ENGINE_USE_UIA",
128+
]
126129

127130
public_deps = [
128131
"//flutter/fml:string_conversion",
@@ -227,6 +230,8 @@ executable("flutter_windows_unittests") {
227230

228231
public_configs = [ "//flutter:config" ]
229232

233+
defines = [ "FLUTTER_ENGINE_USE_UIA" ]
234+
230235
deps = [
231236
":flutter_windows_fixtures",
232237
":flutter_windows_headers",

shell/platform/windows/testing/mock_window.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class MockWindow : public Window {
6767

6868
MOCK_METHOD0(GetAxFragmentRootDelegate, ui::AXFragmentRootDelegateWin*());
6969

70+
MOCK_METHOD3(OnGetObject, LRESULT(UINT, WPARAM, LPARAM));
71+
7072
void CallOnImeComposition(UINT const message,
7173
WPARAM const wparam,
7274
LPARAM const lparam);

shell/platform/windows/window.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ class Window : public KeyboardManager::WindowDelegate {
141141
//
142142
// The primary use of this function is to supply Windows with wrapped
143143
// semantics objects for use by Windows accessibility.
144-
LRESULT OnGetObject(UINT const message,
145-
WPARAM const wparam,
146-
LPARAM const lparam);
144+
virtual LRESULT OnGetObject(UINT const message,
145+
WPARAM const wparam,
146+
LPARAM const lparam);
147147

148148
// Called when IME composing begins.
149149
virtual void OnComposeBegin() = 0;

shell/platform/windows/window_unittests.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,5 +360,23 @@ TEST(MockWindow, UnknownPointerTypeSkipsDirectManipulation) {
360360
window.InjectWindowMessage(DM_POINTERHITTEST, MAKEWPARAM(pointer_id, 0), 0);
361361
}
362362

363+
// Test that the root UIA object is queried by WM_GETOBJECT.
364+
TEST(MockWindow, GetObjectUia) {
365+
MockWindow window;
366+
bool uia_called = false;
367+
ON_CALL(window, OnGetObject)
368+
.WillByDefault(Invoke([&uia_called](UINT msg, WPARAM wpar, LPARAM lpar) {
369+
#ifdef FLUTTER_ENGINE_USE_UIA
370+
uia_called = true;
371+
#endif // FLUTTER_ENGINE_USE_UIA
372+
return static_cast<LRESULT>(0);
373+
}));
374+
EXPECT_CALL(window, OnGetObject).Times(1);
375+
376+
window.InjectWindowMessage(WM_GETOBJECT, 0, UiaRootObjectId);
377+
378+
EXPECT_TRUE(uia_called);
379+
}
380+
363381
} // namespace testing
364382
} // namespace flutter

0 commit comments

Comments
 (0)