reactos/modules/rostests/apitests/imm32/himc.c

155 lines
5.3 KiB
C
Raw Normal View History

/*
* 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");
pIC = ImmLockIMC(hNewIMC);
2022-01-02 17:54:45 +00:00
ok(pIC == NULL, "ImmLockIMC succeeded unexpectedly\n");
ImmUnlockIMC(hNewIMC);
2022-01-02 17:54:45 +00:00
ok(ImmDestroyContext(hNewIMC), "ImmDestroyContext failed\n");
/* ImmGetContext against NULL */
hIMC = ImmGetContext(NULL);
2022-01-02 17:54:45 +00:00
ok(hIMC == NULL, "ImmGetContext failed\n");
/* 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");
/* 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");
/* ImmGetContext/ImmReleaseContext and ImmLockIMC/ImmUnlockIMC */
hIMC1 = hIMC = ImmGetContext(hwndEdit);
2022-01-02 17:54:45 +00:00
ok(hIMC != NULL, "ImmGetContext failed\n");
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");
}
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");
}
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");
}
ImmUnlockIMC(hNewIMC);
2022-01-02 17:54:45 +00:00
ok(ImmSetOpenStatus(hIMC, TRUE), "ImmSetOpenStatus failed\n");
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");
}
ImmUnlockIMC(hNewIMC);
2022-01-02 17:54:45 +00:00
ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n");
hIMC2 = hIMC = ImmGetContext(hwndStatic);
2022-01-02 17:54:45 +00:00
ok(hIMC != NULL, "ImmGetContext failed\n");
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");
}
ImmUnlockIMC(hNewIMC);
2022-01-02 17:54:45 +00:00
ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n");
2022-01-02 17:54:45 +00:00
ok(hIMC1 == hIMC2, "hIMC1 = %p, expected %p\n", hIMC1, hIMC2);
/* ImmAssociateContext */
hNewIMC = ImmCreateContext();
2022-01-02 17:54:45 +00:00
ok(hNewIMC != NULL, "ImmCreateContext failed \n");
pIC = ImmLockIMC(hNewIMC);
2022-01-02 17:54:45 +00:00
ok(pIC != NULL, "ImmLockIMC failed\n");
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);
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);
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");
}
ImmUnlockIMC(hNewIMC);
2022-01-02 17:54:45 +00:00
ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n");
ok(ImmDestroyContext(hNewIMC), "ImmDestroyContext failed\n");
DestroyWindow(hwndEdit);
DestroyWindow(hwndStatic);
}