1 /* 2 * Unit test suite for windowless rich edit controls 3 * 4 * Copyright 2008 Maarten Lankhorst 5 * Copyright 2008 Austin Lund 6 * Copyright 2008 Dylan Smith 7 * 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. 12 * 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. 17 * 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 21 */ 22 23 #define COBJMACROS 24 #define CONST_VTABLE 25 26 #include <stdio.h> 27 #include <stdarg.h> 28 #include <windef.h> 29 #include <winbase.h> 30 #include <objbase.h> 31 #include <richedit.h> 32 #include <tom.h> 33 #include <richole.h> 34 #include <initguid.h> 35 #include <imm.h> 36 #include <textserv.h> 37 #include <wine/test.h> 38 #include <oleauto.h> 39 #include <limits.h> 40 41 static HMODULE hmoduleRichEdit; 42 static IID *pIID_ITextServices; 43 static IID *pIID_ITextHost; 44 static IID *pIID_ITextHost2; 45 static PCreateTextServices pCreateTextServices; 46 47 /* Define C Macros for ITextServices calls. */ 48 49 /* Use a special table for x86 machines to convert the thiscall 50 * calling convention. This isn't needed on other platforms. */ 51 #if defined(__i386__) && !defined(__MINGW32__) 52 static ITextServicesVtbl itextServicesStdcallVtbl; 53 #define TXTSERV_VTABLE(This) (&itextServicesStdcallVtbl) 54 #else /* __i386__ */ 55 #define TXTSERV_VTABLE(This) (This)->lpVtbl 56 #endif /* __i386__ */ 57 58 #define ITextServices_TxSendMessage(This,a,b,c,d) TXTSERV_VTABLE(This)->TxSendMessage(This,a,b,c,d) 59 #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) 60 #define ITextServices_TxGetHScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetHScroll(This,a,b,c,d,e) 61 #define ITextServices_TxGetVScroll(This,a,b,c,d,e) TXTSERV_VTABLE(This)->TxGetVScroll(This,a,b,c,d,e) 62 #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) 63 #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) 64 #define ITextServices_OnTxInplaceActivate(This,a) TXTSERV_VTABLE(This)->OnTxInplaceActivate(This,a) 65 #define ITextServices_OnTxInplaceDeactivate(This) TXTSERV_VTABLE(This)->OnTxInplaceDeactivate(This) 66 #define ITextServices_OnTxUIActivate(This) TXTSERV_VTABLE(This)->OnTxUIActivate(This) 67 #define ITextServices_OnTxUIDeactivate(This) TXTSERV_VTABLE(This)->OnTxUIDeactivate(This) 68 #define ITextServices_TxGetText(This,a) TXTSERV_VTABLE(This)->TxGetText(This,a) 69 #define ITextServices_TxSetText(This,a) TXTSERV_VTABLE(This)->TxSetText(This,a) 70 #define ITextServices_TxGetCurTargetX(This,a) TXTSERV_VTABLE(This)->TxGetCurTargetX(This,a) 71 #define ITextServices_TxGetBaseLinePos(This,a) TXTSERV_VTABLE(This)->TxGetBaseLinePos(This,a) 72 #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) 73 #define ITextServices_TxGetDropTarget(This,a) TXTSERV_VTABLE(This)->TxGetDropTarget(This,a) 74 #define ITextServices_OnTxPropertyBitsChange(This,a,b) TXTSERV_VTABLE(This)->OnTxPropertyBitsChange(This,a,b) 75 #define ITextServices_TxGetCachedSize(This,a,b) TXTSERV_VTABLE(This)->TxGetCachedSize(This,a,b) 76 77 /* Set the WINETEST_DEBUG environment variable to be greater than 1 for verbose 78 * function call traces of ITextHost. */ 79 #define TRACECALL if(winetest_debug > 1) trace 80 81 /************************************************************************/ 82 /* ITextHost implementation for conformance testing. */ 83 84 typedef struct ITextHostTestImpl 85 { 86 ITextHost ITextHost_iface; 87 LONG refCount; 88 CHARFORMAT2W char_format; 89 } ITextHostTestImpl; 90 91 static inline ITextHostTestImpl *impl_from_ITextHost(ITextHost *iface) 92 { 93 return CONTAINING_RECORD(iface, ITextHostTestImpl, ITextHost_iface); 94 } 95 96 static HRESULT WINAPI ITextHostImpl_QueryInterface(ITextHost *iface, 97 REFIID riid, 98 LPVOID *ppvObject) 99 { 100 ITextHostTestImpl *This = impl_from_ITextHost(iface); 101 102 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, pIID_ITextHost)) { 103 *ppvObject = &This->ITextHost_iface; 104 ITextHost_AddRef((ITextHost *)*ppvObject); 105 return S_OK; 106 } 107 108 return E_NOINTERFACE; 109 } 110 111 static ULONG WINAPI ITextHostImpl_AddRef(ITextHost *iface) 112 { 113 ITextHostTestImpl *This = impl_from_ITextHost(iface); 114 ULONG refCount = InterlockedIncrement(&This->refCount); 115 return refCount; 116 } 117 118 static ULONG WINAPI ITextHostImpl_Release(ITextHost *iface) 119 { 120 ITextHostTestImpl *This = impl_from_ITextHost(iface); 121 ULONG refCount = InterlockedDecrement(&This->refCount); 122 123 if (!refCount) 124 { 125 CoTaskMemFree(This); 126 return 0; 127 } else { 128 return refCount; 129 } 130 } 131 132 static HDC WINAPI ITextHostImpl_TxGetDC(ITextHost *iface) 133 { 134 ITextHostTestImpl *This = impl_from_ITextHost(iface); 135 TRACECALL("Call to TxGetDC(%p)\n", This); 136 return NULL; 137 } 138 139 static INT WINAPI ITextHostImpl_TxReleaseDC(ITextHost *iface, 140 HDC hdc) 141 { 142 ITextHostTestImpl *This = impl_from_ITextHost(iface); 143 TRACECALL("Call to TxReleaseDC(%p)\n", This); 144 return 0; 145 } 146 147 static BOOL WINAPI ITextHostImpl_TxShowScrollBar(ITextHost *iface, 148 INT fnBar, 149 BOOL fShow) 150 { 151 ITextHostTestImpl *This = impl_from_ITextHost(iface); 152 TRACECALL("Call to TxShowScrollBar(%p, fnBar=%d, fShow=%d)\n", 153 This, fnBar, fShow); 154 return FALSE; 155 } 156 157 static BOOL WINAPI ITextHostImpl_TxEnableScrollBar(ITextHost *iface, 158 INT fuSBFlags, 159 INT fuArrowflags) 160 { 161 ITextHostTestImpl *This = impl_from_ITextHost(iface); 162 TRACECALL("Call to TxEnableScrollBar(%p, fuSBFlags=%d, fuArrowflags=%d)\n", 163 This, fuSBFlags, fuArrowflags); 164 return FALSE; 165 } 166 167 static BOOL WINAPI ITextHostImpl_TxSetScrollRange(ITextHost *iface, 168 INT fnBar, 169 LONG nMinPos, 170 INT nMaxPos, 171 BOOL fRedraw) 172 { 173 ITextHostTestImpl *This = impl_from_ITextHost(iface); 174 TRACECALL("Call to TxSetScrollRange(%p, fnBar=%d, nMinPos=%d, nMaxPos=%d, fRedraw=%d)\n", 175 This, fnBar, nMinPos, nMaxPos, fRedraw); 176 return FALSE; 177 } 178 179 static BOOL WINAPI ITextHostImpl_TxSetScrollPos(ITextHost *iface, 180 INT fnBar, 181 INT nPos, 182 BOOL fRedraw) 183 { 184 ITextHostTestImpl *This = impl_from_ITextHost(iface); 185 TRACECALL("Call to TxSetScrollPos(%p, fnBar=%d, nPos=%d, fRedraw=%d)\n", 186 This, fnBar, nPos, fRedraw); 187 return FALSE; 188 } 189 190 static void WINAPI ITextHostImpl_TxInvalidateRect(ITextHost *iface, 191 LPCRECT prc, 192 BOOL fMode) 193 { 194 ITextHostTestImpl *This = impl_from_ITextHost(iface); 195 TRACECALL("Call to TxInvalidateRect(%p, prc=%p, fMode=%d)\n", 196 This, prc, fMode); 197 } 198 199 static void WINAPI ITextHostImpl_TxViewChange(ITextHost *iface, BOOL fUpdate) 200 { 201 ITextHostTestImpl *This = impl_from_ITextHost(iface); 202 TRACECALL("Call to TxViewChange(%p, fUpdate=%d)\n", 203 This, fUpdate); 204 } 205 206 static BOOL WINAPI ITextHostImpl_TxCreateCaret(ITextHost *iface, 207 HBITMAP hbmp, 208 INT xWidth, INT yHeight) 209 { 210 ITextHostTestImpl *This = impl_from_ITextHost(iface); 211 TRACECALL("Call to TxCreateCaret(%p, nbmp=%p, xWidth=%d, yHeight=%d)\n", 212 This, hbmp, xWidth, yHeight); 213 return FALSE; 214 } 215 216 static BOOL WINAPI ITextHostImpl_TxShowCaret(ITextHost *iface, BOOL fShow) 217 { 218 ITextHostTestImpl *This = impl_from_ITextHost(iface); 219 TRACECALL("Call to TxShowCaret(%p, fShow=%d)\n", 220 This, fShow); 221 return FALSE; 222 } 223 224 static BOOL WINAPI ITextHostImpl_TxSetCaretPos(ITextHost *iface, 225 INT x, INT y) 226 { 227 ITextHostTestImpl *This = impl_from_ITextHost(iface); 228 TRACECALL("Call to TxSetCaretPos(%p, x=%d, y=%d)\n", This, x, y); 229 return FALSE; 230 } 231 232 static BOOL WINAPI ITextHostImpl_TxSetTimer(ITextHost *iface, 233 UINT idTimer, UINT uTimeout) 234 { 235 ITextHostTestImpl *This = impl_from_ITextHost(iface); 236 TRACECALL("Call to TxSetTimer(%p, idTimer=%u, uTimeout=%u)\n", 237 This, idTimer, uTimeout); 238 return FALSE; 239 } 240 241 static void WINAPI ITextHostImpl_TxKillTimer(ITextHost *iface, UINT idTimer) 242 { 243 ITextHostTestImpl *This = impl_from_ITextHost(iface); 244 TRACECALL("Call to TxKillTimer(%p, idTimer=%u)\n", This, idTimer); 245 } 246 247 static void WINAPI ITextHostImpl_TxScrollWindowEx(ITextHost *iface, 248 INT dx, INT dy, 249 LPCRECT lprcScroll, 250 LPCRECT lprcClip, 251 HRGN hRgnUpdate, 252 LPRECT lprcUpdate, 253 UINT fuScroll) 254 { 255 ITextHostTestImpl *This = impl_from_ITextHost(iface); 256 TRACECALL("Call to TxScrollWindowEx(%p, %d, %d, %p, %p, %p, %p, %d)\n", 257 This, dx, dy, lprcScroll, lprcClip, hRgnUpdate, lprcUpdate, fuScroll); 258 } 259 260 static void WINAPI ITextHostImpl_TxSetCapture(ITextHost *iface, BOOL fCapture) 261 { 262 ITextHostTestImpl *This = impl_from_ITextHost(iface); 263 TRACECALL("Call to TxSetCapture(%p, fCapture=%d)\n", This, fCapture); 264 } 265 266 static void WINAPI ITextHostImpl_TxSetFocus(ITextHost *iface) 267 { 268 ITextHostTestImpl *This = impl_from_ITextHost(iface); 269 TRACECALL("Call to TxSetFocus(%p)\n", This); 270 } 271 272 static void WINAPI ITextHostImpl_TxSetCursor(ITextHost *iface, 273 HCURSOR hcur, 274 BOOL fText) 275 { 276 ITextHostTestImpl *This = impl_from_ITextHost(iface); 277 TRACECALL("Call to TxSetCursor(%p, hcur=%p, fText=%d)\n", 278 This, hcur, fText); 279 } 280 281 static BOOL WINAPI ITextHostImpl_TxScreenToClient(ITextHost *iface, 282 LPPOINT lppt) 283 { 284 ITextHostTestImpl *This = impl_from_ITextHost(iface); 285 TRACECALL("Call to TxScreenToClient(%p, lppt=%p)\n", This, lppt); 286 return FALSE; 287 } 288 289 static BOOL WINAPI ITextHostImpl_TxClientToScreen(ITextHost *iface, 290 LPPOINT lppt) 291 { 292 ITextHostTestImpl *This = impl_from_ITextHost(iface); 293 TRACECALL("Call to TxClientToScreen(%p, lppt=%p)\n", This, lppt); 294 return FALSE; 295 } 296 297 static HRESULT WINAPI ITextHostImpl_TxActivate(ITextHost *iface, 298 LONG *plOldState) 299 { 300 ITextHostTestImpl *This = impl_from_ITextHost(iface); 301 TRACECALL("Call to TxActivate(%p, plOldState=%p)\n", This, plOldState); 302 return E_NOTIMPL; 303 } 304 305 static HRESULT WINAPI ITextHostImpl_TxDeactivate(ITextHost *iface, 306 LONG lNewState) 307 { 308 ITextHostTestImpl *This = impl_from_ITextHost(iface); 309 TRACECALL("Call to TxDeactivate(%p, lNewState=%d)\n", This, lNewState); 310 return E_NOTIMPL; 311 } 312 313 static HRESULT WINAPI ITextHostImpl_TxGetClientRect(ITextHost *iface, 314 LPRECT prc) 315 { 316 ITextHostTestImpl *This = impl_from_ITextHost(iface); 317 TRACECALL("Call to TxGetClientRect(%p, prc=%p)\n", This, prc); 318 return E_NOTIMPL; 319 } 320 321 static HRESULT WINAPI ITextHostImpl_TxGetViewInset(ITextHost *iface, 322 LPRECT prc) 323 { 324 ITextHostTestImpl *This = impl_from_ITextHost(iface); 325 TRACECALL("Call to TxGetViewInset(%p, prc=%p)\n", This, prc); 326 return E_NOTIMPL; 327 } 328 329 static HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface, 330 const CHARFORMATW **ppCF) 331 { 332 ITextHostTestImpl *This = impl_from_ITextHost(iface); 333 TRACECALL("Call to TxGetCharFormat(%p, ppCF=%p)\n", This, ppCF); 334 return E_NOTIMPL; 335 } 336 337 static HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface, 338 const PARAFORMAT **ppPF) 339 { 340 ITextHostTestImpl *This = impl_from_ITextHost(iface); 341 TRACECALL("Call to TxGetParaFormat(%p, ppPF=%p)\n", This, ppPF); 342 return E_NOTIMPL; 343 } 344 345 static COLORREF WINAPI ITextHostImpl_TxGetSysColor(ITextHost *iface, 346 int nIndex) 347 { 348 ITextHostTestImpl *This = impl_from_ITextHost(iface); 349 TRACECALL("Call to TxGetSysColor(%p, nIndex=%d)\n", This, nIndex); 350 return E_NOTIMPL; 351 } 352 353 static HRESULT WINAPI ITextHostImpl_TxGetBackStyle(ITextHost *iface, 354 TXTBACKSTYLE *pStyle) 355 { 356 ITextHostTestImpl *This = impl_from_ITextHost(iface); 357 TRACECALL("Call to TxGetBackStyle(%p, pStyle=%p)\n", This, pStyle); 358 return E_NOTIMPL; 359 } 360 361 static HRESULT WINAPI ITextHostImpl_TxGetMaxLength(ITextHost *iface, 362 DWORD *pLength) 363 { 364 ITextHostTestImpl *This = impl_from_ITextHost(iface); 365 TRACECALL("Call to TxGetMaxLength(%p, pLength=%p)\n", This, pLength); 366 return E_NOTIMPL; 367 } 368 369 static HRESULT WINAPI ITextHostImpl_TxGetScrollBars(ITextHost *iface, 370 DWORD *pdwScrollBar) 371 { 372 ITextHostTestImpl *This = impl_from_ITextHost(iface); 373 TRACECALL("Call to TxGetScrollBars(%p, pdwScrollBar=%p)\n", 374 This, pdwScrollBar); 375 return E_NOTIMPL; 376 } 377 378 static HRESULT WINAPI ITextHostImpl_TxGetPasswordChar(ITextHost *iface, 379 WCHAR *pch) 380 { 381 ITextHostTestImpl *This = impl_from_ITextHost(iface); 382 TRACECALL("Call to TxGetPasswordChar(%p, pch=%p)\n", This, pch); 383 return E_NOTIMPL; 384 } 385 386 static HRESULT WINAPI ITextHostImpl_TxGetAcceleratorPos(ITextHost *iface, 387 LONG *pch) 388 { 389 ITextHostTestImpl *This = impl_from_ITextHost(iface); 390 TRACECALL("Call to TxGetAcceleratorPos(%p, pch=%p)\n", This, pch); 391 return E_NOTIMPL; 392 } 393 394 static HRESULT WINAPI ITextHostImpl_TxGetExtent(ITextHost *iface, 395 LPSIZEL lpExtent) 396 { 397 ITextHostTestImpl *This = impl_from_ITextHost(iface); 398 TRACECALL("Call to TxGetExtent(%p, lpExtent=%p)\n", This, lpExtent); 399 return E_NOTIMPL; 400 } 401 402 static HRESULT WINAPI ITextHostImpl_OnTxCharFormatChange(ITextHost *iface, 403 const CHARFORMATW *pcf) 404 { 405 ITextHostTestImpl *This = impl_from_ITextHost(iface); 406 TRACECALL("Call to OnTxCharFormatChange(%p, pcf=%p)\n", This, pcf); 407 return E_NOTIMPL; 408 } 409 410 static HRESULT WINAPI ITextHostImpl_OnTxParaFormatChange(ITextHost *iface, 411 const PARAFORMAT *ppf) 412 { 413 ITextHostTestImpl *This = impl_from_ITextHost(iface); 414 TRACECALL("Call to OnTxParaFormatChange(%p, ppf=%p)\n", This, ppf); 415 return E_NOTIMPL; 416 } 417 418 /* This must return S_OK for the native ITextServices object to 419 initialize. */ 420 static HRESULT WINAPI ITextHostImpl_TxGetPropertyBits(ITextHost *iface, 421 DWORD dwMask, 422 DWORD *pdwBits) 423 { 424 ITextHostTestImpl *This = impl_from_ITextHost(iface); 425 TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08x, pdwBits=%p)\n", 426 This, dwMask, pdwBits); 427 *pdwBits = 0; 428 return S_OK; 429 } 430 431 static HRESULT WINAPI ITextHostImpl_TxNotify(ITextHost *iface, DWORD iNotify, 432 void *pv) 433 { 434 ITextHostTestImpl *This = impl_from_ITextHost(iface); 435 TRACECALL("Call to TxNotify(%p, iNotify=%d, pv=%p)\n", This, iNotify, pv); 436 return E_NOTIMPL; 437 } 438 439 static HIMC WINAPI ITextHostImpl_TxImmGetContext(ITextHost *iface) 440 { 441 ITextHostTestImpl *This = impl_from_ITextHost(iface); 442 TRACECALL("Call to TxImmGetContext(%p)\n", This); 443 return 0; 444 } 445 446 static void WINAPI ITextHostImpl_TxImmReleaseContext(ITextHost *iface, HIMC himc) 447 { 448 ITextHostTestImpl *This = impl_from_ITextHost(iface); 449 TRACECALL("Call to TxImmReleaseContext(%p, himc=%p)\n", This, himc); 450 } 451 452 /* This function must set the variable pointed to by *lSelBarWidth. 453 Otherwise an uninitialized value will be used to calculate 454 positions and sizes even if E_NOTIMPL is returned. */ 455 static HRESULT WINAPI ITextHostImpl_TxGetSelectionBarWidth(ITextHost *iface, 456 LONG *lSelBarWidth) 457 { 458 ITextHostTestImpl *This = impl_from_ITextHost(iface); 459 TRACECALL("Call to TxGetSelectionBarWidth(%p, lSelBarWidth=%p)\n", 460 This, lSelBarWidth); 461 *lSelBarWidth = 0; 462 return E_NOTIMPL; 463 } 464 465 static ITextHostVtbl itextHostVtbl = { 466 ITextHostImpl_QueryInterface, 467 ITextHostImpl_AddRef, 468 ITextHostImpl_Release, 469 ITextHostImpl_TxGetDC, 470 ITextHostImpl_TxReleaseDC, 471 ITextHostImpl_TxShowScrollBar, 472 ITextHostImpl_TxEnableScrollBar, 473 ITextHostImpl_TxSetScrollRange, 474 ITextHostImpl_TxSetScrollPos, 475 ITextHostImpl_TxInvalidateRect, 476 ITextHostImpl_TxViewChange, 477 ITextHostImpl_TxCreateCaret, 478 ITextHostImpl_TxShowCaret, 479 ITextHostImpl_TxSetCaretPos, 480 ITextHostImpl_TxSetTimer, 481 ITextHostImpl_TxKillTimer, 482 ITextHostImpl_TxScrollWindowEx, 483 ITextHostImpl_TxSetCapture, 484 ITextHostImpl_TxSetFocus, 485 ITextHostImpl_TxSetCursor, 486 ITextHostImpl_TxScreenToClient, 487 ITextHostImpl_TxClientToScreen, 488 ITextHostImpl_TxActivate, 489 ITextHostImpl_TxDeactivate, 490 ITextHostImpl_TxGetClientRect, 491 ITextHostImpl_TxGetViewInset, 492 ITextHostImpl_TxGetCharFormat, 493 ITextHostImpl_TxGetParaFormat, 494 ITextHostImpl_TxGetSysColor, 495 ITextHostImpl_TxGetBackStyle, 496 ITextHostImpl_TxGetMaxLength, 497 ITextHostImpl_TxGetScrollBars, 498 ITextHostImpl_TxGetPasswordChar, 499 ITextHostImpl_TxGetAcceleratorPos, 500 ITextHostImpl_TxGetExtent, 501 ITextHostImpl_OnTxCharFormatChange, 502 ITextHostImpl_OnTxParaFormatChange, 503 ITextHostImpl_TxGetPropertyBits, 504 ITextHostImpl_TxNotify, 505 ITextHostImpl_TxImmGetContext, 506 ITextHostImpl_TxImmReleaseContext, 507 ITextHostImpl_TxGetSelectionBarWidth 508 }; 509 510 static void *wrapperCodeMem = NULL; 511 512 #include "pshpack1.h" 513 514 /* Code structure for x86 byte code */ 515 typedef struct 516 { 517 BYTE pop_eax; /* popl %eax */ 518 BYTE push_ecx; /* pushl %ecx */ 519 BYTE push_eax; /* pushl %eax */ 520 BYTE jmp_func; /* jmp $func */ 521 DWORD func; 522 } THISCALL_TO_STDCALL_THUNK; 523 524 typedef struct 525 { 526 BYTE pop_eax; /* popl %eax */ 527 BYTE pop_ecx; /* popl %ecx */ 528 BYTE push_eax; /* pushl %eax */ 529 BYTE mov_vtable_eax[2]; /* movl (%ecx), %eax */ 530 BYTE jmp_eax[2]; /* jmp *$vtablefunc_offset(%eax) */ 531 int vtablefunc_offset; 532 } STDCALL_TO_THISCALL_THUNK; 533 534 #include "poppack.h" 535 536 static void setup_thiscall_wrappers(void) 537 { 538 #if defined(__i386__) && !defined(__MINGW32__) 539 void** pVtable; 540 void** pVtableEnd; 541 THISCALL_TO_STDCALL_THUNK *thunk; 542 STDCALL_TO_THISCALL_THUNK *thunk2; 543 544 wrapperCodeMem = VirtualAlloc(NULL, 545 (sizeof(ITextHostVtbl)/sizeof(void*) - 3) 546 * sizeof(THISCALL_TO_STDCALL_THUNK) 547 +(sizeof(ITextServicesVtbl)/sizeof(void*) - 3) 548 * sizeof(STDCALL_TO_THISCALL_THUNK), 549 MEM_COMMIT, PAGE_EXECUTE_READWRITE); 550 thunk = wrapperCodeMem; 551 552 /* Wrap all ITextHostImpl methods with code to perform a thiscall to 553 * stdcall conversion. The thiscall calling convention places the This 554 * pointer in ecx on the x86 platform, and the stdcall calling convention 555 * pushes the This pointer on the stack as the first argument. 556 * 557 * The byte code does the conversion then jumps to the real function. 558 * 559 * Each wrapper needs to be modified so that the function to jump to is 560 * modified in the byte code. */ 561 562 /* Skip QueryInterface, AddRef, and Release native actually 563 * defined them with the stdcall calling convention. */ 564 pVtable = (void**)&itextHostVtbl + 3; 565 pVtableEnd = (void**)(&itextHostVtbl + 1); 566 while (pVtable != pVtableEnd) { 567 /* write byte code to executable memory */ 568 thunk->pop_eax = 0x58; /* popl %eax */ 569 thunk->push_ecx = 0x51; /* pushl %ecx */ 570 thunk->push_eax = 0x50; /* pushl %eax */ 571 thunk->jmp_func = 0xe9; /* jmp $func */ 572 /* The address needs to be relative to the end of the jump instructions. */ 573 thunk->func = (char*)*pVtable - (char*)(&thunk->func + 1); 574 *pVtable = thunk; 575 pVtable++; 576 thunk++; 577 } 578 579 /* Setup an ITextServices standard call vtable that will call the 580 * native thiscall vtable when the methods are called. */ 581 582 /* QueryInterface, AddRef, and Release should be called directly on the 583 * real vtable since they use the stdcall calling convention. */ 584 thunk2 = (STDCALL_TO_THISCALL_THUNK *)thunk; 585 pVtable = (void**)&itextServicesStdcallVtbl + 3; 586 pVtableEnd = (void**)(&itextServicesStdcallVtbl + 1); 587 while (pVtable != pVtableEnd) { 588 /* write byte code to executable memory */ 589 thunk2->pop_eax = 0x58; /* popl %eax */ 590 thunk2->pop_ecx = 0x59; /* popl %ecx */ 591 thunk2->push_eax = 0x50; /* pushl %eax */ 592 thunk2->mov_vtable_eax[0] = 0x8b; /* movl (%ecx), %eax */ 593 thunk2->mov_vtable_eax[1] = 0x01; 594 thunk2->jmp_eax[0] = 0xff; /* jmp *$vtablefunc_offset(%eax) */ 595 thunk2->jmp_eax[1] = 0xa0; 596 thunk2->vtablefunc_offset = (char*)pVtable - (char*)&itextServicesStdcallVtbl; 597 *pVtable = thunk2; 598 pVtable++; 599 thunk2++; 600 } 601 #endif /* __i386__ */ 602 } 603 604 static void hf_to_cf(HFONT hf, CHARFORMAT2W *cf) 605 { 606 LOGFONTW lf; 607 608 GetObjectW(hf, sizeof(lf), &lf); 609 lstrcpyW(cf->szFaceName, lf.lfFaceName); 610 cf->yHeight = MulDiv(abs(lf.lfHeight), 1440, GetDeviceCaps(GetDC(NULL), LOGPIXELSY)); 611 if (lf.lfWeight > FW_NORMAL) cf->dwEffects |= CFE_BOLD; 612 if (lf.lfItalic) cf->dwEffects |= CFE_ITALIC; 613 if (lf.lfUnderline) cf->dwEffects |= CFE_UNDERLINE; 614 if (lf.lfStrikeOut) cf->dwEffects |= CFE_SUBSCRIPT; 615 cf->bPitchAndFamily = lf.lfPitchAndFamily; 616 cf->bCharSet = lf.lfCharSet; 617 } 618 619 /*************************************************************************/ 620 /* Conformance test functions. */ 621 622 /* Initialize the test texthost structure */ 623 static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) 624 { 625 ITextHostTestImpl *dummyTextHost; 626 IUnknown *init; 627 HRESULT result; 628 HFONT hf; 629 630 dummyTextHost = CoTaskMemAlloc(sizeof(*dummyTextHost)); 631 if (dummyTextHost == NULL) { 632 win_skip("Insufficient memory to create ITextHost interface\n"); 633 return FALSE; 634 } 635 dummyTextHost->ITextHost_iface.lpVtbl = &itextHostVtbl; 636 dummyTextHost->refCount = 1; 637 memset(&dummyTextHost->char_format, 0, sizeof(dummyTextHost->char_format)); 638 dummyTextHost->char_format.cbSize = sizeof(dummyTextHost->char_format); 639 dummyTextHost->char_format.dwMask = CFM_ALL2; 640 hf = GetStockObject(DEFAULT_GUI_FONT); 641 hf_to_cf(hf, &dummyTextHost->char_format); 642 643 /* MSDN states that an IUnknown object is returned by 644 CreateTextServices which is then queried to obtain a 645 ITextServices object. */ 646 result = pCreateTextServices(NULL, &dummyTextHost->ITextHost_iface, &init); 647 ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result); 648 if (result != S_OK) { 649 CoTaskMemFree(dummyTextHost); 650 win_skip("CreateTextServices failed.\n"); 651 return FALSE; 652 } 653 654 result = IUnknown_QueryInterface(init, pIID_ITextServices, (void**)txtserv); 655 ok((result == S_OK) && (*txtserv != NULL), "Querying interface failed (result = %x, txtserv = %p)\n", result, *txtserv); 656 IUnknown_Release(init); 657 if (!((result == S_OK) && (*txtserv != NULL))) { 658 CoTaskMemFree(dummyTextHost); 659 win_skip("Could not retrieve ITextServices interface\n"); 660 return FALSE; 661 } 662 663 *ret = &dummyTextHost->ITextHost_iface; 664 return TRUE; 665 } 666 667 static void test_TxGetText(void) 668 { 669 ITextServices *txtserv; 670 ITextHost *host; 671 HRESULT hres; 672 BSTR rettext; 673 674 if (!init_texthost(&txtserv, &host)) 675 return; 676 677 hres = ITextServices_TxGetText(txtserv, &rettext); 678 ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); 679 SysFreeString(rettext); 680 681 ITextServices_Release(txtserv); 682 ITextHost_Release(host); 683 } 684 685 static void test_TxSetText(void) 686 { 687 ITextServices *txtserv; 688 ITextHost *host; 689 HRESULT hres; 690 BSTR rettext; 691 WCHAR settext[] = {'T','e','s','t',0}; 692 693 if (!init_texthost(&txtserv, &host)) 694 return; 695 696 hres = ITextServices_TxSetText(txtserv, settext); 697 ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres); 698 699 hres = ITextServices_TxGetText(txtserv, &rettext); 700 ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); 701 702 ok(SysStringLen(rettext) == 4, 703 "String returned of wrong length (expected 4, got %d)\n", SysStringLen(rettext)); 704 ok(memcmp(rettext,settext,SysStringByteLen(rettext)) == 0, 705 "String returned differs\n"); 706 707 SysFreeString(rettext); 708 709 /* Null-pointer should behave the same as empty-string */ 710 711 hres = ITextServices_TxSetText(txtserv, 0); 712 ok(hres == S_OK, "ITextServices_TxSetText failed (result = %x)\n", hres); 713 714 hres = ITextServices_TxGetText(txtserv, &rettext); 715 ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); 716 ok(SysStringLen(rettext) == 0, 717 "String returned of wrong length (expected 0, got %d)\n", SysStringLen(rettext)); 718 719 SysFreeString(rettext); 720 ITextServices_Release(txtserv); 721 ITextHost_Release(host); 722 } 723 724 #define CHECK_TXGETNATURALSIZE(res,width,height,hdc,rect,string) \ 725 _check_txgetnaturalsize(res, width, height, hdc, rect, string, __LINE__) 726 static void _check_txgetnaturalsize(HRESULT res, LONG width, LONG height, HDC hdc, RECT rect, LPCWSTR string, int line) 727 { 728 RECT expected_rect = rect; 729 LONG expected_width, expected_height; 730 731 DrawTextW(hdc, string, -1, &expected_rect, DT_LEFT | DT_CALCRECT | DT_NOCLIP | DT_EDITCONTROL | DT_WORDBREAK); 732 expected_width = expected_rect.right - expected_rect.left; 733 expected_height = expected_rect.bottom - expected_rect.top; 734 ok_(__FILE__,line)(res == S_OK, "ITextServices_TxGetNaturalSize failed: 0x%08x.\n", res); 735 ok_(__FILE__,line)(width >= expected_width && width <= expected_width + 1, 736 "got wrong width: %d, expected: %d {+1}.\n", width, expected_width); 737 ok_(__FILE__,line)(height == expected_height, "got wrong height: %d, expected: %d.\n", 738 height, expected_height); 739 } 740 741 static void test_TxGetNaturalSize(void) 742 { 743 ITextServices *txtserv; 744 ITextHost *host; 745 HRESULT result; 746 SIZEL extent; 747 static const WCHAR test_text[] = {'T','e','s','t','S','o','m','e','T','e','x','t',0}; 748 LONG width, height; 749 HDC hdcDraw; 750 HWND hwnd; 751 RECT rect; 752 CHARFORMAT2W cf; 753 LRESULT lresult; 754 HFONT hf; 755 756 if (!init_texthost(&txtserv, &host)) 757 return; 758 759 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE, 760 0, 0, 100, 100, 0, 0, 0, NULL); 761 hdcDraw = GetDC(hwnd); 762 SetMapMode(hdcDraw,MM_TEXT); 763 GetClientRect(hwnd, &rect); 764 765 memset(&cf, 0, sizeof(cf)); 766 cf.cbSize = sizeof(cf); 767 cf.dwMask = CFM_ALL2; 768 hf = GetStockObject(DEFAULT_GUI_FONT); 769 hf_to_cf(hf, &cf); 770 result = ITextServices_TxSendMessage(txtserv, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf, &lresult); 771 ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result); 772 SelectObject(hdcDraw, hf); 773 774 result = ITextServices_TxSetText(txtserv, test_text); 775 ok(result == S_OK, "ITextServices_TxSetText failed: 0x%08x.\n", result); 776 777 extent.cx = -1; extent.cy = -1; 778 width = rect.right - rect.left; 779 height = 0; 780 result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL, 781 TXTNS_FITTOCONTENT, &extent, &width, &height); 782 todo_wine CHECK_TXGETNATURALSIZE(result, width, height, hdcDraw, rect, test_text); 783 784 ReleaseDC(hwnd, hdcDraw); 785 DestroyWindow(hwnd); 786 ITextServices_Release(txtserv); 787 ITextHost_Release(host); 788 } 789 790 static void test_TxDraw(void) 791 { 792 ITextServices *txtserv; 793 ITextHost *host; 794 HDC tmphdc = GetDC(NULL); 795 DWORD dwAspect = DVASPECT_CONTENT; 796 HDC hicTargetDev = NULL; /* Means "default" device */ 797 DVTARGETDEVICE *ptd = NULL; 798 void *pvAspect = NULL; 799 HRESULT result; 800 RECTL client = {0,0,100,100}; 801 802 803 if (!init_texthost(&txtserv, &host)) 804 return; 805 806 todo_wine { 807 result = ITextServices_TxDraw(txtserv, dwAspect, 0, pvAspect, ptd, 808 tmphdc, hicTargetDev, &client, NULL, 809 NULL, NULL, 0, 0); 810 ok(result == S_OK, "TxDraw failed (result = %x)\n", result); 811 } 812 813 ITextServices_Release(txtserv); 814 ITextHost_Release(host); 815 } 816 817 DEFINE_GUID(expected_iid_itextservices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5); 818 DEFINE_GUID(expected_iid_itexthost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1); 819 DEFINE_GUID(expected_iid_itexthost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1); 820 821 static void test_IIDs(void) 822 { 823 ok(IsEqualIID(pIID_ITextServices, &expected_iid_itextservices), 824 "unexpected value for IID_ITextServices: %s\n", wine_dbgstr_guid(pIID_ITextServices)); 825 ok(IsEqualIID(pIID_ITextHost, &expected_iid_itexthost), 826 "unexpected value for IID_ITextHost: %s\n", wine_dbgstr_guid(pIID_ITextHost)); 827 ok(IsEqualIID(pIID_ITextHost2, &expected_iid_itexthost2), 828 "unexpected value for IID_ITextHost2: %s\n", wine_dbgstr_guid(pIID_ITextHost2)); 829 } 830 831 /* Outer IUnknown for COM aggregation tests */ 832 struct unk_impl { 833 IUnknown IUnknown_iface; 834 LONG ref; 835 IUnknown *inner_unk; 836 }; 837 838 static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface) 839 { 840 return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface); 841 } 842 843 static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) 844 { 845 struct unk_impl *This = impl_from_IUnknown(iface); 846 847 return IUnknown_QueryInterface(This->inner_unk, riid, ppv); 848 } 849 850 static ULONG WINAPI unk_AddRef(IUnknown *iface) 851 { 852 struct unk_impl *This = impl_from_IUnknown(iface); 853 854 return InterlockedIncrement(&This->ref); 855 } 856 857 static ULONG WINAPI unk_Release(IUnknown *iface) 858 { 859 struct unk_impl *This = impl_from_IUnknown(iface); 860 861 return InterlockedDecrement(&This->ref); 862 } 863 864 static const IUnknownVtbl unk_vtbl = 865 { 866 unk_QueryInterface, 867 unk_AddRef, 868 unk_Release 869 }; 870 871 static void test_COM(void) 872 { 873 struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL}; 874 struct ITextHostTestImpl texthost = {{&itextHostVtbl}, 1}; 875 ITextServices *textsrv; 876 ULONG refcount; 877 HRESULT hr; 878 879 /* COM aggregation */ 880 hr = pCreateTextServices(&unk_obj.IUnknown_iface, &texthost.ITextHost_iface, 881 &unk_obj.inner_unk); 882 ok(hr == S_OK, "CreateTextServices failed: %08x\n", hr); 883 hr = IUnknown_QueryInterface(unk_obj.inner_unk, pIID_ITextServices, (void**)&textsrv); 884 ok(hr == S_OK, "QueryInterface for IID_ITextServices failed: %08x\n", hr); 885 refcount = ITextServices_AddRef(textsrv); 886 ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM aggregation\n"); 887 refcount = ITextServices_Release(textsrv); 888 ok(refcount == unk_obj.ref, "CreateTextServices just pretends to support COM aggregation\n"); 889 refcount = ITextServices_Release(textsrv); 890 ok(refcount == 19, "Refcount should be back at 19 but is %u\n", refcount); 891 892 IUnknown_Release(unk_obj.inner_unk); 893 } 894 895 static ULONG get_refcount(IUnknown *iface) 896 { 897 IUnknown_AddRef(iface); 898 return IUnknown_Release(iface); 899 } 900 901 static void test_QueryInterface(void) 902 { 903 ITextServices *txtserv; 904 ITextHost *host; 905 HRESULT hres; 906 IRichEditOle *reole, *txtsrv_reole; 907 ITextDocument *txtdoc, *txtsrv_txtdoc; 908 ITextDocument2Old *txtdoc2old, *txtsrv_txtdoc2old; 909 ULONG refcount; 910 911 if(!init_texthost(&txtserv, &host)) 912 return; 913 914 refcount = get_refcount((IUnknown *)txtserv); 915 ok(refcount == 1, "got wrong ref count: %d\n", refcount); 916 917 /* IID_IRichEditOle */ 918 hres = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&txtsrv_reole); 919 ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres); 920 refcount = get_refcount((IUnknown *)txtserv); 921 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 922 refcount = get_refcount((IUnknown *)txtsrv_reole); 923 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 924 925 hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument, (void **)&txtdoc); 926 ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres); 927 refcount = get_refcount((IUnknown *)txtserv); 928 ok(refcount == 3, "got wrong ref count: %d\n", refcount); 929 refcount = get_refcount((IUnknown *)txtsrv_reole); 930 ok(refcount == 3, "got wrong ref count: %d\n", refcount); 931 932 ITextDocument_Release(txtdoc); 933 refcount = get_refcount((IUnknown *)txtserv); 934 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 935 936 hres = IRichEditOle_QueryInterface(txtsrv_reole, &IID_ITextDocument2Old, (void **)&txtdoc2old); 937 ok(hres == S_OK, "IRichEditOle_QueryInterface: 0x%08x\n", hres); 938 refcount = get_refcount((IUnknown *)txtserv); 939 ok(refcount == 3, "got wrong ref count: %d\n", refcount); 940 refcount = get_refcount((IUnknown *)txtsrv_reole); 941 ok(refcount == 3, "got wrong ref count: %d\n", refcount); 942 943 ITextDocument2Old_Release(txtdoc2old); 944 refcount = get_refcount((IUnknown *)txtserv); 945 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 946 IRichEditOle_Release(txtsrv_reole); 947 refcount = get_refcount((IUnknown *)txtserv); 948 ok(refcount == 1, "got wrong ref count: %d\n", refcount); 949 950 /* IID_ITextDocument */ 951 hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument, (void **)&txtsrv_txtdoc); 952 ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres); 953 refcount = get_refcount((IUnknown *)txtserv); 954 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 955 refcount = get_refcount((IUnknown *)txtsrv_txtdoc); 956 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 957 958 hres = ITextDocument_QueryInterface(txtsrv_txtdoc, &IID_IRichEditOle, (void **)&reole); 959 ok(hres == S_OK, "ITextDocument_QueryInterface: 0x%08x\n", hres); 960 refcount = get_refcount((IUnknown *)txtserv); 961 ok(refcount == 3, "got wrong ref count: %d\n", refcount); 962 refcount = get_refcount((IUnknown *)txtsrv_txtdoc); 963 ok(refcount == 3, "got wrong ref count: %d\n", refcount); 964 965 IRichEditOle_Release(reole); 966 refcount = get_refcount((IUnknown *)txtserv); 967 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 968 ITextDocument_Release(txtsrv_txtdoc); 969 refcount = get_refcount((IUnknown *)txtserv); 970 ok(refcount == 1, "got wrong ref count: %d\n", refcount); 971 972 /* ITextDocument2Old */ 973 hres = ITextServices_QueryInterface(txtserv, &IID_ITextDocument2Old, (void **)&txtsrv_txtdoc2old); 974 ok(hres == S_OK, "ITextServices_QueryInterface: 0x%08x\n", hres); 975 refcount = get_refcount((IUnknown *)txtserv); 976 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 977 refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old); 978 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 979 980 hres = ITextDocument2Old_QueryInterface(txtsrv_txtdoc2old, &IID_IRichEditOle, (void **)&reole); 981 ok(hres == S_OK, "ITextDocument2Old_QueryInterface: 0x%08x\n", hres); 982 refcount = get_refcount((IUnknown *)txtserv); 983 ok(refcount == 3, "got wrong ref count: %d\n", refcount); 984 refcount = get_refcount((IUnknown *)txtsrv_txtdoc2old); 985 ok(refcount == 3, "got wrong ref count: %d\n", refcount); 986 987 IRichEditOle_Release(reole); 988 refcount = get_refcount((IUnknown *)txtserv); 989 ok(refcount == 2, "got wrong ref count: %d\n", refcount); 990 ITextDocument2Old_Release(txtsrv_txtdoc2old); 991 refcount = get_refcount((IUnknown *)txtserv); 992 ok(refcount == 1, "got wrong ref count: %d\n", refcount); 993 994 ITextServices_Release(txtserv); 995 ITextHost_Release(host); 996 } 997 998 static void test_default_format(void) 999 { 1000 ITextServices *txtserv; 1001 ITextHost *host; 1002 HRESULT result; 1003 LRESULT lresult; 1004 CHARFORMAT2W cf2; 1005 const CHARFORMATW *host_cf; 1006 DWORD expected_effects; 1007 1008 if (!init_texthost(&txtserv, &host)) 1009 return; 1010 1011 cf2.cbSize = sizeof(CHARFORMAT2W); 1012 result = ITextServices_TxSendMessage(txtserv, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&cf2, &lresult); 1013 ok(result == S_OK, "ITextServices_TxSendMessage failed: 0x%08x.\n", result); 1014 1015 ITextHostImpl_TxGetCharFormat(host, &host_cf); 1016 ok(!lstrcmpW(host_cf->szFaceName, cf2.szFaceName), "got wrong font name: %s.\n", wine_dbgstr_w(cf2.szFaceName)); 1017 ok(cf2.yHeight == host_cf->yHeight, "got wrong yHeight: %d, expected %d.\n", cf2.yHeight, host_cf->yHeight); 1018 expected_effects = (cf2.dwEffects & ~(CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR)); 1019 ok(host_cf->dwEffects == expected_effects, "got wrong dwEffects: %x, expected %x.\n", cf2.dwEffects, expected_effects); 1020 ok(cf2.bPitchAndFamily == host_cf->bPitchAndFamily, "got wrong bPitchAndFamily: %x, expected %x.\n", 1021 cf2.bPitchAndFamily, host_cf->bPitchAndFamily); 1022 ok(cf2.bCharSet == host_cf->bCharSet, "got wrong bCharSet: %x, expected %x.\n", cf2.bCharSet, host_cf->bCharSet); 1023 1024 ITextServices_Release(txtserv); 1025 ITextHost_Release(host); 1026 } 1027 1028 static void test_TxGetScroll(void) 1029 { 1030 ITextServices *txtserv; 1031 ITextHost *host; 1032 HRESULT ret; 1033 1034 if (!init_texthost(&txtserv, &host)) 1035 return; 1036 1037 ret = ITextServices_TxGetHScroll(txtserv, NULL, NULL, NULL, NULL, NULL); 1038 ok(ret == S_OK, "ITextSerHices_GetVScroll failed: 0x%08x.\n", ret); 1039 1040 ret = ITextServices_TxGetVScroll(txtserv, NULL, NULL, NULL, NULL, NULL); 1041 ok(ret == S_OK, "ITextServices_GetVScroll failed: 0x%08x.\n", ret); 1042 1043 ITextServices_Release(txtserv); 1044 ITextHost_Release(host); 1045 } 1046 1047 START_TEST( txtsrv ) 1048 { 1049 ITextServices *txtserv; 1050 ITextHost *host; 1051 1052 setup_thiscall_wrappers(); 1053 1054 /* Must explicitly LoadLibrary(). The test has no references to functions in 1055 * RICHED20.DLL, so the linker doesn't actually link to it. */ 1056 hmoduleRichEdit = LoadLibraryA("riched20.dll"); 1057 ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError()); 1058 1059 pIID_ITextServices = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextServices"); 1060 pIID_ITextHost = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost"); 1061 pIID_ITextHost2 = (IID*)GetProcAddress(hmoduleRichEdit, "IID_ITextHost2"); 1062 pCreateTextServices = (void*)GetProcAddress(hmoduleRichEdit, "CreateTextServices"); 1063 1064 test_IIDs(); 1065 test_COM(); 1066 1067 if (init_texthost(&txtserv, &host)) 1068 { 1069 ITextServices_Release(txtserv); 1070 ITextHost_Release(host); 1071 1072 test_TxGetText(); 1073 test_TxSetText(); 1074 test_TxGetNaturalSize(); 1075 test_TxDraw(); 1076 test_QueryInterface(); 1077 test_default_format(); 1078 test_TxGetScroll(); 1079 } 1080 if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); 1081 } 1082