2 * Unit test suite for windowless rich edit controls
4 * Copyright 2008 Maarten Lankhorst
5 * Copyright 2008 Austin Lund
6 * Copyright 2008 Dylan Smith
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include <wine/test.h>
35 static HMODULE hmoduleRichEdit
;
37 /* Define C Macros for ITextServices calls. */
39 /* Use a special table for x86 machines to convert the thiscall
40 * calling convention. This isn't needed on other platforms. */
42 #define TXTSERV_VTABLE(This) (&itextServicesStdcallVtbl)
44 #define TXTSERV_VTABLE(This) (This)->lpVtbl
47 #define ITextServices_TxSendMessage(This,a,b,c,d) TXTSERV_VTABLE(This)->TxSendMessage(This,a,b,c,d)
48 #define ITextServices_TxDraw(This,a,b,c,d,e,f,g,h,i,j,k,l) TXTSERV_VTABLE(This)->TxDraw(This,a,b,c,d,e,f,g,h,i,j,k,l)
49 #define ITextServices_TxGetHScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetHScroll(This,a,b,c,d,e)
50 #define ITextServices_TxGetVScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetVScroll(This,a,b,c,d,e)
51 #define ITextServices_OnTxSetCursor(This,a,b,c,d,e,f,g,h,i) TXTSERV_VTABLE(This)->OnTxSetCursor(This,a,b,c,d,e,f,g,h,i)
52 #define ITextServices_TxQueryHitPoint(This,a,b,c,d,e,f,g,h,i,j) TXTSERV_VTABLE(This)->TxQueryHitPoint(This,a,b,c,d,e,f,g,h,i,j)
53 #define ITextServices_OnTxInplaceActivate(This,a) TXTSERV_VTABLE(This)->OnTxInplaceActivate(This,a)
54 #define ITextServices_OnTxInplaceDeactivate(This) TXTSERV_VTABLE(This)->OnTxInplaceDeactivate(This)
55 #define ITextServices_OnTxUIActivate(This) TXTSERV_VTABLE(This)->OnTxUIActivate(This)
56 #define ITextServices_OnTxUIDeactivate(This) TXTSERV_VTABLE(This)->OnTxUIDeactivate(This)
57 #define ITextServices_TxGetText(This,a) TXTSERV_VTABLE(This)->TxGetText(This,a)
58 #define ITextServices_TxSetText(This,a) TXTSERV_VTABLE(This)->TxSetText(This,a)
59 #define ITextServices_TxGetCurrentTargetX(This,a) TXTSERV_VTABLE(This)->TxGetCurrentTargetX(This,a)
60 #define ITextServices_TxGetBaseLinePos(This,a) TXTSERV_VTABLE(This)->TxGetBaseLinePos(This,a)
61 #define ITextServices_TxGetNaturalSize(This,a,b,c,d,e,f,g,h) TXTSERV_VTABLE(This)->TxGetNaturalSize(This,a,b,c,d,e,f,g,h)
62 #define ITextServices_TxGetDropTarget(This,a) TXTSERV_VTABLE(This)->TxGetDropTarget(This,a)
63 #define ITextServices_OnTxPropertyBitsChange(This,a,b) TXTSERV_VTABLE(This)->OnTxPropertyBitsChange(This,a,b)
64 #define ITextServices_TxGetCachedSize(This,a,b) TXTSERV_VTABLE(This)->TxGetCachedSize(This,a,b)
66 /* Set the WINETEST_DEBUG environment variable to be greater than 1 for verbose
67 * function call traces of ITextHost. */
68 #define TRACECALL if(winetest_debug > 1) trace
70 /************************************************************************/
71 /* ITextHost implementation for conformance testing. */
73 typedef struct ITextHostTestImpl
75 ITextHostVtbl
*lpVtbl
;
79 static HRESULT WINAPI
ITextHostImpl_QueryInterface(ITextHost
*iface
,
83 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
85 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_ITextHost
)) {
87 ITextHost_AddRef((ITextHost
*)*ppvObject
);
94 static ULONG WINAPI
ITextHostImpl_AddRef(ITextHost
*iface
)
96 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
97 ULONG refCount
= InterlockedIncrement(&This
->refCount
);
101 static ULONG WINAPI
ITextHostImpl_Release(ITextHost
*iface
)
103 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
104 ULONG refCount
= InterlockedDecrement(&This
->refCount
);
115 static HDC WINAPI
ITextHostImpl_TxGetDC(ITextHost
*iface
)
117 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
118 TRACECALL("Call to TxGetDC(%p)\n", This
);
122 static INT WINAPI
ITextHostImpl_TxReleaseDC(ITextHost
*iface
,
125 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
126 TRACECALL("Call to TxReleaseDC(%p)\n", This
);
130 static BOOL WINAPI
ITextHostImpl_TxShowScrollBar(ITextHost
*iface
,
134 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
135 TRACECALL("Call to TxShowScrollBar(%p, fnBar=%d, fShow=%d)\n",
140 static BOOL WINAPI
ITextHostImpl_TxEnableScrollBar(ITextHost
*iface
,
144 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
145 TRACECALL("Call to TxEnableScrollBar(%p, fuSBFlags=%d, fuArrowflags=%d)\n",
146 This
, fuSBFlags
, fuArrowflags
);
150 static BOOL WINAPI
ITextHostImpl_TxSetScrollRange(ITextHost
*iface
,
156 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
157 TRACECALL("Call to TxSetScrollRange(%p, fnBar=%d, nMinPos=%d, nMaxPos=%d, fRedraw=%d)\n",
158 This
, fnBar
, nMinPos
, nMaxPos
, fRedraw
);
162 static BOOL WINAPI
ITextHostImpl_TxSetScrollPos(ITextHost
*iface
,
167 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
168 TRACECALL("Call to TxSetScrollPos(%p, fnBar=%d, nPos=%d, fRedraw=%d)\n",
169 This
, fnBar
, nPos
, fRedraw
);
173 static void WINAPI
ITextHostImpl_TxInvalidateRect(ITextHost
*iface
,
177 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
178 TRACECALL("Call to TxInvalidateRect(%p, prc=%p, fMode=%d)\n",
182 static void WINAPI
ITextHostImpl_TxViewChange(ITextHost
*iface
, BOOL fUpdate
)
184 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
185 TRACECALL("Call to TxViewChange(%p, fUpdate=%d)\n",
189 static BOOL WINAPI
ITextHostImpl_TxCreateCaret(ITextHost
*iface
,
191 INT xWidth
, INT yHeight
)
193 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
194 TRACECALL("Call to TxCreateCaret(%p, nbmp=%p, xWidth=%d, yHeight=%d)\n",
195 This
, hbmp
, xWidth
, yHeight
);
199 static BOOL WINAPI
ITextHostImpl_TxShowCaret(ITextHost
*iface
, BOOL fShow
)
201 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
202 TRACECALL("Call to TxShowCaret(%p, fShow=%d)\n",
207 static BOOL WINAPI
ITextHostImpl_TxSetCaretPos(ITextHost
*iface
,
210 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
211 TRACECALL("Call to TxSetCaretPos(%p, x=%d, y=%d)\n", This
, x
, y
);
215 static BOOL WINAPI
ITextHostImpl_TxSetTimer(ITextHost
*iface
,
216 UINT idTimer
, UINT uTimeout
)
218 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
219 TRACECALL("Call to TxSetTimer(%p, idTimer=%u, uTimeout=%u)\n",
220 This
, idTimer
, uTimeout
);
224 static void WINAPI
ITextHostImpl_TxKillTimer(ITextHost
*iface
, UINT idTimer
)
226 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
227 TRACECALL("Call to TxKillTimer(%p, idTimer=%u)\n", This
, idTimer
);
230 static void WINAPI
ITextHostImpl_TxScrollWindowEx(ITextHost
*iface
,
238 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
239 TRACECALL("Call to TxScrollWindowEx(%p, %d, %d, %p, %p, %p, %p, %d)\n",
240 This
, dx
, dy
, lprcScroll
, lprcClip
, hRgnUpdate
, lprcUpdate
, fuScroll
);
243 static void WINAPI
ITextHostImpl_TxSetCapture(ITextHost
*iface
, BOOL fCapture
)
245 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
246 TRACECALL("Call to TxSetCapture(%p, fCapture=%d)\n", This
, fCapture
);
249 static void WINAPI
ITextHostImpl_TxSetFocus(ITextHost
*iface
)
251 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
252 TRACECALL("Call to TxSetFocus(%p)\n", This
);
255 static void WINAPI
ITextHostImpl_TxSetCursor(ITextHost
*iface
,
259 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
260 TRACECALL("Call to TxSetCursor(%p, hcur=%p, fText=%d)\n",
264 static BOOL WINAPI
ITextHostImpl_TxScreenToClient(ITextHost
*iface
,
267 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
268 TRACECALL("Call to TxScreenToClient(%p, lppt=%p)\n", This
, lppt
);
272 static BOOL WINAPI
ITextHostImpl_TxClientToScreen(ITextHost
*iface
,
275 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
276 TRACECALL("Call to TxClientToScreen(%p, lppt=%p)\n", This
, lppt
);
280 static HRESULT WINAPI
ITextHostImpl_TxActivate(ITextHost
*iface
,
283 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
284 TRACECALL("Call to TxActivate(%p, plOldState=%p)\n", This
, plOldState
);
288 static HRESULT WINAPI
ITextHostImpl_TxDeactivate(ITextHost
*iface
,
291 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
292 TRACECALL("Call to TxDeactivate(%p, lNewState=%d)\n", This
, lNewState
);
296 static HRESULT WINAPI
ITextHostImpl_TxGetClientRect(ITextHost
*iface
,
299 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
300 TRACECALL("Call to TxGetClientRect(%p, prc=%p)\n", This
, prc
);
304 static HRESULT WINAPI
ITextHostImpl_TxGetViewInset(ITextHost
*iface
,
307 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
308 TRACECALL("Call to TxGetViewInset(%p, prc=%p)\n", This
, prc
);
312 static HRESULT WINAPI
ITextHostImpl_TxGetCharFormat(ITextHost
*iface
,
313 const CHARFORMATW
**ppCF
)
315 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
316 TRACECALL("Call to TxGetCharFormat(%p, ppCF=%p)\n", This
, ppCF
);
320 static HRESULT WINAPI
ITextHostImpl_TxGetParaFormat(ITextHost
*iface
,
321 const PARAFORMAT
**ppPF
)
323 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
324 TRACECALL("Call to TxGetParaFormat(%p, ppPF=%p)\n", This
, ppPF
);
328 static COLORREF WINAPI
ITextHostImpl_TxGetSysColor(ITextHost
*iface
,
331 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
332 TRACECALL("Call to TxGetSysColor(%p, nIndex=%d)\n", This
, nIndex
);
336 static HRESULT WINAPI
ITextHostImpl_TxGetBackStyle(ITextHost
*iface
,
337 TXTBACKSTYLE
*pStyle
)
339 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
340 TRACECALL("Call to TxGetBackStyle(%p, pStyle=%p)\n", This
, pStyle
);
344 static HRESULT WINAPI
ITextHostImpl_TxGetMaxLength(ITextHost
*iface
,
347 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
348 TRACECALL("Call to TxGetMaxLength(%p, pLength=%p)\n", This
, pLength
);
352 static HRESULT WINAPI
ITextHostImpl_TxGetScrollbars(ITextHost
*iface
,
355 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
356 TRACECALL("Call to TxGetScrollbars(%p, pdwScrollBar=%p)\n",
361 static HRESULT WINAPI
ITextHostImpl_TxGetPasswordChar(ITextHost
*iface
,
364 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
365 TRACECALL("Call to TxGetPasswordChar(%p, pch=%p)\n", This
, pch
);
369 static HRESULT WINAPI
ITextHostImpl_TxGetAcceleratorPos(ITextHost
*iface
,
372 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
373 TRACECALL("Call to TxGetAcceleratorPos(%p, pch=%p)\n", This
, pch
);
377 static HRESULT WINAPI
ITextHostImpl_TxGetExtent(ITextHost
*iface
,
380 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
381 TRACECALL("Call to TxGetExtent(%p, lpExtent=%p)\n", This
, lpExtent
);
385 static HRESULT WINAPI
ITextHostImpl_OnTxCharFormatChange(ITextHost
*iface
,
386 const CHARFORMATW
*pcf
)
388 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
389 TRACECALL("Call to OnTxCharFormatChange(%p, pcf=%p)\n", This
, pcf
);
393 static HRESULT WINAPI
ITextHostImpl_OnTxParaFormatChange(ITextHost
*iface
,
394 const PARAFORMAT
*ppf
)
396 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
397 TRACECALL("Call to OnTxParaFormatChange(%p, ppf=%p)\n", This
, ppf
);
401 /* This must return S_OK for the native ITextServices object to
403 static HRESULT WINAPI
ITextHostImpl_TxGetPropertyBits(ITextHost
*iface
,
407 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
408 TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08x, pdwBits=%p)\n",
409 This
, dwMask
, pdwBits
);
414 static HRESULT WINAPI
ITextHostImpl_TxNotify(ITextHost
*iface
, DWORD iNotify
,
417 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
418 TRACECALL("Call to TxNotify(%p, iNotify=%d, pv=%p)\n", This
, iNotify
, pv
);
422 static HIMC WINAPI
ITextHostImpl_TxImmGetContext(ITextHost
*iface
)
424 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
425 TRACECALL("Call to TxImmGetContext(%p)\n", This
);
429 static void WINAPI
ITextHostImpl_TxImmReleaseContext(ITextHost
*iface
, HIMC himc
)
431 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
432 TRACECALL("Call to TxImmReleaseContext(%p, himc=%p)\n", This
, himc
);
435 static HRESULT WINAPI
ITextHostImpl_TxGetSelectionBarWidth(ITextHost
*iface
,
438 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
439 TRACECALL("Call to TxGetSelectionBarWidth(%p, lSelBarWidth=%p)\n",
444 static ITextServicesVtbl itextServicesStdcallVtbl
;
446 static ITextHostVtbl itextHostVtbl
= {
447 ITextHostImpl_QueryInterface
,
448 ITextHostImpl_AddRef
,
449 ITextHostImpl_Release
,
450 ITextHostImpl_TxGetDC
,
451 ITextHostImpl_TxReleaseDC
,
452 ITextHostImpl_TxShowScrollBar
,
453 ITextHostImpl_TxEnableScrollBar
,
454 ITextHostImpl_TxSetScrollRange
,
455 ITextHostImpl_TxSetScrollPos
,
456 ITextHostImpl_TxInvalidateRect
,
457 ITextHostImpl_TxViewChange
,
458 ITextHostImpl_TxCreateCaret
,
459 ITextHostImpl_TxShowCaret
,
460 ITextHostImpl_TxSetCaretPos
,
461 ITextHostImpl_TxSetTimer
,
462 ITextHostImpl_TxKillTimer
,
463 ITextHostImpl_TxScrollWindowEx
,
464 ITextHostImpl_TxSetCapture
,
465 ITextHostImpl_TxSetFocus
,
466 ITextHostImpl_TxSetCursor
,
467 ITextHostImpl_TxScreenToClient
,
468 ITextHostImpl_TxClientToScreen
,
469 ITextHostImpl_TxActivate
,
470 ITextHostImpl_TxDeactivate
,
471 ITextHostImpl_TxGetClientRect
,
472 ITextHostImpl_TxGetViewInset
,
473 ITextHostImpl_TxGetCharFormat
,
474 ITextHostImpl_TxGetParaFormat
,
475 ITextHostImpl_TxGetSysColor
,
476 ITextHostImpl_TxGetBackStyle
,
477 ITextHostImpl_TxGetMaxLength
,
478 ITextHostImpl_TxGetScrollbars
,
479 ITextHostImpl_TxGetPasswordChar
,
480 ITextHostImpl_TxGetAcceleratorPos
,
481 ITextHostImpl_TxGetExtent
,
482 ITextHostImpl_OnTxCharFormatChange
,
483 ITextHostImpl_OnTxParaFormatChange
,
484 ITextHostImpl_TxGetPropertyBits
,
485 ITextHostImpl_TxNotify
,
486 ITextHostImpl_TxImmGetContext
,
487 ITextHostImpl_TxImmReleaseContext
,
488 ITextHostImpl_TxGetSelectionBarWidth
491 static ITextServices
*txtserv
= NULL
;
492 static ITextHostTestImpl
*dummyTextHost
;
493 static void *wrapperCodeMem
= NULL
;
495 #include "pshpack1.h"
497 /* Code structure for x86 byte code */
500 BYTE pop_eax
; /* popl %eax */
501 BYTE push_ecx
; /* pushl %ecx */
502 BYTE push_eax
; /* pushl %eax */
503 BYTE jmp_func
; /* jmp $func */
505 } THISCALL_TO_STDCALL_THUNK
;
509 BYTE pop_eax
; /* popl %eax */
510 BYTE pop_ecx
; /* popl %ecx */
511 BYTE push_eax
; /* pushl %eax */
512 BYTE mov_vtable_eax
[2]; /* movl (%ecx), %eax */
513 BYTE jmp_eax
[2]; /* jmp *$vtablefunc_offset(%eax) */
514 int vtablefunc_offset
;
515 } STDCALL_TO_THISCALL_THUNK
;
519 static void setup_thiscall_wrappers(void)
524 THISCALL_TO_STDCALL_THUNK
*thunk
;
525 STDCALL_TO_THISCALL_THUNK
*thunk2
;
527 wrapperCodeMem
= VirtualAlloc(NULL
,
528 (sizeof(ITextHostVtbl
)/sizeof(void*) - 3)
529 * sizeof(THISCALL_TO_STDCALL_THUNK
)
530 +(sizeof(ITextServicesVtbl
)/sizeof(void*) - 3)
531 * sizeof(STDCALL_TO_THISCALL_THUNK
),
532 MEM_COMMIT
, PAGE_EXECUTE_READWRITE
);
533 thunk
= wrapperCodeMem
;
535 /* Wrap all ITextHostImpl methods with code to perform a thiscall to
536 * stdcall conversion. The thiscall calling convention places the This
537 * pointer in ecx on the x86 platform, and the stdcall calling convention
538 * pushes the This pointer on the stack as the first argument.
540 * The byte code does the conversion then jumps to the real function.
542 * Each wrapper needs to be modified so that the function to jump to is
543 * modified in the byte code. */
545 /* Skip QueryInterface, AddRef, and Release native actually
546 * defined them with the stdcall calling convention. */
547 pVtable
= (void**)&itextHostVtbl
+ 3;
548 pVtableEnd
= (void**)(&itextHostVtbl
+ 1);
549 while (pVtable
!= pVtableEnd
) {
550 /* write byte code to executable memory */
551 thunk
->pop_eax
= 0x58; /* popl %eax */
552 thunk
->push_ecx
= 0x51; /* pushl %ecx */
553 thunk
->push_eax
= 0x50; /* pushl %eax */
554 thunk
->jmp_func
= 0xe9; /* jmp $func */
555 /* The address needs to be relative to the end of the jump instructions. */
556 thunk
->func
= (char*)*pVtable
- (char*)(&thunk
->func
+ 1);
562 /* Setup an ITextServices standard call vtable that will call the
563 * native thiscall vtable when the methods are called. */
565 /* QueryInterface, AddRef, and Release should be called directly on the
566 * real vtable since they use the stdcall calling convention. */
567 thunk2
= (STDCALL_TO_THISCALL_THUNK
*)thunk
;
568 pVtable
= (void**)&itextServicesStdcallVtbl
+ 3;
569 pVtableEnd
= (void**)(&itextServicesStdcallVtbl
+ 1);
570 while (pVtable
!= pVtableEnd
) {
571 /* write byte code to executable memory */
572 thunk2
->pop_eax
= 0x58; /* popl %eax */
573 thunk2
->pop_ecx
= 0x59; /* popl %ecx */
574 thunk2
->push_eax
= 0x50; /* pushl %eax */
575 thunk2
->mov_vtable_eax
[0] = 0x8b; /* movl (%ecx), %eax */
576 thunk2
->mov_vtable_eax
[1] = 0x01;
577 thunk2
->jmp_eax
[0] = 0xff; /* jmp *$vtablefunc_offset(%eax) */
578 thunk2
->jmp_eax
[1] = 0xa0;
579 thunk2
->vtablefunc_offset
= (char*)pVtable
- (char*)&itextServicesStdcallVtbl
;
584 #endif /* __i386__ */
587 /*************************************************************************/
588 /* Conformance test functions. */
590 /* Initialize the test texthost structure */
591 static BOOL
init_texthost(void)
595 PCreateTextServices pCreateTextServices
;
597 dummyTextHost
= CoTaskMemAlloc(sizeof(*dummyTextHost
));
598 if (dummyTextHost
== NULL
) {
599 skip("Insufficient memory to create ITextHost interface\n");
602 dummyTextHost
->lpVtbl
= &itextHostVtbl
;
603 dummyTextHost
->refCount
= 1;
605 /* MSDN states that an IUnknown object is returned by
606 CreateTextServices which is then queried to obtain a
607 ITextServices object. */
608 pCreateTextServices
= (void*)GetProcAddress(hmoduleRichEdit
, "CreateTextServices");
609 result
= (*pCreateTextServices
)(NULL
,(ITextHost
*)dummyTextHost
, &init
);
610 ok(result
== S_OK
, "Did not return OK when created. Returned %x\n", result
);
611 if (result
!= S_OK
) {
612 CoTaskMemFree(dummyTextHost
);
613 skip("CreateTextServices failed.\n");
617 result
= IUnknown_QueryInterface(init
, &IID_ITextServices
,
619 ok((result
== S_OK
) && (txtserv
!= NULL
), "Querying interface failed\n");
620 IUnknown_Release(init
);
621 if (!((result
== S_OK
) && (txtserv
!= NULL
))) {
622 CoTaskMemFree(dummyTextHost
);
623 skip("Could not retrieve ITextServices interface\n");
630 static void test_TxGetText(void)
635 if (!init_texthost())
638 hres
= ITextServices_TxGetText(txtserv
, &rettext
);
639 todo_wine
ok(hres
== S_OK
, "ITextServices_TxGetText failed\n");
641 IUnknown_Release(txtserv
);
642 CoTaskMemFree(dummyTextHost
);
647 setup_thiscall_wrappers();
649 /* Must explicitly LoadLibrary(). The test has no references to functions in
650 * RICHED20.DLL, so the linker doesn't actually link to it. */
651 hmoduleRichEdit
= LoadLibrary("RICHED20.DLL");
652 ok(hmoduleRichEdit
!= NULL
, "error: %d\n", (int) GetLastError());
656 IUnknown_Release(txtserv
);
657 CoTaskMemFree(dummyTextHost
);
661 if (wrapperCodeMem
) VirtualFree(wrapperCodeMem
, 0, MEM_RELEASE
);