[MSCTF_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536
[reactos.git] / rostests / winetests / msctf / inputprocessor.c
index 027795d..58d4d26 100644 (file)
@@ -921,6 +921,7 @@ static void test_EnumInputProcessorInfo(void)
             if(IsEqualGUID(&g,&CLSID_FakeService))
                 found = TRUE;
         }
+        IEnumGUID_Release(ppEnum);
     }
     ok(found,"Did not find registered text service\n");
 }
@@ -938,10 +939,12 @@ static void test_EnumLanguageProfiles(void)
             {
                 found = TRUE;
                 ok(profile.langid == gLangid, "LangId Incorrect\n");
-                ok(IsEqualGUID(&profile.catid,&GUID_TFCAT_TIP_KEYBOARD), "CatId Incorrect\n");
+                ok(IsEqualGUID(&profile.catid,&GUID_TFCAT_TIP_KEYBOARD) ||
+                   broken(IsEqualGUID(&profile.catid,&GUID_NULL) /* Win8 */), "CatId Incorrect\n");
                 ok(IsEqualGUID(&profile.guidProfile,&CLSID_FakeService), "guidProfile Incorrect\n");
             }
         }
+        IEnumTfLanguageProfiles_Release(ppEnum);
     }
     ok(found,"Registered text service not found\n");
 }
@@ -1406,6 +1409,7 @@ static void test_startSession(void)
     ITfContext *cxt,*cxt2,*cxt3,*cxtTest;
     ITextStoreACP *ts;
     TfClientId cid2 = 0;
+    ITfThreadMgrEx *tmex;
 
     hr = ITfThreadMgr_Deactivate(g_tm);
     ok(hr == E_UNEXPECTED,"Deactivate should have failed with E_UNEXPECTED\n");
@@ -1418,10 +1422,21 @@ static void test_startSession(void)
     test_ShouldActivate = FALSE;
     hr = ITfThreadMgr_Activate(g_tm,&cid2);
     ok(SUCCEEDED(hr),"Failed to Activate\n");
-    ok (cid == cid2, "Second activate client ID does not match\n");
+    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");
+
+    ITfThreadMgrEx_Release(tmex);
 
     hr = ITfThreadMgr_Deactivate(g_tm);
-    ok(SUCCEEDED(hr),"Failed to Deactivate\n");
+    ok(SUCCEEDED(hr), "Failed to Deactivate\n");
+    hr = ITfThreadMgr_Deactivate(g_tm);
+    ok(SUCCEEDED(hr), "Failed to Deactivate\n");
 
     test_EnumDocumentMgr(g_tm,NULL,NULL);
 
@@ -2000,10 +2015,10 @@ static void processPendingMessages(void)
     {
         if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT)
             break;
-        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
+        while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
         {
             TranslateMessage(&msg);
-            DispatchMessage(&msg);
+            DispatchMessageW(&msg);
         }
         diff = time - GetTickCount();
     }
@@ -2032,11 +2047,11 @@ static void test_AssociateFocus(void)
     hr = ITfThreadMgr_CreateDocumentMgr(g_tm,&dm2);
     ok(SUCCEEDED(hr),"CreateDocumentMgr failed\n");
 
-    wnd1 = CreateWindow("edit",NULL,WS_POPUP,0,0,200,60,NULL,NULL,NULL,NULL);
+    wnd1 = CreateWindowA("edit",NULL,WS_POPUP,0,0,200,60,NULL,NULL,NULL,NULL);
     ok(wnd1!=NULL,"Unable to create window 1\n");
-    wnd2 = CreateWindow("edit",NULL,WS_POPUP,0,65,200,60,NULL,NULL,NULL,NULL);
+    wnd2 = CreateWindowA("edit",NULL,WS_POPUP,0,65,200,60,NULL,NULL,NULL,NULL);
     ok(wnd2!=NULL,"Unable to create window 2\n");
-    wnd3 = CreateWindow("edit",NULL,WS_POPUP,0,130,200,60,NULL,NULL,NULL,NULL);
+    wnd3 = CreateWindowA("edit",NULL,WS_POPUP,0,130,200,60,NULL,NULL,NULL,NULL);
     ok(wnd3!=NULL,"Unable to create window 3\n");
 
     processPendingMessages();
