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>
36 static HMODULE hmoduleRichEdit
;
38 /* Define C Macros for ITextServices calls. */
40 /* Use a special table for x86 machines to convert the thiscall
41 * calling convention. This isn't needed on other platforms. */
43 static ITextServicesVtbl itextServicesStdcallVtbl
;
44 #define TXTSERV_VTABLE(This) (&itextServicesStdcallVtbl)
46 #define TXTSERV_VTABLE(This) (This)->lpVtbl
49 #define ITextServices_TxSendMessage(This,a,b,c,d) TXTSERV_VTABLE(This)->TxSendMessage(This,a,b,c,d)
50 #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)
51 #define ITextServices_TxGetHScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetHScroll(This,a,b,c,d,e)
52 #define ITextServices_TxGetVScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetVScroll(This,a,b,c,d,e)
53 #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)
54 #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)
55 #define ITextServices_OnTxInplaceActivate(This,a) TXTSERV_VTABLE(This)->OnTxInplaceActivate(This,a)
56 #define ITextServices_OnTxInplaceDeactivate(This) TXTSERV_VTABLE(This)->OnTxInplaceDeactivate(This)
57 #define ITextServices_OnTxUIActivate(This) TXTSERV_VTABLE(This)->OnTxUIActivate(This)
58 #define ITextServices_OnTxUIDeactivate(This) TXTSERV_VTABLE(This)->OnTxUIDeactivate(This)
59 #define ITextServices_TxGetText(This,a) TXTSERV_VTABLE(This)->TxGetText(This,a)
60 #define ITextServices_TxSetText(This,a) TXTSERV_VTABLE(This)->TxSetText(This,a)
61 #define ITextServices_TxGetCurrentTargetX(This,a) TXTSERV_VTABLE(This)->TxGetCurrentTargetX(This,a)
62 #define ITextServices_TxGetBaseLinePos(This,a) TXTSERV_VTABLE(This)->TxGetBaseLinePos(This,a)
63 #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)
64 #define ITextServices_TxGetDropTarget(This,a) TXTSERV_VTABLE(This)->TxGetDropTarget(This,a)
65 #define ITextServices_OnTxPropertyBitsChange(This,a,b) TXTSERV_VTABLE(This)->OnTxPropertyBitsChange(This,a,b)
66 #define ITextServices_TxGetCachedSize(This,a,b) TXTSERV_VTABLE(This)->TxGetCachedSize(This,a,b)
68 /* Set the WINETEST_DEBUG environment variable to be greater than 1 for verbose
69 * function call traces of ITextHost. */
70 #define TRACECALL if(winetest_debug > 1) trace
72 /************************************************************************/
73 /* ITextHost implementation for conformance testing. */
75 typedef struct ITextHostTestImpl
77 ITextHostVtbl
*lpVtbl
;
81 static HRESULT WINAPI
ITextHostImpl_QueryInterface(ITextHost
*iface
,
85 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
87 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_ITextHost
)) {
89 ITextHost_AddRef((ITextHost
*)*ppvObject
);
96 static ULONG WINAPI
ITextHostImpl_AddRef(ITextHost
*iface
)
98 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
99 ULONG refCount
= InterlockedIncrement(&This
->refCount
);
103 static ULONG WINAPI
ITextHostImpl_Release(ITextHost
*iface
)
105 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
106 ULONG refCount
= InterlockedDecrement(&This
->refCount
);
117 static HDC WINAPI
ITextHostImpl_TxGetDC(ITextHost
*iface
)
119 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
120 TRACECALL("Call to TxGetDC(%p)\n", This
);
124 static INT WINAPI
ITextHostImpl_TxReleaseDC(ITextHost
*iface
,
127 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
128 TRACECALL("Call to TxReleaseDC(%p)\n", This
);
132 static BOOL WINAPI
ITextHostImpl_TxShowScrollBar(ITextHost
*iface
,
136 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
137 TRACECALL("Call to TxShowScrollBar(%p, fnBar=%d, fShow=%d)\n",
142 static BOOL WINAPI
ITextHostImpl_TxEnableScrollBar(ITextHost
*iface
,
146 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
147 TRACECALL("Call to TxEnableScrollBar(%p, fuSBFlags=%d, fuArrowflags=%d)\n",
148 This
, fuSBFlags
, fuArrowflags
);
152 static BOOL WINAPI
ITextHostImpl_TxSetScrollRange(ITextHost
*iface
,
158 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
159 TRACECALL("Call to TxSetScrollRange(%p, fnBar=%d, nMinPos=%d, nMaxPos=%d, fRedraw=%d)\n",
160 This
, fnBar
, nMinPos
, nMaxPos
, fRedraw
);
164 static BOOL WINAPI
ITextHostImpl_TxSetScrollPos(ITextHost
*iface
,
169 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
170 TRACECALL("Call to TxSetScrollPos(%p, fnBar=%d, nPos=%d, fRedraw=%d)\n",
171 This
, fnBar
, nPos
, fRedraw
);
175 static void WINAPI
ITextHostImpl_TxInvalidateRect(ITextHost
*iface
,
179 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
180 TRACECALL("Call to TxInvalidateRect(%p, prc=%p, fMode=%d)\n",
184 static void WINAPI
ITextHostImpl_TxViewChange(ITextHost
*iface
, BOOL fUpdate
)
186 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
187 TRACECALL("Call to TxViewChange(%p, fUpdate=%d)\n",
191 static BOOL WINAPI
ITextHostImpl_TxCreateCaret(ITextHost
*iface
,
193 INT xWidth
, INT yHeight
)
195 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
196 TRACECALL("Call to TxCreateCaret(%p, nbmp=%p, xWidth=%d, yHeight=%d)\n",
197 This
, hbmp
, xWidth
, yHeight
);
201 static BOOL WINAPI
ITextHostImpl_TxShowCaret(ITextHost
*iface
, BOOL fShow
)
203 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
204 TRACECALL("Call to TxShowCaret(%p, fShow=%d)\n",
209 static BOOL WINAPI
ITextHostImpl_TxSetCaretPos(ITextHost
*iface
,
212 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
213 TRACECALL("Call to TxSetCaretPos(%p, x=%d, y=%d)\n", This
, x
, y
);
217 static BOOL WINAPI
ITextHostImpl_TxSetTimer(ITextHost
*iface
,
218 UINT idTimer
, UINT uTimeout
)
220 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
221 TRACECALL("Call to TxSetTimer(%p, idTimer=%u, uTimeout=%u)\n",
222 This
, idTimer
, uTimeout
);
226 static void WINAPI
ITextHostImpl_TxKillTimer(ITextHost
*iface
, UINT idTimer
)
228 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
229 TRACECALL("Call to TxKillTimer(%p, idTimer=%u)\n", This
, idTimer
);
232 static void WINAPI
ITextHostImpl_TxScrollWindowEx(ITextHost
*iface
,
240 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
241 TRACECALL("Call to TxScrollWindowEx(%p, %d, %d, %p, %p, %p, %p, %d)\n",
242 This
, dx
, dy
, lprcScroll
, lprcClip
, hRgnUpdate
, lprcUpdate
, fuScroll
);
245 static void WINAPI
ITextHostImpl_TxSetCapture(ITextHost
*iface
, BOOL fCapture
)
247 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
248 TRACECALL("Call to TxSetCapture(%p, fCapture=%d)\n", This
, fCapture
);
251 static void WINAPI
ITextHostImpl_TxSetFocus(ITextHost
*iface
)
253 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
254 TRACECALL("Call to TxSetFocus(%p)\n", This
);
257 static void WINAPI
ITextHostImpl_TxSetCursor(ITextHost
*iface
,
261 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
262 TRACECALL("Call to TxSetCursor(%p, hcur=%p, fText=%d)\n",
266 static BOOL WINAPI
ITextHostImpl_TxScreenToClient(ITextHost
*iface
,
269 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
270 TRACECALL("Call to TxScreenToClient(%p, lppt=%p)\n", This
, lppt
);
274 static BOOL WINAPI
ITextHostImpl_TxClientToScreen(ITextHost
*iface
,
277 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
278 TRACECALL("Call to TxClientToScreen(%p, lppt=%p)\n", This
, lppt
);
282 static HRESULT WINAPI
ITextHostImpl_TxActivate(ITextHost
*iface
,
285 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
286 TRACECALL("Call to TxActivate(%p, plOldState=%p)\n", This
, plOldState
);
290 static HRESULT WINAPI
ITextHostImpl_TxDeactivate(ITextHost
*iface
,
293 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
294 TRACECALL("Call to TxDeactivate(%p, lNewState=%d)\n", This
, lNewState
);
298 static HRESULT WINAPI
ITextHostImpl_TxGetClientRect(ITextHost
*iface
,
301 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
302 TRACECALL("Call to TxGetClientRect(%p, prc=%p)\n", This
, prc
);
306 static HRESULT WINAPI
ITextHostImpl_TxGetViewInset(ITextHost
*iface
,
309 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
310 TRACECALL("Call to TxGetViewInset(%p, prc=%p)\n", This
, prc
);
314 static HRESULT WINAPI
ITextHostImpl_TxGetCharFormat(ITextHost
*iface
,
315 const CHARFORMATW
**ppCF
)
317 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
318 TRACECALL("Call to TxGetCharFormat(%p, ppCF=%p)\n", This
, ppCF
);
322 static HRESULT WINAPI
ITextHostImpl_TxGetParaFormat(ITextHost
*iface
,
323 const PARAFORMAT
**ppPF
)
325 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
326 TRACECALL("Call to TxGetParaFormat(%p, ppPF=%p)\n", This
, ppPF
);
330 static COLORREF WINAPI
ITextHostImpl_TxGetSysColor(ITextHost
*iface
,
333 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
334 TRACECALL("Call to TxGetSysColor(%p, nIndex=%d)\n", This
, nIndex
);
338 static HRESULT WINAPI
ITextHostImpl_TxGetBackStyle(ITextHost
*iface
,
339 TXTBACKSTYLE
*pStyle
)
341 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
342 TRACECALL("Call to TxGetBackStyle(%p, pStyle=%p)\n", This
, pStyle
);
346 static HRESULT WINAPI
ITextHostImpl_TxGetMaxLength(ITextHost
*iface
,
349 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
350 TRACECALL("Call to TxGetMaxLength(%p, pLength=%p)\n", This
, pLength
);
354 static HRESULT WINAPI
ITextHostImpl_TxGetScrollBars(ITextHost
*iface
,
357 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
358 TRACECALL("Call to TxGetScrollBars(%p, pdwScrollBar=%p)\n",
363 static HRESULT WINAPI
ITextHostImpl_TxGetPasswordChar(ITextHost
*iface
,
366 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
367 TRACECALL("Call to TxGetPasswordChar(%p, pch=%p)\n", This
, pch
);
371 static HRESULT WINAPI
ITextHostImpl_TxGetAcceleratorPos(ITextHost
*iface
,
374 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
375 TRACECALL("Call to TxGetAcceleratorPos(%p, pch=%p)\n", This
, pch
);
379 static HRESULT WINAPI
ITextHostImpl_TxGetExtent(ITextHost
*iface
,
382 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
383 TRACECALL("Call to TxGetExtent(%p, lpExtent=%p)\n", This
, lpExtent
);
387 static HRESULT WINAPI
ITextHostImpl_OnTxCharFormatChange(ITextHost
*iface
,
388 const CHARFORMATW
*pcf
)
390 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
391 TRACECALL("Call to OnTxCharFormatChange(%p, pcf=%p)\n", This
, pcf
);
395 static HRESULT WINAPI
ITextHostImpl_OnTxParaFormatChange(ITextHost
*iface
,
396 const PARAFORMAT
*ppf
)
398 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
399 TRACECALL("Call to OnTxParaFormatChange(%p, ppf=%p)\n", This
, ppf
);
403 /* This must return S_OK for the native ITextServices object to
405 static HRESULT WINAPI
ITextHostImpl_TxGetPropertyBits(ITextHost
*iface
,
409 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
410 TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08x, pdwBits=%p)\n",
411 This
, dwMask
, pdwBits
);
416 static HRESULT WINAPI
ITextHostImpl_TxNotify(ITextHost
*iface
, DWORD iNotify
,
419 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
420 TRACECALL("Call to TxNotify(%p, iNotify=%d, pv=%p)\n", This
, iNotify
, pv
);
424 static HIMC WINAPI
ITextHostImpl_TxImmGetContext(ITextHost
*iface
)
426 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
427 TRACECALL("Call to TxImmGetContext(%p)\n", This
);
431 static void WINAPI
ITextHostImpl_TxImmReleaseContext(ITextHost
*iface
, HIMC himc
)
433 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
434 TRACECALL("Call to TxImmReleaseContext(%p, himc=%p)\n", This
, himc
);
437 static HRESULT WINAPI
ITextHostImpl_TxGetSelectionBarWidth(ITextHost
*iface
,
440 ITextHostTestImpl
*This
= (ITextHostTestImpl
*)iface
;
441 TRACECALL("Call to TxGetSelectionBarWidth(%p, lSelBarWidth=%p)\n",
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
);
645 static void test_TxSetText(void)
649 WCHAR settext
[] = {'T','e','s','t',0};
651 if (!init_texthost())
654 hres
= ITextServices_TxSetText(txtserv
, settext
);
655 todo_wine
ok(hres
== S_OK
, "ITextServices_TxSetText failed\n");
657 hres
= ITextServices_TxGetText(txtserv
, &rettext
);
658 todo_wine
ok(hres
== S_OK
, "ITextServices_TxGetText failed\n");
660 todo_wine
ok(SysStringLen(rettext
) == 4,
661 "String returned of wrong length\n");
662 todo_wine
ok(memcmp(rettext
,settext
,SysStringByteLen(rettext
)) == 0,
663 "String returned differs\n");
665 IUnknown_Release(txtserv
);
666 CoTaskMemFree(dummyTextHost
);
671 setup_thiscall_wrappers();
673 /* Must explicitly LoadLibrary(). The test has no references to functions in
674 * RICHED20.DLL, so the linker doesn't actually link to it. */
675 hmoduleRichEdit
= LoadLibrary("RICHED20.DLL");
676 ok(hmoduleRichEdit
!= NULL
, "error: %d\n", (int) GetLastError());
680 IUnknown_Release(txtserv
);
681 CoTaskMemFree(dummyTextHost
);
686 if (wrapperCodeMem
) VirtualFree(wrapperCodeMem
, 0, MEM_RELEASE
);