mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
dinput8/tests: Tests for DIPROP_USERNAME property.
This commit is contained in:
parent
32f79acc49
commit
46e408d54c
@ -1,5 +1,5 @@
|
||||
TESTDLL = dinput8.dll
|
||||
IMPORTS = dinput8 ole32 user32
|
||||
IMPORTS = dinput8 ole32 user32 advapi32
|
||||
|
||||
C_SRCS = \
|
||||
device.c \
|
||||
|
@ -31,6 +31,7 @@ struct enum_data {
|
||||
LPDIACTIONFORMAT lpdiaf;
|
||||
LPDIRECTINPUTDEVICE8 keyboard;
|
||||
LPDIRECTINPUTDEVICE8 mouse;
|
||||
const char* username;
|
||||
int ndevices;
|
||||
};
|
||||
|
||||
@ -156,6 +157,9 @@ static BOOL CALLBACK enumeration_callback(
|
||||
HRESULT hr;
|
||||
DIPROPDWORD dp;
|
||||
DIPROPRANGE dpr;
|
||||
DIPROPSTRING dps;
|
||||
WCHAR usernameW[MAX_PATH];
|
||||
DWORD username_size = MAX_PATH;
|
||||
struct enum_data *data = pvRef;
|
||||
DWORD cnt;
|
||||
DIDEVICEOBJECTDATA buffer[5];
|
||||
@ -164,6 +168,15 @@ static BOOL CALLBACK enumeration_callback(
|
||||
|
||||
data->ndevices++;
|
||||
|
||||
/* Convert username to WCHAR */
|
||||
if (data->username != NULL)
|
||||
{
|
||||
username_size = MultiByteToWideChar(CP_ACP, 0, data->username, -1, usernameW, 0);
|
||||
MultiByteToWideChar(CP_ACP, 0, data->username, -1, usernameW, username_size);
|
||||
}
|
||||
else
|
||||
GetUserNameW(usernameW, &username_size);
|
||||
|
||||
/* collect the mouse and keyboard */
|
||||
if (IsEqualGUID(&lpddi->guidInstance, &GUID_SysKeyboard))
|
||||
{
|
||||
@ -190,12 +203,23 @@ static BOOL CALLBACK enumeration_callback(
|
||||
hr = IDirectInputDevice8_Acquire(lpdid);
|
||||
ok (hr == DIERR_INVALIDPARAM, "Device was acquired before SetActionMap hr=%08x\n", hr);
|
||||
|
||||
hr = IDirectInputDevice8_SetActionMap(lpdid, data->lpdiaf, NULL, 0);
|
||||
hr = IDirectInputDevice8_SetActionMap(lpdid, data->lpdiaf, data->username, 0);
|
||||
ok (SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr);
|
||||
|
||||
/* Some joysticks may have no suitable actions and thus should not be tested */
|
||||
if (hr == DI_NOEFFECT) return DIENUM_CONTINUE;
|
||||
|
||||
/* Test username after SetActionMap */
|
||||
dps.diph.dwSize = sizeof(dps);
|
||||
dps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
dps.diph.dwObj = 0;
|
||||
dps.diph.dwHow = DIPH_DEVICE;
|
||||
dps.wsz[0] = '\0';
|
||||
|
||||
hr = IDirectInputDevice_GetProperty(lpdid, DIPROP_USERNAME, &dps.diph);
|
||||
todo_wine ok (SUCCEEDED(hr), "GetProperty failed hr=%08x\n", hr);
|
||||
todo_wine ok (!lstrcmpW(usernameW, dps.wsz), "Username not set correctly expected=%s, got=%s\n", wine_dbgstr_wn(usernameW, -1), wine_dbgstr_wn(dps.wsz, -1));
|
||||
|
||||
/* Test buffer size */
|
||||
memset(&dp, 0, sizeof(dp));
|
||||
dp.diph.dwSize = sizeof(dp);
|
||||
@ -245,7 +269,7 @@ static void test_action_mapping(void)
|
||||
HINSTANCE hinst = GetModuleHandle(NULL);
|
||||
LPDIRECTINPUT8 pDI = NULL;
|
||||
DIACTIONFORMAT af;
|
||||
struct enum_data data = {pDI, &af, NULL, NULL, 0};
|
||||
struct enum_data data = {pDI, &af, NULL, NULL, NULL, 0};
|
||||
|
||||
hr = CoCreateInstance(&CLSID_DirectInput8, 0, 1, &IID_IDirectInput8A, (LPVOID*)&pDI);
|
||||
if (hr == DIERR_OLDDIRECTINPUTVERSION ||
|
||||
@ -281,6 +305,11 @@ static void test_action_mapping(void)
|
||||
hr = IDirectInput8_EnumDevicesBySemantics(pDI, 0, &af, enumeration_callback, &data, DIEDBSFL_ATTACHEDONLY);
|
||||
ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr);
|
||||
|
||||
/* Repeat tests with a non NULL user */
|
||||
data.username = "Ninja Brian";
|
||||
hr = IDirectInput8_EnumDevicesBySemantics(pDI, NULL, &af, enumeration_callback, &data, DIEDBSFL_ATTACHEDONLY);
|
||||
ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%08x\n", hr);
|
||||
|
||||
if (data.keyboard != NULL)
|
||||
{
|
||||
/* Test keyboard BuildActionMap */
|
||||
|
Loading…
Reference in New Issue
Block a user