Commit 2e7b6da2 authored by Connor McAdams's avatar Connor McAdams Committed by Alexandre Julliard

uiautomationcore/tests: Expand UiaHostProviderFromHwnd tests.

parent b5f4511b
TESTDLL = uiautomationcore.dll TESTDLL = uiautomationcore.dll
IMPORTS = uiautomationcore user32 ole32 IMPORTS = uiautomationcore user32 ole32 oleaut32
C_SRCS = \ C_SRCS = \
uiautomation.c uiautomation.c
...@@ -34,9 +34,12 @@ static LRESULT WINAPI test_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPAR ...@@ -34,9 +34,12 @@ static LRESULT WINAPI test_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPAR
static void test_UiaHostProviderFromHwnd(void) static void test_UiaHostProviderFromHwnd(void)
{ {
IRawElementProviderSimple *p, *p2; IRawElementProviderSimple *p, *p2;
enum ProviderOptions prov_opt;
WNDCLASSA cls; WNDCLASSA cls;
HRESULT hr; HRESULT hr;
HWND hwnd; HWND hwnd;
VARIANT v;
int i;
cls.style = 0; cls.style = 0;
cls.lpfnWndProc = test_wnd_proc; cls.lpfnWndProc = test_wnd_proc;
...@@ -61,6 +64,9 @@ static void test_UiaHostProviderFromHwnd(void) ...@@ -61,6 +64,9 @@ static void test_UiaHostProviderFromHwnd(void)
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
ok(p == NULL, "Unexpected instance.\n"); ok(p == NULL, "Unexpected instance.\n");
hr = UiaHostProviderFromHwnd(hwnd, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
p = NULL; p = NULL;
hr = UiaHostProviderFromHwnd(hwnd, &p); hr = UiaHostProviderFromHwnd(hwnd, &p);
ok(hr == S_OK, "Failed to get host provider, hr %#x.\n", hr); ok(hr == S_OK, "Failed to get host provider, hr %#x.\n", hr);
...@@ -75,9 +81,54 @@ static void test_UiaHostProviderFromHwnd(void) ...@@ -75,9 +81,54 @@ static void test_UiaHostProviderFromHwnd(void)
ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(p2 == NULL, "Unexpected instance.\n"); ok(p2 == NULL, "Unexpected instance.\n");
IRawElementProviderSimple_Release(p); hr = IRawElementProviderSimple_GetPropertyValue(p, UIA_NativeWindowHandlePropertyId, &v);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(V_VT(&v) == VT_I4, "V_VT(&v) = %d\n", V_VT(&v));
ok(V_I4(&v) == HandleToUlong(hwnd), "V_I4(&v) = %#x, expected %#x\n", V_I4(&v), HandleToUlong(hwnd));
hr = IRawElementProviderSimple_GetPropertyValue(p, UIA_ProviderDescriptionPropertyId, &v);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(V_VT(&v) == VT_BSTR, "V_VT(&v) = %d\n", V_VT(&v));
VariantClear(&v);
/* No patterns are implemented on the HWND Host provider. */
for (i = UIA_InvokePatternId; i < (UIA_CustomNavigationPatternId + 1); i++)
{
IUnknown *unk;
unk = (void *)0xdeadbeef;
hr = IRawElementProviderSimple_GetPatternProvider(p, i, &unk);
ok(hr == S_OK, "Unexpected hr %#x, %d.\n", hr, i);
ok(!unk, "Pattern %d returned %p\n", i, unk);
}
hr = IRawElementProviderSimple_get_ProviderOptions(p, &prov_opt);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok((prov_opt == ProviderOptions_ServerSideProvider) ||
broken(prov_opt == ProviderOptions_ClientSideProvider), /* Windows < 10 1507 */
"Unexpected provider options %#x\n", prov_opt);
/* Test behavior post Window destruction. */
DestroyWindow(hwnd); DestroyWindow(hwnd);
hr = IRawElementProviderSimple_GetPropertyValue(p, UIA_NativeWindowHandlePropertyId, &v);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(V_VT(&v) == VT_I4, "V_VT(&v) = %d\n", V_VT(&v));
ok(V_I4(&v) == HandleToUlong(hwnd), "V_I4(&v) = %#x, expected %#x\n", V_I4(&v), HandleToUlong(hwnd));
hr = IRawElementProviderSimple_GetPropertyValue(p, UIA_ProviderDescriptionPropertyId, &v);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(V_VT(&v) == VT_BSTR, "V_VT(&v) = %d\n", V_VT(&v));
VariantClear(&v);
hr = IRawElementProviderSimple_get_ProviderOptions(p, &prov_opt);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok((prov_opt == ProviderOptions_ServerSideProvider) ||
broken(prov_opt == ProviderOptions_ClientSideProvider), /* Windows < 10 1507 */
"Unexpected provider options %#x\n", prov_opt);
IRawElementProviderSimple_Release(p);
UnregisterClassA("HostProviderFromHwnd class", NULL); UnregisterClassA("HostProviderFromHwnd class", NULL);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment