2021-09-21 03:26:43 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
|
|
|
* PURPOSE: Test for imm32 HIMC
|
|
|
|
* COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
START_TEST(himc)
|
|
|
|
{
|
|
|
|
DWORD style;
|
|
|
|
HWND hwndEdit, hwndStatic;
|
|
|
|
HIMC hNewIMC, hOldIMC, hIMC, hIMC1, hIMC2;
|
|
|
|
LPINPUTCONTEXT pIC;
|
|
|
|
|
|
|
|
/* ImmCreateContext/ImmDestroyContext and ImmLockIMC/ImmUnlockIMC */
|
|
|
|
hNewIMC = ImmCreateContext();
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hNewIMC != NULL, "ImmCreateContext failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
pIC = ImmLockIMC(hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(pIC == NULL, "ImmLockIMC succeeded unexpectedly\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
ImmUnlockIMC(hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(ImmDestroyContext(hNewIMC), "ImmDestroyContext failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
|
|
|
|
/* ImmGetContext against NULL */
|
|
|
|
hIMC = ImmGetContext(NULL);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hIMC == NULL, "ImmGetContext failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
|
|
|
|
/* Create EDIT control */
|
|
|
|
style = ES_MULTILINE | ES_LEFT;
|
|
|
|
hwndEdit = CreateWindowW(L"EDIT", NULL, style, 0, 0, 100, 20, NULL, NULL,
|
|
|
|
GetModuleHandleW(NULL), NULL);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hwndEdit != NULL, "CreateWindowW failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
|
|
|
|
/* Create STATIC control */
|
|
|
|
style = SS_LEFT;
|
|
|
|
hwndStatic = CreateWindowW(L"STATIC", NULL, style, 0, 30, 100, 20, NULL, NULL,
|
|
|
|
GetModuleHandleW(NULL), NULL);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hwndStatic != NULL, "CreateWindowW failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
|
|
|
|
/* ImmGetContext/ImmReleaseContext and ImmLockIMC/ImmUnlockIMC */
|
|
|
|
hIMC1 = hIMC = ImmGetContext(hwndEdit);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hIMC != NULL, "ImmGetContext failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
pIC = ImmLockIMC(hIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(pIC != NULL, "ImmLockIMC failed\n");
|
|
|
|
if (pIC != NULL)
|
|
|
|
{
|
|
|
|
ok(pIC->hWnd == NULL, "pIC->hWnd = %p\n", pIC->hWnd);
|
|
|
|
ok(!pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen);
|
|
|
|
ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("No pIC\n");
|
|
|
|
}
|
2021-09-21 03:26:43 +00:00
|
|
|
ImmUnlockIMC(hNewIMC);
|
|
|
|
SetFocus(hwndEdit);
|
|
|
|
pIC = ImmLockIMC(hIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(pIC != NULL, "ImmLockIMC failed\n");
|
|
|
|
if (pIC != NULL)
|
|
|
|
{
|
|
|
|
ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit);
|
|
|
|
ok(!pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("No pIC\n");
|
|
|
|
}
|
2021-09-21 03:26:43 +00:00
|
|
|
ImmUnlockIMC(hNewIMC);
|
|
|
|
SetFocus(NULL);
|
|
|
|
pIC = ImmLockIMC(hIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(pIC != NULL, "ImmLockIMC failed\n");
|
|
|
|
if (pIC != NULL)
|
|
|
|
{
|
|
|
|
ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("No pIC\n");
|
|
|
|
}
|
2021-09-21 03:26:43 +00:00
|
|
|
ImmUnlockIMC(hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(ImmSetOpenStatus(hIMC, TRUE), "ImmSetOpenStatus failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
pIC = ImmLockIMC(hIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(pIC != NULL, "ImmLockIMC failed\n");
|
|
|
|
if (pIC != NULL)
|
|
|
|
{
|
|
|
|
ok(pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("No pIC\n");
|
|
|
|
}
|
2021-09-21 03:26:43 +00:00
|
|
|
ImmUnlockIMC(hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
|
|
|
|
hIMC2 = hIMC = ImmGetContext(hwndStatic);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hIMC != NULL, "ImmGetContext failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
pIC = ImmLockIMC(hIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(pIC != NULL, "ImmLockIMC failed\n");
|
|
|
|
if (pIC != NULL)
|
|
|
|
{
|
|
|
|
ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit);
|
|
|
|
ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("No pIC\n");
|
|
|
|
}
|
2021-09-21 03:26:43 +00:00
|
|
|
ImmUnlockIMC(hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hIMC1 == hIMC2, "hIMC1 = %p, expected %p\n", hIMC1, hIMC2);
|
2021-09-21 03:26:43 +00:00
|
|
|
|
|
|
|
/* ImmAssociateContext */
|
|
|
|
hNewIMC = ImmCreateContext();
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hNewIMC != NULL, "ImmCreateContext failed \n");
|
2021-09-21 03:26:43 +00:00
|
|
|
pIC = ImmLockIMC(hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(pIC != NULL, "ImmLockIMC failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
ImmUnlockIMC(hNewIMC);
|
|
|
|
hOldIMC = ImmAssociateContext(hwndEdit, hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hNewIMC != hOldIMC, "hNewIMC = %p, expected not %p\n", hNewIMC, hOldIMC);
|
2021-09-21 03:26:43 +00:00
|
|
|
hIMC = ImmGetContext(hwndEdit);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(hIMC == hNewIMC, "hIMC = %p, expected %p\n", hIMC, hNewIMC);
|
|
|
|
ok(hIMC != hOldIMC, "hIMC = %p, expected not %p\n", hIMC, hOldIMC);
|
2021-09-21 03:26:43 +00:00
|
|
|
pIC = ImmLockIMC(hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(pIC != NULL, "ImmLockIMC failed\n");
|
|
|
|
if (pIC != NULL)
|
|
|
|
{
|
|
|
|
ok(pIC->hWnd == NULL, "pIC->hWnd = %p\n", pIC->hWnd);
|
|
|
|
ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n");
|
|
|
|
ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("No pIC\n");
|
|
|
|
}
|
2021-09-21 03:26:43 +00:00
|
|
|
ImmUnlockIMC(hNewIMC);
|
2022-01-02 17:54:45 +00:00
|
|
|
ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n");
|
|
|
|
ok(ImmDestroyContext(hNewIMC), "ImmDestroyContext failed\n");
|
2021-09-21 03:26:43 +00:00
|
|
|
|
|
|
|
DestroyWindow(hwndEdit);
|
|
|
|
DestroyWindow(hwndStatic);
|
|
|
|
}
|