[MSCTF_WINETEST] Sync with Wine Staging 1.9.11. CORE-11368
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 5 Jun 2016 19:38:56 +0000 (19:38 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 5 Jun 2016 19:38:56 +0000 (19:38 +0000)
svn path=/trunk/; revision=71569

rostests/winetests/msctf/inputprocessor.c

index 58d4d26..16df012 100644 (file)
@@ -62,6 +62,7 @@ static BOOL test_ShouldDeactivate = FALSE;
 
 static DWORD tmSinkCookie;
 static DWORD tmSinkRefCount;
+static DWORD dmSinkCookie;
 static DWORD documentStatus;
 static ITfDocumentMgr *test_CurrentFocus = NULL;
 static ITfDocumentMgr *test_PrevFocus = NULL;
@@ -117,9 +118,7 @@ static inline void _sink_fire_ok(INT *sink, const CHAR* name)
             *sink = (*sink & ~SINK_EXPECTED_COUNT_MASK) + (count << 16);
             return;
         default:
-            if (todo)
-                todo_wine winetest_ok(0, "Unexpected %s sink\n",name);
-            else
+            todo_wine_if (todo)
                 winetest_ok(0, "Unexpected %s sink\n",name);
     }
     *sink = SINK_FIRED;
@@ -147,9 +146,7 @@ static inline void _sink_check_ok(INT *sink, const CHAR* name)
                 winetest_trace("optional sink %s not fired\n",name);
             break;
         default:
-            if (todo)
-                todo_wine winetest_ok(0, "%s not fired as expected, in state %x\n",name,*sink);
-            else
+            todo_wine_if (todo)
                 winetest_ok(0, "%s not fired as expected, in state %x\n",name,*sink);
     }
     *sink = SINK_UNEXPECTED;
@@ -230,12 +227,18 @@ static ULONG WINAPI TextStoreACP_Release(ITextStoreACP *iface)
 static HRESULT WINAPI TextStoreACP_AdviseSink(ITextStoreACP *iface,
     REFIID riid, IUnknown *punk, DWORD dwMask)
 {
+    ITextStoreACPServices *services;
     HRESULT hr;
 
     sink_fire_ok(&test_ACP_AdviseSink,"TextStoreACP_AdviseSink");
 
-    hr = IUnknown_QueryInterface(punk, &IID_ITextStoreACPSink,(LPVOID*)(&ACPSink));
+    hr = IUnknown_QueryInterface(punk, &IID_ITextStoreACPSink, (void**)&ACPSink);
     ok(SUCCEEDED(hr),"Unable to QueryInterface on sink\n");
+
+    hr = ITextStoreACPSink_QueryInterface(ACPSink, &IID_ITextStoreACPServices, (void**)&services);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ITextStoreACPServices_Release(services);
+
     return S_OK;
 }
 
@@ -620,6 +623,42 @@ static HRESULT ThreadMgrEventSink_Constructor(IUnknown **ppOut)
     return S_OK;
 }
 
+static HRESULT WINAPI TfTransitoryExtensionSink_QueryInterface(ITfTransitoryExtensionSink *iface, REFIID riid, void **ppv)
+{
+    if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_ITfTransitoryExtensionSink, riid)) {
+        *ppv = iface;
+        return S_OK;
+    }
+
+    *ppv = NULL;
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI TfTransitoryExtensionSink_AddRef(ITfTransitoryExtensionSink *iface)
+{
+    return 2;
+}
+
+static ULONG WINAPI TfTransitoryExtensionSink_Release(ITfTransitoryExtensionSink *iface)
+{
+    return 1;
+}
+
+static HRESULT WINAPI TfTransitoryExtensionSink_OnTransitoryExtensionUpdated(ITfTransitoryExtensionSink *iface, ITfContext *pic,
+        TfEditCookie ecReadOnly, ITfRange *pResultRange, ITfRange *pCompositionRange, BOOL *pfDeleteResultRange)
+{
+    ok(0, "unexpected call\n");
+    return E_NOTIMPL;
+}
+
+static const ITfTransitoryExtensionSinkVtbl TfTransitoryExtensionSinkVtbl = {
+    TfTransitoryExtensionSink_QueryInterface,
+    TfTransitoryExtensionSink_AddRef,
+    TfTransitoryExtensionSink_Release,
+    TfTransitoryExtensionSink_OnTransitoryExtensionUpdated
+};
+
+static ITfTransitoryExtensionSink TfTransitoryExtensionSink = { &TfTransitoryExtensionSinkVtbl };
 
 /********************************************************************************************
  * Stub text service for testing
@@ -1051,6 +1090,34 @@ static void test_ThreadMgrUnadviseSinks(void)
     ITfSource_Release(source);
 }
 
+static void test_DocumentMgrAdviseSinks(void)
+{
+    ITfSource *source;
+    HRESULT hr;
+
+    hr = ITfDocumentMgr_QueryInterface(g_dm, &IID_ITfSource, (void**)&source);
+    ok(hr == S_OK,"Failed to get IID_ITfSource for DocumentMgr\n");
+
+    dmSinkCookie = 0;
+    hr = ITfSource_AdviseSink(source, &IID_ITfTransitoryExtensionSink, (IUnknown*)&TfTransitoryExtensionSink, &dmSinkCookie);
+    ok(hr == S_OK,"Failed to Advise Sink\n");
+
+    ITfSource_Release(source);
+}
+
+static void test_DocumentMgrUnadviseSinks(void)
+{
+    ITfSource *source = NULL;
+    HRESULT hr;
+
+    hr = ITfDocumentMgr_QueryInterface(g_dm, &IID_ITfSource, (void**)&source);
+    ok(hr == S_OK,"Failed to get IID_ITfSource for DocumentMgr\n");
+
+    hr = ITfSource_UnadviseSink(source, dmSinkCookie);
+    ok(hr == S_OK,"Failed to unadvise Sink\n");
+    ITfSource_Release(source);
+}
+
 /**********************************************************************
  * ITfKeyEventSink
  **********************************************************************/
