[PATCH] uiautomationcore: Add UiaHostProviderFromHwnd() stub.

Nikolay Sivov nsivov at codeweavers.com
Tue Feb 12 07:26:51 CST 2019


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---

Called from OneNote 2016.

 configure                                   |  1 +
 configure.ac                                |  1 +
 dlls/uiautomationcore/Makefile.in           |  1 +
 dlls/uiautomationcore/tests/Makefile.in     |  5 ++
 dlls/uiautomationcore/tests/uiautomation.c  | 92 +++++++++++++++++++++
 dlls/uiautomationcore/uia_main.c            |  6 ++
 dlls/uiautomationcore/uiautomationcore.spec |  2 +-
 include/uiautomationcoreapi.h               |  1 +
 8 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 dlls/uiautomationcore/tests/Makefile.in
 create mode 100644 dlls/uiautomationcore/tests/uiautomation.c

diff --git a/configure b/configure
index ec211a538b..7f89b1e7e4 100755
--- a/configure
+++ b/configure
@@ -19985,6 +19985,7 @@ wine_fn_config_makefile dlls/tzres enable_tzres
 wine_fn_config_makefile dlls/ucrtbase enable_ucrtbase
 wine_fn_config_makefile dlls/ucrtbase/tests enable_tests
 wine_fn_config_makefile dlls/uiautomationcore enable_uiautomationcore
+wine_fn_config_makefile dlls/uiautomationcore/tests enable_tests
 wine_fn_config_makefile dlls/uiribbon enable_uiribbon
 wine_fn_config_makefile dlls/unicows enable_unicows
 wine_fn_config_makefile dlls/updspapi enable_updspapi
diff --git a/configure.ac b/configure.ac
index 1b425d22a2..36add65ae1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3724,6 +3724,7 @@ WINE_CONFIG_MAKEFILE(dlls/tzres)
 WINE_CONFIG_MAKEFILE(dlls/ucrtbase)
 WINE_CONFIG_MAKEFILE(dlls/ucrtbase/tests)
 WINE_CONFIG_MAKEFILE(dlls/uiautomationcore)
+WINE_CONFIG_MAKEFILE(dlls/uiautomationcore/tests)
 WINE_CONFIG_MAKEFILE(dlls/uiribbon)
 WINE_CONFIG_MAKEFILE(dlls/unicows)
 WINE_CONFIG_MAKEFILE(dlls/updspapi)
diff --git a/dlls/uiautomationcore/Makefile.in b/dlls/uiautomationcore/Makefile.in
index 78d6254a01..52214506f7 100644
--- a/dlls/uiautomationcore/Makefile.in
+++ b/dlls/uiautomationcore/Makefile.in
@@ -1,4 +1,5 @@
 MODULE = uiautomationcore.dll
+IMPORTLIB = uiautomationcore
 
 C_SRCS = \
 	uia_main.c
