mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / uiautomationcore / tests / uiautomation.c
blobcbcba1af294886cb08a40fbeac2352ea0b7b6b4a
1 /*
2 * UI Automation tests
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
21 #define COBJMACROS
23 #include "windows.h"
24 #include "initguid.h"
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;
37 WNDCLASSA cls;
38 HRESULT hr;
39 HWND hwnd;
41 cls.style = 0;
42 cls.lpfnWndProc = test_wnd_proc;
43 cls.cbClsExtra = 0;
44 cls.cbWndExtra = 0;
45 cls.hInstance = GetModuleHandleA(NULL);
46 cls.hIcon = 0;
47 cls.hCursor = NULL;
48 cls.hbrBackground = NULL;
49 cls.lpszMenuName = NULL;
50 cls.lpszClassName = "HostProviderFromHwnd class";
52 RegisterClassA(&cls);
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);
61 todo_wine {
62 ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
63 ok(p == NULL, "Unexpected instance.\n");
65 p = NULL;
66 hr = UiaHostProviderFromHwnd(hwnd, &p);
67 todo_wine
68 ok(hr == S_OK, "Failed to get host provider, hr %#x.\n", hr);
70 if (hr == S_OK)
72 p2 = NULL;
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);
85 DestroyWindow(hwnd);
86 UnregisterClassA("HostProviderFromHwnd class", NULL);
89 START_TEST(uiautomation)
91 test_UiaHostProviderFromHwnd();