@@ -1204,13 +1271,13 @@ static void test_KeystrokeMgr(void)
     ok(hr == E_INVALIDARG,"Wrong return, expected E_INVALIDARG\n");
 
     hr =ITfKeystrokeMgr_PreserveKey(keymgr, 0, &CLSID_PreservedKey, &tfpk, NULL, 0);
-    ok(hr==E_INVALIDARG,"ITfKeystrokeMgr_PreserveKey inproperly succeeded\n");
+    ok(hr==E_INVALIDARG,"ITfKeystrokeMgr_PreserveKey improperly succeeded\n");
 
     hr =ITfKeystrokeMgr_PreserveKey(keymgr, tid, &CLSID_PreservedKey, &tfpk, NULL, 0);
     ok(SUCCEEDED(hr),"ITfKeystrokeMgr_PreserveKey failed\n");
 
     hr =ITfKeystrokeMgr_PreserveKey(keymgr, tid, &CLSID_PreservedKey, &tfpk, NULL, 0);
-    ok(hr == TF_E_ALREADY_EXISTS,"ITfKeystrokeMgr_PreserveKey inproperly succeeded\n");
+    ok(hr == TF_E_ALREADY_EXISTS,"ITfKeystrokeMgr_PreserveKey improperly succeeded\n");
 
     preserved = FALSE;
     hr = ITfKeystrokeMgr_IsPreservedKey(keymgr, &CLSID_PreservedKey, &tfpk, &preserved);
@@ -1225,7 +1292,7 @@ static void test_KeystrokeMgr(void)
     if (hr == S_FALSE) ok(preserved == FALSE,"misreporting preserved key\n");
 
     hr = ITfKeystrokeMgr_UnpreserveKey(keymgr, &CLSID_PreservedKey,&tfpk);
-    ok(hr==CONNECT_E_NOCONNECTION,"ITfKeystrokeMgr_UnpreserveKey inproperly succeeded\n");
+    ok(hr==CONNECT_E_NOCONNECTION,"ITfKeystrokeMgr_UnpreserveKey improperly succeeded\n");
 
     hr = ITfKeystrokeMgr_UnadviseKeyEventSink(keymgr,tid);
     ok(SUCCEEDED(hr),"ITfKeystrokeMgr_UnadviseKeyEventSink failed\n");
@@ -1425,13 +1492,16 @@ static void test_startSession(void)
     ok(cid == cid2, "Second activate client ID does not match\n");
 
     hr = ITfThreadMgr_QueryInterface(g_tm, &IID_ITfThreadMgrEx, (void **)&tmex);
-    ok(SUCCEEDED(hr), "Unable to acquire ITfThreadMgrEx interface\n");
-
-    hr = ITfThreadMgrEx_ActivateEx(tmex, &cid2, 0);
-    ok(SUCCEEDED(hr), "Failed to Activate\n");
-    ok(cid == cid2, "ActivateEx client ID does not match\n");
+    if (hr == S_OK)
+    {
+        hr = ITfThreadMgrEx_ActivateEx(tmex, &cid2, 0);
+        ok(SUCCEEDED(hr), "Failed to Activate\n");
+        ok(cid == cid2, "ActivateEx client ID does not match\n");
 
-    ITfThreadMgrEx_Release(tmex);
+        ITfThreadMgrEx_Release(tmex);
+    }
+    else
+        win_skip("ITfThreadMgrEx is not supported\n");
 
     hr = ITfThreadMgr_Deactivate(g_tm);
     ok(SUCCEEDED(hr), "Failed to Deactivate\n");
@@ -2235,6 +2305,7 @@ START_TEST(inputprocessor)
         test_ThreadMgrAdviseSinks();
         test_Activate();
         test_startSession();
+        test_DocumentMgrAdviseSinks();
         test_TfGuidAtom();
         test_ClientId();
         test_KeystrokeMgr();
@@ -2245,6 +2316,7 @@ START_TEST(inputprocessor)
         test_FindClosestCategory();
         test_Disable();
         test_ThreadMgrUnadviseSinks();
+        test_DocumentMgrUnadviseSinks();
         test_UnregisterCategory();
         test_Unregister();
         test_profile_mgr();