diff --git a/dlls/uiautomationcore/tests/Makefile.in b/dlls/uiautomationcore/tests/Makefile.in
new file mode 100644
index 0000000000..c39b062b6f
--- /dev/null
+++ b/dlls/uiautomationcore/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = uiautomationcore.dll
+IMPORTS = uiautomationcore user32
+
+C_SRCS = \
+	uiautomation.c
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c
new file mode 100644
index 0000000000..cbcba1af29
--- /dev/null
+++ b/dlls/uiautomationcore/tests/uiautomation.c
@@ -0,0 +1,92 @@
+/*
+ * UI Automation tests
+ *
+ * Copyright 2019 Nikolay Sivov for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include "windows.h"
+#include "initguid.h"
+#include "uiautomation.h"
+
+#include "wine/test.h"
+
+static LRESULT WINAPI test_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    return DefWindowProcA(hwnd, message, wParam, lParam);
+}
+
+static void test_UiaHostProviderFromHwnd(void)
+{
+    IRawElementProviderSimple *p, *p2;
+    WNDCLASSA cls;
+    HRESULT hr;
+    HWND hwnd;
+
+    cls.style = 0;
+    cls.lpfnWndProc = test_wnd_proc;
+    cls.cbClsExtra = 0;
+    cls.cbWndExtra = 0;
+    cls.hInstance = GetModuleHandleA(NULL);
+    cls.hIcon = 0;
+    cls.hCursor = NULL;
+    cls.hbrBackground = NULL;
+    cls.lpszMenuName = NULL;
+    cls.lpszClassName = "HostProviderFromHwnd class";
+
+    RegisterClassA(&cls);
+
+    hwnd = CreateWindowExA(0, "HostProviderFromHwnd class", "Test window 1",
+            WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE,
+            0, 0, 100, 100, GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
+    ok(hwnd != NULL, "Failed to create a test window.\n");
+
+    p = (void *)0xdeadbeef;
+    hr = UiaHostProviderFromHwnd(NULL, &p);
+todo_wine {
+    ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+    ok(p == NULL, "Unexpected instance.\n");
+}
+    p = NULL;
+    hr = UiaHostProviderFromHwnd(hwnd, &p);
+todo_wine
+    ok(hr == S_OK, "Failed to get host provider, hr %#x.\n", hr);
+
+if (hr == S_OK)
+{
+    p2 = NULL;
+    hr = UiaHostProviderFromHwnd(hwnd, &p2);
+    ok(hr == S_OK, "Failed to get host provider, hr %#x.\n", hr);
+    ok(p != p2, "Unexpected instance.\n");
+    IRawElementProviderSimple_Release(p2);
+
+    hr = IRawElementProviderSimple_get_HostRawElementProvider(p, &p2);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(p2 == NULL, "Unexpected instance.\n");
+
+    IRawElementProviderSimple_Release(p);
+}
+
+    DestroyWindow(hwnd);
+    UnregisterClassA("HostProviderFromHwnd class", NULL);
+}
+
+START_TEST(uiautomation)
+{
+    test_UiaHostProviderFromHwnd();
+}
diff --git a/dlls/uiautomationcore/uia_main.c b/dlls/uiautomationcore/uia_main.c
index 07308461e3..f0d8247724 100644
--- a/dlls/uiautomationcore/uia_main.c
+++ b/dlls/uiautomationcore/uia_main.c
@@ -93,3 +93,9 @@ HRESULT WINAPI UiaRaiseAutomationEvent(IRawElementProviderSimple *provider, EVEN
     FIXME("(%p, %d): stub\n", provider, id);
     return S_OK;
 }
+
+HRESULT WINAPI UiaHostProviderFromHwnd(HWND hwnd, IRawElementProviderSimple **provider)
+{
+    FIXME("(%p, %p): stub\n", hwnd, provider);
+    return E_NOTIMPL;
+}
diff --git a/dlls/uiautomationcore/uiautomationcore.spec b/dlls/uiautomationcore/uiautomationcore.spec
index 28eefc9339..53ef893064 100644
--- a/dlls/uiautomationcore/uiautomationcore.spec
+++ b/dlls/uiautomationcore/uiautomationcore.spec
@@ -72,7 +72,7 @@
 @ stub UiaHTextRangeFromVariant
 @ stub UiaHUiaNodeFromVariant
 @ stub UiaHasServerSideProvider
-@ stub UiaHostProviderFromHwnd
+@ stdcall UiaHostProviderFromHwnd(long ptr)
 #@ stub UiaIAccessibleFromProvider
 @ stdcall UiaLookupId(long ptr)
 @ stub UiaNavigate
diff --git a/include/uiautomationcoreapi.h b/include/uiautomationcoreapi.h
index 1898fe9857..0acdc29e0e 100644
--- a/include/uiautomationcoreapi.h
+++ b/include/uiautomationcoreapi.h
@@ -59,6 +59,7 @@ BOOL WINAPI UiaPatternRelease(HUIAPATTERNOBJECT hobj);
 HRESULT WINAPI UiaRaiseAutomationEvent(IRawElementProviderSimple *provider, EVENTID id);
 LRESULT WINAPI UiaReturnRawElementProvider(HWND hwnd, WPARAM wParam, LPARAM lParam, IRawElementProviderSimple *elprov);
 BOOL WINAPI UiaTextRangeRelease(HUIATEXTRANGE hobj);
+HRESULT WINAPI UiaHostProviderFromHwnd(HWND hwnd, IRawElementProviderSimple **elprov);
 
 #ifdef __cplusplus
 }
-- 
2.20.1




More information about the wine-devel mailing list