4 * Copyright 2019 Nikolay Sivov for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "uiautomation.h"
27 #include "wine/test.h"
29 static LRESULT WINAPI
test_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
31 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
34 static void test_UiaHostProviderFromHwnd(void)
36 IRawElementProviderSimple
*p
, *p2
;
42 cls
.lpfnWndProc
= test_wnd_proc
;
45 cls
.hInstance
= GetModuleHandleA(NULL
);
48 cls
.hbrBackground
= NULL
;
49 cls
.lpszMenuName
= NULL
;
50 cls
.lpszClassName
= "HostProviderFromHwnd class";
54 hwnd
= CreateWindowExA(0, "HostProviderFromHwnd class", "Test window 1",
55 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_VISIBLE
,
56 0, 0, 100, 100, GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
57 ok(hwnd
!= NULL
, "Failed to create a test window.\n");
59 p
= (void *)0xdeadbeef;
60 hr
= UiaHostProviderFromHwnd(NULL
, &p
);
62 ok(hr
== E_INVALIDARG
, "Unexpected hr %#x.\n", hr
);
63 ok(p
== NULL
, "Unexpected instance.\n");
66 hr
= UiaHostProviderFromHwnd(hwnd
, &p
);
68 ok(hr
== S_OK
, "Failed to get host provider, hr %#x.\n", hr
);
73 hr
= UiaHostProviderFromHwnd(hwnd
, &p2
);
74 ok(hr
== S_OK
, "Failed to get host provider, hr %#x.\n", hr
);
75 ok(p
!= p2
, "Unexpected instance.\n");
76 IRawElementProviderSimple_Release(p2
);
78 hr
= IRawElementProviderSimple_get_HostRawElementProvider(p
, &p2
);
79 ok(hr
== S_OK
, "Unexpected hr %#x.\n", hr
);
80 ok(p2
== NULL
, "Unexpected instance.\n");
82 IRawElementProviderSimple_Release(p
);
86 UnregisterClassA("HostProviderFromHwnd class", NULL
);
89 START_TEST(uiautomation
)
91 test_UiaHostProviderFromHwnd();