mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 14:44:39 +00:00
imm32/tests: Test ImmInstallIMEW with an actual IME.
This commit is contained in:
parent
2d39dcafc8
commit
d07a5e6b91
|
@ -1,5 +1,8 @@
|
|||
TESTDLL = imm32.dll
|
||||
IMPORTS = imm32 ole32 user32
|
||||
IMPORTS = imm32 ole32 user32 advapi32
|
||||
|
||||
C_SRCS = \
|
||||
SOURCES = \
|
||||
ime_wrapper.c \
|
||||
ime_wrapper.rc \
|
||||
ime_wrapper.spec \
|
||||
imm32.c
|
||||
|
|
35
dlls/imm32/tests/ime_test.h
Normal file
35
dlls/imm32/tests/ime_test.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2023 Rémi Bernon for CodeWeavers
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef __WINE_IME_TEST_H
|
||||
#define __WINE_IME_TEST_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "wingdi.h"
|
||||
|
||||
#include "imm.h"
|
||||
#include "immdev.h"
|
||||
|
||||
#endif /* __WINE_IME_TEST_H */
|
107
dlls/imm32/tests/ime_wrapper.c
Normal file
107
dlls/imm32/tests/ime_wrapper.c
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright 2023 Rémi Bernon for CodeWeavers
|
||||
*
|
||||
* 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 "ime_test.h"
|
||||
|
||||
BOOL WINAPI ImeConfigure( HKL hkl, HWND hwnd, DWORD mode, void *data )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DWORD WINAPI ImeConversionList( HIMC himc, const WCHAR *source, CANDIDATELIST *dest, DWORD dest_len, UINT flag )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeDestroy( UINT force )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT WINAPI ImeEnumRegisterWord( REGISTERWORDENUMPROCW proc, const WCHAR *reading, DWORD style,
|
||||
const WCHAR *string, void *data )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT WINAPI ImeEscape( HIMC himc, UINT escape, void *data )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD WINAPI ImeGetImeMenuItems( HIMC himc, DWORD flags, DWORD type, IMEMENUITEMINFOW *parent,
|
||||
IMEMENUITEMINFOW *menu, DWORD size )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT WINAPI ImeGetRegisterWordStyle( UINT item, STYLEBUFW *style_buf )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeInquire( IMEINFO *info, WCHAR *ui_class, DWORD flags )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeProcessKey( HIMC himc, UINT vkey, LPARAM key_data, BYTE *key_state )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeRegisterWord( const WCHAR *reading, DWORD style, const WCHAR *string )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeSelect( HIMC himc, BOOL select )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeSetActiveContext( HIMC himc, BOOL flag )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeSetCompositionString( HIMC himc, DWORD index, const void *comp, DWORD comp_len,
|
||||
const void *read, DWORD read_len )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT WINAPI ImeToAsciiEx( UINT vkey, UINT scan_code, BYTE *key_state, TRANSMSGLIST *msgs, UINT state, HIMC himc )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL WINAPI ImeUnregisterWord( const WCHAR *reading, DWORD style, const WCHAR *string )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WINAPI NotifyIME( HIMC himc, DWORD action, DWORD index, DWORD value )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, LPVOID reserved )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
28
dlls/imm32/tests/ime_wrapper.rc
Normal file
28
dlls/imm32/tests/ime_wrapper.rc
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2023 Rémi Bernon for CodeWeavers
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#pragma makedep testdll
|
||||
|
||||
#define WINE_LANGID 0400
|
||||
#define WINE_FILETYPE VFT_DRV
|
||||
#define WINE_FILESUBTYPE VFT2_DRV_INPUTMETHOD
|
||||
#define WINE_FILENAME "ime_wrapper"
|
||||
#define WINE_FILENAME_STR "ime_wrapper.dll"
|
||||
#define WINE_FILEDESCRIPTION_STR "WineTest IME"
|
||||
|
||||
#include "wine/wine_common_ver.rc"
|
16
dlls/imm32/tests/ime_wrapper.spec
Normal file
16
dlls/imm32/tests/ime_wrapper.spec
Normal file
|
@ -0,0 +1,16 @@
|
|||
@ stdcall ImeConfigure(long long long ptr)
|
||||
@ stdcall ImeConversionList(long wstr ptr long long)
|
||||
@ stdcall ImeDestroy(long)
|
||||
@ stdcall ImeEnumRegisterWord(ptr wstr long wstr ptr)
|
||||
@ stdcall ImeEscape(long long ptr)
|
||||
@ stdcall ImeGetImeMenuItems(long long long ptr ptr long)
|
||||
@ stdcall ImeGetRegisterWordStyle(long ptr)
|
||||
@ stdcall ImeInquire(ptr wstr wstr)
|
||||
@ stdcall ImeProcessKey(long long long ptr)
|
||||
@ stdcall ImeRegisterWord(wstr long wstr)
|
||||
@ stdcall ImeSelect(long long)
|
||||
@ stdcall ImeSetActiveContext(long long)
|
||||
@ stdcall ImeSetCompositionString(long long ptr long ptr long)
|
||||
@ stdcall ImeToAsciiEx(long long ptr ptr long long)
|
||||
@ stdcall ImeUnregisterWord(wstr long wstr)
|
||||
@ stdcall NotifyIME(long long long long)
|
|
@ -18,7 +18,13 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "objbase.h"
|
||||
|
@ -27,6 +33,8 @@
|
|||
#include "imm.h"
|
||||
#include "immdev.h"
|
||||
|
||||
#include "ime_test.h"
|
||||
|
||||
BOOL WINAPI ImmSetActiveContext(HWND, HIMC, BOOL);
|
||||
|
||||
static BOOL (WINAPI *pImmAssociateContextEx)(HWND,HIMC,DWORD);
|
||||
|
@ -206,6 +214,28 @@ static HWND hwnd, child;
|
|||
|
||||
static HWND get_ime_window(void);
|
||||
|
||||
static void load_resource( const WCHAR *name, WCHAR *filename )
|
||||
{
|
||||
static WCHAR path[MAX_PATH];
|
||||
DWORD written;
|
||||
HANDLE file;
|
||||
HRSRC res;
|
||||
void *ptr;
|
||||
|
||||
GetTempPathW( ARRAY_SIZE(path), path );
|
||||
GetTempFileNameW( path, name, 0, filename );
|
||||
|
||||
file = CreateFileW( filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
|
||||
ok( file != INVALID_HANDLE_VALUE, "failed to create %s, error %lu\n", debugstr_w(filename), GetLastError() );
|
||||
|
||||
res = FindResourceW( NULL, name, L"TESTDLL" );
|
||||
ok( res != 0, "couldn't find resource\n" );
|
||||
ptr = LockResource( LoadResource( GetModuleHandleW( NULL ), res ) );
|
||||
WriteFile( file, ptr, SizeofResource( GetModuleHandleW( NULL ), res ), &written, NULL );
|
||||
ok( written == SizeofResource( GetModuleHandleW( NULL ), res ), "couldn't write resource\n" );
|
||||
CloseHandle( file );
|
||||
}
|
||||
|
||||
static LRESULT WINAPI wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND default_ime_wnd;
|
||||
|
@ -2453,7 +2483,109 @@ static void test_ImmDisableIME(void)
|
|||
ok(!def, "ImmGetDefaultIMEWnd(hwnd) returned %p\n", def);
|
||||
}
|
||||
|
||||
START_TEST(imm32) {
|
||||
static UINT ime_count;
|
||||
static WCHAR ime_path[MAX_PATH];
|
||||
|
||||
static HKL ime_install(void)
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
DWORD len, ret;
|
||||
HKEY hkey;
|
||||
HKL hkl;
|
||||
|
||||
/* install the actual IME module, it will lookup the functions from the DLL */
|
||||
load_resource( L"ime_wrapper.dll", buffer );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
swprintf( ime_path, ARRAY_SIZE(ime_path), L"c:\\windows\\system32\\wine%04x.ime", ime_count++ );
|
||||
ret = MoveFileW( buffer, ime_path );
|
||||
todo_wine_if( GetLastError() == ERROR_ALREADY_EXISTS )
|
||||
ok( ret || broken( !ret ) /* sometimes still in use */,
|
||||
"MoveFileW failed, error %lu\n", GetLastError() );
|
||||
|
||||
hkl = ImmInstallIMEW( ime_path, L"WineTest IME" );
|
||||
todo_wine
|
||||
ok( hkl == (HKL)(int)0xe0200400, "ImmInstallIMEW returned %p, error %lu\n", hkl, GetLastError() );
|
||||
|
||||
swprintf( buffer, ARRAY_SIZE(buffer), L"System\\CurrentControlSet\\Control\\Keyboard Layouts\\%08x", hkl );
|
||||
ret = RegOpenKeyW( HKEY_LOCAL_MACHINE, buffer, &hkey );
|
||||
ok( !ret, "RegOpenKeyW returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
|
||||
len = sizeof(buffer);
|
||||
memset( buffer, 0xcd, sizeof(buffer) );
|
||||
ret = RegQueryValueExW( hkey, L"Ime File", NULL, NULL, (BYTE *)buffer, &len );
|
||||
ok( !ret, "RegQueryValueExW returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
todo_wine
|
||||
ok( !wcsicmp( buffer, wcsrchr( ime_path, '\\' ) + 1 ), "got Ime File %s\n", debugstr_w(buffer) );
|
||||
|
||||
len = sizeof(buffer);
|
||||
memset( buffer, 0xcd, sizeof(buffer) );
|
||||
ret = RegQueryValueExW( hkey, L"Layout Text", NULL, NULL, (BYTE *)buffer, &len );
|
||||
ok( !ret, "RegQueryValueExW returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
ok( !wcscmp( buffer, L"WineTest IME" ), "got Layout Text %s\n", debugstr_w(buffer) );
|
||||
|
||||
len = sizeof(buffer);
|
||||
memset( buffer, 0xcd, sizeof(buffer) );
|
||||
ret = RegQueryValueExW( hkey, L"Layout File", NULL, NULL, (BYTE *)buffer, &len );
|
||||
todo_wine
|
||||
ok( !ret, "RegQueryValueExW returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
todo_wine
|
||||
ok( !wcscmp( buffer, L"kbdus.dll" ), "got Layout File %s\n", debugstr_w(buffer) );
|
||||
|
||||
ret = RegCloseKey( hkey );
|
||||
ok( !ret, "RegCloseKey returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
|
||||
return hkl;
|
||||
}
|
||||
|
||||
static void ime_cleanup( HKL hkl )
|
||||
{
|
||||
WCHAR buffer[MAX_PATH], value[MAX_PATH];
|
||||
DWORD i, buffer_len, value_len, ret;
|
||||
HKEY hkey;
|
||||
|
||||
ret = UnloadKeyboardLayout( hkl );
|
||||
todo_wine
|
||||
ok( ret, "UnloadKeyboardLayout failed, error %lu\n", GetLastError() );
|
||||
|
||||
swprintf( buffer, ARRAY_SIZE(buffer), L"System\\CurrentControlSet\\Control\\Keyboard Layouts\\%08x", hkl );
|
||||
ret = RegDeleteKeyW( HKEY_LOCAL_MACHINE, buffer );
|
||||
ok( !ret, "RegDeleteKeyW returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
|
||||
ret = RegOpenKeyW( HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", &hkey );
|
||||
ok( !ret, "RegOpenKeyW returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
|
||||
value_len = ARRAY_SIZE(value);
|
||||
buffer_len = sizeof(buffer);
|
||||
for (i = 0; !RegEnumValueW( hkey, i, value, &value_len, NULL, NULL, (void *)buffer, &buffer_len ); i++)
|
||||
{
|
||||
value_len = ARRAY_SIZE(value);
|
||||
buffer_len = sizeof(buffer);
|
||||
if (hkl != UlongToHandle( wcstoul( buffer, NULL, 16 ) )) continue;
|
||||
ret = RegDeleteValueW( hkey, value );
|
||||
ok( !ret, "RegDeleteValueW returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
}
|
||||
|
||||
ret = RegCloseKey( hkey );
|
||||
ok( !ret, "RegCloseKey returned %#lx, error %lu\n", ret, GetLastError() );
|
||||
|
||||
ret = DeleteFileW( ime_path );
|
||||
todo_wine_if( GetLastError() == ERROR_ACCESS_DENIED )
|
||||
ok( ret || broken( !ret ) /* sometimes still in use */,
|
||||
"DeleteFileW failed, error %lu\n", GetLastError() );
|
||||
}
|
||||
|
||||
static void test_ImmInstallIME(void)
|
||||
{
|
||||
HKL hkl;
|
||||
|
||||
if (!(hkl = ime_install())) return;
|
||||
|
||||
ime_cleanup( hkl );
|
||||
}
|
||||
|
||||
START_TEST(imm32)
|
||||
{
|
||||
if (!is_ime_enabled())
|
||||
{
|
||||
win_skip("IME support not implemented\n");
|
||||
|
@ -2462,6 +2594,8 @@ START_TEST(imm32) {
|
|||
|
||||
test_com_initialization();
|
||||
|
||||
test_ImmInstallIME();
|
||||
|
||||
if (init())
|
||||
{
|
||||
test_ImmNotifyIME();
|
||||
|
|
Loading…
Reference in a new issue