4 * Copyright 2008 Nikolay Sivov
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
23 #include "wine/test.h"
29 static HANDLE (WINAPI
*pGetProcessHandleFromHwnd
)(HWND
);
31 static BOOL
init(void)
33 HMODULE oleacc
= GetModuleHandleA("oleacc.dll");
35 pGetProcessHandleFromHwnd
= (void*)GetProcAddress(oleacc
, "GetProcessHandleFromHwnd");
36 if(!pGetProcessHandleFromHwnd
) {
37 win_skip("GetProcessHandleFromHwnd not available\n");
44 static void test_getroletext(void)
48 WCHAR bufW
[2], *buffW
;
50 /* wrong role number */
51 ret
= GetRoleTextA(-1, NULL
, 0);
52 ok(ret
== 0, "GetRoleTextA doesn't return zero on wrong role number, got %d\n", ret
);
54 ret
= GetRoleTextA(-1, buf
, 2);
55 ok(ret
== 0, "GetRoleTextA doesn't return zero on wrong role number, got %d\n", ret
);
56 ok(buf
[0] == 0, "GetRoleTextA doesn't return NULL char on wrong role number\n");
58 ret
= GetRoleTextA(-1, buf
, 0);
59 ok(ret
== 0, "GetRoleTextA doesn't return zero on wrong role number, got %d\n", ret
);
60 ok(buf
[0] == '*', "GetRoleTextA modified buffer on wrong role number\n");
62 ret
= GetRoleTextW(-1, NULL
, 0);
63 ok(ret
== 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret
);
65 ret
= GetRoleTextW(-1, bufW
, 2);
66 ok(ret
== 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret
);
67 ok(bufW
[0] == '\0', "GetRoleTextW doesn't return NULL char on wrong role number\n");
69 ret
= GetRoleTextW(-1, bufW
, 0);
70 ok(ret
== 0, "GetRoleTextW doesn't return zero on wrong role number, got %d\n", ret
);
72 /* zero role number - not documented */
73 ret
= GetRoleTextA(0, NULL
, 0);
74 ok(ret
> 0, "GetRoleTextA doesn't return (>0) for zero role number, got %d\n", ret
);
75 ret
= GetRoleTextW(0, NULL
, 0);
76 ok(ret
> 0, "GetRoleTextW doesn't return (>0) for zero role number, got %d\n", ret
);
78 /* NULL buffer, return length */
79 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, NULL
, 0);
80 ok(ret
> 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret
);
81 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, NULL
, 1);
82 ok(ret
> 0, "GetRoleTextA doesn't return length on NULL buffer, got %d\n", ret
);
83 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, NULL
, 0);
84 ok(ret
> 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret
);
85 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, NULL
, 1);
86 ok(ret
> 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret
);
88 /* use a smaller buffer */
90 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, buf
, 0);
91 ok(!ret
, "GetRoleTextA doesn't return 0, got %d\n", ret
);
92 ok(buf
[0] == '*', "GetRoleTextA modified buffer\n");
94 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, (WCHAR
*)&buffW
, 0);
95 ok(ret
, "GetRoleTextW doesn't return length\n");
96 ok(buffW
!= NULL
, "GetRoleTextW doesn't modify buffer\n");
98 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, buf
, 1);
99 ok(ret
== 0, "GetRoleTextA returned wrong length\n");
100 ok(buf
[0] == '\0', "GetRoleTextA returned not zero-length buffer\n");
102 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, buf
, 2);
103 ok(!ret
, "GetRoleTextA returned wrong length, got %d, expected 0\n", ret
);
104 ok(!buf
[0] || broken(buf
[0]!='*') /* WinXP */,
105 "GetRoleTextA returned not zero-length buffer : (%c)\n", buf
[0]);
108 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, bufW
, 1);
109 ok(ret
== 0, "GetRoleTextW returned wrong length, got %d, expected 1\n", ret
);
110 ok(bufW
[0] == '\0', "GetRoleTextW returned not zero-length buffer\n");
112 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, bufW
, 2);
113 ok(ret
== 1, "GetRoleTextW returned wrong length, got %d, expected 1\n", ret
);
114 ok(bufW
[1] == '\0', "GetRoleTextW returned not zero-length buffer\n");
116 /* use bigger buffer */
117 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, NULL
, 0);
118 buff
= HeapAlloc(GetProcessHeap(), 0, 2*ret
);
120 ret
= GetRoleTextA(ROLE_SYSTEM_TITLEBAR
, buff
, 2*ret
);
121 ok(buff
[2*ret
-1] == '*', "GetRoleTextA shouldn't modify this part of buffer\n");
122 HeapFree(GetProcessHeap(), 0, buff
);
124 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, NULL
, 0);
125 buffW
= HeapAlloc(GetProcessHeap(), 0, 2*ret
*sizeof(WCHAR
));
126 buffW
[2*ret
-1] = '*';
127 ret
= GetRoleTextW(ROLE_SYSTEM_TITLEBAR
, buffW
, 2*ret
);
128 ok(buffW
[2*ret
-1] == '*', "GetRoleTextW shouldn't modify this part of buffer\n");
129 HeapFree(GetProcessHeap(), 0, buffW
);
131 /* check returned length for all roles */
132 for(role
= 0; role
<= ROLE_SYSTEM_OUTLINEBUTTON
; role
++){
136 /* NT4 and W2K don't clear the buffer on a nonexistent role in the A-call */
137 memset(buff2
, 0, sizeof(buff2
));
139 ret
= GetRoleTextA(role
, NULL
, 0);
140 ok(ret
> 0, "Expected the role to be present\n");
142 GetRoleTextA(role
, buff2
, sizeof(buff2
));
143 ok(ret
== lstrlenA(buff2
),
144 "GetRoleTextA: returned length doesn't match returned buffer for role %d\n", role
);
146 /* Win98 and WinMe don't clear the buffer on a nonexistent role in the W-call */
147 memset(buff2W
, 0, sizeof(buff2W
));
149 ret
= GetRoleTextW(role
, NULL
, 0);
150 GetRoleTextW(role
, buff2W
, sizeof(buff2W
)/sizeof(WCHAR
));
151 ok(ret
== lstrlenW(buff2W
),
152 "GetRoleTextW: returned length doesn't match returned buffer for role %d\n", role
);
156 static void test_GetStateText(void)
158 WCHAR buf
[1024], buf2
[1024];
164 ret2
= GetStateTextW(0, NULL
, 1024);
165 ok(ret2
, "GetStateText failed\n");
168 ret
= GetStateTextW(0, (WCHAR
*)&ptr
, 0);
169 ok(ret
== ret2
, "got %d, expected %d\n", ret
, ret2
);
170 ok(ptr
!= NULL
, "ptr was not changed\n");
172 ret
= GetStateTextW(0, buf
, 1024);
173 ok(ret
== ret2
, "got %d, expected %d\n", ret
, ret2
);
174 ok(!memcmp(buf
, ptr
, ret
*sizeof(WCHAR
)), "got %s, expected %s\n",
175 wine_dbgstr_wn(buf
, ret
), wine_dbgstr_wn(ptr
, ret
));
177 ret
= GetStateTextW(0, buf
, 1);
178 ok(!ret
, "got %d, expected 0\n", ret
);
179 ok(!buf
[0], "buf[0] = '%c'\n", buf
[0]);
181 for(i
=0; i
<31; i
++) {
182 ret
= GetStateTextW(1<<i
, buf
, 1024);
183 ok(ret
, "%d) GetStateText failed\n", i
);
185 ret
= GetStateTextW(1<<31, buf
, 1024);
186 ok(!ret
, "31) GetStateText succeeded: %d\n", ret
);
188 ret
= GetStateTextW(2, buf
, 1024);
189 ok(ret
, "GetStateText failed\n");
190 ret2
= GetStateTextW(3, buf2
, 1024);
191 ok(ret2
, "GetStateText failed\n");
192 ok(ret
== ret2
, "got %d, expected %d\n", ret2
, ret
);
193 ok(!memcmp(buf
, buf2
, ret
*sizeof(WCHAR
)),
194 "GetStateText(2,...) returned different data than GetStateText(3,...)\n");
196 ret2
= GetStateTextA(0, NULL
, 1024);
197 ok(ret2
, "GetStateText failed\n");
200 ret
= GetStateTextA(0, (CHAR
*)&ptr
, 0);
201 ok(!ret
, "got %d\n", ret
);
202 ok(ptr
== NULL
, "ptr was changed\n");
204 ret
= GetStateTextA(0, NULL
, 0);
205 ok(ret
== ret2
, "got %d, expected %d\n", ret
, ret2
);
207 ret
= GetStateTextA(0, bufa
, 1024);
208 ok(ret
== ret2
, "got %d, expected %d\n", ret
, ret2
);
210 ret
= GetStateTextA(0, bufa
, 1);
211 ok(!ret
, "got %d, expected 0\n", ret
);
212 ok(!bufa
[0], "bufa[0] = '%c'\n", bufa
[0]);
214 for(i
=0; i
<31; i
++) {
215 ret
= GetStateTextA(1<<i
, bufa
, 1024);
216 ok(ret
, "%d) GetStateText failed\n", i
);
218 ret
= GetStateTextA(1<<31, bufa
, 1024);
219 ok(!ret
, "31) GetStateText succeeded: %d\n", ret
);
222 static int Object_ref
= 1;
223 static HRESULT WINAPI
Object_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
225 if(IsEqualIID(riid
, &IID_IUnknown
)) {
227 IUnknown_AddRef(iface
);
230 return E_NOINTERFACE
;
233 static ULONG WINAPI
Object_AddRef(IUnknown
*iface
)
235 return InterlockedIncrement(&Object_ref
);
238 static ULONG WINAPI
Object_Release(IUnknown
*iface
)
240 return InterlockedDecrement(&Object_ref
);
243 static IUnknownVtbl ObjectVtbl
= {
244 Object_QueryInterface
,
249 static IUnknown Object
= {&ObjectVtbl
};
251 static void test_LresultFromObject(const char *name
)
253 PROCESS_INFORMATION proc
;
254 STARTUPINFOA startup
;
255 char cmdline
[MAX_PATH
];
260 lres
= LresultFromObject(NULL
, 0, 0);
261 ok(lres
== E_INVALIDARG
, "got %lx\n", lres
);
263 hres
= ObjectFromLresult(0, &IID_IUnknown
, 0, (void**)&unk
);
264 ok(hres
== E_FAIL
, "got %x\n", hres
);
265 hres
= ObjectFromLresult(0x10000, &IID_IUnknown
, 0, (void**)&unk
);
266 ok(hres
== E_FAIL
, "got %x\n", hres
);
268 ok(Object_ref
== 1, "Object_ref = %d\n", Object_ref
);
269 lres
= LresultFromObject(&IID_IUnknown
, 0, &Object
);
270 ok(SUCCEEDED(lres
), "got %lx\n", lres
);
271 ok(Object_ref
> 1, "Object_ref = %d\n", Object_ref
);
273 hres
= ObjectFromLresult(lres
, &IID_IUnknown
, 0, (void**)&unk
);
274 ok(hres
== S_OK
, "hres = %x\n", hres
);
275 ok(unk
== &Object
, "unk != &Object\n");
276 IUnknown_Release(unk
);
277 ok(Object_ref
== 1, "Object_ref = %d\n", Object_ref
);
279 lres
= LresultFromObject(&IID_IUnknown
, 0, &Object
);
280 ok(SUCCEEDED(lres
), "got %lx\n", lres
);
281 ok(Object_ref
> 1, "Object_ref = %d\n", Object_ref
);
283 sprintf(cmdline
, "\"%s\" main ObjectFromLresult %lx", name
, lres
);
284 memset(&startup
, 0, sizeof(startup
));
285 startup
.cb
= sizeof(startup
);
286 CreateProcessA(NULL
, cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &startup
, &proc
);
287 winetest_wait_child_process(proc
.hProcess
);
288 ok(Object_ref
== 1, "Object_ref = %d\n", Object_ref
);
291 static LRESULT WINAPI
test_window_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
295 if(lparam
== OBJID_QUERYCLASSNAMEIDX
) {
296 ok(!wparam
, "wparam = %lx\n", wparam
);
300 ok(wparam
==0xffffffff, "wparam = %lx\n", wparam
);
301 if(lparam
== (DWORD
)OBJID_CURSOR
)
303 if(lparam
== (DWORD
)OBJID_CLIENT
)
304 return LresultFromObject(&IID_IUnknown
, wparam
, &Object
);
305 if(lparam
== (DWORD
)OBJID_WINDOW
)
308 ok(0, "unexpected (%ld)\n", lparam
);
312 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
315 static BOOL
register_window_class(void)
319 memset(&cls
, 0, sizeof(cls
));
320 cls
.lpfnWndProc
= test_window_proc
;
321 cls
.lpszClassName
= "oleacc_test";
322 cls
.hInstance
= GetModuleHandleA(NULL
);
324 return RegisterClassA(&cls
);
327 static void unregister_window_class(void)
329 UnregisterClassA("oleacc_test", NULL
);
332 static void test_AccessibleObjectFromWindow(void)
338 hr
= AccessibleObjectFromWindow(NULL
, OBJID_CURSOR
, &IID_IUnknown
, NULL
);
339 ok(hr
== E_INVALIDARG
, "got %x\n", hr
);
341 hr
= AccessibleObjectFromWindow(NULL
, OBJID_CURSOR
, &IID_IUnknown
, (void**)&unk
);
342 todo_wine
ok(hr
== S_OK
, "got %x\n", hr
);
343 if(hr
== S_OK
) IUnknown_Release(unk
);
345 hwnd
= CreateWindowA("oleacc_test", "test", WS_OVERLAPPEDWINDOW
,
346 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
347 ok(hwnd
!= NULL
, "CreateWindow failed\n");
349 hr
= AccessibleObjectFromWindow(hwnd
, OBJID_CURSOR
, &IID_IUnknown
, (void**)&unk
);
350 ok(hr
== E_UNEXPECTED
, "got %x\n", hr
);
352 ok(Object_ref
== 1, "Object_ref = %d\n", Object_ref
);
353 hr
= AccessibleObjectFromWindow(hwnd
, OBJID_CLIENT
, &IID_IUnknown
, (void**)&unk
);
354 ok(hr
== S_OK
, "got %x\n", hr
);
355 ok(Object_ref
== 2, "Object_ref = %d\n", Object_ref
);
356 IUnknown_Release(unk
);
361 static void test_GetProcessHandleFromHwnd(void)
366 proc
= pGetProcessHandleFromHwnd(NULL
);
367 ok(!proc
, "proc = %p\n", proc
);
369 hwnd
= CreateWindowA("static", "", 0, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
370 ok(hwnd
!= NULL
, "CreateWindow failed\n");
372 proc
= pGetProcessHandleFromHwnd(hwnd
);
373 ok(proc
!= NULL
, "proc == NULL\n");
379 static void test_default_client_accessible_object(void)
381 static const WCHAR testW
[] = {'t','e','s','t',' ','t',' ','&','j','u','n','k',0};
382 static const WCHAR shortcutW
[] = {'A','l','t','+','t',0};
387 HWND chld
, hwnd
, hwnd2
;
393 LONG l
, left
, top
, width
, height
;
395 hwnd
= CreateWindowA("oleacc_test", "test &t &junk", WS_OVERLAPPEDWINDOW
,
396 0, 0, 100, 100, NULL
, NULL
, NULL
, NULL
);
397 ok(hwnd
!= NULL
, "CreateWindow failed\n");
398 chld
= CreateWindowA("static", "message", WS_CHILD
| WS_VISIBLE
,
399 0, 0, 50, 50, hwnd
, NULL
, NULL
, NULL
);
400 ok(chld
!= NULL
, "CreateWindow failed\n");
402 hr
= CreateStdAccessibleObject(NULL
, OBJID_CLIENT
, &IID_IAccessible
, (void**)&acc
);
403 ok(hr
== E_FAIL
, "got %x\n", hr
);
405 hr
= CreateStdAccessibleObject(hwnd
, OBJID_CLIENT
, &IID_IAccessible
, (void**)&acc
);
406 ok(hr
== S_OK
, "got %x\n", hr
);
408 hr
= IAccessible_QueryInterface(acc
, &IID_IOleWindow
, (void**)&ow
);
409 ok(hr
== S_OK
, "got %x\n", hr
);
410 hr
= IOleWindow_GetWindow(ow
, &hwnd2
);
411 ok(hr
== S_OK
, "got %x\n", hr
);
412 ok(hwnd
== hwnd2
, "hwnd2 = %p, expected %p\n", hwnd2
, hwnd
);
413 hr
= WindowFromAccessibleObject(acc
, &hwnd2
);
414 ok(hr
== S_OK
, "got %x\n", hr
);
415 ok(hwnd
== hwnd2
, "hwnd2 = %p, expected %p\n", hwnd2
, hwnd
);
416 IOleWindow_Release(ow
);
418 hr
= IAccessible_get_accChildCount(acc
, &l
);
419 ok(hr
== S_OK
, "got %x\n", hr
);
420 ok(l
== 1, "l = %d\n", l
);
423 V_I4(&vid
) = CHILDID_SELF
;
424 disp
= (void*)0xdeadbeef;
425 hr
= IAccessible_get_accChild(acc
, vid
, &disp
);
426 ok(hr
== E_INVALIDARG
, "get_accChild returned %x\n", hr
);
427 ok(disp
== NULL
, "disp = %p\n", disp
);
430 disp
= (void*)0xdeadbeef;
431 hr
= IAccessible_get_accChild(acc
, vid
, &disp
);
432 ok(hr
== E_INVALIDARG
, "get_accChild returned %x\n", hr
);
433 ok(disp
== NULL
, "disp = %p\n", disp
);
436 V_I4(&vid
) = CHILDID_SELF
;
437 hr
= IAccessible_get_accName(acc
, vid
, &str
);
438 ok(hr
== S_OK
, "got %x\n", hr
);
439 ok(!lstrcmpW(str
, testW
), "name = %s\n", wine_dbgstr_w(str
));
443 str
= (void*)0xdeadbeef;
444 hr
= IAccessible_get_accName(acc
, vid
, &str
);
445 ok(hr
== E_INVALIDARG
, "got %x\n", hr
);
446 ok(!str
, "str != NULL\n");
447 V_I4(&vid
) = CHILDID_SELF
;
449 str
= (void*)0xdeadbeef;
450 hr
= IAccessible_get_accValue(acc
, vid
, &str
);
451 ok(hr
== S_FALSE
, "got %x\n", hr
);
452 ok(!str
, "str != NULL\n");
454 str
= (void*)0xdeadbeef;
455 hr
= IAccessible_get_accDescription(acc
, vid
, &str
);
456 ok(hr
== S_FALSE
, "got %x\n", hr
);
457 ok(!str
, "str != NULL\n");
459 V_VT(&v
) = VT_DISPATCH
;
460 V_DISPATCH(&v
) = (void*)0xdeadbeef;
461 hr
= IAccessible_get_accRole(acc
, vid
, &v
);
462 ok(hr
== S_OK
, "got %x\n", hr
);
463 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
464 ok(V_I4(&v
) == ROLE_SYSTEM_CLIENT
, "V_I4(&v) = %d\n", V_I4(&v
));
466 V_VT(&v
) = VT_DISPATCH
;
467 V_DISPATCH(&v
) = (void*)0xdeadbeef;
468 hr
= IAccessible_get_accState(acc
, vid
, &v
);
469 ok(hr
== S_OK
, "got %x\n", hr
);
470 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
471 ok(V_I4(&v
) == (STATE_SYSTEM_FOCUSABLE
|STATE_SYSTEM_INVISIBLE
),
472 "V_I4(&v) = %x\n", V_I4(&v
));
474 str
= (void*)0xdeadbeef;
475 hr
= IAccessible_get_accHelp(acc
, vid
, &str
);
476 ok(hr
== S_FALSE
, "got %x\n", hr
);
477 ok(!str
, "str != NULL\n");
479 hr
= IAccessible_get_accKeyboardShortcut(acc
, vid
, &str
);
480 ok(hr
== S_OK
, "got %x\n", hr
);
481 ok(!lstrcmpW(str
, shortcutW
), "str = %s\n", wine_dbgstr_w(str
));
484 str
= (void*)0xdeadbeef;
485 hr
= IAccessible_get_accDefaultAction(acc
, vid
, &str
);
486 ok(hr
== S_FALSE
, "got %x\n", hr
);
487 ok(!str
, "str != NULL\n");
490 ok(ClientToScreen(hwnd
, &pt
), "ClientToScreen failed\n");
491 hr
= IAccessible_accHitTest(acc
, pt
.x
, pt
.y
, &v
);
492 ok(hr
== S_OK
, "got %x\n", hr
);
493 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
494 ok(V_I4(&v
) == 0, "V_I4(&v) = %d\n", V_I4(&v
));
497 ok(ClientToScreen(hwnd
, &pt
), "ClientToScreen failed\n");
498 hr
= IAccessible_accHitTest(acc
, pt
.x
, pt
.y
, &v
);
499 ok(hr
== S_OK
, "got %x\n", hr
);
500 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
501 ok(V_I4(&v
) == 0, "V_I4(&v) = %d\n", V_I4(&v
));
503 ShowWindow(hwnd
, TRUE
);
505 ok(ClientToScreen(hwnd
, &pt
), "ClientToScreen failed\n");
506 hr
= IAccessible_accHitTest(acc
, pt
.x
, pt
.y
, &v
);
507 ok(hr
== S_OK
, "got %x\n", hr
);
508 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
509 ok(V_I4(&v
) == 0, "V_I4(&v) = %d\n", V_I4(&v
));
512 ok(ClientToScreen(hwnd
, &pt
), "ClientToScreen failed\n");
513 hr
= IAccessible_accHitTest(acc
, pt
.x
, pt
.y
, &v
);
514 ok(hr
== S_OK
, "got %x\n", hr
);
515 ok(V_VT(&v
) == VT_DISPATCH
, "V_VT(&v) = %d\n", V_VT(&v
));
516 ok(V_DISPATCH(&v
) != NULL
, "V_DISPATCH(&v) = %p\n", V_DISPATCH(&v
));
519 ShowWindow(chld
, FALSE
);
521 ok(ClientToScreen(hwnd
, &pt
), "ClientToScreen failed\n");
522 hr
= IAccessible_accHitTest(acc
, pt
.x
, pt
.y
, &v
);
523 ok(hr
== S_OK
, "got %x\n", hr
);
524 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
525 ok(V_I4(&v
) == 0, "V_I4(&v) = %d\n", V_I4(&v
));
527 hr
= IAccessible_get_accParent(acc
, &disp
);
528 ok(hr
== S_OK
, "got %x\n", hr
);
529 ok(disp
!= NULL
, "disp == NULL\n");
530 IDispatch_Release(disp
);
532 ok(GetClientRect(hwnd
, &rect
), "GetClientRect failed\n");
535 MapWindowPoints(hwnd
, NULL
, &pt
, 1);
540 MapWindowPoints(hwnd
, NULL
, &pt
, 1);
541 hr
= IAccessible_accLocation(acc
, &left
, &top
, &width
, &height
, vid
);
542 ok(hr
== S_OK
, "got %x\n", hr
);
543 ok(left
== rect
.left
, "left = %d, expected %d\n", left
, rect
.left
);
544 ok(top
== rect
.top
, "top = %d, expected %d\n", top
, rect
.top
);
545 ok(width
== pt
.x
-rect
.left
, "width = %d, expected %d\n", width
, pt
.x
-rect
.left
);
546 ok(height
== pt
.y
-rect
.top
, "height = %d, expected %d\n", height
, pt
.y
-rect
.top
);
550 hr
= IAccessible_get_accChildCount(acc
, &l
);
551 ok(hr
== S_OK
, "got %x\n", hr
);
552 ok(l
== 0, "l = %d\n", l
);
554 hr
= IAccessible_get_accName(acc
, vid
, &str
);
555 ok(hr
== E_INVALIDARG
, "got %x\n", hr
);
557 hr
= IAccessible_get_accValue(acc
, vid
, &str
);
558 ok(hr
== S_FALSE
, "got %x\n", hr
);
560 hr
= IAccessible_get_accRole(acc
, vid
, &v
);
561 ok(hr
== S_OK
, "got %x\n", hr
);
562 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
563 ok(V_I4(&v
) == ROLE_SYSTEM_CLIENT
, "V_I4(&v) = %d\n", V_I4(&v
));
565 hr
= IAccessible_get_accState(acc
, vid
, &v
);
566 ok(hr
== S_OK
, "got %x\n", hr
);
567 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
568 ok(V_I4(&v
) == STATE_SYSTEM_INVISIBLE
, "V_I4(&v) = %x\n", V_I4(&v
));
570 hr
= IAccessible_accHitTest(acc
, 200, 200, &v
);
571 ok(hr
== S_OK
, "got %x\n", hr
);
572 ok(V_VT(&v
) == VT_I4
, "V_VT(&v) = %d\n", V_VT(&v
));
573 ok(V_I4(&v
) == 0, "V_I4(&v) = %d\n", V_I4(&v
));
575 disp
= (void*)0xdeadbeef;
576 hr
= IAccessible_get_accParent(acc
, &disp
);
577 ok(hr
== E_FAIL
, "got %x\n", hr
);
578 ok(disp
== NULL
, "disp = %p\n", disp
);
580 hr
= IAccessible_accLocation(acc
, &left
, &top
, &width
, &height
, vid
);
581 ok(hr
== S_OK
, "got %x\n", hr
);
582 ok(left
== 0, "left = %d\n", left
);
583 ok(top
== 0, "top = %d\n", top
);
584 ok(width
== 0, "width = %d\n", width
);
585 ok(height
== 0, "height = %d\n", height
);
587 IAccessible_Release(acc
);
590 static void test_CAccPropServices(void)
592 IAccPropServices
*acc_prop_services
;
595 hres
= CoCreateInstance(&CLSID_CAccPropServices
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
596 &IID_IAccPropServices
, (void**)&acc_prop_services
);
597 ok(hres
== S_OK
, "Could not create CAccPropServices instance: %08x\n", hres
);
599 IAccPropServices_Release(acc_prop_services
);
610 CoInitializeEx(NULL
, COINIT_MULTITHREADED
);
612 argc
= winetest_get_mainargs(&argv
);
613 if(argc
== 4 && !strcmp(argv
[2], "ObjectFromLresult")) {
618 sscanf(argv
[3], "%lx", &lres
);
619 hres
= ObjectFromLresult(lres
, &IID_IUnknown
, 0, (void**)&unk
);
620 ok(hres
== S_OK
, "hres = %x\n", hres
);
621 IUnknown_Release(unk
);
627 if(!register_window_class()) {
628 skip("can't register test window class\n");
634 test_LresultFromObject(argv
[0]);
635 test_AccessibleObjectFromWindow();
636 test_GetProcessHandleFromHwnd();
637 test_default_client_accessible_object();
639 unregister_window_class();
643 test_CAccPropServices();