Module: wine Branch: master Commit: 2656e418e2de27491f92eae0569b4f4e02c28128 URL: https://gitlab.winehq.org/wine/wine/-/commit/2656e418e2de27491f92eae0569b4f4...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Mar 16 13:27:37 2023 +0100
dinput/tests: Test SaveActionMap effect on DIPROP_USERNAME property.
---
dlls/dinput/tests/joystick8.c | 50 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index 6dbd4f3e9d6..a1720bb7b26 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -725,11 +725,29 @@ static void test_action_map( IDirectInputDevice8W *device, HANDLE file, HANDLE e {.objid = TRUE}, {.objid = TRUE, .how = TRUE}, }; + DIPROPSTRING prop_username = + { + .diph = + { + .dwHeaderSize = sizeof(DIPROPHEADER), + .dwSize = sizeof(DIPROPSTRING), + .dwHow = DIPH_DEVICE, + } + }; DIACTIONW actions[ARRAY_SIZE(expect_actions)]; DIACTIONFORMATW action_format; - DWORD flags; + WCHAR username[256]; + DWORD res, flags; HRESULT hr;
+ res = ARRAY_SIZE(username); + GetUserNameW( username, &res ); + + memset( prop_username.wsz, 0, sizeof(prop_username.wsz) ); + hr = IDirectInputDevice_GetProperty( device, DIPROP_USERNAME, &prop_username.diph ); + ok( hr == DI_NOEFFECT, "GetProperty returned %#lx\n", hr ); + ok( !wcscmp( prop_username.wsz, L"" ), "got username %s\n", debugstr_w(prop_username.wsz) ); +
hr = IDirectInputDevice8_BuildActionMap( device, NULL, L"username", DIDBAM_DEFAULT ); ok( hr == DIERR_INVALIDPARAM, "BuildActionMap returned %#lx\n", hr ); @@ -768,12 +786,26 @@ static void test_action_map( IDirectInputDevice8W *device, HANDLE file, HANDLE e todo_wine ok( hr == DI_SETTINGSNOTSAVED, "SetActionMap returned %#lx\n", hr );
+ memset( prop_username.wsz, 0, sizeof(prop_username.wsz) ); + hr = IDirectInputDevice_GetProperty( device, DIPROP_USERNAME, &prop_username.diph ); + todo_wine + ok( hr == DI_OK, "GetProperty returned %#lx\n", hr ); + todo_wine + ok( !wcscmp( prop_username.wsz, username ), "got username %s\n", debugstr_w(prop_username.wsz) ); + hr = IDirectInputDevice8_SetActionMap( device, &voice_action_format, NULL, DIDSAM_DEFAULT ); ok( hr == DI_NOEFFECT, "SetActionMap returned %#lx\n", hr ); hr = IDirectInputDevice8_SetActionMap( device, &voice_action_format, NULL, DIDSAM_FORCESAVE ); todo_wine ok( hr == DI_SETTINGSNOTSAVED, "SetActionMap returned %#lx\n", hr );
+ memset( prop_username.wsz, 0, sizeof(prop_username.wsz) ); + hr = IDirectInputDevice_GetProperty( device, DIPROP_USERNAME, &prop_username.diph ); + todo_wine + ok( hr == DI_OK, "GetProperty returned %#lx\n", hr ); + todo_wine + ok( !wcscmp( prop_username.wsz, username ), "got username %s\n", debugstr_w(prop_username.wsz) ); +
action_format = action_format_1; action_format.rgoAction = actions; @@ -891,6 +923,22 @@ static void test_action_map( IDirectInputDevice8W *device, HANDLE file, HANDLE e hr = IDirectInputDevice8_BuildActionMap( device, &action_format, L"username", DIDBAM_PRESERVE ); ok( hr == DI_OK, "BuildActionMap returned %#lx\n", hr ); check_diactionformatw_( __LINE__, &action_format, &expect_action_format_2, actions_todos_2 ); + + + /* DIDSAM_NOUSER flag clears the device user property */ + + memset( prop_username.wsz, 0, sizeof(prop_username.wsz) ); + hr = IDirectInputDevice_GetProperty( device, DIPROP_USERNAME, &prop_username.diph ); + ok( hr == DI_OK, "GetProperty returned %#lx\n", hr ); + ok( !wcscmp( prop_username.wsz, L"username" ), "got username %s\n", debugstr_w(prop_username.wsz) ); + + hr = IDirectInputDevice8_SetActionMap( device, &action_format, L"username", DIDSAM_NOUSER ); + ok( hr == DI_OK, "SetActionMap returned %#lx\n", hr ); + + memset( prop_username.wsz, 0, sizeof(prop_username.wsz) ); + hr = IDirectInputDevice_GetProperty( device, DIPROP_USERNAME, &prop_username.diph ); + ok( hr == DI_NOEFFECT, "GetProperty returned %#lx\n", hr ); + ok( !wcscmp( prop_username.wsz, L"" ), "got username %s\n", debugstr_w(prop_username.wsz) ); }
static void test_simple_joystick( DWORD version )