Module: wine Branch: master Commit: 203b4fbff09a95c7ac1c51b65144f5f7b6110848 URL: http://source.winehq.org/git/wine.git/?a=commit;h=203b4fbff09a95c7ac1c51b651...
Author: Aric Stewart aric@codeweavers.com Date: Tue Nov 20 14:07:07 2012 -0600
imm32/tests: Test showing that communication to the IME window is done via SendMessage.
---
dlls/imm32/tests/imm32.c | 73 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 62 insertions(+), 11 deletions(-)
diff --git a/dlls/imm32/tests/imm32.c b/dlls/imm32/tests/imm32.c index 6eb8a41..5aff7f7 100644 --- a/dlls/imm32/tests/imm32.c +++ b/dlls/imm32/tests/imm32.c @@ -33,11 +33,16 @@ static BOOL (WINAPI *pImmIsUIMessageA)(HWND,UINT,WPARAM,LPARAM); /* * msgspy - record and analyse message traces sent to a certain window */ +typedef struct _msgs { + CWPSTRUCT msg; + BOOL post; +} imm_msgs; + static struct _msg_spy { HWND hwnd; HHOOK get_msg_hook; HHOOK call_wnd_proc_hook; - CWPSTRUCT msgs[32]; + imm_msgs msgs[32]; unsigned int i_msg; } msg_spy;
@@ -46,13 +51,14 @@ static LRESULT CALLBACK get_msg_filter(int nCode, WPARAM wParam, LPARAM lParam) if (HC_ACTION == nCode) { MSG *msg = (MSG*)lParam;
- if ((msg->hwnd == msg_spy.hwnd) && + if ((msg->hwnd == msg_spy.hwnd || msg_spy.hwnd == NULL) && (msg_spy.i_msg < NUMELEMS(msg_spy.msgs))) { - msg_spy.msgs[msg_spy.i_msg].hwnd = msg->hwnd; - msg_spy.msgs[msg_spy.i_msg].message = msg->message; - msg_spy.msgs[msg_spy.i_msg].wParam = msg->wParam; - msg_spy.msgs[msg_spy.i_msg].lParam = msg->lParam; + msg_spy.msgs[msg_spy.i_msg].msg.hwnd = msg->hwnd; + msg_spy.msgs[msg_spy.i_msg].msg.message = msg->message; + msg_spy.msgs[msg_spy.i_msg].msg.wParam = msg->wParam; + msg_spy.msgs[msg_spy.i_msg].msg.lParam = msg->lParam; + msg_spy.msgs[msg_spy.i_msg].post = TRUE; msg_spy.i_msg++; } } @@ -66,10 +72,11 @@ static LRESULT CALLBACK call_wnd_proc_filter(int nCode, WPARAM wParam, if (HC_ACTION == nCode) { CWPSTRUCT *cwp = (CWPSTRUCT*)lParam;
- if ((cwp->hwnd == msg_spy.hwnd) && + if (((cwp->hwnd == msg_spy.hwnd || msg_spy.hwnd == NULL)) && (msg_spy.i_msg < NUMELEMS(msg_spy.msgs))) { - memcpy(&msg_spy.msgs[msg_spy.i_msg], cwp, sizeof(msg_spy.msgs[0])); + memcpy(&msg_spy.msgs[msg_spy.i_msg].msg, cwp, sizeof(msg_spy.msgs[0].msg)); + msg_spy.msgs[msg_spy.i_msg].post = FALSE; msg_spy.i_msg++; } } @@ -93,7 +100,7 @@ static void msg_spy_flush_msgs(void) { msg_spy.i_msg = 0; }
-static CWPSTRUCT* msg_spy_find_msg(UINT message) { +static imm_msgs* msg_spy_find_next_msg(UINT message, UINT *start) { UINT i;
msg_spy_pump_msg_queue(); @@ -102,13 +109,22 @@ static CWPSTRUCT* msg_spy_find_msg(UINT message) { fprintf(stdout, "%s:%d: msg_spy: message buffer overflow!\n", __FILE__, __LINE__);
- for (i = 0; i < msg_spy.i_msg; i++) - if (msg_spy.msgs[i].message == message) + for (i = *start; i < msg_spy.i_msg; i++) + if (msg_spy.msgs[i].msg.message == message) + { + *start = i+1; return &msg_spy.msgs[i]; + }
return NULL; }
+static imm_msgs* msg_spy_find_msg(UINT message) { + UINT i = 0; + + return msg_spy_find_next_msg(message, &i); +} + static void msg_spy_init(HWND hwnd) { msg_spy.hwnd = hwnd; msg_spy.get_msg_hook = @@ -655,6 +671,36 @@ static void test_ImmDefaultHwnd(void) DestroyWindow(hwnd); }
+static void test_ImmMessages(void) +{ + CANDIDATEFORM cf; + imm_msgs *msg; + HWND defwnd; + HIMC imc; + UINT idx = 0; + + HWND hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "Wine imm32.dll test", + WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, + 240, 120, NULL, NULL, GetModuleHandle(0), NULL); + + ShowWindow(hwnd, SW_SHOWNORMAL); + defwnd = ImmGetDefaultIMEWnd(hwnd); + imc = ImmGetContext(hwnd); + + ImmSetOpenStatus(imc, TRUE); + msg_spy_flush_msgs(); + SendMessage(defwnd, WM_IME_CONTROL, IMC_GETCANDIDATEPOS, (LPARAM)&cf ); + do + { + msg = msg_spy_find_next_msg(WM_IME_CONTROL,&idx); + if (msg) ok(!msg->post, "Message should not be posted\n"); + } while (msg); + msg_spy_flush_msgs(); + ImmSetOpenStatus(imc, FALSE); + ImmReleaseContext(hwnd, imc); + DestroyWindow(hwnd); +} + START_TEST(imm32) { if (init()) { @@ -668,6 +714,11 @@ START_TEST(imm32) { test_ImmGetContext(); test_ImmGetDescription(); test_ImmDefaultHwnd(); + msg_spy_cleanup(); + /* Reinitialize the hooks to capture all windows */ + msg_spy_init(NULL); + test_ImmMessages(); + msg_spy_cleanup(); } cleanup(); }