ReactOS 0.4.15-dev-8227-g32d615f
ImmEnumInputContext.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 ImmEnumInputContext
5 * COPYRIGHT: Copyright 2022 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "precomp.h"
9#include <windowsx.h>
10
11static HWND s_hwnd = NULL;
12static INT s_nCounter = 0;
13static HIMC s_hImc1 = NULL;
14static HIMC s_hImc2 = NULL;
15static HIMC s_hImc3 = NULL;
16static HIMC s_hImc4 = NULL;
17
18static BOOL CALLBACK
20{
21 trace("s_nCounter %d\n", s_nCounter);
22 switch (s_nCounter)
23 {
24 case 0:
25 ok_long((LONG)lParam, 0xDEADBEEF);
26 ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
27 break;
28 case 1:
29 ok_long((LONG)lParam, 0xDEADFACE);
30 ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
31 break;
32 case 2:
33 ok_long((LONG)lParam, 0xDEADFACE);
34 ok(hImc == s_hImc2, "hImc was %p, s_hImc2 was %p\n", hImc, s_hImc1);
35 break;
36 case 3:
37 ok_long((LONG)lParam, 0xBEEFCAFE);
38 ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
39 break;
40 case 4:
41 ok_long((LONG)lParam, 0xAC1DFACE);
42 ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
43 break;
44 case 5:
45 ok_long((LONG)lParam, 0xDEADBEEF);
46 s_hImc3 = hImc;
47 ok(hImc != s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
48 break;
49 case 6:
50 ok_long((LONG)lParam, 0xBEEFCAFE);
51 ok(hImc == s_hImc3, "hImc was %p, s_hImc3 was %p\n", hImc, s_hImc3);
52 break;
53 case 7:
54 ok_long((LONG)lParam, 0xDEADFACE);
55 ok(hImc == s_hImc3, "hImc was %p, s_hImc3 was %p\n", hImc, s_hImc3);
56 break;
57 case 8:
58 ok_long((LONG)lParam, 0xDEADFACE);
59 ok(hImc == s_hImc4, "hImc was %p, s_hImc4 was %p\n", hImc, s_hImc4);
60 break;
61 case 9:
62 ok_long((LONG)lParam, 0xFEEDF00D);
63 ok(hImc == s_hImc3, "hImc was %p, s_hImc3 was %p\n", hImc, s_hImc3);
64 break;
65 case 10:
66 ok_long((LONG)lParam, 0xFEEDF00D);
67 ok(hImc == s_hImc1, "hImc was %p, s_hImc1 was %p\n", hImc, s_hImc1);
68 break;
69 default:
70 ok_long(0, 1);
71 ok_int(0, 1);
72 break;
73 }
74 ++s_nCounter;
75 return TRUE;
76}
77
79{
82
85
87
90
92 s_hImc4 = NULL;
93
95 ok_int(s_nCounter, 11);
96
98 return 0;
99}
100
101/* WM_INITDIALOG */
103{
105
106 s_hwnd = hwnd;
107 s_nCounter = 0;
108
110 ok(s_hImc1 != NULL, "s_hImc1 was NULL\n");
111
112 ok_int(ImmEnumInputContext(0, ImcEnumProc, 0xDEADBEEF), TRUE);
113 ok_int(s_nCounter, 1);
114
116 ok_int(s_nCounter, 1);
117
119 ok(s_hImc2 != NULL, "s_hImc1 was NULL\n");
120
121 ok_int(ImmEnumInputContext(0, ImcEnumProc, 0xDEADFACE), TRUE);
122 ok_int(s_nCounter, 3);
123
125 s_hImc2 = NULL;
126
127 ok_int(ImmEnumInputContext(0, ImcEnumProc, 0xBEEFCAFE), TRUE);
128 ok_int(s_nCounter, 4);
129
131 ok_int(s_nCounter, 5);
132
134 if (hThread == NULL)
135 {
136 skip("hThread was NULL\n");
138 }
140
141 return TRUE;
142}
143
144/* WM_COMMAND */
145static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
146{
147 switch (id)
148 {
149 case IDOK:
150 case IDCANCEL:
151 case IDYES:
152 EndDialog(hwnd, id);
153 break;
154 }
155}
156
157static INT_PTR CALLBACK
159{
160 switch (uMsg)
161 {
164 }
165 return 0;
166}
167
169{
170 INT_PTR id;
172 if (id != IDYES)
173 {
174 skip("Tests skipped\n");
175 }
176}
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static HWND s_hwnd
static BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
static HIMC s_hImc1
static BOOL CALLBACK ImcEnumProc(HIMC hImc, LPARAM lParam)
static DWORD WINAPI AnotherThreadFunc(LPVOID arg)
static INT s_nCounter
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
static HIMC s_hImc3
static HIMC s_hImc4
static HIMC s_hImc2
#define ok_long(expression, result)
Definition: atltest.h:133
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
DWORD HIMC
Definition: dimm.idl:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define CALLBACK
Definition: compat.h:35
HIMC WINAPI ImmCreateContext(void)
Definition: imm.c:590
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1044
BOOL WINAPI ImmDestroyContext(HIMC hIMC)
Definition: imm.c:915
BOOL WINAPI ImmEnumInputContext(DWORD dwThreadId, IMCENUMPROC lpfn, LPARAM lParam)
Definition: imm.c:1096
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint id
Definition: glext.h:5910
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
long LONG
Definition: pedump.c:60
int32_t INT_PTR
Definition: typedefs.h:64
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:322
#define IDCANCEL
Definition: winuser.h:831
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4399
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
#define IDNO
Definition: winuser.h:836
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDYES
Definition: winuser.h:835
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)