ReactOS  0.4.15-dev-5122-g72bdbdd
ImmGetImeInfoEx.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Test for ImmGetImeInfoEx
5  * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6  */
7 
8 #include "precomp.h"
9 
10 //#define DO_PRINT
11 
12 static VOID PrintInfoEx(PIMEINFOEX pInfoEx)
13 {
14 #ifdef DO_PRINT
15  trace("---\n");
16  trace("hkl: %p\n", pInfoEx->hkl);
17  trace("ImeInfo.dwPrivateDataSize: 0x%lX\n", pInfoEx->ImeInfo.dwPrivateDataSize);
18  trace("ImeInfo.fdwProperty: 0x%lX\n", pInfoEx->ImeInfo.fdwProperty);
19  trace("ImeInfo.fdwConversionCaps: 0x%lX\n", pInfoEx->ImeInfo.fdwConversionCaps);
20  trace("ImeInfo.fdwSentenceCaps: 0x%lX\n", pInfoEx->ImeInfo.fdwSentenceCaps);
21  trace("ImeInfo.fdwUICaps: 0x%lX\n", pInfoEx->ImeInfo.fdwUICaps);
22  trace("ImeInfo.fdwSCSCaps: 0x%lX\n", pInfoEx->ImeInfo.fdwSCSCaps);
23  trace("ImeInfo.fdwSelectCaps: 0x%lX\n", pInfoEx->ImeInfo.fdwSelectCaps);
24  trace("wszUIClass: '%ls'\n", pInfoEx->wszUIClass);
25  trace("fdwInitConvMode: 0x%lX\n", pInfoEx->fdwInitConvMode);
26  trace("fInitOpen: %d\n", pInfoEx->fInitOpen);
27  trace("fLoadFlag: %d\n", pInfoEx->fLoadFlag);
28  trace("dwProdVersion: 0x%lX\n", pInfoEx->dwProdVersion);
29  trace("dwImeWinVersion: 0x%lX\n", pInfoEx->dwImeWinVersion);
30  trace("wszImeDescription: '%ls'\n", pInfoEx->wszImeDescription);
31  trace("wszImeFile: '%ls'\n", pInfoEx->wszImeFile);
32  trace("fInitOpen: %d\n", pInfoEx->fInitOpen);
33 #endif
34 }
35 
37 
39 {
40  IMEINFOEX InfoEx;
41  BOOL ret, bMatch;
42  size_t ib;
44  HKL hKL = GetKeyboardLayout(0), hOldKL;
45 
46  HMODULE hImm32 = GetModuleHandleA("imm32");
47  FN_ImmGetImeInfoEx fnImmGetImeInfoEx =
48  (FN_ImmGetImeInfoEx)GetProcAddress(hImm32, "ImmGetImeInfoEx");
49  if (!fnImmGetImeInfoEx)
50  {
51  skip("ImmGetImeInfoEx not found\n");
52  return;
53  }
54 
55  if (!GetSystemMetrics(SM_IMMENABLED))
56  {
57  skip("IME is not available\n");
58  return;
59  }
60 
61  // ImeInfoExKeyboardLayout
62  hOldKL = hKL;
63  FillMemory(&InfoEx, sizeof(InfoEx), 0xCC);
64  InfoEx.wszUIClass[0] = InfoEx.wszImeFile[0] = 0;
65  ret = fnImmGetImeInfoEx(&InfoEx, ImeInfoExKeyboardLayout, &hKL);
66  PrintInfoEx(&InfoEx);
67  ok_int(ret, TRUE);
68  ok_long((DWORD)(DWORD_PTR)hOldKL, (DWORD)(DWORD_PTR)hKL);
69  if (IS_IME_HKL(InfoEx.hkl))
70  {
71  ok_long(LOWORD(InfoEx.hkl), LangID);
72  }
73  else
74  {
75  ok_int(LOWORD(InfoEx.hkl), LangID);
76  ok_int(HIWORD(InfoEx.hkl), LangID);
77  }
78  ok(InfoEx.ImeInfo.dwPrivateDataSize >= 4, "\n");
79  ok(InfoEx.wszUIClass[0] != 0, "wszUIClass was empty\n");
80  ok_long(InfoEx.dwImeWinVersion, 0x40000);
81  ok(InfoEx.wszImeFile[0] != 0, "wszImeFile was empty\n");
82  hKL = hOldKL;
83 
84  // ImeInfoExKeyboardLayoutTFS
85  hOldKL = hKL;
86  FillMemory(&InfoEx, sizeof(InfoEx), 0xCC);
87  InfoEx.wszUIClass[0] = InfoEx.wszImeFile[0] = 0;
88  ret = fnImmGetImeInfoEx(&InfoEx, ImeInfoExKeyboardLayoutTFS, &hKL);
89  PrintInfoEx(&InfoEx);
90  ok_int(ret, TRUE);
91  if (IS_IME_HKL(InfoEx.hkl))
92  {
93  ok_long(LOWORD(InfoEx.hkl), LangID);
94  }
95  else
96  {
97  ok_int(LOWORD(InfoEx.hkl), LangID);
98  ok_int(HIWORD(InfoEx.hkl), LangID);
99  }
100  ok(InfoEx.ImeInfo.dwPrivateDataSize >= 4, "\n");
101  ok(InfoEx.wszUIClass[0] != 0, "wszUIClass was empty\n");
102  ok_long(InfoEx.dwImeWinVersion, 0x40000);
103  ok(InfoEx.wszImeFile[0] != 0, "wszImeFile was empty\n");
104  hKL = hOldKL;
105 
106  // ImeInfoExImeWindow
107  hOldKL = hKL;
108  FillMemory(&InfoEx, sizeof(InfoEx), 0xCC);
109  ret = fnImmGetImeInfoEx(&InfoEx, ImeInfoExImeWindow, &hKL);
110  ok_int(ret, FALSE);
111  bMatch = TRUE;
112  for (ib = 0; ib < sizeof(InfoEx); ++ib)
113  {
114  if (((LPBYTE)&InfoEx)[ib] != 0xCC)
115  {
116  bMatch = FALSE;
117  break;
118  }
119  }
120  ok_int(bMatch, TRUE);
121 
122  // ImeInfoExImeFileName
123  hOldKL = hKL;
124  FillMemory(&InfoEx, sizeof(InfoEx), 0xCC);
125  InfoEx.wszUIClass[0] = InfoEx.wszImeFile[0] = 0;
126  ret = fnImmGetImeInfoEx(&InfoEx, ImeInfoExImeFileName, L"THISISTEST");
127  PrintInfoEx(&InfoEx);
128  ok_int(ret, FALSE);
129  ok(InfoEx.ImeInfo.dwPrivateDataSize >= 4, "\n");
130  ok_wstr(InfoEx.wszUIClass, L"");
131  ok_long(InfoEx.dwImeWinVersion, 0xCCCCCCCC);
132  ok_wstr(InfoEx.wszImeFile, L"THISISTEST");
133  hKL = hOldKL;
134 
135  // 4
136  hOldKL = hKL;
137  FillMemory(&InfoEx, sizeof(InfoEx), 0xCC);
138  ret = fnImmGetImeInfoEx(&InfoEx, 4, &hKL);
139  ok_int(ret, FALSE);
140  bMatch = TRUE;
141  for (ib = 0; ib < sizeof(InfoEx); ++ib)
142  {
143  if (((LPBYTE)&InfoEx)[ib] != 0xCC)
144  {
145  bMatch = FALSE;
146  break;
147  }
148  }
149  ok_int(bMatch, TRUE);
150 }
DWORD dwProdVersion
Definition: ntuser.h:1184
INT fInitOpen
Definition: ntuser.h:1182
#define TRUE
Definition: types.h:120
struct tagIMEINFOEX * PIMEINFOEX
BOOL WINAPI ImmGetImeInfoEx(PIMEINFOEX pImeInfoEx, IMEINFOEXCLASS SearchType, PVOID pvSearchKey)
Definition: ime.c:873
WORD LANGID
Definition: typedefs.h:81
static VOID PrintInfoEx(PIMEINFOEX pInfoEx)
#define ok_long(expression, result)
Definition: atltest.h:133
#define BOOL
Definition: nt_native.h:43
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
DWORD fdwUICaps
Definition: imm.h:161
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok_int(expression, result)
Definition: atltest.h:134
void * PVOID
Definition: retypes.h:9
DWORD fdwSelectCaps
Definition: imm.h:163
IMEINFOEXCLASS
Definition: ntuser.h:1195
#define trace
Definition: atltest.h:70
DWORD fdwProperty
Definition: imm.h:158
#define WINAPI
Definition: msvc.h:6
LANGID WINAPI GetSystemDefaultLangID(void)
Definition: lang.c:755
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
WCHAR wszUIClass[16]
Definition: ntuser.h:1180
DWORD fdwConversionCaps
Definition: imm.h:159
int ret
DWORD dwPrivateDataSize
Definition: imm.h:157
#define ok_wstr(x, y)
Definition: atltest.h:130
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
UINT_PTR HKL
Definition: msctf.idl:101
uint32_t DWORD_PTR
Definition: typedefs.h:65
WCHAR wszImeFile[80]
Definition: ntuser.h:1187
DWORD fdwSCSCaps
Definition: imm.h:162
#define IS_IME_HKL(hKL)
Definition: input.h:88
ULONG fdwInitConvMode
Definition: ntuser.h:1181
IMEINFO ImeInfo
Definition: ntuser.h:1179
BOOL(WINAPI * FN_ImmGetImeInfoEx)(PIMEINFOEX, IMEINFOEXCLASS, PVOID)
#define ok(value,...)
Definition: atltest.h:57
WCHAR wszImeDescription[50]
Definition: ntuser.h:1186
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
START_TEST(ImmGetImeInfoEx)
INT fLoadFlag
Definition: ntuser.h:1183
#define skip(...)
Definition: atltest.h:64
#define HIWORD(l)
Definition: typedefs.h:247
#define GetProcAddress(x, y)
Definition: compat.h:612
DWORD dwImeWinVersion
Definition: ntuser.h:1185
DWORD fdwSentenceCaps
Definition: imm.h:160
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1075
#define LOWORD(l)
Definition: pedump.c:82