2 * Unit tests for ITfInputProcessor
4 * Copyright 2009 Aric Stewart, CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
33 static ITfInputProcessorProfiles* g_ipp;
34 static LANGID gLangid;
35 static ITfCategoryMgr * g_cm = NULL;
36 static ITfThreadMgr* g_tm = NULL;
37 static ITfDocumentMgr *g_dm = NULL;
38 static TfClientId cid = 0;
39 static TfClientId tid = 0;
41 static ITextStoreACPSink *ACPSink;
43 #define SINK_UNEXPECTED 0
44 #define SINK_EXPECTED 1
47 static BOOL test_ShouldActivate = FALSE;
48 static BOOL test_ShouldDeactivate = FALSE;
50 static DWORD tmSinkCookie;
51 static DWORD tmSinkRefCount;
52 static DWORD documentStatus;
53 static ITfDocumentMgr *test_CurrentFocus = NULL;
54 static ITfDocumentMgr *test_PrevFocus = NULL;
55 static INT test_OnSetFocus = SINK_UNEXPECTED;
56 static INT test_OnInitDocumentMgr = SINK_UNEXPECTED;
57 static INT test_OnPushContext = SINK_UNEXPECTED;
58 static INT test_OnPopContext = SINK_UNEXPECTED;
59 static INT test_KEV_OnSetFocus = SINK_UNEXPECTED;
60 static INT test_ACP_AdviseSink = SINK_UNEXPECTED;
61 static INT test_ACP_GetStatus = SINK_UNEXPECTED;
62 static INT test_ACP_RequestLock = SINK_UNEXPECTED;
63 static INT test_ACP_GetEndACP = SINK_UNEXPECTED;
64 static INT test_ACP_GetSelection = SINK_UNEXPECTED;
65 static INT test_DoEditSession = SINK_UNEXPECTED;
66 static INT test_ACP_InsertTextAtSelection = SINK_UNEXPECTED;
67 static INT test_ACP_SetSelection = SINK_UNEXPECTED;
68 static INT test_OnEndEdit = SINK_UNEXPECTED;
71 /**********************************************************************
73 **********************************************************************/
74 typedef struct tagTextStoreACP
76 const ITextStoreACPVtbl *TextStoreACPVtbl;
81 static void TextStoreACP_Destructor(TextStoreACP *This)
83 HeapFree(GetProcessHeap(),0,This);
86 static HRESULT WINAPI TextStoreACP_QueryInterface(ITextStoreACP *iface, REFIID iid, LPVOID *ppvOut)
88 TextStoreACP *This = (TextStoreACP *)iface;
91 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITextStoreACP))
98 IUnknown_AddRef(iface);
102 return E_NOINTERFACE;
105 static ULONG WINAPI TextStoreACP_AddRef(ITextStoreACP *iface)
107 TextStoreACP *This = (TextStoreACP *)iface;
108 return InterlockedIncrement(&This->refCount);
111 static ULONG WINAPI TextStoreACP_Release(ITextStoreACP *iface)
113 TextStoreACP *This = (TextStoreACP *)iface;
116 ret = InterlockedDecrement(&This->refCount);
118 TextStoreACP_Destructor(This);
122 static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface,
123 REFIID riid, IUnknown *punk, DWORD dwMask)
127 ok(test_ACP_AdviseSink == SINK_EXPECTED, "Unexpected TextStoreACP_AdviseSink sink\n");
128 test_ACP_AdviseSink = SINK_FIRED;
130 hr = IUnknown_QueryInterface(punk, &IID_ITextStoreACPSink,(LPVOID*)(&ACPSink));
131 ok(SUCCEEDED(hr),"Unable to QueryInterface on sink\n");
135 static HRESULT WINAPI TextStoreACP_UnadviseSink(ITextStoreACP *iface,
142 static HRESULT WINAPI TextStoreACP_RequestLock(ITextStoreACP *iface,
143 DWORD dwLockFlags, HRESULT *phrSession)
145 ok(test_ACP_RequestLock == SINK_EXPECTED,"Unexpected TextStoreACP_RequestLock\n");
146 test_ACP_RequestLock = SINK_FIRED;
147 *phrSession = ITextStoreACPSink_OnLockGranted(ACPSink, dwLockFlags);
150 static HRESULT WINAPI TextStoreACP_GetStatus(ITextStoreACP *iface,
153 ok(test_ACP_GetStatus == SINK_EXPECTED, "Unexpected TextStoreACP_GetStatus\n");
154 test_ACP_GetStatus = SINK_FIRED;
155 pdcs->dwDynamicFlags = documentStatus;
158 static HRESULT WINAPI TextStoreACP_QueryInsert(ITextStoreACP *iface,
159 LONG acpTestStart, LONG acpTestEnd, ULONG cch, LONG *pacpResultStart,
165 static HRESULT WINAPI TextStoreACP_GetSelection(ITextStoreACP *iface,
166 ULONG ulIndex, ULONG ulCount, TS_SELECTION_ACP *pSelection, ULONG *pcFetched)
168 ok(test_ACP_GetSelection == SINK_EXPECTED, "Unexpected TextStoreACP_GetSelection\n");
169 test_ACP_GetSelection = SINK_FIRED;
171 pSelection->acpStart = 10;
172 pSelection->acpEnd = 20;
173 pSelection->style.fInterimChar = 0;
174 pSelection->style.ase = TS_AE_NONE;
179 static HRESULT WINAPI TextStoreACP_SetSelection(ITextStoreACP *iface,
180 ULONG ulCount, const TS_SELECTION_ACP *pSelection)
182 ok(test_ACP_SetSelection == SINK_EXPECTED,"Unexpected TextStoreACP_SetSelection\n");
183 test_ACP_SetSelection = SINK_FIRED;
186 static HRESULT WINAPI TextStoreACP_GetText(ITextStoreACP *iface,
187 LONG acpStart, LONG acpEnd, WCHAR *pchPlain, ULONG cchPlainReq,
188 ULONG *pcchPlainRet, TS_RUNINFO *prgRunInfo, ULONG cRunInfoReq,
189 ULONG *pcRunInfoRet, LONG *pacpNext)
194 static HRESULT WINAPI TextStoreACP_SetText(ITextStoreACP *iface,
195 DWORD dwFlags, LONG acpStart, LONG acpEnd, const WCHAR *pchText,
196 ULONG cch, TS_TEXTCHANGE *pChange)
201 static HRESULT WINAPI TextStoreACP_GetFormattedText(ITextStoreACP *iface,
202 LONG acpStart, LONG acpEnd, IDataObject **ppDataObject)
207 static HRESULT WINAPI TextStoreACP_GetEmbedded(ITextStoreACP *iface,
208 LONG acpPos, REFGUID rguidService, REFIID riid, IUnknown **ppunk)
213 static HRESULT WINAPI TextStoreACP_QueryInsertEmbedded(ITextStoreACP *iface,
214 const GUID *pguidService, const FORMATETC *pFormatEtc, BOOL *pfInsertable)
219 static HRESULT WINAPI TextStoreACP_InsertEmbedded(ITextStoreACP *iface,
220 DWORD dwFlags, LONG acpStart, LONG acpEnd, IDataObject *pDataObject,
221 TS_TEXTCHANGE *pChange)
226 static HRESULT WINAPI TextStoreACP_InsertTextAtSelection(ITextStoreACP *iface,
227 DWORD dwFlags, const WCHAR *pchText, ULONG cch, LONG *pacpStart,
228 LONG *pacpEnd, TS_TEXTCHANGE *pChange)
230 ok(test_ACP_InsertTextAtSelection == SINK_EXPECTED,"Unexpected TextStoreACP_InsertTextAtSelection\n");
231 test_ACP_InsertTextAtSelection = SINK_FIRED;
234 static HRESULT WINAPI TextStoreACP_InsertEmbeddedAtSelection(ITextStoreACP *iface,
235 DWORD dwFlags, IDataObject *pDataObject, LONG *pacpStart, LONG *pacpEnd,
236 TS_TEXTCHANGE *pChange)
241 static HRESULT WINAPI TextStoreACP_RequestSupportedAttrs(ITextStoreACP *iface,
242 DWORD dwFlags, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs)
247 static HRESULT WINAPI TextStoreACP_RequestAttrsAtPosition(ITextStoreACP *iface,
248 LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs,
254 static HRESULT WINAPI TextStoreACP_RequestAttrsTransitioningAtPosition(ITextStoreACP *iface,
255 LONG acpPos, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs,
261 static HRESULT WINAPI TextStoreACP_FindNextAttrTransition(ITextStoreACP *iface,
262 LONG acpStart, LONG acpHalt, ULONG cFilterAttrs, const TS_ATTRID *paFilterAttrs,
263 DWORD dwFlags, LONG *pacpNext, BOOL *pfFound, LONG *plFoundOffset)
268 static HRESULT WINAPI TextStoreACP_RetrieveRequestedAttrs(ITextStoreACP *iface,
269 ULONG ulCount, TS_ATTRVAL *paAttrVals, ULONG *pcFetched)
274 static HRESULT WINAPI TextStoreACP_GetEndACP(ITextStoreACP *iface,
277 ok(test_ACP_GetEndACP == SINK_EXPECTED,"Unexpected TextStoreACP_GetEndACP\n");
278 test_ACP_GetEndACP = SINK_FIRED;
281 static HRESULT WINAPI TextStoreACP_GetActiveView(ITextStoreACP *iface,
282 TsViewCookie *pvcView)
287 static HRESULT WINAPI TextStoreACP_GetACPFromPoint(ITextStoreACP *iface,
288 TsViewCookie vcView, const POINT *ptScreen, DWORD dwFlags,
294 static HRESULT WINAPI TextStoreACP_GetTextExt(ITextStoreACP *iface,
295 TsViewCookie vcView, LONG acpStart, LONG acpEnd, RECT *prc,
301 static HRESULT WINAPI TextStoreACP_GetScreenExt(ITextStoreACP *iface,
302 TsViewCookie vcView, RECT *prc)
307 static HRESULT WINAPI TextStoreACP_GetWnd(ITextStoreACP *iface,
308 TsViewCookie vcView, HWND *phwnd)
314 static const ITextStoreACPVtbl TextStoreACP_TextStoreACPVtbl =
316 TextStoreACP_QueryInterface,
318 TextStoreACP_Release,
320 TextStoreACP_AdviseSink,
321 TextStoreACP_UnadviseSink,
322 TextStoreACP_RequestLock,
323 TextStoreACP_GetStatus,
324 TextStoreACP_QueryInsert,
325 TextStoreACP_GetSelection,
326 TextStoreACP_SetSelection,
327 TextStoreACP_GetText,
328 TextStoreACP_SetText,
329 TextStoreACP_GetFormattedText,
330 TextStoreACP_GetEmbedded,
331 TextStoreACP_QueryInsertEmbedded,
332 TextStoreACP_InsertEmbedded,
333 TextStoreACP_InsertTextAtSelection,
334 TextStoreACP_InsertEmbeddedAtSelection,
335 TextStoreACP_RequestSupportedAttrs,
336 TextStoreACP_RequestAttrsAtPosition,
337 TextStoreACP_RequestAttrsTransitioningAtPosition,
338 TextStoreACP_FindNextAttrTransition,
339 TextStoreACP_RetrieveRequestedAttrs,
340 TextStoreACP_GetEndACP,
341 TextStoreACP_GetActiveView,
342 TextStoreACP_GetACPFromPoint,
343 TextStoreACP_GetTextExt,
344 TextStoreACP_GetScreenExt,
348 static HRESULT TextStoreACP_Constructor(IUnknown **ppOut)
352 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TextStoreACP));
354 return E_OUTOFMEMORY;
356 This->TextStoreACPVtbl = &TextStoreACP_TextStoreACPVtbl;
359 *ppOut = (IUnknown *)This;
363 /**********************************************************************
364 * ITfThreadMgrEventSink
365 **********************************************************************/
366 typedef struct tagThreadMgrEventSink
368 const ITfThreadMgrEventSinkVtbl *ThreadMgrEventSinkVtbl;
370 } ThreadMgrEventSink;
372 static void ThreadMgrEventSink_Destructor(ThreadMgrEventSink *This)
374 HeapFree(GetProcessHeap(),0,This);
377 static HRESULT WINAPI ThreadMgrEventSink_QueryInterface(ITfThreadMgrEventSink *iface, REFIID iid, LPVOID *ppvOut)
379 ThreadMgrEventSink *This = (ThreadMgrEventSink *)iface;
382 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfThreadMgrEventSink))
389 IUnknown_AddRef(iface);
393 return E_NOINTERFACE;
396 static ULONG WINAPI ThreadMgrEventSink_AddRef(ITfThreadMgrEventSink *iface)
398 ThreadMgrEventSink *This = (ThreadMgrEventSink *)iface;
399 ok (tmSinkRefCount == This->refCount,"ThreadMgrEventSink refcount off %i vs %i\n",This->refCount,tmSinkRefCount);
400 return InterlockedIncrement(&This->refCount);
403 static ULONG WINAPI ThreadMgrEventSink_Release(ITfThreadMgrEventSink *iface)
405 ThreadMgrEventSink *This = (ThreadMgrEventSink *)iface;
408 ok (tmSinkRefCount == This->refCount,"ThreadMgrEventSink refcount off %i vs %i\n",This->refCount,tmSinkRefCount);
409 ret = InterlockedDecrement(&This->refCount);
411 ThreadMgrEventSink_Destructor(This);
415 static HRESULT WINAPI ThreadMgrEventSink_OnInitDocumentMgr(ITfThreadMgrEventSink *iface,
416 ITfDocumentMgr *pdim)
418 ok(test_OnInitDocumentMgr == SINK_EXPECTED, "Unexpected OnInitDocumentMgr sink\n");
419 test_OnInitDocumentMgr = SINK_FIRED;
423 static HRESULT WINAPI ThreadMgrEventSink_OnUninitDocumentMgr(ITfThreadMgrEventSink *iface,
424 ITfDocumentMgr *pdim)
430 static HRESULT WINAPI ThreadMgrEventSink_OnSetFocus(ITfThreadMgrEventSink *iface,
431 ITfDocumentMgr *pdimFocus, ITfDocumentMgr *pdimPrevFocus)
433 ok(test_OnSetFocus == SINK_EXPECTED, "Unexpected OnSetFocus sink\n");
434 ok(pdimFocus == test_CurrentFocus,"Sink reports wrong focus\n");
435 ok(pdimPrevFocus == test_PrevFocus,"Sink reports wrong previous focus\n");
436 test_OnSetFocus = SINK_FIRED;
440 static HRESULT WINAPI ThreadMgrEventSink_OnPushContext(ITfThreadMgrEventSink *iface,
444 ITfDocumentMgr *docmgr;
447 hr = ITfContext_GetDocumentMgr(pic,&docmgr);
448 ok(SUCCEEDED(hr),"GetDocumenMgr failed\n");
449 test = (ITfContext*)0xdeadbeef;
450 ITfDocumentMgr_Release(docmgr);
451 hr = ITfDocumentMgr_GetTop(docmgr,&test);
452 ok(SUCCEEDED(hr),"GetTop failed\n");
453 ok(test == pic, "Wrong context is on top\n");
455 ITfContext_Release(test);
457 ok(test_OnPushContext == SINK_EXPECTED, "Unexpected OnPushContext sink\n");
458 test_OnPushContext = SINK_FIRED;
462 static HRESULT WINAPI ThreadMgrEventSink_OnPopContext(ITfThreadMgrEventSink *iface,
466 ITfDocumentMgr *docmgr;
469 hr = ITfContext_GetDocumentMgr(pic,&docmgr);
470 ok(SUCCEEDED(hr),"GetDocumenMgr failed\n");
471 ITfDocumentMgr_Release(docmgr);
472 test = (ITfContext*)0xdeadbeef;
473 hr = ITfDocumentMgr_GetTop(docmgr,&test);
474 ok(SUCCEEDED(hr),"GetTop failed\n");
475 ok(test == pic, "Wrong context is on top\n");
477 ITfContext_Release(test);
479 ok(test_OnPopContext == SINK_EXPECTED, "Unexpected OnPopContext sink\n");
480 test_OnPopContext = SINK_FIRED;
484 static const ITfThreadMgrEventSinkVtbl ThreadMgrEventSink_ThreadMgrEventSinkVtbl =
486 ThreadMgrEventSink_QueryInterface,
487 ThreadMgrEventSink_AddRef,
488 ThreadMgrEventSink_Release,
490 ThreadMgrEventSink_OnInitDocumentMgr,
491 ThreadMgrEventSink_OnUninitDocumentMgr,
492 ThreadMgrEventSink_OnSetFocus,
493 ThreadMgrEventSink_OnPushContext,
494 ThreadMgrEventSink_OnPopContext
497 static HRESULT ThreadMgrEventSink_Constructor(IUnknown **ppOut)
499 ThreadMgrEventSink *This;
501 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ThreadMgrEventSink));
503 return E_OUTOFMEMORY;
505 This->ThreadMgrEventSinkVtbl = &ThreadMgrEventSink_ThreadMgrEventSinkVtbl;
508 *ppOut = (IUnknown *)This;
513 /********************************************************************************************
514 * Stub text service for testing
515 ********************************************************************************************/
517 static LONG TS_refCount;
518 static IClassFactory *cf;
521 typedef HRESULT (*LPFNCONSTRUCTOR)(IUnknown *pUnkOuter, IUnknown **ppvOut);
523 typedef struct tagClassFactory
525 const IClassFactoryVtbl *vtbl;
527 LPFNCONSTRUCTOR ctor;
530 typedef struct tagTextService
532 const ITfTextInputProcessorVtbl *TextInputProcessorVtbl;
536 static void ClassFactory_Destructor(ClassFactory *This)
538 HeapFree(GetProcessHeap(),0,This);
542 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppvOut)
545 if (IsEqualIID(riid, &IID_IClassFactory) || IsEqualIID(riid, &IID_IUnknown))
547 IClassFactory_AddRef(iface);
552 return E_NOINTERFACE;
555 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
557 ClassFactory *This = (ClassFactory *)iface;
558 return InterlockedIncrement(&This->ref);
561 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
563 ClassFactory *This = (ClassFactory *)iface;
564 ULONG ret = InterlockedDecrement(&This->ref);
567 ClassFactory_Destructor(This);
571 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *punkOuter, REFIID iid, LPVOID *ppvOut)
573 ClassFactory *This = (ClassFactory *)iface;
577 ret = This->ctor(punkOuter, &obj);
580 ret = IUnknown_QueryInterface(obj, iid, ppvOut);
581 IUnknown_Release(obj);
585 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
588 InterlockedIncrement(&TS_refCount);
590 InterlockedDecrement(&TS_refCount);
595 static const IClassFactoryVtbl ClassFactoryVtbl = {
597 ClassFactory_QueryInterface,
599 ClassFactory_Release,
602 ClassFactory_CreateInstance,
603 ClassFactory_LockServer
606 static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
608 ClassFactory *This = HeapAlloc(GetProcessHeap(),0,sizeof(ClassFactory));
609 This->vtbl = &ClassFactoryVtbl;
612 *ppvOut = (LPVOID)This;
617 static void TextService_Destructor(TextService *This)
619 HeapFree(GetProcessHeap(),0,This);
622 static HRESULT WINAPI TextService_QueryInterface(ITfTextInputProcessor *iface, REFIID iid, LPVOID *ppvOut)
624 TextService *This = (TextService *)iface;
627 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfTextInputProcessor))
634 IUnknown_AddRef(iface);
638 return E_NOINTERFACE;
641 static ULONG WINAPI TextService_AddRef(ITfTextInputProcessor *iface)
643 TextService *This = (TextService *)iface;
644 return InterlockedIncrement(&This->refCount);
647 static ULONG WINAPI TextService_Release(ITfTextInputProcessor *iface)
649 TextService *This = (TextService *)iface;
652 ret = InterlockedDecrement(&This->refCount);
654 TextService_Destructor(This);
658 static HRESULT WINAPI TextService_Activate(ITfTextInputProcessor *iface,
659 ITfThreadMgr *ptim, TfClientId id)
661 trace("TextService_Activate\n");
662 ok(test_ShouldActivate,"Activation came unexpectedly\n");
667 static HRESULT WINAPI TextService_Deactivate(ITfTextInputProcessor *iface)
669 trace("TextService_Deactivate\n");
670 ok(test_ShouldDeactivate,"Deactivation came unexpectedly\n");
674 static const ITfTextInputProcessorVtbl TextService_TextInputProcessorVtbl=
676 TextService_QueryInterface,
680 TextService_Activate,
681 TextService_Deactivate
684 static HRESULT TextService_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
688 return CLASS_E_NOAGGREGATION;
690 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TextService));
692 return E_OUTOFMEMORY;
694 This->TextInputProcessorVtbl= &TextService_TextInputProcessorVtbl;
697 *ppOut = (IUnknown *)This;
701 static HRESULT RegisterTextService(REFCLSID rclsid)
703 ClassFactory_Constructor( TextService_Constructor ,(LPVOID*)&cf);
704 return CoRegisterClassObject(rclsid, (IUnknown*) cf, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
707 static HRESULT UnregisterTextService()
709 return CoRevokeClassObject(regid);
716 DEFINE_GUID(CLSID_FakeService, 0xEDE1A7AD,0x66DE,0x47E0,0xB6,0x20,0x3E,0x92,0xF8,0x24,0x6B,0xF3);
717 DEFINE_GUID(CLSID_TF_InputProcessorProfiles, 0x33c53a50,0xf456,0x4884,0xb0,0x49,0x85,0xfd,0x64,0x3e,0xcf,0xed);
718 DEFINE_GUID(CLSID_TF_CategoryMgr, 0xA4B544A1,0x438D,0x4B41,0x93,0x25,0x86,0x95,0x23,0xE2,0xD6,0xC7);
719 DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD, 0x34745c63,0xb2f0,0x4784,0x8b,0x67,0x5e,0x12,0xc8,0x70,0x1a,0x31);
720 DEFINE_GUID(GUID_TFCAT_TIP_SPEECH, 0xB5A73CD1,0x8355,0x426B,0xA1,0x61,0x25,0x98,0x08,0xF2,0x6B,0x14);
721 DEFINE_GUID(GUID_TFCAT_TIP_HANDWRITING, 0x246ecb87,0xc2f2,0x4abe,0x90,0x5b,0xc8,0xb3,0x8a,0xdd,0x2c,0x43);
722 DEFINE_GUID (GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER, 0x046B8C80,0x1647,0x40F7,0x9B,0x21,0xB9,0x3B,0x81,0xAA,0xBC,0x1B);
723 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
724 DEFINE_GUID(CLSID_TF_ThreadMgr, 0x529a9e6b,0x6587,0x4f23,0xab,0x9e,0x9c,0x7d,0x68,0x3e,0x3c,0x50);
725 DEFINE_GUID(CLSID_PreservedKey, 0xA0ED8E55,0xCD3B,0x4274,0xB2,0x95,0xF6,0xC9,0xBA,0x2B,0x84,0x72);
726 DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_DISABLED, 0x71a5b253,0x1951,0x466b,0x9f,0xbc,0x9c,0x88,0x08,0xfa,0x84,0xf2);
727 DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE, 0x58273aad,0x01bb,0x4164,0x95,0xc6,0x75,0x5b,0xa0,0xb5,0x16,0x2d);
728 DEFINE_GUID(GUID_COMPARTMENT_HANDWRITING_OPENCLOSE, 0xf9ae2c6b,0x1866,0x4361,0xaf,0x72,0x7a,0xa3,0x09,0x48,0x89,0x0e);
729 DEFINE_GUID(GUID_COMPARTMENT_SPEECH_DISABLED, 0x56c5c607,0x0703,0x4e59,0x8e,0x52,0xcb,0xc8,0x4e,0x8b,0xbe,0x35);
730 DEFINE_GUID(GUID_COMPARTMENT_SPEECH_OPENCLOSE, 0x544d6a63,0xe2e8,0x4752,0xbb,0xd1,0x00,0x09,0x60,0xbc,0xa0,0x83);
731 DEFINE_GUID(GUID_COMPARTMENT_SPEECH_GLOBALSTATE, 0x2a54fe8e,0x0d08,0x460c,0xa7,0x5d,0x87,0x03,0x5f,0xf4,0x36,0xc5);
732 DEFINE_GUID(GUID_COMPARTMENT_PERSISTMENUENABLED, 0x575f3783,0x70c8,0x47c8,0xae,0x5d,0x91,0xa0,0x1a,0x1f,0x75,0x92);
733 DEFINE_GUID(GUID_COMPARTMENT_EMPTYCONTEXT, 0xd7487dbf,0x804e,0x41c5,0x89,0x4d,0xad,0x96,0xfd,0x4e,0xea,0x13);
734 DEFINE_GUID(GUID_COMPARTMENT_TIPUISTATUS, 0x148ca3ec,0x0366,0x401c,0x8d,0x75,0xed,0x97,0x8d,0x85,0xfb,0xc9);
736 static HRESULT initialize(void)
740 hr = CoCreateInstance (&CLSID_TF_InputProcessorProfiles, NULL,
741 CLSCTX_INPROC_SERVER, &IID_ITfInputProcessorProfiles, (void**)&g_ipp);
743 hr = CoCreateInstance (&CLSID_TF_CategoryMgr, NULL,
744 CLSCTX_INPROC_SERVER, &IID_ITfCategoryMgr, (void**)&g_cm);
746 hr = CoCreateInstance (&CLSID_TF_ThreadMgr, NULL,
747 CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (void**)&g_tm);
751 static void cleanup(void)
754 ITfInputProcessorProfiles_Release(g_ipp);
756 ITfCategoryMgr_Release(g_cm);
758 ITfThreadMgr_Release(g_tm);
762 static void test_Register(void)
766 static const WCHAR szDesc[] = {'F','a','k','e',' ','W','i','n','e',' ','S','e','r','v','i','c','e',0};
767 static const WCHAR szFile[] = {'F','a','k','e',' ','W','i','n','e',' ','S','e','r','v','i','c','e',' ','F','i','l','e',0};
769 hr = ITfInputProcessorProfiles_GetCurrentLanguage(g_ipp,&gLangid);
770 ok(SUCCEEDED(hr),"Unable to get current language id\n");
771 trace("Current Language %x\n",gLangid);
773 hr = RegisterTextService(&CLSID_FakeService);
774 ok(SUCCEEDED(hr),"Unable to register COM for TextService\n");
775 hr = ITfInputProcessorProfiles_Register(g_ipp, &CLSID_FakeService);
776 ok(SUCCEEDED(hr),"Unable to register text service(%x)\n",hr);
777 hr = ITfInputProcessorProfiles_AddLanguageProfile(g_ipp, &CLSID_FakeService, gLangid, &CLSID_FakeService, szDesc, sizeof(szDesc)/sizeof(WCHAR), szFile, sizeof(szFile)/sizeof(WCHAR), 1);
778 ok(SUCCEEDED(hr),"Unable to add Language Profile (%x)\n",hr);
781 static void test_Unregister(void)
784 hr = ITfInputProcessorProfiles_Unregister(g_ipp, &CLSID_FakeService);
785 ok(SUCCEEDED(hr),"Unable to unregister text service(%x)\n",hr);
786 UnregisterTextService();
789 static void test_EnumInputProcessorInfo(void)
794 if (SUCCEEDED(ITfInputProcessorProfiles_EnumInputProcessorInfo(g_ipp, &ppEnum)))
798 while (IEnumGUID_Next(ppEnum, 1, &g, &fetched) == S_OK)
800 if(IsEqualGUID(&g,&CLSID_FakeService))
804 ok(found,"Did not find registered text service\n");
807 static void test_EnumLanguageProfiles(void)
810 IEnumTfLanguageProfiles *ppEnum;
811 if (SUCCEEDED(ITfInputProcessorProfiles_EnumLanguageProfiles(g_ipp,gLangid,&ppEnum)))
813 TF_LANGUAGEPROFILE profile;
814 while (IEnumTfLanguageProfiles_Next(ppEnum,1,&profile,NULL)==S_OK)
816 if (IsEqualGUID(&profile.clsid,&CLSID_FakeService))
819 ok(profile.langid == gLangid, "LangId Incorrect\n");
820 ok(IsEqualGUID(&profile.catid,&GUID_TFCAT_TIP_KEYBOARD), "CatId Incorrect\n");
821 ok(IsEqualGUID(&profile.guidProfile,&CLSID_FakeService), "guidProfile Incorrect\n");
825 ok(found,"Registered text service not found\n");
828 static void test_RegisterCategory(void)
831 hr = ITfCategoryMgr_RegisterCategory(g_cm, &CLSID_FakeService, &GUID_TFCAT_TIP_KEYBOARD, &CLSID_FakeService);
832 ok(SUCCEEDED(hr),"ITfCategoryMgr_RegisterCategory failed\n");
833 hr = ITfCategoryMgr_RegisterCategory(g_cm, &CLSID_FakeService, &GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER, &CLSID_FakeService);
834 ok(SUCCEEDED(hr),"ITfCategoryMgr_RegisterCategory failed\n");
837 static void test_UnregisterCategory(void)
840 hr = ITfCategoryMgr_UnregisterCategory(g_cm, &CLSID_FakeService, &GUID_TFCAT_TIP_KEYBOARD, &CLSID_FakeService);
841 ok(SUCCEEDED(hr),"ITfCategoryMgr_UnregisterCategory failed\n");
842 hr = ITfCategoryMgr_UnregisterCategory(g_cm, &CLSID_FakeService, &GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER, &CLSID_FakeService);
843 ok(SUCCEEDED(hr),"ITfCategoryMgr_UnregisterCategory failed\n");
846 static void test_FindClosestCategory(void)
850 const GUID *list[3] = {&GUID_TFCAT_TIP_SPEECH, &GUID_TFCAT_TIP_KEYBOARD, &GUID_TFCAT_TIP_HANDWRITING};
852 hr = ITfCategoryMgr_FindClosestCategory(g_cm, &CLSID_FakeService, &output, NULL, 0);
853 ok(SUCCEEDED(hr),"ITfCategoryMgr_FindClosestCategory failed (%x)\n",hr);
854 ok(IsEqualGUID(&output,&GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER),"Wrong GUID\n");
856 hr = ITfCategoryMgr_FindClosestCategory(g_cm, &CLSID_FakeService, &output, list, 1);
857 ok(SUCCEEDED(hr),"ITfCategoryMgr_FindClosestCategory failed (%x)\n",hr);
858 ok(IsEqualGUID(&output,&GUID_NULL),"Wrong GUID\n");
860 hr = ITfCategoryMgr_FindClosestCategory(g_cm, &CLSID_FakeService, &output, list, 3);
861 ok(SUCCEEDED(hr),"ITfCategoryMgr_FindClosestCategory failed (%x)\n",hr);
862 ok(IsEqualGUID(&output,&GUID_TFCAT_TIP_KEYBOARD),"Wrong GUID\n");
865 static void test_Enable(void)
868 BOOL enabled = FALSE;
870 hr = ITfInputProcessorProfiles_EnableLanguageProfile(g_ipp,&CLSID_FakeService, gLangid, &CLSID_FakeService, TRUE);
871 ok(SUCCEEDED(hr),"Failed to enable text service\n");
872 hr = ITfInputProcessorProfiles_IsEnabledLanguageProfile(g_ipp,&CLSID_FakeService, gLangid, &CLSID_FakeService, &enabled);
873 ok(SUCCEEDED(hr),"Failed to get enabled state\n");
874 ok(enabled == TRUE,"enabled state incorrect\n");
877 static void test_Disable(void)
881 trace("Disabling\n");
882 hr = ITfInputProcessorProfiles_EnableLanguageProfile(g_ipp,&CLSID_FakeService, gLangid, &CLSID_FakeService, FALSE);
883 ok(SUCCEEDED(hr),"Failed to disable text service\n");
886 static void test_ThreadMgrAdviseSinks(void)
888 ITfSource *source = NULL;
892 hr = ITfThreadMgr_QueryInterface(g_tm, &IID_ITfSource, (LPVOID*)&source);
893 ok(SUCCEEDED(hr),"Failed to get IID_ITfSource for ThreadMgr\n");
897 hr = ThreadMgrEventSink_Constructor(&sink);
898 ok(hr == S_OK, "got %08x\n", hr);
899 if(FAILED(hr)) return;
903 hr = ITfSource_AdviseSink(source,&IID_ITfThreadMgrEventSink, sink, &tmSinkCookie);
904 ok(SUCCEEDED(hr),"Failed to Advise Sink\n");
905 ok(tmSinkCookie!=0,"Failed to get sink cookie\n");
907 /* Advising the sink adds a ref, Relesing here lets the object be deleted
910 IUnknown_Release(sink);
911 ITfSource_Release(source);
914 static void test_ThreadMgrUnadviseSinks(void)
916 ITfSource *source = NULL;
919 hr = ITfThreadMgr_QueryInterface(g_tm, &IID_ITfSource, (LPVOID*)&source);
920 ok(SUCCEEDED(hr),"Failed to get IID_ITfSource for ThreadMgr\n");
925 hr = ITfSource_UnadviseSink(source, tmSinkCookie);
926 ok(SUCCEEDED(hr),"Failed to unadvise Sink\n");
927 ITfSource_Release(source);
930 /**********************************************************************
932 **********************************************************************/
933 typedef struct tagKeyEventSink
935 const ITfKeyEventSinkVtbl *KeyEventSinkVtbl;
939 static void KeyEventSink_Destructor(KeyEventSink *This)
941 HeapFree(GetProcessHeap(),0,This);
944 static HRESULT WINAPI KeyEventSink_QueryInterface(ITfKeyEventSink *iface, REFIID iid, LPVOID *ppvOut)
946 KeyEventSink *This = (KeyEventSink *)iface;
949 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfKeyEventSink))
956 IUnknown_AddRef(iface);
960 return E_NOINTERFACE;
963 static ULONG WINAPI KeyEventSink_AddRef(ITfKeyEventSink *iface)
965 KeyEventSink *This = (KeyEventSink *)iface;
966 return InterlockedIncrement(&This->refCount);
969 static ULONG WINAPI KeyEventSink_Release(ITfKeyEventSink *iface)
971 KeyEventSink *This = (KeyEventSink *)iface;
974 ret = InterlockedDecrement(&This->refCount);
976 KeyEventSink_Destructor(This);
980 static HRESULT WINAPI KeyEventSink_OnSetFocus(ITfKeyEventSink *iface,
983 ok(test_KEV_OnSetFocus == SINK_EXPECTED,"Unexpected KeyEventSink_OnSetFocus\n");
984 test_KEV_OnSetFocus = SINK_FIRED;
988 static HRESULT WINAPI KeyEventSink_OnTestKeyDown(ITfKeyEventSink *iface,
989 ITfContext *pic, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
995 static HRESULT WINAPI KeyEventSink_OnTestKeyUp(ITfKeyEventSink *iface,
996 ITfContext *pic, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
1002 static HRESULT WINAPI KeyEventSink_OnKeyDown(ITfKeyEventSink *iface,
1003 ITfContext *pic, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
1009 static HRESULT WINAPI KeyEventSink_OnKeyUp(ITfKeyEventSink *iface,
1010 ITfContext *pic, WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
1016 static HRESULT WINAPI KeyEventSink_OnPreservedKey(ITfKeyEventSink *iface,
1017 ITfContext *pic, REFGUID rguid, BOOL *pfEaten)
1023 static const ITfKeyEventSinkVtbl KeyEventSink_KeyEventSinkVtbl =
1025 KeyEventSink_QueryInterface,
1026 KeyEventSink_AddRef,
1027 KeyEventSink_Release,
1029 KeyEventSink_OnSetFocus,
1030 KeyEventSink_OnTestKeyDown,
1031 KeyEventSink_OnTestKeyUp,
1032 KeyEventSink_OnKeyDown,
1033 KeyEventSink_OnKeyUp,
1034 KeyEventSink_OnPreservedKey
1037 static HRESULT KeyEventSink_Constructor(ITfKeyEventSink **ppOut)
1041 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(KeyEventSink));
1043 return E_OUTOFMEMORY;
1045 This->KeyEventSinkVtbl = &KeyEventSink_KeyEventSinkVtbl;
1048 *ppOut = (ITfKeyEventSink*)This;
1053 static void test_KeystrokeMgr(void)
1055 ITfKeystrokeMgr *keymgr= NULL;
1057 TF_PRESERVEDKEY tfpk;
1059 ITfKeyEventSink *sink = NULL;
1061 KeyEventSink_Constructor(&sink);
1063 hr = ITfThreadMgr_QueryInterface(g_tm, &IID_ITfKeystrokeMgr, (LPVOID*)&keymgr);
1064 ok(SUCCEEDED(hr),"Failed to get IID_ITfKeystrokeMgr for ThreadMgr\n");
1067 tfpk.uModifiers = TF_MOD_SHIFT;
1069 test_KEV_OnSetFocus = SINK_EXPECTED;
1070 hr = ITfKeystrokeMgr_AdviseKeyEventSink(keymgr,tid,sink,TRUE);
1071 ok(SUCCEEDED(hr),"ITfKeystrokeMgr_AdviseKeyEventSink failed\n");
1072 ok(test_KEV_OnSetFocus == SINK_FIRED, "KeyEventSink_OnSetFocus not fired as expected\n");
1073 hr = ITfKeystrokeMgr_AdviseKeyEventSink(keymgr,tid,sink,TRUE);
1074 ok(hr == CONNECT_E_ADVISELIMIT,"Wrong return, expected CONNECT_E_ADVISELIMIT\n");
1075 hr = ITfKeystrokeMgr_AdviseKeyEventSink(keymgr,cid,sink,TRUE);
1076 ok(hr == E_INVALIDARG,"Wrong return, expected E_INVALIDARG\n");
1078 hr =ITfKeystrokeMgr_PreserveKey(keymgr, 0, &CLSID_PreservedKey, &tfpk, NULL, 0);
1079 ok(hr==E_INVALIDARG,"ITfKeystrokeMgr_PreserveKey inproperly succeeded\n");
1081 hr =ITfKeystrokeMgr_PreserveKey(keymgr, tid, &CLSID_PreservedKey, &tfpk, NULL, 0);
1082 ok(SUCCEEDED(hr),"ITfKeystrokeMgr_PreserveKey failed\n");
1084 hr =ITfKeystrokeMgr_PreserveKey(keymgr, tid, &CLSID_PreservedKey, &tfpk, NULL, 0);
1085 ok(hr == TF_E_ALREADY_EXISTS,"ITfKeystrokeMgr_PreserveKey inproperly succeeded\n");
1088 hr = ITfKeystrokeMgr_IsPreservedKey(keymgr, &CLSID_PreservedKey, &tfpk, &preserved);
1089 ok(hr == S_OK, "ITfKeystrokeMgr_IsPreservedKey failed\n");
1090 if (hr == S_OK) ok(preserved == TRUE,"misreporting preserved key\n");
1092 hr = ITfKeystrokeMgr_UnpreserveKey(keymgr, &CLSID_PreservedKey,&tfpk);
1093 ok(SUCCEEDED(hr),"ITfKeystrokeMgr_UnpreserveKey failed\n");
1095 hr = ITfKeystrokeMgr_IsPreservedKey(keymgr, &CLSID_PreservedKey, &tfpk, &preserved);
1096 ok(hr == S_FALSE, "ITfKeystrokeMgr_IsPreservedKey failed\n");
1097 if (hr == S_FALSE) ok(preserved == FALSE,"misreporting preserved key\n");
1099 hr = ITfKeystrokeMgr_UnpreserveKey(keymgr, &CLSID_PreservedKey,&tfpk);
1100 ok(hr==CONNECT_E_NOCONNECTION,"ITfKeystrokeMgr_UnpreserveKey inproperly succeeded\n");
1102 hr = ITfKeystrokeMgr_UnadviseKeyEventSink(keymgr,tid);
1103 ok(SUCCEEDED(hr),"ITfKeystrokeMgr_UnadviseKeyEventSink failed\n");
1105 ITfKeystrokeMgr_Release(keymgr);
1106 ITfKeyEventSink_Release(sink);
1109 static void test_Activate(void)
1113 hr = ITfInputProcessorProfiles_ActivateLanguageProfile(g_ipp,&CLSID_FakeService,gLangid,&CLSID_FakeService);
1114 ok(SUCCEEDED(hr),"Failed to Activate text service\n");
1118 static void test_EnumContexts(ITfDocumentMgr *dm, ITfContext *search)
1121 IEnumTfContexts* pEnum;
1124 hr = ITfDocumentMgr_EnumContexts(dm,&pEnum);
1125 ok(SUCCEEDED(hr),"EnumContexts failed\n");
1130 while (IEnumTfContexts_Next(pEnum, 1, &cxt, &fetched) == S_OK)
1134 else if (search == cxt)
1136 ITfContext_Release(cxt);
1138 IEnumTfContexts_Release(pEnum);
1141 ok(found,"Did not find proper ITfContext\n");
1143 ok(!found,"Found an ITfContext we should should not have\n");
1146 static void test_EnumDocumentMgr(ITfThreadMgr *tm, ITfDocumentMgr *search, ITfDocumentMgr *absent)
1149 IEnumTfDocumentMgrs* pEnum;
1151 BOOL notfound = TRUE;
1153 hr = ITfThreadMgr_EnumDocumentMgrs(tm,&pEnum);
1154 ok(SUCCEEDED(hr),"EnumDocumentMgrs failed\n");
1159 while (IEnumTfDocumentMgrs_Next(pEnum, 1, &dm, &fetched) == S_OK)
1163 else if (search == dm)
1165 if (absent && dm == absent)
1167 ITfDocumentMgr_Release(dm);
1169 IEnumTfDocumentMgrs_Release(pEnum);
1172 ok(found,"Did not find proper ITfDocumentMgr\n");
1174 ok(!found,"Found an ITfDocumentMgr we should should not have\n");
1176 ok(notfound,"Found an ITfDocumentMgr we believe should be absent\n");
1179 static inline int check_context_refcount(ITfContext *iface)
1181 IUnknown_AddRef(iface);
1182 return IUnknown_Release(iface);
1186 /**********************************************************************
1188 **********************************************************************/
1189 typedef struct tagTextEditSink
1191 const ITfTextEditSinkVtbl *TextEditSinkVtbl;
1195 static void TextEditSink_Destructor(TextEditSink *This)
1197 HeapFree(GetProcessHeap(),0,This);
1200 static HRESULT WINAPI TextEditSink_QueryInterface(ITfTextEditSink *iface, REFIID iid, LPVOID *ppvOut)
1202 TextEditSink *This = (TextEditSink *)iface;
1205 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfTextEditSink))
1212 IUnknown_AddRef(iface);
1216 return E_NOINTERFACE;
1219 static ULONG WINAPI TextEditSink_AddRef(ITfTextEditSink *iface)
1221 TextEditSink *This = (TextEditSink *)iface;
1222 return InterlockedIncrement(&This->refCount);
1225 static ULONG WINAPI TextEditSink_Release(ITfTextEditSink *iface)
1227 TextEditSink *This = (TextEditSink *)iface;
1230 ret = InterlockedDecrement(&This->refCount);
1232 TextEditSink_Destructor(This);
1236 static HRESULT WINAPI TextEditSink_OnEndEdit(ITfTextEditSink *iface,
1237 ITfContext *pic, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord)
1239 ok(test_OnEndEdit == SINK_EXPECTED, "Unexpected OnEndEdit\n");
1240 test_OnEndEdit = SINK_FIRED;
1244 static const ITfTextEditSinkVtbl TextEditSink_TextEditSinkVtbl =
1246 TextEditSink_QueryInterface,
1247 TextEditSink_AddRef,
1248 TextEditSink_Release,
1250 TextEditSink_OnEndEdit
1253 static HRESULT TextEditSink_Constructor(ITfTextEditSink **ppOut)
1258 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TextEditSink));
1260 return E_OUTOFMEMORY;
1262 This->TextEditSinkVtbl = &TextEditSink_TextEditSinkVtbl;
1265 *ppOut = (ITfTextEditSink*)This;
1269 static void test_startSession(void)
1274 ITfDocumentMgr *dmtest;
1275 ITfContext *cxt,*cxt2,*cxt3,*cxtTest;
1277 TfClientId cid2 = 0;
1279 hr = ITfThreadMgr_Deactivate(g_tm);
1280 ok(hr == E_UNEXPECTED,"Deactivate should have failed with E_UNEXPECTED\n");
1282 test_ShouldActivate = TRUE;
1283 hr = ITfThreadMgr_Activate(g_tm,&cid);
1284 ok(SUCCEEDED(hr),"Failed to Activate\n");
1285 ok(cid != tid,"TextService id mistakenly matches Client id\n");
1287 test_ShouldActivate = FALSE;
1288 hr = ITfThreadMgr_Activate(g_tm,&cid2);
1289 ok(SUCCEEDED(hr),"Failed to Activate\n");
1290 ok (cid == cid2, "Second activate client ID does not match\n");
1292 hr = ITfThreadMgr_Deactivate(g_tm);
1293 ok(SUCCEEDED(hr),"Failed to Deactivate\n");
1295 test_EnumDocumentMgr(g_tm,NULL,NULL);
1297 hr = ITfThreadMgr_CreateDocumentMgr(g_tm,&g_dm);
1298 ok(SUCCEEDED(hr),"CreateDocumentMgr failed\n");
1300 test_EnumDocumentMgr(g_tm,g_dm,NULL);
1302 hr = ITfThreadMgr_CreateDocumentMgr(g_tm,&dmtest);
1303 ok(SUCCEEDED(hr),"CreateDocumentMgr failed\n");
1305 test_EnumDocumentMgr(g_tm,dmtest,NULL);
1307 ITfDocumentMgr_Release(dmtest);
1308 test_EnumDocumentMgr(g_tm,g_dm,dmtest);
1310 hr = ITfThreadMgr_GetFocus(g_tm,&dmtest);
1311 ok(SUCCEEDED(hr),"GetFocus Failed\n");
1312 ok(dmtest == NULL,"Initial focus not null\n");
1314 test_CurrentFocus = g_dm;
1315 test_PrevFocus = NULL;
1316 test_OnSetFocus = SINK_EXPECTED;
1317 hr = ITfThreadMgr_SetFocus(g_tm,g_dm);
1318 ok(SUCCEEDED(hr),"SetFocus Failed\n");
1319 ok(test_OnSetFocus == SINK_FIRED, "OnSetFocus sink not called\n");
1320 test_OnSetFocus = SINK_UNEXPECTED;
1322 hr = ITfThreadMgr_GetFocus(g_tm,&dmtest);
1323 ok(SUCCEEDED(hr),"GetFocus Failed\n");
1324 ok(g_dm == dmtest,"Expected DocumentMgr not focused\n");
1326 cnt = ITfDocumentMgr_Release(g_dm);
1327 ok(cnt == 2,"DocumentMgr refcount not expected (2 vs %i)\n",cnt);
1329 hr = ITfThreadMgr_GetFocus(g_tm,&dmtest);
1330 ok(SUCCEEDED(hr),"GetFocus Failed\n");
1331 ok(g_dm == dmtest,"Expected DocumentMgr not focused\n");
1332 ITfDocumentMgr_Release(dmtest);
1334 TextStoreACP_Constructor((IUnknown**)&ts);
1336 hr = ITfDocumentMgr_CreateContext(g_dm, cid, 0, (IUnknown*)ts, &cxt, &editCookie);
1337 ok(SUCCEEDED(hr),"CreateContext Failed\n");
1339 hr = ITfDocumentMgr_CreateContext(g_dm, cid, 0, NULL, &cxt2, &editCookie);
1340 ok(SUCCEEDED(hr),"CreateContext Failed\n");
1342 hr = ITfDocumentMgr_CreateContext(g_dm, cid, 0, NULL, &cxt3, &editCookie);
1343 ok(SUCCEEDED(hr),"CreateContext Failed\n");
1345 test_EnumContexts(g_dm, NULL);
1347 hr = ITfContext_GetDocumentMgr(cxt,&dmtest);
1348 ok(hr == S_OK, "ITfContext_GetDocumentMgr failed with %x\n",hr);
1349 ok(dmtest == g_dm, "Wrong documentmgr\n");
1350 ITfDocumentMgr_Release(dmtest);
1352 cnt = check_context_refcount(cxt);
1353 test_OnPushContext = SINK_EXPECTED;
1354 test_ACP_AdviseSink = SINK_EXPECTED;
1355 test_OnInitDocumentMgr = SINK_EXPECTED;
1356 hr = ITfDocumentMgr_Push(g_dm, cxt);
1357 ok(SUCCEEDED(hr),"Push Failed\n");
1358 ok(check_context_refcount(cxt) > cnt, "Ref count did not increase\n");
1359 ok(test_OnPushContext == SINK_FIRED, "OnPushContext sink not fired\n");
1360 ok(test_OnInitDocumentMgr == SINK_FIRED, "OnInitDocumentMgr sink not fired\n");
1361 ok(test_ACP_AdviseSink == SINK_FIRED,"TextStoreACP_AdviseSink not fired\n");
1363 test_EnumContexts(g_dm, cxt);
1365 hr = ITfDocumentMgr_GetTop(g_dm, &cxtTest);
1366 ok(SUCCEEDED(hr),"GetTop Failed\n");
1367 ok(cxtTest == cxt, "Wrong context on top\n");
1368 ok(check_context_refcount(cxt) > cnt, "Ref count did not increase\n");
1369 cnt = ITfContext_Release(cxtTest);
1371 hr = ITfDocumentMgr_GetBase(g_dm, &cxtTest);
1372 ok(SUCCEEDED(hr),"GetBase Failed\n");
1373 ok(cxtTest == cxt, "Wrong context on Base\n");
1374 ok(check_context_refcount(cxt) > cnt, "Ref count did not increase\n");
1375 ITfContext_Release(cxtTest);
1377 check_context_refcount(cxt2);
1378 test_OnPushContext = SINK_EXPECTED;
1379 hr = ITfDocumentMgr_Push(g_dm, cxt2);
1380 ok(SUCCEEDED(hr),"Push Failed\n");
1381 ok(test_OnPushContext == SINK_FIRED, "OnPushContext sink not fired\n");
1383 cnt = check_context_refcount(cxt2);
1384 hr = ITfDocumentMgr_GetTop(g_dm, &cxtTest);
1385 ok(SUCCEEDED(hr),"GetTop Failed\n");
1386 ok(cxtTest == cxt2, "Wrong context on top\n");
1387 ok(check_context_refcount(cxt2) > cnt, "Ref count did not increase\n");
1388 ITfContext_Release(cxtTest);
1390 cnt = check_context_refcount(cxt);
1391 hr = ITfDocumentMgr_GetBase(g_dm, &cxtTest);
1392 ok(SUCCEEDED(hr),"GetBase Failed\n");
1393 ok(cxtTest == cxt, "Wrong context on Base\n");
1394 ok(check_context_refcount(cxt) > cnt, "Ref count did not increase\n");
1395 ITfContext_Release(cxtTest);
1397 cnt = check_context_refcount(cxt3);
1398 hr = ITfDocumentMgr_Push(g_dm, cxt3);
1399 ok(FAILED(hr),"Push Succeeded\n");
1400 ok(check_context_refcount(cxt3) == cnt, "Ref changed\n");
1402 cnt = check_context_refcount(cxt2);
1403 hr = ITfDocumentMgr_GetTop(g_dm, &cxtTest);
1404 ok(SUCCEEDED(hr),"GetTop Failed\n");
1405 ok(cxtTest == cxt2, "Wrong context on top\n");
1406 ok(check_context_refcount(cxt2) > cnt, "Ref count did not increase\n");
1407 ITfContext_Release(cxtTest);
1409 cnt = check_context_refcount(cxt);
1410 hr = ITfDocumentMgr_GetBase(g_dm, &cxtTest);
1411 ok(SUCCEEDED(hr),"GetBase Failed\n");
1412 ok(cxtTest == cxt, "Wrong context on Base\n");
1413 ok(check_context_refcount(cxt) > cnt, "Ref count did not increase\n");
1414 ITfContext_Release(cxtTest);
1416 cnt = check_context_refcount(cxt2);
1417 test_OnPopContext = SINK_EXPECTED;
1418 hr = ITfDocumentMgr_Pop(g_dm, 0);
1419 ok(SUCCEEDED(hr),"Pop Failed\n");
1420 ok(check_context_refcount(cxt2) < cnt, "Ref count did not decrease\n");
1421 ok(test_OnPopContext == SINK_FIRED, "OnPopContext sink not fired\n");
1423 dmtest = (void *)0xfeedface;
1424 hr = ITfContext_GetDocumentMgr(cxt2,&dmtest);
1425 ok(hr == S_FALSE, "ITfContext_GetDocumentMgr wrong rc %x\n",hr);
1426 ok(dmtest == NULL,"returned documentmgr should be null\n");
1428 hr = ITfDocumentMgr_GetTop(g_dm, &cxtTest);
1429 ok(SUCCEEDED(hr),"GetTop Failed\n");
1430 ok(cxtTest == cxt, "Wrong context on top\n");
1431 ITfContext_Release(cxtTest);
1433 hr = ITfDocumentMgr_GetBase(g_dm, &cxtTest);
1434 ok(SUCCEEDED(hr),"GetBase Failed\n");
1435 ok(cxtTest == cxt, "Wrong context on base\n");
1436 ITfContext_Release(cxtTest);
1438 hr = ITfDocumentMgr_Pop(g_dm, 0);
1439 ok(FAILED(hr),"Pop Succeeded\n");
1441 hr = ITfDocumentMgr_GetTop(g_dm, &cxtTest);
1442 ok(SUCCEEDED(hr),"GetTop Failed\n");
1443 ok(cxtTest == cxt, "Wrong context on top\n");
1444 ITfContext_Release(cxtTest);
1446 hr = ITfDocumentMgr_GetBase(g_dm, &cxtTest);
1447 ok(SUCCEEDED(hr),"GetBase Failed\n");
1448 ok(cxtTest == cxt, "Wrong context on base\n");
1449 ITfContext_Release(cxtTest);
1451 ITfContext_Release(cxt);
1452 ITfContext_Release(cxt2);
1453 ITfContext_Release(cxt3);
1456 static void test_endSession(void)
1459 test_ShouldDeactivate = TRUE;
1460 test_CurrentFocus = NULL;
1461 test_PrevFocus = g_dm;
1462 test_OnSetFocus = SINK_EXPECTED;
1463 hr = ITfThreadMgr_Deactivate(g_tm);
1464 ok(SUCCEEDED(hr),"Failed to Deactivate\n");
1465 ok(test_OnSetFocus == SINK_FIRED, "OnSetFocus sink not called\n");
1466 test_OnSetFocus = SINK_UNEXPECTED;
1469 static void test_TfGuidAtom(void)
1473 TfGuidAtom atom1,atom2;
1476 CoCreateGuid(>est);
1478 /* msdn reports this should return E_INVALIDARG. However my test show it crashing (winxp)*/
1480 hr = ITfCategoryMgr_RegisterGUID(g_cm,>est,NULL);
1481 ok(hr==E_INVALIDARG,"ITfCategoryMgr_RegisterGUID should have failed\n");
1483 hr = ITfCategoryMgr_RegisterGUID(g_cm,>est,&atom1);
1484 ok(SUCCEEDED(hr),"ITfCategoryMgr_RegisterGUID failed\n");
1485 hr = ITfCategoryMgr_RegisterGUID(g_cm,>est,&atom2);
1486 ok(SUCCEEDED(hr),"ITfCategoryMgr_RegisterGUID failed\n");
1487 ok(atom1 == atom2,"atoms do not match\n");
1488 hr = ITfCategoryMgr_GetGUID(g_cm,atom2,NULL);
1489 ok(hr==E_INVALIDARG,"ITfCategoryMgr_GetGUID should have failed\n");
1490 hr = ITfCategoryMgr_GetGUID(g_cm,atom2,&g1);
1491 ok(SUCCEEDED(hr),"ITfCategoryMgr_GetGUID failed\n");
1492 ok(IsEqualGUID(&g1,>est),"guids do not match\n");
1493 hr = ITfCategoryMgr_IsEqualTfGuidAtom(g_cm,atom1,>est,NULL);
1494 ok(hr==E_INVALIDARG,"ITfCategoryMgr_IsEqualTfGuidAtom should have failed\n");
1495 hr = ITfCategoryMgr_IsEqualTfGuidAtom(g_cm,atom1,>est,&equal);
1496 ok(SUCCEEDED(hr),"ITfCategoryMgr_IsEqualTfGuidAtom failed\n");
1497 ok(equal == TRUE,"Equal value invalid\n");
1499 /* show that cid and tid TfClientIds are also TfGuidAtoms */
1500 hr = ITfCategoryMgr_IsEqualTfGuidAtom(g_cm,tid,&CLSID_FakeService,&equal);
1501 ok(SUCCEEDED(hr),"ITfCategoryMgr_IsEqualTfGuidAtom failed\n");
1502 ok(equal == TRUE,"Equal value invalid\n");
1503 hr = ITfCategoryMgr_GetGUID(g_cm,cid,&g1);
1504 ok(SUCCEEDED(hr),"ITfCategoryMgr_GetGUID failed\n");
1505 ok(!IsEqualGUID(&g1,&GUID_NULL),"guid should not be NULL\n");
1508 static void test_ClientId(void)
1515 hr = ITfThreadMgr_QueryInterface(g_tm, &IID_ITfClientId, (LPVOID*)&pcid);
1516 ok(SUCCEEDED(hr),"Unable to acquire ITfClientId interface\n");
1520 hr = ITfClientId_GetClientId(pcid,&GUID_NULL,&id1);
1521 ok(SUCCEEDED(hr),"GetClientId failed\n");
1522 hr = ITfClientId_GetClientId(pcid,&GUID_NULL,&id2);
1523 ok(SUCCEEDED(hr),"GetClientId failed\n");
1524 ok(id1==id2,"Id's for GUID_NULL do not match\n");
1525 hr = ITfClientId_GetClientId(pcid,&CLSID_FakeService,&id2);
1526 ok(SUCCEEDED(hr),"GetClientId failed\n");
1527 ok(id2!=id1,"Id matches GUID_NULL\n");
1528 ok(id2==tid,"Id for CLSID_FakeService not matching tid\n");
1529 ok(id2!=cid,"Id for CLSID_FakeService matching cid\n");
1530 hr = ITfClientId_GetClientId(pcid,&g2,&id2);
1531 ok(SUCCEEDED(hr),"GetClientId failed\n");
1532 ok(id2!=id1,"Id matches GUID_NULL\n");
1533 ok(id2!=tid,"Id for random guid matching tid\n");
1534 ok(id2!=cid,"Id for random guid matching cid\n");
1535 ITfClientId_Release(pcid);
1538 /**********************************************************************
1540 **********************************************************************/
1541 typedef struct tagEditSession
1543 const ITfEditSessionVtbl *EditSessionVtbl;
1547 static void EditSession_Destructor(EditSession *This)
1549 HeapFree(GetProcessHeap(),0,This);
1552 static HRESULT WINAPI EditSession_QueryInterface(ITfEditSession *iface, REFIID iid, LPVOID *ppvOut)
1554 EditSession *This = (EditSession *)iface;
1557 if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfEditSession))
1564 IUnknown_AddRef(iface);
1568 return E_NOINTERFACE;
1571 static ULONG WINAPI EditSession_AddRef(ITfEditSession *iface)
1573 EditSession *This = (EditSession *)iface;
1574 return InterlockedIncrement(&This->refCount);
1577 static ULONG WINAPI EditSession_Release(ITfEditSession *iface)
1579 EditSession *This = (EditSession *)iface;
1582 ret = InterlockedDecrement(&This->refCount);
1584 EditSession_Destructor(This);
1588 static void test_InsertAtSelection(TfEditCookie ec, ITfContext *cxt)
1591 ITfInsertAtSelection *iis;
1592 ITfRange *range=NULL;
1593 static const WCHAR txt[] = {'H','e','l','l','o',' ','W','o','r','l','d',0};
1595 hr = ITfContext_QueryInterface(cxt, &IID_ITfInsertAtSelection , (LPVOID*)&iis);
1596 ok(SUCCEEDED(hr),"Failed to get ITfInsertAtSelection interface\n");
1597 test_ACP_InsertTextAtSelection = SINK_EXPECTED;
1598 hr = ITfInsertAtSelection_InsertTextAtSelection(iis, ec, 0, txt, 11, &range);
1599 ok(SUCCEEDED(hr),"ITfInsertAtSelection_InsertTextAtSelection failed %x\n",hr);
1600 ok(test_ACP_InsertTextAtSelection == SINK_FIRED,"expected InsertTextAtSelection not fired\n");
1601 ok(range != NULL,"No range returned\n");
1602 ITfRange_Release(range);
1603 ITfInsertAtSelection_Release(iis);
1606 static HRESULT WINAPI EditSession_DoEditSession(ITfEditSession *iface,
1612 TF_SELECTION selection;
1616 ok(test_DoEditSession == SINK_EXPECTED, "Unexpected DoEditSession\n");
1617 ok(test_ACP_RequestLock == SINK_FIRED,"Expected RequestLock not fired\n");
1618 test_DoEditSession = SINK_FIRED;
1620 ITfThreadMgr_GetFocus(g_tm, &dm);
1621 ITfDocumentMgr_GetTop(dm,&cxt);
1623 hr = ITfContext_GetStart(cxt,ec,NULL);
1624 ok(hr == E_INVALIDARG,"Unexpected return code %x\n",hr);
1626 range = (ITfRange*)0xdeaddead;
1627 hr = ITfContext_GetStart(cxt,0xdeadcafe,&range);
1628 ok(hr == TF_E_NOLOCK,"Unexpected return code %x\n",hr);
1629 ok(range == NULL,"Range not set to NULL\n");
1631 hr = ITfContext_GetStart(cxt,ec,&range);
1632 ok(SUCCEEDED(hr),"Unexpected return code %x\n",hr);
1633 ok(range != NULL,"Range set to NULL\n");
1635 ITfRange_Release(range);
1637 hr = ITfContext_GetEnd(cxt,ec,NULL);
1638 ok(hr == E_INVALIDARG,"Unexpected return code %x\n",hr);
1640 range = (ITfRange*)0xdeaddead;
1641 hr = ITfContext_GetEnd(cxt,0xdeadcafe,&range);
1642 ok(hr == TF_E_NOLOCK,"Unexpected return code %x\n",hr);
1643 ok(range == NULL,"Range not set to NULL\n");
1645 test_ACP_GetEndACP = SINK_EXPECTED;
1646 hr = ITfContext_GetEnd(cxt,ec,&range);
1647 ok(SUCCEEDED(hr),"Unexpected return code %x\n",hr);
1648 ok(range != NULL,"Range set to NULL\n");
1649 ok(test_ACP_GetEndACP == SINK_FIRED, "GetEndACP not fired as expected\n");
1651 ITfRange_Release(range);
1653 selection.range = NULL;
1654 test_ACP_GetSelection = SINK_EXPECTED;
1655 hr = ITfContext_GetSelection(cxt, ec, TF_DEFAULT_SELECTION, 1, &selection, &fetched);
1656 ok(SUCCEEDED(hr),"ITfContext_GetSelection failed\n");
1657 ok(fetched == 1,"fetched incorrect\n");
1658 ok(selection.range != NULL,"NULL range\n");
1659 ok(test_ACP_GetSelection == SINK_FIRED," expected ACP_GetSepection not fired\n");
1660 ITfRange_Release(selection.range);
1662 test_InsertAtSelection(ec, cxt);
1664 test_ACP_GetEndACP = SINK_EXPECTED;
1665 hr = ITfContext_GetEnd(cxt,ec,&range);
1666 ok(SUCCEEDED(hr),"Unexpected return code %x\n",hr);
1667 ok(range != NULL,"Range set to NULL\n");
1668 ok(test_ACP_GetEndACP == SINK_FIRED, "GetEndACP not fired as expected\n");
1670 selection.range = range;
1671 selection.style.ase = TF_AE_NONE;
1672 selection.style.fInterimChar = FALSE;
1673 test_ACP_SetSelection = SINK_EXPECTED;
1674 hr = ITfContext_SetSelection(cxt, ec, 1, &selection);
1675 ok(test_ACP_SetSelection == SINK_FIRED, "SetSelection not fired as expected\n");
1676 ITfRange_Release(range);
1678 ITfContext_Release(cxt);
1679 ITfDocumentMgr_Release(dm);
1683 static const ITfEditSessionVtbl EditSession_EditSessionVtbl =
1685 EditSession_QueryInterface,
1687 EditSession_Release,
1689 EditSession_DoEditSession
1692 static HRESULT EditSession_Constructor(ITfEditSession **ppOut)
1697 This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(EditSession));
1699 return E_OUTOFMEMORY;
1701 This->EditSessionVtbl = &EditSession_EditSessionVtbl;
1704 *ppOut = (ITfEditSession*)This;
1708 static void test_TStoApplicationText(void)
1710 HRESULT hr, hrSession;
1714 ITfTextEditSink *sink;
1715 ITfSource *source = NULL;
1716 DWORD editSinkCookie = -1;
1718 ITfThreadMgr_GetFocus(g_tm, &dm);
1719 EditSession_Constructor(&es);
1720 ITfDocumentMgr_GetTop(dm,&cxt);
1722 TextEditSink_Constructor(&sink);
1723 hr = ITfContext_QueryInterface(cxt,&IID_ITfSource,(LPVOID*)&source);
1724 ok(SUCCEEDED(hr),"Failed to get IID_ITfSource for Context\n");
1727 hr = ITfSource_AdviseSink(source, &IID_ITfTextEditSink, (LPVOID)sink, &editSinkCookie);
1728 ok(SUCCEEDED(hr),"Failed to advise Sink\n");
1729 ok(editSinkCookie != -1,"Failed to get sink cookie\n");
1732 hrSession = 0xfeedface;
1733 /* Test no premissions flags */
1734 hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC, &hrSession);
1735 ok(hr == E_INVALIDARG,"RequestEditSession should have failed with %x not %x\n",E_INVALIDARG,hr);
1736 ok(hrSession == E_FAIL,"hrSession should be %x not %x\n",E_FAIL,hrSession);
1738 documentStatus = TS_SD_READONLY;
1739 hrSession = 0xfeedface;
1740 test_ACP_GetStatus = SINK_EXPECTED;
1741 hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READWRITE, &hrSession);
1742 ok(SUCCEEDED(hr),"ITfContext_RequestEditSession failed\n");
1743 ok(hrSession == TS_E_READONLY,"Unexpected hrSession (%x)\n",hrSession);
1744 ok(test_ACP_GetStatus == SINK_FIRED," expected GetStatus not fired\n");
1746 /* signal a change to allow readwrite sessions */
1748 test_ACP_RequestLock = SINK_EXPECTED;
1749 ITextStoreACPSink_OnStatusChange(ACPSink,documentStatus);
1750 ok(test_ACP_RequestLock == SINK_FIRED," expected RequestLock not fired\n");
1752 test_ACP_GetStatus = SINK_EXPECTED;
1753 test_ACP_RequestLock = SINK_EXPECTED;
1754 test_DoEditSession = SINK_EXPECTED;
1755 hrSession = 0xfeedface;
1756 test_OnEndEdit = SINK_EXPECTED;
1757 hr = ITfContext_RequestEditSession(cxt, tid, es, TF_ES_SYNC|TF_ES_READWRITE, &hrSession);
1758 ok(SUCCEEDED(hr),"ITfContext_RequestEditSession failed\n");
1759 ok(test_OnEndEdit == SINK_FIRED, "OnEndEdit not fired as expected\n");
1760 ok(test_ACP_RequestLock == SINK_FIRED," expected RequestLock not fired\n");
1761 ok(test_DoEditSession == SINK_FIRED," expected DoEditSession not fired\n");
1762 ok(test_ACP_GetStatus == SINK_FIRED," expected GetStatus not fired\n");
1763 ok(hrSession == 0xdeadcafe,"Unexpected hrSession (%x)\n",hrSession);
1767 hr = ITfSource_UnadviseSink(source, editSinkCookie);
1768 ok(SUCCEEDED(hr),"Failed to unadvise Sink\n");
1769 ITfTextEditSink_Release(sink);
1770 ITfSource_Release(source);
1773 ITfContext_Release(cxt);
1774 ITfDocumentMgr_Release(dm);
1775 ITfEditSession_Release(es);
1778 static void enum_compartments(ITfCompartmentMgr *cmpmgr, REFGUID present, REFGUID absent)
1784 if (SUCCEEDED(ITfCompartmentMgr_EnumCompartments(cmpmgr, &ppEnum)))
1788 while (IEnumGUID_Next(ppEnum, 1, &g, &fetched) == S_OK)
1792 StringFromGUID2(&g,str,50);
1793 WideCharToMultiByte(CP_ACP,0,str,50,strA,50,0,0);
1794 trace("found %s\n",strA);
1795 if (present && IsEqualGUID(present,&g))
1797 if (absent && IsEqualGUID(absent, &g))
1800 IEnumGUID_Release(ppEnum);
1803 ok(found,"Did not find compartment\n");
1805 ok(!found2,"Found compartment that should be absent\n");
1808 static void test_Compartments(void)
1812 ITfCompartmentMgr *cmpmgr;
1813 ITfCompartment *cmp;
1816 ITfThreadMgr_GetFocus(g_tm, &dm);
1817 ITfDocumentMgr_GetTop(dm,&cxt);
1820 hr = ITfThreadMgr_GetGlobalCompartment(g_tm, &cmpmgr);
1821 ok(SUCCEEDED(hr),"GetGlobalCompartment failed\n");
1822 hr = ITfCompartmentMgr_GetCompartment(cmpmgr, &GUID_COMPARTMENT_SPEECH_OPENCLOSE, &cmp);
1823 ok(SUCCEEDED(hr),"GetCompartment failed\n");
1824 ITfCompartment_Release(cmp);
1825 enum_compartments(cmpmgr,&GUID_COMPARTMENT_SPEECH_OPENCLOSE,NULL);
1826 ITfCompartmentMgr_Release(cmpmgr);
1829 hr = ITfThreadMgr_QueryInterface(g_tm, &IID_ITfCompartmentMgr, (LPVOID*)&cmpmgr);
1830 ok(SUCCEEDED(hr),"ThreadMgr QI for IID_ITfCompartmentMgr failed\n");
1831 hr = ITfCompartmentMgr_GetCompartment(cmpmgr, &CLSID_FakeService, &cmp);
1832 ok(SUCCEEDED(hr),"GetCompartment failed\n");
1833 enum_compartments(cmpmgr,&CLSID_FakeService,&GUID_COMPARTMENT_SPEECH_OPENCLOSE);
1834 ITfCompartmentMgr_ClearCompartment(cmpmgr,tid,&CLSID_FakeService);
1835 enum_compartments(cmpmgr,NULL,&CLSID_FakeService);
1836 ITfCompartmentMgr_Release(cmpmgr);
1837 ITfCompartment_Release(cmp);
1840 hr = ITfDocumentMgr_QueryInterface(dm, &IID_ITfCompartmentMgr, (LPVOID*)&cmpmgr);
1841 ok(SUCCEEDED(hr),"DocumentMgr QI for IID_ITfCompartmentMgr failed\n");
1843 hr = ITfCompartmentMgr_GetCompartment(cmpmgr, &GUID_COMPARTMENT_PERSISTMENUENABLED, &cmp);
1844 ok(SUCCEEDED(hr),"GetCompartment failed\n");
1845 enum_compartments(cmpmgr,&GUID_COMPARTMENT_PERSISTMENUENABLED,&GUID_COMPARTMENT_SPEECH_OPENCLOSE);
1846 ITfCompartmentMgr_Release(cmpmgr);
1849 hr = ITfContext_QueryInterface(cxt, &IID_ITfCompartmentMgr, (LPVOID*)&cmpmgr);
1850 ok(SUCCEEDED(hr),"Context QI for IID_ITfCompartmentMgr failed\n");
1851 enum_compartments(cmpmgr,NULL,&GUID_COMPARTMENT_PERSISTMENUENABLED);
1852 ITfCompartmentMgr_Release(cmpmgr);
1854 ITfContext_Release(cxt);
1855 ITfDocumentMgr_Release(dm);
1858 START_TEST(inputprocessor)
1860 if (SUCCEEDED(initialize()))
1863 test_RegisterCategory();
1864 test_EnumInputProcessorInfo();
1866 test_ThreadMgrAdviseSinks();
1868 test_startSession();
1871 test_KeystrokeMgr();
1872 test_TStoApplicationText();
1873 test_Compartments();
1875 test_EnumLanguageProfiles();
1876 test_FindClosestCategory();
1878 test_ThreadMgrUnadviseSinks();
1879 test_UnregisterCategory();
1883 skip("Unable to create InputProcessor\n");