@@ -2075,20 +2090,15 @@ static void test_AssociateFocus(void)
     processPendingMessages();
 
     ITfThreadMgr_GetFocus(g_tm, &dmcheck);
-    if (dmcheck != NULL)
-    {
-        ok(dmcheck == dm1, "Expected DocumentMgr not focused\n");
-        ITfDocumentMgr_Release(dmcheck);
-    }
-    else
-    {
-        /* Sometimes we need to explicitly set focus on Win7 */
-        test_CurrentFocus = dm1;
-        test_PrevFocus = FOCUS_IGNORE;
-        test_OnSetFocus = SINK_EXPECTED;
-        ITfThreadMgr_SetFocus(g_tm, dm1);
-        sink_check_ok(&test_OnSetFocus,"OnSetFocus");
-    }
+    ok(dmcheck == dm1 || broken(dmcheck == dmorig /* Win7+ */), "Expected DocumentMgr not focused\n");
+    ITfDocumentMgr_Release(dmcheck);
+
+    /* We need to explicitly set focus on Win7+ */
+    test_CurrentFocus = dm1;
+    test_PrevFocus = FOCUS_IGNORE;
+    test_OnSetFocus = SINK_OPTIONAL; /* Doesn't always fire on Win7+ */
+    ITfThreadMgr_SetFocus(g_tm, dm1);
+    sink_check_ok(&test_OnSetFocus, "OnSetFocus");
 
     hr = ITfThreadMgr_AssociateFocus(g_tm,wnd2,dm2,&olddm);
     ok(SUCCEEDED(hr),"AssociateFocus failed\n");
@@ -2133,7 +2143,7 @@ static void test_AssociateFocus(void)
 
     test_CurrentFocus = dmorig;
     test_PrevFocus = dm1;
-    test_OnSetFocus  = SINK_EXPECTED;
+    test_OnSetFocus  = SINK_OPTIONAL; /* Doesn't always fire on Win7+ */
     test_ACP_GetStatus = SINK_IGNORE;
     ITfThreadMgr_SetFocus(g_tm,dmorig);
     sink_check_ok(&test_OnSetFocus,"OnSetFocus");
@@ -2178,7 +2188,6 @@ static void test_AssociateFocus(void)
     test_PrevFocus = FOCUS_IGNORE;
     DestroyWindow(wnd1);
     DestroyWindow(wnd2);
-    test_OnSetFocus = SINK_UNEXPECTED;
     test_OnPopContext = SINK_OPTIONAL; /* Vista and greater */
     test_OnSetFocus = SINK_OPTIONAL; /* Vista and greater */
     ITfThreadMgr_GetFocus(g_tm, &test_PrevFocus);
@@ -2190,6 +2199,28 @@ static void test_AssociateFocus(void)
     sink_check_ok(&test_OnPopContext,"OnPopContext");
 }
 
+static void test_profile_mgr(void)
+{
+    IEnumTfInputProcessorProfiles *enum_profiles;
+    ITfInputProcessorProfileMgr *ipp_mgr;
+    HRESULT hres;
+
+    hres = ITfInputProcessorProfiles_QueryInterface(g_ipp, &IID_ITfInputProcessorProfileMgr, (void**)&ipp_mgr);
+    if (hres != S_OK)
+    {
+        win_skip("ITfInputProcessorProfileMgr is not supported.\n");
+        return;
+    }
+    ok(hres == S_OK, "Could not get ITfInputProcessorProfileMgr iface: %08x\n", hres);
+
+    hres = ITfInputProcessorProfileMgr_EnumProfiles(ipp_mgr, 0, &enum_profiles);
+    ok(hres == S_OK, "EnumProfiles failed: %08x\n", hres);
+
+    IEnumTfInputProcessorProfiles_Release(enum_profiles);
+
+    ITfInputProcessorProfileMgr_Release(ipp_mgr);
+}
+
 START_TEST(inputprocessor)
 {
     if (SUCCEEDED(initialize()))
@@ -2216,6 +2247,7 @@ START_TEST(inputprocessor)
         test_ThreadMgrUnadviseSinks();
         test_UnregisterCategory();
         test_Unregister();
+        test_profile_mgr();
     }
     else
         skip("Unable to create InputProcessor\n");