From 6be757f3b7928f4f3840d2d8f5cd1e7db8982384 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Wed, 9 Mar 2016 08:32:48 +0000 Subject: [PATCH] [IMM32_WINETEST] Sync with Wine Staging 1.9.4. CORE-10912 svn path=/trunk/; revision=70975 --- rostests/winetests/imm32/imm32.c | 143 +++++++++++++++++++++++++++---- 1 file changed, 125 insertions(+), 18 deletions(-) diff --git a/rostests/winetests/imm32/imm32.c b/rostests/winetests/imm32/imm32.c index 4c0a8880fd4..b1f39131a31 100644 --- a/rostests/winetests/imm32/imm32.c +++ b/rostests/winetests/imm32/imm32.c @@ -416,6 +416,7 @@ typedef struct _igc_threadinfo { HWND hwnd; HANDLE event; HIMC himc; + HIMC u_himc; } igc_threadinfo; @@ -424,16 +425,19 @@ static DWORD WINAPI ImmGetContextThreadFunc( LPVOID lpParam) HIMC h1,h2; HWND hwnd2; COMPOSITIONFORM cf; + CANDIDATEFORM cdf; POINT pt; + MSG msg; + igc_threadinfo *info= (igc_threadinfo*)lpParam; info->hwnd = CreateWindowExA(WS_EX_CLIENTEDGE, wndcls, "Wine imm32.dll test", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, NULL, NULL, GetModuleHandleW(NULL), NULL); h1 = ImmGetContext(hwnd); - todo_wine ok(info->himc == h1, "hwnd context changed in new thread\n"); + ok(info->himc == h1, "hwnd context changed in new thread\n"); h2 = ImmGetContext(info->hwnd); - todo_wine ok(h2 != h1, "new hwnd in new thread should have different context\n"); + ok(h2 != h1, "new hwnd in new thread should have different context\n"); info->himc = h2; ImmReleaseContext(hwnd,h1); @@ -450,9 +454,21 @@ static DWORD WINAPI ImmGetContextThreadFunc( LPVOID lpParam) /* priming for later tests */ ImmSetCompositionWindow(h1, &cf); ImmSetStatusWindowPos(h1, &pt); + info->u_himc = ImmCreateContext(); + ImmSetOpenStatus(info->u_himc, TRUE); + cdf.dwIndex = 0; + cdf.dwStyle = CFS_CANDIDATEPOS; + cdf.ptCurrentPos.x = 0; + cdf.ptCurrentPos.y = 0; + ImmSetCandidateWindow(info->u_himc, &cdf); SetEvent(info->event); - Sleep(INFINITE); + + while(GetMessageW(&msg, 0, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } return 1; } @@ -477,18 +493,26 @@ static void test_ImmThreads(void) otherHimc = ImmGetContext(threadinfo.hwnd); - todo_wine ok(himc != otherHimc, "Windows from other threads should have different himc\n"); - todo_wine ok(otherHimc == threadinfo.himc, "Context from other thread should not change in main thread\n"); + ok(himc != otherHimc, "Windows from other threads should have different himc\n"); + ok(otherHimc == threadinfo.himc, "Context from other thread should not change in main thread\n"); - if (0) /* FIXME: Causes wine to hang */ - { h1 = ImmAssociateContext(hwnd,otherHimc); ok(h1 == NULL, "Should fail to be able to Associate a default context from a different thread\n"); h1 = ImmGetContext(hwnd); ok(h1 == himc, "Context for window should remain unchanged\n"); ImmReleaseContext(hwnd,h1); - } + h1 = ImmAssociateContext(hwnd, threadinfo.u_himc); + ok (h1 == NULL, "Should fail to associate a context from a different thread\n"); + h1 = ImmGetContext(hwnd); + ok(h1 == himc, "Context for window should remain unchanged\n"); + ImmReleaseContext(hwnd,h1); + + h1 = ImmAssociateContext(threadinfo.hwnd, threadinfo.u_himc); + ok (h1 == NULL, "Should fail to associate a context from a different thread into a window from that thread.\n"); + h1 = ImmGetContext(threadinfo.hwnd); + ok(h1 == threadinfo.himc, "Context for window should remain unchanged\n"); + ImmReleaseContext(threadinfo.hwnd,h1); /* OpenStatus */ rc = ImmSetOpenStatus(himc, TRUE); @@ -501,11 +525,15 @@ static void test_ImmThreads(void) ok(rc == 0, "ImmGetOpenStatus failed\n"); rc = ImmSetOpenStatus(otherHimc, TRUE); - todo_wine ok(rc == 0, "ImmSetOpenStatus should fail\n"); + ok(rc == 0, "ImmSetOpenStatus should fail\n"); + rc = ImmSetOpenStatus(threadinfo.u_himc, TRUE); + ok(rc == 0, "ImmSetOpenStatus should fail\n"); rc = ImmGetOpenStatus(otherHimc); - todo_wine ok(rc == 0, "ImmGetOpenStatus failed\n"); + ok(rc == 0, "ImmGetOpenStatus failed\n"); + rc = ImmGetOpenStatus(threadinfo.u_himc); + ok (rc == 1 || broken(rc == 0), "ImmGetOpenStatus should return 1\n"); rc = ImmSetOpenStatus(otherHimc, FALSE); - todo_wine ok(rc == 0, "ImmSetOpenStatus should fail\n"); + ok(rc == 0, "ImmSetOpenStatus should fail\n"); rc = ImmGetOpenStatus(otherHimc); ok(rc == 0, "ImmGetOpenStatus failed\n"); @@ -517,8 +545,12 @@ static void test_ImmThreads(void) rc = ImmGetCompositionFontA(otherHimc, &lf); ok(rc != 0 || broken(rc == 0), "ImmGetCompositionFont failed\n"); + rc = ImmGetCompositionFontA(threadinfo.u_himc, &lf); + ok(rc != 0 || broken(rc == 0), "ImmGetCompositionFont user himc failed\n"); rc = ImmSetCompositionFontA(otherHimc, &lf); - todo_wine ok(rc == 0, "ImmSetCompositionFont should fail\n"); + ok(rc == 0, "ImmSetCompositionFont should fail\n"); + rc = ImmSetCompositionFontA(threadinfo.u_himc, &lf); + ok(rc == 0, "ImmSetCompositionFont should fail\n"); /* CompositionWindow */ rc = ImmSetCompositionWindow(himc, &cf); @@ -527,9 +559,13 @@ static void test_ImmThreads(void) ok(rc != 0, "ImmGetCompositionWindow failed\n"); rc = ImmSetCompositionWindow(otherHimc, &cf); - todo_wine ok(rc == 0, "ImmSetCompositionWindow should fail\n"); + ok(rc == 0, "ImmSetCompositionWindow should fail\n"); + rc = ImmSetCompositionWindow(threadinfo.u_himc, &cf); + ok(rc == 0, "ImmSetCompositionWindow should fail\n"); rc = ImmGetCompositionWindow(otherHimc, &cf); ok(rc != 0 || broken(rc == 0), "ImmGetCompositionWindow failed\n"); + rc = ImmGetCompositionWindow(threadinfo.u_himc, &cf); + ok(rc != 0 || broken(rc == 0), "ImmGetCompositionWindow failed\n"); /* ConversionStatus */ rc = ImmGetConversionStatus(himc, &status, &sentence); @@ -539,8 +575,12 @@ static void test_ImmThreads(void) rc = ImmGetConversionStatus(otherHimc, &status, &sentence); ok(rc != 0 || broken(rc == 0), "ImmGetConversionStatus failed\n"); + rc = ImmGetConversionStatus(threadinfo.u_himc, &status, &sentence); + ok(rc != 0 || broken(rc == 0), "ImmGetConversionStatus failed\n"); rc = ImmSetConversionStatus(otherHimc, status, sentence); - todo_wine ok(rc == 0, "ImmSetConversionStatus should fail\n"); + ok(rc == 0, "ImmSetConversionStatus should fail\n"); + rc = ImmSetConversionStatus(threadinfo.u_himc, status, sentence); + ok(rc == 0, "ImmSetConversionStatus should fail\n"); /* StatusWindowPos */ rc = ImmSetStatusWindowPos(himc, &pt); @@ -549,9 +589,25 @@ static void test_ImmThreads(void) ok(rc != 0, "ImmGetStatusWindowPos failed\n"); rc = ImmSetStatusWindowPos(otherHimc, &pt); - todo_wine ok(rc == 0, "ImmSetStatusWindowPos should fail\n"); + ok(rc == 0, "ImmSetStatusWindowPos should fail\n"); + rc = ImmSetStatusWindowPos(threadinfo.u_himc, &pt); + ok(rc == 0, "ImmSetStatusWindowPos should fail\n"); rc = ImmGetStatusWindowPos(otherHimc, &pt); ok(rc != 0 || broken(rc == 0), "ImmGetStatusWindowPos failed\n"); + rc = ImmGetStatusWindowPos(threadinfo.u_himc, &pt); + ok(rc != 0 || broken(rc == 0), "ImmGetStatusWindowPos failed\n"); + + h1 = ImmAssociateContext(threadinfo.hwnd, NULL); + ok (h1 == otherHimc, "ImmAssociateContext cross thread with NULL should work\n"); + h1 = ImmGetContext(threadinfo.hwnd); + ok (h1 == NULL, "CrossThread window context should be NULL\n"); + h1 = ImmAssociateContext(threadinfo.hwnd, h1); + ok (h1 == NULL, "Resetting cross thread context should fail\n"); + h1 = ImmGetContext(threadinfo.hwnd); + ok (h1 == NULL, "CrossThread window context should still be NULL\n"); + + rc = ImmDestroyContext(threadinfo.u_himc); + ok (rc == 0, "ImmDestroyContext Cross Thread should fail\n"); /* Candidate Window */ rc = ImmGetCandidateWindow(himc, 0, &cdf); @@ -566,9 +622,13 @@ static void test_ImmThreads(void) ok (rc == 1, "ImmGetCandidateWindow should succeed\n"); rc = ImmGetCandidateWindow(otherHimc, 0, &cdf); - todo_wine ok (rc == 0, "ImmGetCandidateWindow should fail\n"); + ok (rc == 0, "ImmGetCandidateWindow should fail\n"); rc = ImmSetCandidateWindow(otherHimc, &cdf); - todo_wine ok (rc == 0, "ImmSetCandidateWindow should fail\n"); + ok (rc == 0, "ImmSetCandidateWindow should fail\n"); + rc = ImmGetCandidateWindow(threadinfo.u_himc, 0, &cdf); + ok (rc == 1 || broken( rc == 0), "ImmGetCandidateWindow should succeed\n"); + rc = ImmSetCandidateWindow(threadinfo.u_himc, &cdf); + ok (rc == 0, "ImmSetCandidateWindow should fail\n"); ImmReleaseContext(threadinfo.hwnd,otherHimc); ImmReleaseContext(hwnd,himc); @@ -577,7 +637,7 @@ static void test_ImmThreads(void) TerminateThread(hThread, 1); himc = ImmGetContext(GetDesktopWindow()); - todo_wine ok(himc == NULL, "Should not be able to get himc from other process window\n"); + ok(himc == NULL, "Should not be able to get himc from other process window\n"); } static void test_ImmIsUIMessage(void) @@ -607,6 +667,14 @@ static void test_ImmIsUIMessage(void) { 0, FALSE } /* mark the end */ }; + UINT WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService"); + UINT WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions"); + UINT WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation"); + UINT WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest"); + UINT WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert"); + UINT WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition"); + UINT WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed"); + const struct test *test; BOOL ret; @@ -626,6 +694,21 @@ static void test_ImmIsUIMessage(void) else ok(!msg_spy_find_msg(test->msg), "Windows does not send 0x%x\n", test->msg); } + + ret = pImmIsUIMessageA(NULL, WM_MSIME_SERVICE, 0, 0); + ok(!ret, "ImmIsUIMessageA returned TRUE for WM_MSIME_SERVICE\n"); + ret = pImmIsUIMessageA(NULL, WM_MSIME_RECONVERTOPTIONS, 0, 0); + ok(!ret, "ImmIsUIMessageA returned TRUE for WM_MSIME_RECONVERTOPTIONS\n"); + ret = pImmIsUIMessageA(NULL, WM_MSIME_MOUSE, 0, 0); + ok(!ret, "ImmIsUIMessageA returned TRUE for WM_MSIME_MOUSE\n"); + ret = pImmIsUIMessageA(NULL, WM_MSIME_RECONVERTREQUEST, 0, 0); + ok(!ret, "ImmIsUIMessageA returned TRUE for WM_MSIME_RECONVERTREQUEST\n"); + ret = pImmIsUIMessageA(NULL, WM_MSIME_RECONVERT, 0, 0); + ok(!ret, "ImmIsUIMessageA returned TRUE for WM_MSIME_RECONVERT\n"); + ret = pImmIsUIMessageA(NULL, WM_MSIME_QUERYPOSITION, 0, 0); + ok(!ret, "ImmIsUIMessageA returned TRUE for WM_MSIME_QUERYPOSITION\n"); + ret = pImmIsUIMessageA(NULL, WM_MSIME_DOCUMENTFEED, 0, 0); + ok(!ret, "ImmIsUIMessageA returned TRUE for WM_MSIME_DOCUMENTFEED\n"); } static void test_ImmGetContext(void) @@ -699,10 +782,29 @@ static void test_ImmGetDescription(void) UnloadKeyboardLayout(hkl); } +static LRESULT (WINAPI *old_imm_wnd_proc)(HWND, UINT, WPARAM, LPARAM); +static LRESULT WINAPI imm_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + ok(msg != WM_DESTROY, "got WM_DESTROY message\n"); + return old_imm_wnd_proc(hwnd, msg, wparam, lparam); +} + +static HWND thread_ime_wnd; +static DWORD WINAPI test_ImmGetDefaultIMEWnd_thread(void *arg) +{ + CreateWindowA("static", "static", WS_POPUP, 0, 0, 1, 1, NULL, NULL, NULL, NULL); + + thread_ime_wnd = ImmGetDefaultIMEWnd(0); + ok(thread_ime_wnd != 0, "ImmGetDefaultIMEWnd returned NULL\n"); + old_imm_wnd_proc = (void*)SetWindowLongPtrW(thread_ime_wnd, GWLP_WNDPROC, (LONG_PTR)imm_wnd_proc); + return 0; +} + static void test_ImmDefaultHwnd(void) { HIMC imc1, imc2, imc3; HWND def1, def3; + HANDLE thread; HWND hwnd; hwnd = CreateWindowExA(WS_EX_CLIENTEDGE, "EDIT", "Wine imm32.dll test", @@ -730,6 +832,11 @@ static void test_ImmDefaultHwnd(void) ok(imc1 == imc3, "IME context should not change\n"); ImmSetOpenStatus(imc2, FALSE); + thread = CreateThread(NULL, 0, test_ImmGetDefaultIMEWnd_thread, NULL, 0, NULL); + WaitForSingleObject(thread, INFINITE); + ok(thread_ime_wnd != def1, "thread_ime_wnd == def1\n"); + ok(!IsWindow(thread_ime_wnd), "thread_ime_wnd was not destroyed\n"); + ImmReleaseContext(hwnd, imc1); ImmReleaseContext(hwnd, imc3); ImmDestroyContext(imc2);