1d6a0299eSKatayama Hirofumi MZ /* 2d6a0299eSKatayama Hirofumi MZ * PROJECT: ReactOS api tests 3d6a0299eSKatayama Hirofumi MZ * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4d6a0299eSKatayama Hirofumi MZ * PURPOSE: Test for imm32 HIMC 5d6a0299eSKatayama Hirofumi MZ * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) 6d6a0299eSKatayama Hirofumi MZ */ 7d6a0299eSKatayama Hirofumi MZ 8d6a0299eSKatayama Hirofumi MZ #include "precomp.h" 9d6a0299eSKatayama Hirofumi MZ 10*3820744aSKatayama Hirofumi MZ static void Test1(void) 11d6a0299eSKatayama Hirofumi MZ { 12d6a0299eSKatayama Hirofumi MZ DWORD style; 13d6a0299eSKatayama Hirofumi MZ HWND hwndEdit, hwndStatic; 14d6a0299eSKatayama Hirofumi MZ HIMC hNewIMC, hOldIMC, hIMC, hIMC1, hIMC2; 15d6a0299eSKatayama Hirofumi MZ LPINPUTCONTEXT pIC; 16d6a0299eSKatayama Hirofumi MZ 17d6a0299eSKatayama Hirofumi MZ /* ImmCreateContext/ImmDestroyContext and ImmLockIMC/ImmUnlockIMC */ 18d6a0299eSKatayama Hirofumi MZ hNewIMC = ImmCreateContext(); 197c3902e5SThomas Faber ok(hNewIMC != NULL, "ImmCreateContext failed\n"); 20d6a0299eSKatayama Hirofumi MZ pIC = ImmLockIMC(hNewIMC); 217c3902e5SThomas Faber ok(pIC == NULL, "ImmLockIMC succeeded unexpectedly\n"); 22d6a0299eSKatayama Hirofumi MZ ImmUnlockIMC(hNewIMC); 237c3902e5SThomas Faber ok(ImmDestroyContext(hNewIMC), "ImmDestroyContext failed\n"); 24d6a0299eSKatayama Hirofumi MZ 25d6a0299eSKatayama Hirofumi MZ /* ImmGetContext against NULL */ 26d6a0299eSKatayama Hirofumi MZ hIMC = ImmGetContext(NULL); 277c3902e5SThomas Faber ok(hIMC == NULL, "ImmGetContext failed\n"); 28d6a0299eSKatayama Hirofumi MZ 29d6a0299eSKatayama Hirofumi MZ /* Create EDIT control */ 30d6a0299eSKatayama Hirofumi MZ style = ES_MULTILINE | ES_LEFT; 31d6a0299eSKatayama Hirofumi MZ hwndEdit = CreateWindowW(L"EDIT", NULL, style, 0, 0, 100, 20, NULL, NULL, 32d6a0299eSKatayama Hirofumi MZ GetModuleHandleW(NULL), NULL); 337c3902e5SThomas Faber ok(hwndEdit != NULL, "CreateWindowW failed\n"); 34d6a0299eSKatayama Hirofumi MZ 35d6a0299eSKatayama Hirofumi MZ /* Create STATIC control */ 36d6a0299eSKatayama Hirofumi MZ style = SS_LEFT; 37d6a0299eSKatayama Hirofumi MZ hwndStatic = CreateWindowW(L"STATIC", NULL, style, 0, 30, 100, 20, NULL, NULL, 38d6a0299eSKatayama Hirofumi MZ GetModuleHandleW(NULL), NULL); 397c3902e5SThomas Faber ok(hwndStatic != NULL, "CreateWindowW failed\n"); 40d6a0299eSKatayama Hirofumi MZ 41d6a0299eSKatayama Hirofumi MZ /* ImmGetContext/ImmReleaseContext and ImmLockIMC/ImmUnlockIMC */ 42d6a0299eSKatayama Hirofumi MZ hIMC1 = hIMC = ImmGetContext(hwndEdit); 437c3902e5SThomas Faber ok(hIMC != NULL, "ImmGetContext failed\n"); 44d6a0299eSKatayama Hirofumi MZ pIC = ImmLockIMC(hIMC); 457c3902e5SThomas Faber ok(pIC != NULL, "ImmLockIMC failed\n"); 467c3902e5SThomas Faber if (pIC != NULL) 477c3902e5SThomas Faber { 487c3902e5SThomas Faber ok(pIC->hWnd == NULL, "pIC->hWnd = %p\n", pIC->hWnd); 497c3902e5SThomas Faber ok(!pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen); 507c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n"); 517c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n"); 527c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n"); 537c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n"); 547c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n"); 557c3902e5SThomas Faber } 567c3902e5SThomas Faber else 577c3902e5SThomas Faber { 587c3902e5SThomas Faber skip("No pIC\n"); 597c3902e5SThomas Faber } 60d6a0299eSKatayama Hirofumi MZ ImmUnlockIMC(hNewIMC); 61d6a0299eSKatayama Hirofumi MZ SetFocus(hwndEdit); 62d6a0299eSKatayama Hirofumi MZ pIC = ImmLockIMC(hIMC); 637c3902e5SThomas Faber ok(pIC != NULL, "ImmLockIMC failed\n"); 647c3902e5SThomas Faber if (pIC != NULL) 657c3902e5SThomas Faber { 667c3902e5SThomas Faber ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit); 677c3902e5SThomas Faber ok(!pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen); 687c3902e5SThomas Faber } 697c3902e5SThomas Faber else 707c3902e5SThomas Faber { 717c3902e5SThomas Faber skip("No pIC\n"); 727c3902e5SThomas Faber } 73d6a0299eSKatayama Hirofumi MZ ImmUnlockIMC(hNewIMC); 74d6a0299eSKatayama Hirofumi MZ SetFocus(NULL); 75d6a0299eSKatayama Hirofumi MZ pIC = ImmLockIMC(hIMC); 767c3902e5SThomas Faber ok(pIC != NULL, "ImmLockIMC failed\n"); 777c3902e5SThomas Faber if (pIC != NULL) 787c3902e5SThomas Faber { 797c3902e5SThomas Faber ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit); 807c3902e5SThomas Faber } 817c3902e5SThomas Faber else 827c3902e5SThomas Faber { 837c3902e5SThomas Faber skip("No pIC\n"); 847c3902e5SThomas Faber } 85d6a0299eSKatayama Hirofumi MZ ImmUnlockIMC(hNewIMC); 867c3902e5SThomas Faber ok(ImmSetOpenStatus(hIMC, TRUE), "ImmSetOpenStatus failed\n"); 87d6a0299eSKatayama Hirofumi MZ pIC = ImmLockIMC(hIMC); 887c3902e5SThomas Faber ok(pIC != NULL, "ImmLockIMC failed\n"); 897c3902e5SThomas Faber if (pIC != NULL) 907c3902e5SThomas Faber { 917c3902e5SThomas Faber ok(pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen); 927c3902e5SThomas Faber } 937c3902e5SThomas Faber else 947c3902e5SThomas Faber { 957c3902e5SThomas Faber skip("No pIC\n"); 967c3902e5SThomas Faber } 97d6a0299eSKatayama Hirofumi MZ ImmUnlockIMC(hNewIMC); 987c3902e5SThomas Faber ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n"); 99d6a0299eSKatayama Hirofumi MZ 100d6a0299eSKatayama Hirofumi MZ hIMC2 = hIMC = ImmGetContext(hwndStatic); 1017c3902e5SThomas Faber ok(hIMC != NULL, "ImmGetContext failed\n"); 102d6a0299eSKatayama Hirofumi MZ pIC = ImmLockIMC(hIMC); 1037c3902e5SThomas Faber ok(pIC != NULL, "ImmLockIMC failed\n"); 1047c3902e5SThomas Faber if (pIC != NULL) 1057c3902e5SThomas Faber { 1067c3902e5SThomas Faber ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit); 1077c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n"); 1087c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n"); 1097c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n"); 1107c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n"); 1117c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n"); 1127c3902e5SThomas Faber } 1137c3902e5SThomas Faber else 1147c3902e5SThomas Faber { 1157c3902e5SThomas Faber skip("No pIC\n"); 1167c3902e5SThomas Faber } 117d6a0299eSKatayama Hirofumi MZ ImmUnlockIMC(hNewIMC); 1187c3902e5SThomas Faber ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n"); 119d6a0299eSKatayama Hirofumi MZ 1207c3902e5SThomas Faber ok(hIMC1 == hIMC2, "hIMC1 = %p, expected %p\n", hIMC1, hIMC2); 121d6a0299eSKatayama Hirofumi MZ 122d6a0299eSKatayama Hirofumi MZ /* ImmAssociateContext */ 123d6a0299eSKatayama Hirofumi MZ hNewIMC = ImmCreateContext(); 1247c3902e5SThomas Faber ok(hNewIMC != NULL, "ImmCreateContext failed \n"); 125d6a0299eSKatayama Hirofumi MZ pIC = ImmLockIMC(hNewIMC); 1267c3902e5SThomas Faber ok(pIC != NULL, "ImmLockIMC failed\n"); 127d6a0299eSKatayama Hirofumi MZ ImmUnlockIMC(hNewIMC); 128d6a0299eSKatayama Hirofumi MZ hOldIMC = ImmAssociateContext(hwndEdit, hNewIMC); 1297c3902e5SThomas Faber ok(hNewIMC != hOldIMC, "hNewIMC = %p, expected not %p\n", hNewIMC, hOldIMC); 130d6a0299eSKatayama Hirofumi MZ hIMC = ImmGetContext(hwndEdit); 1317c3902e5SThomas Faber ok(hIMC == hNewIMC, "hIMC = %p, expected %p\n", hIMC, hNewIMC); 1327c3902e5SThomas Faber ok(hIMC != hOldIMC, "hIMC = %p, expected not %p\n", hIMC, hOldIMC); 133d6a0299eSKatayama Hirofumi MZ pIC = ImmLockIMC(hNewIMC); 1347c3902e5SThomas Faber ok(pIC != NULL, "ImmLockIMC failed\n"); 1357c3902e5SThomas Faber if (pIC != NULL) 1367c3902e5SThomas Faber { 1377c3902e5SThomas Faber ok(pIC->hWnd == NULL, "pIC->hWnd = %p\n", pIC->hWnd); 1387c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n"); 1397c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n"); 1407c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n"); 1417c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n"); 1427c3902e5SThomas Faber ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n"); 1437c3902e5SThomas Faber } 1447c3902e5SThomas Faber else 1457c3902e5SThomas Faber { 1467c3902e5SThomas Faber skip("No pIC\n"); 1477c3902e5SThomas Faber } 148d6a0299eSKatayama Hirofumi MZ ImmUnlockIMC(hNewIMC); 1497c3902e5SThomas Faber ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n"); 1507c3902e5SThomas Faber ok(ImmDestroyContext(hNewIMC), "ImmDestroyContext failed\n"); 151d6a0299eSKatayama Hirofumi MZ 152d6a0299eSKatayama Hirofumi MZ DestroyWindow(hwndEdit); 153d6a0299eSKatayama Hirofumi MZ DestroyWindow(hwndStatic); 154d6a0299eSKatayama Hirofumi MZ } 155*3820744aSKatayama Hirofumi MZ 156*3820744aSKatayama Hirofumi MZ static void Test2(void) 157*3820744aSKatayama Hirofumi MZ { 158*3820744aSKatayama Hirofumi MZ static const LPCSTR apszClasses[] = 159*3820744aSKatayama Hirofumi MZ { 160*3820744aSKatayama Hirofumi MZ "BUTTON", 161*3820744aSKatayama Hirofumi MZ "COMBOBOX", 162*3820744aSKatayama Hirofumi MZ "EDIT", 163*3820744aSKatayama Hirofumi MZ "LISTBOX", 164*3820744aSKatayama Hirofumi MZ "SCROLLBAR", 165*3820744aSKatayama Hirofumi MZ "STATIC" 166*3820744aSKatayama Hirofumi MZ }; 167*3820744aSKatayama Hirofumi MZ size_t i; 168*3820744aSKatayama Hirofumi MZ HIMC hIMC; 169*3820744aSKatayama Hirofumi MZ HWND hwnd; 170*3820744aSKatayama Hirofumi MZ 171*3820744aSKatayama Hirofumi MZ for (i = 0; i < _countof(apszClasses); ++i) 172*3820744aSKatayama Hirofumi MZ { 173*3820744aSKatayama Hirofumi MZ LPCSTR pszClass = apszClasses[i]; 174*3820744aSKatayama Hirofumi MZ hwnd = CreateWindowA(pszClass, NULL, WS_VISIBLE, 0, 0, 0, 0, NULL, NULL, 175*3820744aSKatayama Hirofumi MZ GetModuleHandle(NULL), NULL); 176*3820744aSKatayama Hirofumi MZ ok(hwnd != NULL, "CreateWindow failed\n"); 177*3820744aSKatayama Hirofumi MZ 178*3820744aSKatayama Hirofumi MZ hIMC = ImmGetContext(hwnd); 179*3820744aSKatayama Hirofumi MZ 180*3820744aSKatayama Hirofumi MZ if (lstrcmpiA(pszClass, "BUTTON") == 0) 181*3820744aSKatayama Hirofumi MZ ok(hIMC == NULL, "hIMC was %p\n", hIMC); 182*3820744aSKatayama Hirofumi MZ else 183*3820744aSKatayama Hirofumi MZ ok(hIMC != NULL, "hIMC was NULL\n"); 184*3820744aSKatayama Hirofumi MZ 185*3820744aSKatayama Hirofumi MZ ImmReleaseContext(hwnd, hIMC); 186*3820744aSKatayama Hirofumi MZ 187*3820744aSKatayama Hirofumi MZ DestroyWindow(hwnd); 188*3820744aSKatayama Hirofumi MZ } 189*3820744aSKatayama Hirofumi MZ } 190*3820744aSKatayama Hirofumi MZ 191*3820744aSKatayama Hirofumi MZ START_TEST(himc) 192*3820744aSKatayama Hirofumi MZ { 193*3820744aSKatayama Hirofumi MZ Test1(); 194*3820744aSKatayama Hirofumi MZ Test2(); 195*3820744aSKatayama Hirofumi MZ } 196