#define NUMELEMS(array) (sizeof((array))/sizeof((array)[0]))
+static BOOL (WINAPI *pImmAssociateContextEx)(HWND,HIMC,DWORD);
+
/*
* msgspy - record and analyse message traces sent to a certain window
*/
}
static CWPSTRUCT* msg_spy_find_msg(UINT message) {
- int i;
+ UINT i;
msg_spy_pump_msg_queue();
msg_spy_flush_msgs();
}
-static void msg_spy_cleanup() {
+static void msg_spy_cleanup(void) {
if (msg_spy.get_msg_hook)
UnhookWindowsHookEx(msg_spy.get_msg_hook);
if (msg_spy.call_wnd_proc_hook)
static const char wndcls[] = "winetest_imm32_wndcls";
static HWND hwnd;
-static int init(void) {
+static BOOL init(void) {
WNDCLASSEX wc;
HIMC imc;
+ HMODULE hmod;
+
+ hmod = GetModuleHandleA("imm32.dll");
+ pImmAssociateContextEx = (void*)GetProcAddress(hmod, "ImmAssociateContextEx");
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassExA(&wc))
- return 0;
+ return FALSE;
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, wndcls, "Wine imm32.dll test",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
240, 120, NULL, NULL, GetModuleHandle(0), NULL);
if (!hwnd)
- return 0;
+ return FALSE;
imc = ImmGetContext(hwnd);
if (!imc)
{
win_skip("IME support not implemented\n");
- return 0;
+ return FALSE;
}
ImmReleaseContext(hwnd, imc);
msg_spy_init(hwnd);
- return 1;
+ return TRUE;
}
static void cleanup(void) {
imc = ImmGetContext(hwnd);
msg_spy_flush_msgs();
- todo_wine
- {
- ok(!ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0), "Canceling an "
- "empty composition string should fail.\n");
- }
+ ret = ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
+ ok(broken(!ret) ||
+ ret, /* Vista+ */
+ "Canceling an empty composition string should succeed.\n");
ok(!msg_spy_find_msg(WM_IME_COMPOSITION), "Windows does not post "
"WM_IME_COMPOSITION in response to NI_COMPOSITIONSTR / CPS_CANCEL, if "
"the composition string being canceled is empty.\n");
/* behavior differs between win9x and NT */
ret = ImmGetCompositionString(imc, GCS_COMPSTR, resstr, sizeof(resstr));
- ok(ret || !ret, "You'll never read this.\n");
+ ok(!ret, "After being cancelled the composition string is empty.\n");
msg_spy_flush_msgs();
- todo_wine
- {
- ok(!ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0), "Canceling an "
- "empty composition string should fail.\n");
- }
+ ret = ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
+ ok(broken(!ret) ||
+ ret, /* Vista+ */
+ "Canceling an empty composition string should succeed.\n");
ok(!msg_spy_find_msg(WM_IME_COMPOSITION), "Windows does not post "
"WM_IME_COMPOSITION in response to NI_COMPOSITIONSTR / CPS_CANCEL, if "
"the composition string being canceled is empty.\n");
return;
ret = ImmSetCompositionStringW(imc, SCS_SETSTR, NULL, 0, NULL, 0);
- todo_wine
- ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
+ ok(broken(!ret) ||
+ ret, /* Vista+ */
+ "ImmSetCompositionStringW() failed.\n");
ret = ImmSetCompositionStringW(imc, SCS_SETSTR | SCS_CHANGEATTR,
NULL, 0, NULL, 0);
- todo_wine
ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
ret = ImmSetCompositionStringW(imc, SCS_SETSTR | SCS_CHANGECLAUSE,
NULL, 0, NULL, 0);
- todo_wine
ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
ret = ImmSetCompositionStringW(imc, SCS_CHANGEATTR | SCS_CHANGECLAUSE,
NULL, 0, NULL, 0);
- todo_wine
+ ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
+
+ ret = ImmSetCompositionStringW(imc, SCS_SETSTR | SCS_CHANGEATTR | SCS_CHANGECLAUSE,
+ NULL, 0, NULL, 0);
ok(!ret, "ImmSetCompositionStringW() succeeded.\n");
ImmReleaseContext(hwnd, imc);
ImmReleaseContext(hwnd,imc);
}
+static void test_ImmAssociateContextEx(void)
+{
+ HIMC imc;
+ BOOL rc;
+
+ if (!pImmAssociateContextEx) return;
+
+ imc = ImmGetContext(hwnd);
+ if (imc)
+ {
+ HIMC retimc, newimc;
+
+ newimc = ImmCreateContext();
+ ok(newimc != imc, "handles should not be the same\n");
+ rc = pImmAssociateContextEx(NULL, NULL, 0);
+ ok(!rc, "ImmAssociateContextEx succeeded\n");
+ rc = pImmAssociateContextEx(hwnd, NULL, 0);
+ ok(rc, "ImmAssociateContextEx failed\n");
+ rc = pImmAssociateContextEx(NULL, imc, 0);
+ ok(!rc, "ImmAssociateContextEx succeeded\n");
+
+ rc = pImmAssociateContextEx(hwnd, imc, 0);
+ ok(rc, "ImmAssociateContextEx failed\n");
+ retimc = ImmGetContext(hwnd);
+ ok(retimc == imc, "handles should be the same\n");
+ ImmReleaseContext(hwnd,retimc);
+
+ rc = pImmAssociateContextEx(hwnd, newimc, 0);
+ ok(rc, "ImmAssociateContextEx failed\n");
+ retimc = ImmGetContext(hwnd);
+ ok(retimc == newimc, "handles should be the same\n");
+ ImmReleaseContext(hwnd,retimc);
+
+ rc = pImmAssociateContextEx(hwnd, NULL, IACE_DEFAULT);
+ ok(rc, "ImmAssociateContextEx failed\n");
+ }
+ ImmReleaseContext(hwnd,imc);
+}
+
START_TEST(imm32) {
if (init())
{
test_ImmGetCompositionString();
test_ImmSetCompositionString();
test_ImmIME();
+ test_ImmAssociateContextEx();
}
cleanup();
}