Commit 0a31ab7e authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

imm32: Added some unit test cases.

parent 1b997a99
......@@ -189,6 +189,9 @@ dlls/icmp/libicmp.def
dlls/imagehlp/libimagehlp.def
dlls/imm.dll16
dlls/imm32/libimm32.def
dlls/imm32/tests/*.ok
dlls/imm32/tests/imm32_crosstest.exe
dlls/imm32/tests/testlist.c
dlls/imm32/version.res
dlls/inetcomm/libinetcomm.def
dlls/inetcomm/tests/*.ok
......@@ -737,6 +740,7 @@ programs/winetest/dsound_test.exe
programs/winetest/gdi32_test.exe
programs/winetest/gdiplus_test.exe
programs/winetest/hlink_test.exe
programs/winetest/imm32_test.exe
programs/winetest/inetcomm_test.exe
programs/winetest/infosoft_test.exe
programs/winetest/iphlpapi_test.exe
......
......@@ -258,6 +258,7 @@ ALL_MAKEFILES = \
dlls/imaadp32.acm/Makefile \
dlls/imagehlp/Makefile \
dlls/imm32/Makefile \
dlls/imm32/tests/Makefile \
dlls/inetcomm/Makefile \
dlls/inetcomm/tests/Makefile \
dlls/infosoft/Makefile \
......@@ -641,6 +642,7 @@ dlls/ifsmgr.vxd/Makefile: dlls/ifsmgr.vxd/Makefile.in dlls/Makedll.rules
dlls/imaadp32.acm/Makefile: dlls/imaadp32.acm/Makefile.in dlls/Makedll.rules
dlls/imagehlp/Makefile: dlls/imagehlp/Makefile.in dlls/Makedll.rules
dlls/imm32/Makefile: dlls/imm32/Makefile.in dlls/Makedll.rules
dlls/imm32/tests/Makefile: dlls/imm32/tests/Makefile.in dlls/Maketest.rules
dlls/inetcomm/Makefile: dlls/inetcomm/Makefile.in dlls/Makedll.rules
dlls/inetcomm/tests/Makefile: dlls/inetcomm/tests/Makefile.in dlls/Maketest.rules
dlls/infosoft/Makefile: dlls/infosoft/Makefile.in dlls/Makedll.rules
......
......@@ -20808,6 +20808,8 @@ ac_config_files="$ac_config_files dlls/imagehlp/Makefile"
ac_config_files="$ac_config_files dlls/imm32/Makefile"
ac_config_files="$ac_config_files dlls/imm32/tests/Makefile"
ac_config_files="$ac_config_files dlls/inetcomm/Makefile"
ac_config_files="$ac_config_files dlls/inetcomm/tests/Makefile"
......@@ -22010,6 +22012,7 @@ do
"dlls/imaadp32.acm/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/imaadp32.acm/Makefile" ;;
"dlls/imagehlp/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/imagehlp/Makefile" ;;
"dlls/imm32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/imm32/Makefile" ;;
"dlls/imm32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/imm32/tests/Makefile" ;;
"dlls/inetcomm/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/inetcomm/Makefile" ;;
"dlls/inetcomm/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/inetcomm/tests/Makefile" ;;
"dlls/infosoft/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/infosoft/Makefile" ;;
......
......@@ -1684,6 +1684,7 @@ AC_CONFIG_FILES([dlls/ifsmgr.vxd/Makefile])
AC_CONFIG_FILES([dlls/imaadp32.acm/Makefile])
AC_CONFIG_FILES([dlls/imagehlp/Makefile])
AC_CONFIG_FILES([dlls/imm32/Makefile])
AC_CONFIG_FILES([dlls/imm32/tests/Makefile])
AC_CONFIG_FILES([dlls/inetcomm/Makefile])
AC_CONFIG_FILES([dlls/inetcomm/tests/Makefile])
AC_CONFIG_FILES([dlls/infosoft/Makefile])
......
......@@ -271,6 +271,7 @@ TESTSUBDIRS = \
gdi32/tests \
gdiplus/tests \
hlink/tests \
imm32/tests \
inetcomm/tests \
infosoft/tests \
iphlpapi/tests \
......
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = imm32.dll
IMPORTS = imm32 user32 kernel32
CTESTS = \
imm32.c
@MAKE_TEST_RULES@
@DEPENDENCIES@ # everything below this line is overwritten by make depend
/*
* Unit tests for imm32
*
* Copyright (c) 2008 Michael Jung
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include "wine/test.h"
#include "winuser.h"
#include "imm.h"
#define NUMELEMS(array) (sizeof((array))/sizeof((array)[0]))
/*
* msgspy - record and analyse message traces sent to a certain window
*/
static struct _msg_spy {
HWND hwnd;
HHOOK get_msg_hook;
HHOOK call_wnd_proc_hook;
CWPSTRUCT msgs[32];
unsigned int i_msg;
} msg_spy;
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) &&
(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.i_msg++;
}
}
return CallNextHookEx(msg_spy.get_msg_hook, nCode, wParam, lParam);
}
static LRESULT CALLBACK call_wnd_proc_filter(int nCode, WPARAM wParam,
LPARAM lParam)
{
if (HC_ACTION == nCode) {
CWPSTRUCT *cwp = (CWPSTRUCT*)lParam;
if ((cwp->hwnd == msg_spy.hwnd) &&
(msg_spy.i_msg < NUMELEMS(msg_spy.msgs)))
{
memcpy(&msg_spy.msgs[msg_spy.i_msg], cwp, sizeof(msg_spy.msgs[0]));
msg_spy.i_msg++;
}
}
return CallNextHookEx(msg_spy.call_wnd_proc_hook, nCode, wParam, lParam);
}
static void msg_spy_pump_msg_queue(void) {
MSG msg;
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return;
}
static void msg_spy_flush_msgs(void) {
msg_spy_pump_msg_queue();
msg_spy.i_msg = 0;
}
static CWPSTRUCT* msg_spy_find_msg(UINT message) {
int i;
msg_spy_pump_msg_queue();
if (msg_spy.i_msg >= NUMELEMS(msg_spy.msgs))
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)
return &msg_spy.msgs[i];
return NULL;
}
static void msg_spy_init(HWND hwnd) {
msg_spy.hwnd = hwnd;
msg_spy.get_msg_hook =
SetWindowsHookEx(WH_GETMESSAGE, get_msg_filter, GetModuleHandle(0),
GetCurrentThreadId());
msg_spy.call_wnd_proc_hook =
SetWindowsHookEx(WH_CALLWNDPROC, call_wnd_proc_filter,
GetModuleHandle(0), GetCurrentThreadId());
msg_spy.i_msg = 0;
msg_spy_flush_msgs();
}
static void msg_spy_cleanup() {
if (msg_spy.get_msg_hook)
UnhookWindowsHookEx(msg_spy.get_msg_hook);
if (msg_spy.call_wnd_proc_hook)
UnhookWindowsHookEx(msg_spy.call_wnd_proc_hook);
memset(&msg_spy, 0, sizeof(msg_spy));
}
/*
* imm32 test cases - Issue some IMM commands on a dummy window and analyse the
* messages being sent to this window in response.
*/
static const char wndcls[] = "winetest_imm32_wndcls";
static HWND hwnd;
static int init(void) {
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = DefWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(0);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = wndcls;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassExA(&wc))
return 0;
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;
ShowWindow(hwnd, SW_SHOWNORMAL);
UpdateWindow(hwnd);
msg_spy_init(hwnd);
return 1;
}
static void cleanup(void) {
msg_spy_cleanup();
if (hwnd)
DestroyWindow(hwnd);
UnregisterClass(wndcls, GetModuleHandle(0));
}
static int test_ImmNotifyIME(void) {
static const char string[] = "wine";
char resstr[16] = "";
HIMC imc;
imc = ImmGetContext(hwnd);
msg_spy_flush_msgs();
ok(ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0), "Canceling an "
"empty composition string succeeds.\n");
todo_wine {
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");
}
msg_spy_flush_msgs();
ImmSetCompositionString(imc, SCS_SETSTR, string, sizeof(string), NULL, 0);
ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
ok(msg_spy_find_msg(WM_IME_COMPOSITION) != NULL, "Windows does post "
"WM_IME_COMPOSITION in response to NI_COMPOSITIONSTR / CPS_CANCEL, if "
"the composition string being canceled is non empty.\n");
ok(!ImmGetCompositionString(imc, GCS_COMPSTR, resstr, sizeof(resstr)),
"After being canceled the composition string is empty.\n");
msg_spy_flush_msgs();
ok(ImmNotifyIME(imc, NI_COMPOSITIONSTR, CPS_CANCEL, 0), "Canceling an "
"empty composition string succeeds.\n");
todo_wine {
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");
}
msg_spy_flush_msgs();
ImmReleaseContext(hwnd, imc);
return 0;
}
START_TEST(imm32) {
if (init())
test_ImmNotifyIME();
cleanup();
}
......@@ -42,6 +42,7 @@ TESTBINS = \
gdi32_test.exe \
gdiplus_test.exe \
hlink_test.exe \
imm32_test.exe \
inetcomm_test.exe \
infosoft_test.exe \
iphlpapi_test.exe \
......@@ -138,6 +139,8 @@ gdiplus_test.exe: $(DLLDIR)/gdiplus/tests/gdiplus_test.exe$(DLLEXT)
cp $(DLLDIR)/gdiplus/tests/gdiplus_test.exe$(DLLEXT) $@ && $(STRIP) $@
hlink_test.exe: $(DLLDIR)/hlink/tests/hlink_test.exe$(DLLEXT)
cp $(DLLDIR)/hlink/tests/hlink_test.exe$(DLLEXT) $@ && $(STRIP) $@
imm32_test.exe: $(DLLDIR)/imm32/tests/imm32_test.exe$(DLLEXT)
cp $(DLLDIR)/imm32/tests/imm32_test.exe$(DLLEXT) $@ && $(STRIP) $@
inetcomm_test.exe: $(DLLDIR)/inetcomm/tests/inetcomm_test.exe$(DLLEXT)
cp $(DLLDIR)/inetcomm/tests/inetcomm_test.exe$(DLLEXT) $@ && $(STRIP) $@
infosoft_test.exe: $(DLLDIR)/infosoft/tests/infosoft_test.exe$(DLLEXT)
......
......@@ -100,6 +100,7 @@ dsound_test.exe TESTRES "dsound_test.exe"
gdi32_test.exe TESTRES "gdi32_test.exe"
gdiplus_test.exe TESTRES "gdiplus_test.exe"
hlink_test.exe TESTRES "hlink_test.exe"
imm32_test.exe TESTRES "imm32_test.exe"
inetcomm_test.exe TESTRES "inetcomm_test.exe"
infosoft_test.exe TESTRES "infosoft_test.exe"
iphlpapi_test.exe TESTRES "iphlpapi_test.exe"
......
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