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 imm32 ImmLockClientImc/ImmUnlockClientImc
5  * COPYRIGHT:   Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6  */
7 
8 #include "precomp.h"
9 
10 #if 0
11 static void DumpBinary(LPCVOID pv, size_t cb)
12 {
13     const BYTE *pb = pv;
14     while (cb--)
15     {
16         printf("%02X ", (BYTE)*pb++);
17     }
18     printf("\n");
19 }
20 #endif
21 
22 START_TEST(clientimc)
23 {
24     DWORD dwCode;
25     CLIENTIMC *pClientImc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLIENTIMC));
26 
27     pClientImc->hInputContext = (HANDLE)ImmCreateIMCC(4);
28     pClientImc->cLockObj = 2;
29     pClientImc->dwFlags = 0x40;
30     RtlInitializeCriticalSection(&pClientImc->cs);
31     ok_long(ImmGetIMCCSize((HIMCC)pClientImc->hInputContext), 4);
32 
33     ImmUnlockClientImc(pClientImc);
34     ok_long(pClientImc->cLockObj, 1);
35     ok_long(ImmGetIMCCSize((HIMCC)pClientImc->hInputContext), 4);
36 
37     dwCode = 0;
38     _SEH2_TRY
39     {
40         ImmUnlockClientImc(pClientImc);
41     }
42     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
43     {
44         dwCode = _SEH2_GetExceptionCode();
45     }
46     _SEH2_END;
47     ok_long(dwCode, STATUS_ACCESS_VIOLATION);
48 
49     ok_long(pClientImc->cLockObj, 0);
50     ok_long(ImmGetIMCCSize((HIMCC)pClientImc->hInputContext), 0);
51 
52     HeapFree(GetProcessHeap(), 0, pClientImc);
53 }
54