From: "Rémi Bernon" Subject: [PATCH 5/6] dinput8/tests: Add some HID joystick IDirectInputDevice8_SetCooperativeLevel tests. Message-Id: <20210916082043.2693697-5-rbernon@codeweavers.com> Date: Thu, 16 Sep 2021 10:20:42 +0200 In-Reply-To: <20210916082043.2693697-1-rbernon@codeweavers.com> References: <20210916082043.2693697-1-rbernon@codeweavers.com> Signed-off-by: Rémi Bernon --- dlls/dinput8/tests/hid.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index ab3f4b933ef..fd1949ed650 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3417,6 +3417,7 @@ static void test_simple_joystick(void) HRESULT hr; WCHAR *tmp; ULONG ref; + HWND hwnd; GetCurrentDirectoryW( ARRAY_SIZE(cwd), cwd ); GetTempPathW( ARRAY_SIZE(tempdir), tempdir ); @@ -3708,6 +3709,31 @@ static void test_simple_joystick(void) hr = IDirectInputDevice8_SetEventNotification( device, event ); ok( hr == DI_OK, "IDirectInputDevice8_SetEventNotification returned: %#x\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, 0 ); + ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND ); + ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE ); + ok( hr == E_HANDLE, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND | DISCL_EXCLUSIVE ); + ok( hr == E_HANDLE, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND | DISCL_EXCLUSIVE ); + ok( hr == E_HANDLE, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + + hwnd = CreateWindowW( L"static", L"dinput", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 10, 10, 200, 200, + NULL, NULL, NULL, NULL ); + + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE ); + ok( hr == DI_OK, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND | DISCL_EXCLUSIVE ); + ok( hr == DI_OK, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE ); + ok( hr == DI_OK, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + DestroyWindow( hwnd ); + + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE ); + ok( hr == DI_OK, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); + ref = IDirectInputDevice8_Release( device ); ok( ref == 0, "IDirectInputDeviceW_Release returned %d\n", ref ); -- 2.33.0