Commit 80bec586 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

comctl32/tests: Add IME tests for edit control.

parent 1f843165
TESTDLL = comctl32.dll TESTDLL = comctl32.dll
IMPORTS = ole32 user32 gdi32 advapi32 IMPORTS = ole32 user32 gdi32 advapi32 imm32
C_SRCS = \ C_SRCS = \
animate.c \ animate.c \
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <imm.h>
#include "wine/test.h" #include "wine/test.h"
#include "v6util.h" #include "v6util.h"
...@@ -3441,6 +3442,215 @@ static void test_change_focus(void) ...@@ -3441,6 +3442,215 @@ static void test_change_focus(void)
DestroyWindow(hwnd); DestroyWindow(hwnd);
} }
static const struct message wm_ime_composition_seq[] =
{
{WM_IME_STARTCOMPOSITION, sent},
{WM_IME_COMPOSITION, sent | wparam, 'W'},
{WM_IME_CHAR, sent | wparam | defwinproc, 'W'},
{WM_IME_CHAR, sent | wparam | defwinproc, 'i'},
{WM_IME_CHAR, sent | wparam | defwinproc, 'n'},
{WM_IME_CHAR, sent | wparam | defwinproc, 'e'},
{WM_IME_ENDCOMPOSITION, sent},
{WM_CHAR, sent | wparam, 'W'},
{WM_CHAR, sent | wparam, 'i'},
{WM_CHAR, sent | wparam, 'n'},
{WM_CHAR, sent | wparam, 'e'},
{0}
};
static const struct message wm_ime_char_seq[] =
{
{WM_IME_CHAR, sent | wparam, '0'},
{WM_CHAR, sent | wparam, '0'},
{0}
};
static const struct message eimes_getcompstratonce_seq[] =
{
{WM_IME_STARTCOMPOSITION, sent},
{WM_IME_COMPOSITION, sent | wparam, 'W'},
{WM_IME_ENDCOMPOSITION, sent},
{0}
};
static LRESULT CALLBACK edit_ime_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
static LONG defwndproc_counter = 0;
struct message msg = {0};
LRESULT ret;
msg.message = message;
msg.flags = sent | wparam;
if (defwndproc_counter)
msg.flags |= defwinproc;
msg.wParam = wParam;
if (message < 0xc000 &&
message != WM_GETTEXTLENGTH &&
message != WM_GETTEXT &&
message != WM_GETFONT &&
message != WM_GETICON &&
message != WM_IME_SETCONTEXT &&
message != WM_IME_NOTIFY &&
message != WM_CTLCOLOREDIT &&
message != WM_PAINT &&
message != WM_ERASEBKGND &&
message != WM_NCHITTEST &&
message != WM_SETCURSOR &&
message != WM_MOUSEMOVE &&
message != WM_MOUSEACTIVATE &&
message != WM_KEYUP &&
(message < EM_GETSEL || message > EM_GETIMESTATUS))
{
add_message(sequences, COMBINED_SEQ_INDEX, &msg);
}
defwndproc_counter++;
if (IsWindowUnicode(hwnd))
ret = CallWindowProcW(oldproc, hwnd, message, wParam, lParam);
else
ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
defwndproc_counter--;
return ret;
}
static void test_ime(void)
{
WNDPROC old_proc;
LRESULT lr;
HIMC himc;
HWND hwnd;
BOOL ret;
MSG msg;
hwnd = create_editcontrol(WS_POPUP | WS_VISIBLE, 0);
/* Test EM_{GET|SET}IMESTATUS */
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
ok(lr == 0, "Got unexpected lr %#Ix.\n", lr);
/* Note that EM_SETIMESTATUS always return 1, which is contrary to what MSDN says about
* returning the previous LPARAM value */
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING, EIMES_GETCOMPSTRATONCE);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
todo_wine
ok(lr == EIMES_GETCOMPSTRATONCE, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING, EIMES_CANCELCOMPSTRINFOCUS);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
todo_wine
ok(lr == EIMES_CANCELCOMPSTRINFOCUS, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING, EIMES_COMPLETECOMPSTRKILLFOCUS);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
todo_wine
ok(lr == EIMES_COMPLETECOMPSTRKILLFOCUS, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING, EIMES_GETCOMPSTRATONCE
| EIMES_CANCELCOMPSTRINFOCUS | EIMES_COMPLETECOMPSTRKILLFOCUS);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
todo_wine
ok(lr == (EIMES_GETCOMPSTRATONCE | EIMES_CANCELCOMPSTRINFOCUS | EIMES_COMPLETECOMPSTRKILLFOCUS),
"Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
ok(lr == 0, "Got unexpected lr %#Ix.\n", lr);
/* Invalid EM_{GET|SET}IMESTATUS status types and flags */
lr = SendMessageA(hwnd, EM_GETIMESTATUS, 0, 0);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING + 1, 0);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_SETIMESTATUS, 0, EIMES_GETCOMPSTRATONCE);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
ok(lr == 0, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING + 1, EIMES_GETCOMPSTRATONCE);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
ok(lr == 0, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0xFFFFFFFF);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
todo_wine
ok(lr == 0xFFFF, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
ok(lr == 0, "Got unexpected lr %#Ix.\n", lr);
/* Test IME messages when EIMES_GETCOMPSTRATONCE is not set */
old_proc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)edit_ime_subclass_proc);
SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)old_proc);
himc = ImmGetContext(hwnd);
ret = ImmSetCompositionStringA(himc, SCS_SETSTR, "Wine", 4, NULL, 0);
ok(ret, "ImmSetCompositionStringA failed.\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
ret = ImmNotifyIME(himc, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
ok(ret, "ImmNotifyIME failed.\n");
/* Note that the following message loop is necessary to get the WM_CHAR messages because they
* are posted. Same for the later message loops in this function. */
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
ok_sequence(sequences, COMBINED_SEQ_INDEX, wm_ime_composition_seq, "WM_IME_COMPOSITION", TRUE);
/* Test that WM_IME_CHAR is passed to DefWindowProc() to get WM_CHAR */
flush_sequences(sequences, NUM_MSG_SEQUENCES);
SendMessageA(hwnd, WM_IME_CHAR, '0', 1);
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
ok_sequence(sequences, COMBINED_SEQ_INDEX, wm_ime_char_seq, "WM_IME_CHAR", TRUE);
/* Test IME messages when EIMES_GETCOMPSTRATONCE is set */
lr = SendMessageA(hwnd, EM_SETIMESTATUS, EMSIS_COMPOSITIONSTRING, EIMES_GETCOMPSTRATONCE);
todo_wine
ok(lr == 1, "Got unexpected lr %#Ix.\n", lr);
lr = SendMessageA(hwnd, EM_GETIMESTATUS, EMSIS_COMPOSITIONSTRING, 0);
todo_wine
ok(lr == EIMES_GETCOMPSTRATONCE, "Got unexpected lr %#Ix.\n", lr);
ret = ImmSetCompositionStringA(himc, SCS_SETSTR, "Wine", 4, NULL, 0);
ok(ret, "ImmSetCompositionStringA failed.\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
ret = ImmNotifyIME(himc, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
ok(ret, "ImmNotifyIME failed.\n");
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
ok_sequence(sequences, COMBINED_SEQ_INDEX, eimes_getcompstratonce_seq,
"WM_IME_COMPOSITION with EIMES_GETCOMPSTRATONCE", TRUE);
/* Test that WM_IME_CHAR is passed to DefWindowProc() to get WM_CHAR with EIMES_GETCOMPSTRATONCE */
flush_sequences(sequences, NUM_MSG_SEQUENCES);
SendMessageA(hwnd, WM_IME_CHAR, '0', 1);
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
ok_sequence(sequences, COMBINED_SEQ_INDEX, wm_ime_char_seq, "WM_IME_CHAR", TRUE);
ImmReleaseContext(hwnd, himc);
DestroyWindow(hwnd);
}
START_TEST(edit) START_TEST(edit)
{ {
ULONG_PTR ctx_cookie; ULONG_PTR ctx_cookie;
...@@ -3487,6 +3697,7 @@ START_TEST(edit) ...@@ -3487,6 +3697,7 @@ START_TEST(edit)
test_wordbreak_proc(); test_wordbreak_proc();
test_change_focus(); test_change_focus();
test_cue_banner(); test_cue_banner();
test_ime();
UnregisterWindowClasses(); UnregisterWindowClasses();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment