[IMM32_APITEST] Add ImmEnumInputContext testcase (#4876)

Verify the IMM implementation. CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-11-14 18:01:42 +09:00 committed by GitHub
parent 2dddbd5c54
commit 73558102e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 169 additions and 0 deletions

View file

@ -5,6 +5,7 @@ list(APPEND SOURCE
clientimc.c
himc.c
imcc.c
ImmEnumInputContext.c
ImmGetImeInfoEx.c
ImmIsUIMessage.c
JapanImeConvTestA.c

View file

@ -0,0 +1,166 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Test for ImmEnumInputContext
* COPYRIGHT: Copyright 2022 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#include "precomp.h"
#include <windowsx.h>
static HWND s_hwnd = NULL;
static INT s_nCounter = 0;
static HIMC s_hImc1 = NULL;
static HIMC s_hImc2 = NULL;
static HIMC s_hImc3 = NULL;
static BOOL CALLBACK
ImcEnumProc(HIMC hImc, LPARAM lParam)
{
trace("s_nCounter %d\n", s_nCounter);
switch (s_nCounter)
{
case 0:
ok_long((LONG)lParam, 0xDEADBEEF);
ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
break;
case 1:
ok_long((LONG)lParam, 0xDEADFACE);
ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
break;
case 2:
ok_long((LONG)lParam, 0xDEADFACE);
ok(hImc == s_hImc2, "hImc was %p, s_hImc2 was %p\n", hImc, s_hImc1);
break;
case 3:
ok_long((LONG)lParam, 0xBEEFCAFE);
ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
break;
case 4:
ok_long((LONG)lParam, 0xAC1DFACE);
ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
break;
case 5:
ok_long((LONG)lParam, 0xDEADBEEF);
ok(hImc != s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
ok(hImc != s_hImc2, "hImc was %p, s_hImc2 was %p\n", hImc, s_hImc2);
break;
case 6:
ok_long((LONG)lParam, 0xBEEFCAFE);
ok(hImc != s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
ok(hImc != s_hImc2, "hImc was %p, s_hImc2 was %p\n", hImc, s_hImc2);
break;
case 7:
ok_long((LONG)lParam, 0xDEADFACE);
ok(hImc != s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
ok(hImc != s_hImc2, "hImc was %p, s_hImc2 was %p\n", hImc, s_hImc2);
break;
case 8:
ok_long((LONG)lParam, 0xDEADFACE);
ok(hImc == s_hImc3, "hImc was %p, s_hImc3 was %p\n", hImc, s_hImc3);
break;
default:
ok_long(0, 1);
ok_int(0, 1);
break;
}
++s_nCounter;
return TRUE;
}
static DWORD WINAPI AnotherThreadFunc(LPVOID arg)
{
ok_int(ImmEnumInputContext(0, ImcEnumProc, 0xDEADBEEF), TRUE);
ok_int(s_nCounter, 6);
ok_int(ImmEnumInputContext(GetCurrentThreadId(), ImcEnumProc, 0xBEEFCAFE), TRUE);
ok_int(s_nCounter, 7);
s_hImc3 = ImmCreateContext();
ok_int(ImmEnumInputContext(0, ImcEnumProc, 0xDEADFACE), TRUE);
ok_int(s_nCounter, 9);
ok_int(ImmDestroyContext(s_hImc3), TRUE);
s_hImc3 = NULL;
PostMessageW(s_hwnd, WM_COMMAND, IDYES, 0);
return 0;
}
/* WM_INITDIALOG */
static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
HANDLE hThread;
s_hwnd = hwnd;
s_nCounter = 0;
s_hImc1 = ImmGetContext(hwnd);
ok(s_hImc1 != NULL, "s_hImc1 was NULL\n");
ok_int(ImmEnumInputContext(0, ImcEnumProc, 0xDEADBEEF), TRUE);
ok_int(s_nCounter, 1);
ok_int(ImmEnumInputContext(1, ImcEnumProc, 0xFEEDF00D), FALSE);
ok_int(s_nCounter, 1);
s_hImc2 = ImmCreateContext();
ok(s_hImc2 != NULL, "s_hImc1 was NULL\n");
ok_int(ImmEnumInputContext(0, ImcEnumProc, 0xDEADFACE), TRUE);
ok_int(s_nCounter, 3);
ok_int(ImmDestroyContext(s_hImc2), TRUE);
s_hImc2 = NULL;
ok_int(ImmEnumInputContext(0, ImcEnumProc, 0xBEEFCAFE), TRUE);
ok_int(s_nCounter, 4);
ok_int(ImmEnumInputContext(GetCurrentThreadId(), ImcEnumProc, 0xAC1DFACE), TRUE);
ok_int(s_nCounter, 5);
hThread = CreateThread(NULL, 0, AnotherThreadFunc, NULL, 0, NULL);
if (hThread == NULL)
{
skip("hThread was NULL\n");
PostMessageW(hwnd, WM_COMMAND, IDNO, 0);
}
CloseHandle(hThread);
return TRUE;
}
/* WM_COMMAND */
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch (id)
{
case IDOK:
case IDCANCEL:
case IDYES:
EndDialog(hwnd, id);
break;
}
}
static INT_PTR CALLBACK
DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
HANDLE_MSG(hwnd, WM_INITDIALOG, OnInitDialog);
HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
}
return 0;
}
START_TEST(ImmEnumInputContext)
{
INT_PTR id;
id = DialogBoxW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(1), NULL, DialogProc);
if (id != IDYES)
{
skip("Tests skipped\n");
}
}

View file

@ -5,6 +5,7 @@
extern void func_clientimc(void);
extern void func_himc(void);
extern void func_imcc(void);
extern void func_ImmEnumInputContext(void);
extern void func_ImmGetImeInfoEx(void);
extern void func_ImmIsUIMessage(void);
extern void func_JapanImeConvTestA(void);
@ -15,6 +16,7 @@ const struct test winetest_testlist[] =
{ "clientimc", func_clientimc },
{ "himc", func_himc },
{ "imcc", func_imcc },
{ "ImmEnumInputContext", func_ImmEnumInputContext },
{ "ImmGetImeInfoEx", func_ImmGetImeInfoEx },
{ "ImmIsUIMessage", func_ImmIsUIMessage },
{ "JapanImeConvTestA", func_JapanImeConvTestA },