From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/device.c | 20 +++-- dlls/dinput/tests/device8.c | 38 ++------- dlls/dinput/tests/dinput.c | 133 ++++++++++++++--------------- dlls/dinput/tests/dinput_test.h | 3 +- dlls/dinput/tests/force_feedback.c | 4 +- dlls/dinput/tests/hid.c | 51 ++++++----- dlls/dinput/tests/hotplug.c | 4 +- dlls/dinput/tests/joystick.c | 32 ++++--- dlls/dinput/tests/joystick8.c | 4 +- dlls/dinput/tests/keyboard.c | 27 +++--- dlls/dinput/tests/mouse.c | 23 ++--- 11 files changed, 158 insertions(+), 181 deletions(-)
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c index e907c5e8598..6e1e94ba9c2 100644 --- a/dlls/dinput/tests/device.c +++ b/dlls/dinput/tests/device.c @@ -18,14 +18,19 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS -#include <windows.h> +#include <stdarg.h> +#include <stddef.h> +#include <limits.h>
-#include "wine/test.h" +#include "ntstatus.h" +#define WIN32_NO_STATUS #include "windef.h" +#include "winbase.h" + +#define COBJMACROS #include "dinput.h"
-#include <limits.h> +#include "dinput_test.h"
static const DIOBJECTDATAFORMAT obj_data_format[] = { { &GUID_YAxis, 16, DIDFT_OPTIONAL|DIDFT_AXIS |DIDFT_MAKEINSTANCE(1), 0}, @@ -465,7 +470,6 @@ static void device_tests(void) { HRESULT hr; IDirectInputA *pDI = NULL, *obj = NULL; - HINSTANCE hInstance = GetModuleHandleW(NULL); HWND hwnd; struct enum_data data;
@@ -478,7 +482,7 @@ static void device_tests(void) ok(SUCCEEDED(hr), "DirectInputCreateA() failed: %#lx\n", hr); if (FAILED(hr)) return;
- hr = IDirectInput_Initialize(pDI, hInstance, DIRECTINPUT_VERSION); + hr = IDirectInput_Initialize(pDI, instance, DIRECTINPUT_VERSION); ok(SUCCEEDED(hr), "Initialize() failed: %#lx\n", hr); if (FAILED(hr)) return;
@@ -521,9 +525,9 @@ static void device_tests(void)
START_TEST(device) { - CoInitialize(NULL); + dinput_test_init();
device_tests();
- CoUninitialize(); + dinput_test_exit(); } diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c index 2586736cb1d..70c3e516f17 100644 --- a/dlls/dinput/tests/device8.c +++ b/dlls/dinput/tests/device8.c @@ -31,10 +31,7 @@ #include "dinput.h" #include "hidusage.h"
-#include "wine/test.h" - -static HINSTANCE instance; -static BOOL localized; /* object names get translated */ +#include "dinput_test.h"
struct enum_data { IDirectInput8A *pDI; @@ -382,7 +379,6 @@ static void test_appdata_property_vs_map(struct enum_data *data) static void test_action_mapping(void) { HRESULT hr; - HINSTANCE hinst = GetModuleHandleA(NULL); IDirectInput8A *pDI = NULL; DIACTIONFORMATA af; DIPROPSTRING dps; @@ -400,7 +396,7 @@ static void test_action_mapping(void) ok(SUCCEEDED(hr), "DirectInput8 Create failed: hr=%#lx\n", hr); if (FAILED(hr)) return;
- hr = IDirectInput8_Initialize(pDI,hinst, DIRECTINPUT_VERSION); + hr = IDirectInput8_Initialize(pDI, instance, DIRECTINPUT_VERSION); if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION) { win_skip("ActionMapping requires dinput8\n"); @@ -520,7 +516,6 @@ static void test_action_mapping(void) static void test_save_settings(void) { HRESULT hr; - HINSTANCE hinst = GetModuleHandleA(NULL); IDirectInput8A *pDI = NULL; DIACTIONFORMATA af; IDirectInputDevice8A *pKey; @@ -552,7 +547,7 @@ static void test_save_settings(void) ok (SUCCEEDED(hr), "DirectInput8 Create failed: hr=%#lx\n", hr); if (FAILED(hr)) return;
- hr = IDirectInput8_Initialize(pDI,hinst, DIRECTINPUT_VERSION); + hr = IDirectInput8_Initialize(pDI, instance, DIRECTINPUT_VERSION); if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION) { win_skip("ActionMapping requires dinput8\n"); @@ -955,7 +950,6 @@ static void test_keyboard_events(void) static void test_appdata_property(void) { HRESULT hr; - HINSTANCE hinst = GetModuleHandleA(NULL); IDirectInputDevice8A *di_keyboard; IDirectInput8A *pDI = NULL; HWND hwnd; @@ -973,7 +967,7 @@ static void test_appdata_property(void) ok(SUCCEEDED(hr), "DirectInput8 Create failed: hr=%#lx\n", hr); if (FAILED(hr)) return;
- hr = IDirectInput8_Initialize(pDI,hinst, DIRECTINPUT_VERSION); + hr = IDirectInput8_Initialize(pDI, instance, DIRECTINPUT_VERSION); if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_BETADIRECTINPUTVERSION) { win_skip("DIPROP_APPDATA requires dinput8\n"); @@ -1054,24 +1048,6 @@ static void test_appdata_property(void) IDirectInput_Release(pDI); }
-#define check_member_( file, line, val, exp, fmt, member ) \ - ok_( file, line )((val).member == (exp).member, "got " #member " " fmt ", expected " fmt "\n", \ - (val).member, (exp).member) -#define check_member( val, exp, fmt, member ) \ - check_member_( __FILE__, __LINE__, val, exp, fmt, member ) - -#define check_member_guid_( file, line, val, exp, member ) \ - ok_( file, line )(IsEqualGUID( &(val).member, &(exp).member ), "got " #member " %s, expected %s\n", \ - debugstr_guid( &(val).member ), debugstr_guid( &(exp).member )) -#define check_member_guid( val, exp, member ) \ - check_member_guid_( __FILE__, __LINE__, val, exp, member ) - -#define check_member_wstr_( file, line, val, exp, member ) \ - ok_( file, line )(!wcscmp( (val).member, (exp).member ), "got " #member " %s, expected %s\n", \ - debugstr_w((val).member), debugstr_w((exp).member)) -#define check_member_wstr( val, exp, member ) \ - check_member_wstr_( __FILE__, __LINE__, val, exp, member ) - struct check_objects_todos { BOOL offset; @@ -1838,9 +1814,7 @@ static void test_keyboard_info(void)
START_TEST(device8) { - instance = GetModuleHandleW( NULL ); - - CoInitialize(NULL); + dinput_test_init();
test_mouse_info(); test_keyboard_info(); @@ -1850,5 +1824,5 @@ START_TEST(device8) test_keyboard_events(); test_appdata_property();
- CoUninitialize(); + dinput_test_exit(); } diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c index 29d17ce378e..7df8f3ace85 100644 --- a/dlls/dinput/tests/dinput.c +++ b/dlls/dinput/tests/dinput.c @@ -18,19 +18,21 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS -#include <windows.h> -#include "objbase.h" +#include <stdarg.h> +#include <stddef.h>
-#include <initguid.h> -#include <dinput.h> -#include <dinputd.h> +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h"
-#include "wine/test.h" +#define COBJMACROS +#include "dinput.h" +#include "dinputd.h"
-HINSTANCE hInstance; +#include "dinput_test.h"
-static HRESULT (WINAPI *pDirectInputCreateEx)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN); +#include "initguid.h"
static const DWORD dinput_versions[] = { @@ -64,8 +66,8 @@ static REFIID dinput8_interfaces[] = static HRESULT direct_input_create( DWORD version, IDirectInputA **out ) { HRESULT hr; - if (version < 0x800) hr = DirectInputCreateA( hInstance, version, out, NULL ); - else hr = DirectInput8Create( hInstance, version, &IID_IDirectInput8A, (void **)out, NULL ); + if (version < 0x800) hr = DirectInputCreateA( instance, version, out, NULL ); + else hr = DirectInput8Create( instance, version, &IID_IDirectInput8A, (void **)out, NULL ); if (FAILED(hr)) win_skip( "Failed to instantiate a IDirectInput instance, hr %#lx\n", hr ); return hr; } @@ -236,19 +238,19 @@ static void test_DirectInputCreate( DWORD version ) {NULL, version - 1, NULL, &unknown, NULL, DIERR_INVALIDPARAM}, {NULL, version + 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, {NULL, version + 1, NULL, &unknown, NULL, DIERR_INVALIDPARAM}, - {hInstance, 0, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, 0, NULL, &unknown, NULL, DIERR_NOTINITIALIZED}, - {hInstance, version, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version - 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version - 1, NULL, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, - {hInstance, version + 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version + 1, NULL, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, + {instance, 0, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, 0, NULL, &unknown, NULL, DIERR_NOTINITIALIZED}, + {instance, version, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version - 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version - 1, NULL, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, + {instance, version + 1, NULL, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version + 1, NULL, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, }; HRESULT hr; int i;
unknown = (void *)0xdeadbeef; - hr = DirectInputCreateW( hInstance, version, (IDirectInputW **)&unknown, &outer ); + hr = DirectInputCreateW( instance, version, (IDirectInputW **)&unknown, &outer ); ok( hr == DI_OK, "DirectInputCreateW returned %#lx\n", hr ); ok( unknown == NULL, "got IUnknown %p\n", unknown );
@@ -294,21 +296,21 @@ static void test_DirectInputCreateEx( DWORD version ) {NULL, version + 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, {NULL, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, {NULL, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_INVALIDPARAM}, - {hInstance, 0, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, - {hInstance, 0, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, - {hInstance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOTINITIALIZED}, - {hInstance, version, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, - {hInstance, version, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, - {hInstance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version - 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, - {hInstance, version - 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, - {hInstance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version - 1, &IID_IDirectInputA, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, - {hInstance, version + 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, - {hInstance, version + 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, - {hInstance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version + 1, &IID_IDirectInputA, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, + {instance, 0, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {instance, 0, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {instance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOTINITIALIZED}, + {instance, version, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {instance, version, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {instance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version - 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {instance, version - 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {instance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version - 1, &IID_IDirectInputA, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, + {instance, version + 1, &IID_IUnknown, NULL, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {instance, version + 1, &IID_IUnknown, &unknown, (void *)0xdeadbeef, DIERR_NOINTERFACE}, + {instance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version + 1, &IID_IDirectInputA, &unknown, NULL, version < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, }; HRESULT hr; int i; @@ -320,7 +322,7 @@ static void test_DirectInputCreateEx( DWORD version ) }
unknown = (void *)0xdeadbeef; - hr = pDirectInputCreateEx( hInstance, version, &IID_IDirectInputW, (void **)&unknown, &outer ); + hr = pDirectInputCreateEx( instance, version, &IID_IDirectInputW, (void **)&unknown, &outer ); ok( hr == DI_OK, "DirectInputCreateW returned %#lx\n", hr ); ok( unknown == NULL, "got IUnknown %p\n", unknown );
@@ -341,7 +343,7 @@ static void test_DirectInputCreateEx( DWORD version ) { winetest_push_context( "%u", i ); unknown = (void *)0xdeadbeef; - hr = pDirectInputCreateEx( hInstance, version, dinput8_interfaces[i], (void **)&unknown, NULL ); + hr = pDirectInputCreateEx( instance, version, dinput8_interfaces[i], (void **)&unknown, NULL ); ok( hr == DIERR_NOINTERFACE, "DirectInputCreateEx returned %#lx\n", hr ); ok( unknown == (void *)0xdeadbeef, "got IUnknown %p\n", unknown ); winetest_pop_context(); @@ -351,7 +353,7 @@ static void test_DirectInputCreateEx( DWORD version ) { winetest_push_context( "%u", i ); unknown = NULL; - hr = pDirectInputCreateEx( hInstance, version, dinput7_interfaces[i], (void **)&unknown, NULL ); + hr = pDirectInputCreateEx( instance, version, dinput7_interfaces[i], (void **)&unknown, NULL ); if (version < 0x800) ok( hr == DI_OK, "DirectInputCreateEx returned %#lx\n", hr ); else ok( hr == DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateEx returned %#lx\n", hr ); if (version < 0x800) ok( unknown != NULL, "got IUnknown NULL\n" ); @@ -390,27 +392,27 @@ static void test_DirectInput8Create( DWORD version ) {NULL, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, {NULL, version + 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, {NULL, version + 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_INVALIDPARAM}, - {hInstance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, - {hInstance, 0, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, 0, &IID_IDirectInput8A, &unknown, NULL, DIERR_NOTINITIALIZED}, - {hInstance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, - {hInstance, version, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version - 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, - {hInstance, version - 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version - 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_BETADIRECTINPUTVERSION}, - {hInstance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, - {hInstance, version + 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, - {hInstance, version + 1, &IID_IDirectInput8A, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, + {instance, 0, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, 0, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {instance, 0, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, 0, &IID_IDirectInput8A, &unknown, NULL, DIERR_NOTINITIALIZED}, + {instance, version, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {instance, version, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version - 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version - 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {instance, version - 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version - 1, &IID_IDirectInput8A, &unknown, NULL, DIERR_BETADIRECTINPUTVERSION}, + {instance, version + 1, &IID_IDirectInputA, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version + 1, &IID_IDirectInputA, &unknown, NULL, DIERR_NOINTERFACE}, + {instance, version + 1, &IID_IDirectInput8A, NULL, (void *)0xdeadbeef, E_POINTER}, + {instance, version + 1, &IID_IDirectInput8A, &unknown, NULL, version <= 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION}, }; HRESULT hr; int i;
unknown = (void *)0xdeadbeef; - hr = DirectInput8Create( hInstance, version, &IID_IDirectInput8W, (void **)&unknown, &outer ); + hr = DirectInput8Create( instance, version, &IID_IDirectInput8W, (void **)&unknown, &outer ); ok( hr == DI_OK, "DirectInputCreateW returned %#lx\n", hr ); ok( unknown == NULL, "got IUnknown %p\n", unknown );
@@ -430,7 +432,7 @@ static void test_DirectInput8Create( DWORD version ) { winetest_push_context( "%u", i ); unknown = (void *)0xdeadbeef; - hr = DirectInput8Create( hInstance, version, dinput7_interfaces[i], (void **)&unknown, NULL ); + hr = DirectInput8Create( instance, version, dinput7_interfaces[i], (void **)&unknown, NULL ); ok( hr == DIERR_NOINTERFACE, "DirectInput8Create returned %#lx\n", hr ); ok( unknown == NULL, "got IUnknown %p\n", unknown ); winetest_pop_context(); @@ -440,7 +442,7 @@ static void test_DirectInput8Create( DWORD version ) { winetest_push_context( "%u", i ); unknown = NULL; - hr = DirectInput8Create( hInstance, version, dinput8_interfaces[i], (void **)&unknown, NULL ); + hr = DirectInput8Create( instance, version, dinput8_interfaces[i], (void **)&unknown, NULL ); if (i == 2) ok( hr == DIERR_NOINTERFACE, "DirectInput8Create returned %#lx\n", hr ); else if (version == 0x800) ok( hr == DI_OK, "DirectInput8Create returned %#lx\n", hr ); else ok( hr == DIERR_BETADIRECTINPUTVERSION, "DirectInput8Create returned %#lx\n", hr ); @@ -762,18 +764,18 @@ static void test_Initialize( DWORD version ) if (version == 0x300) todo_wine ok( hr == S_OK, "Initialize returned %#lx\n", hr ); else ok( hr == DIERR_INVALIDPARAM, "Initialize returned %#lx\n", hr );
- hr = IDirectInput_Initialize( dinput, hInstance, 0 ); + hr = IDirectInput_Initialize( dinput, instance, 0 ); ok( hr == DIERR_NOTINITIALIZED, "Initialize returned %#lx\n", hr );
- hr = IDirectInput_Initialize( dinput, hInstance, version - 1 ); + hr = IDirectInput_Initialize( dinput, instance, version - 1 ); ok( hr == DIERR_BETADIRECTINPUTVERSION, "Initialize returned %#lx\n", hr );
- hr = IDirectInput_Initialize( dinput, hInstance, version + 1 ); + hr = IDirectInput_Initialize( dinput, instance, version + 1 ); if (version >= 0x700) ok( hr == DIERR_OLDDIRECTINPUTVERSION, "Initialize returned %#lx\n", hr ); else ok( hr == DIERR_BETADIRECTINPUTVERSION, "Initialize returned %#lx\n", hr );
/* Parameters are still validated after successful initialization. */ - hr = IDirectInput_Initialize( dinput, hInstance, 0 ); + hr = IDirectInput_Initialize( dinput, instance, 0 ); ok( hr == DIERR_NOTINITIALIZED, "Initialize returned %#lx\n", hr );
ref = IDirectInput_Release( dinput ); @@ -819,7 +821,7 @@ static void test_DirectInputJoyConfig8(void) HRESULT hr; int i;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); + hr = DirectInputCreateA(instance, DIRECTINPUT_VERSION, &pDI, NULL); if (FAILED(hr)) { win_skip("Failed to instantiate a IDirectInputA instance: 0x%#lx\n", hr); @@ -933,7 +935,7 @@ static void test_EnumDevicesBySemantics(void) int device_total = 0; HRESULT hr;
- hr = DirectInput8Create( hInstance, 0x800, &IID_IDirectInput8A, (void **)&dinput, NULL ); + hr = DirectInput8Create( instance, 0x800, &IID_IDirectInput8A, (void **)&dinput, NULL ); if (FAILED(hr)) { win_skip( "Failed to instantiate a IDirectInputA instance: 0x%#lx\n", hr ); @@ -1051,17 +1053,12 @@ static void test_EnumDevicesBySemantics(void)
START_TEST(dinput) { - HMODULE dinput_mod = GetModuleHandleA("dinput.dll"); DWORD i;
- hInstance = GetModuleHandleA(NULL); + dinput_test_init();
- pDirectInputCreateEx = (void *)GetProcAddress(dinput_mod, "DirectInputCreateEx"); - - CoInitialize( NULL ); test_CoCreateInstance( 0x700 ); test_CoCreateInstance( 0x800 ); - CoUninitialize();
for (i = 0; i < ARRAY_SIZE(dinput_versions); i++) { @@ -1080,4 +1077,6 @@ START_TEST(dinput)
test_DirectInputJoyConfig8(); test_EnumDevicesBySemantics(); + + dinput_test_exit(); } diff --git a/dlls/dinput/tests/dinput_test.h b/dlls/dinput/tests/dinput_test.h index 677f8c96361..04738cffb44 100644 --- a/dlls/dinput/tests/dinput_test.h +++ b/dlls/dinput/tests/dinput_test.h @@ -50,6 +50,7 @@ extern const GUID expect_guid_product; extern const WCHAR expect_path[]; extern const WCHAR expect_path_end[];
+extern typeof(DirectInputCreateEx) *pDirectInputCreateEx; extern HANDLE device_added, device_removed; extern HINSTANCE instance; extern BOOL localized; /* object names get translated */ @@ -62,7 +63,7 @@ void bus_device_stop(void); void cleanup_registry_keys(void);
#define dinput_test_init() dinput_test_init_( __FILE__, __LINE__ ) -BOOL dinput_test_init_( const char *file, int line ); +void dinput_test_init_( const char *file, int line ); void dinput_test_exit(void);
HRESULT dinput_test_create_device( DWORD version, DIDEVICEINSTANCEW *devinst, IDirectInputDevice8W **device ); diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index 30d19cc04a0..1bcd56d685a 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -6405,10 +6405,9 @@ done:
START_TEST( force_feedback ) { - if (!dinput_test_init()) return; + dinput_test_init(); if (!bus_device_start()) goto done;
- CoInitialize( NULL ); if (test_force_feedback_joystick( 0x800 )) { test_force_feedback_joystick( 0x500 ); @@ -6416,7 +6415,6 @@ START_TEST( force_feedback ) test_device_managed_effect(); test_windows_gaming_input(); } - CoUninitialize();
done: bus_device_stop(); diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c index 2d7199fa3e5..e1658f1283f 100644 --- a/dlls/dinput/tests/hid.c +++ b/dlls/dinput/tests/hid.c @@ -44,7 +44,6 @@ #include "objbase.h"
#define COBJMACROS -#include "dinput.h"
#include "initguid.h" #include "ddk/wdm.h" @@ -52,13 +51,16 @@ #include "ddk/hidsdi.h" #include "ddk/hidpi.h" #include "ddk/hidport.h" -#include "hidusage.h" #include "devguid.h" +#include "dinput.h" +#include "dinputd.h" +#include "hidusage.h"
#include "wine/mssign.h"
#include "dinput_test.h"
+typeof(DirectInputCreateEx) *pDirectInputCreateEx; HINSTANCE instance; BOOL localized; /* object names get translated */
@@ -475,6 +477,8 @@ void bus_device_stop(void) DWORD size; BOOL ret;
+ if (!test_data) return; + set = SetupDiCreateDeviceInfoList( NULL, NULL ); ok( set != INVALID_HANDLE_VALUE, "failed to create device list, error %lu\n", GetLastError() );
@@ -600,6 +604,8 @@ BOOL bus_device_start(void) HDEVINFO set; FILE *f;
+ if (!test_data) return FALSE; + old_mute_threshold = winetest_mute_threshold; winetest_mute_threshold = 1;
@@ -3459,52 +3465,55 @@ DWORD WINAPI monitor_thread_proc( void *stop_event ) return 0; }
-BOOL dinput_test_init_( const char *file, int line ) +void dinput_test_init_( const char *file, int line ) { BOOL is_wow64;
monitor_stop = CreateEventW( NULL, FALSE, FALSE, NULL ); - ok( !!monitor_stop, "CreateEventW failed, error %lu\n", GetLastError() ); + ok_(file, line)( !!monitor_stop, "CreateEventW failed, error %lu\n", GetLastError() ); device_added = CreateEventW( NULL, FALSE, FALSE, NULL ); - ok( !!device_added, "CreateEventW failed, error %lu\n", GetLastError() ); + ok_(file, line)( !!device_added, "CreateEventW failed, error %lu\n", GetLastError() ); device_removed = CreateEventW( NULL, FALSE, FALSE, NULL ); - ok( !!device_removed, "CreateEventW failed, error %lu\n", GetLastError() ); + ok_(file, line)( !!device_removed, "CreateEventW failed, error %lu\n", GetLastError() ); monitor_thread = CreateThread( NULL, 0, monitor_thread_proc, monitor_stop, 0, NULL ); - ok( !!monitor_thread, "CreateThread failed, error %lu\n", GetLastError() ); + ok_(file, line)( !!monitor_thread, "CreateThread failed, error %lu\n", GetLastError() ); + + CoInitialize( NULL );
- subtest_(file, line)( "hid" ); instance = GetModuleHandleW( NULL ); localized = GetUserDefaultLCID() != MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT); pSignerSign = (void *)GetProcAddress( LoadLibraryW( L"mssign32" ), "SignerSign" ); + pDirectInputCreateEx = (void *)GetProcAddress( LoadLibraryW(L"dinput.dll"), "DirectInputCreateEx" );
if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64) { - skip( "Running in WoW64.\n" ); - return FALSE; + skip_(file, line)( "Skipping driver tests: running in wow64.\n" ); + return; }
test_data_mapping = CreateFileMappingW( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(*test_data), L"Global\winetest_dinput_section" ); if (!test_data_mapping && GetLastError() == ERROR_ACCESS_DENIED) { - win_skip( "Failed to create test data mapping.\n" ); - return FALSE; + win_skip_(file, line)( "Skipping driver tests: failed to create mapping.\n" ); + return; } - ok( !!test_data_mapping, "got error %lu\n", GetLastError() ); + ok_(file, line)( !!test_data_mapping, "got error %lu\n", GetLastError() ); + test_data = MapViewOfFile( test_data_mapping, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 1024 ); + ok_(file, line)( !!test_data, "MapViewOfFile failed, error %lu\n", GetLastError() ); test_data->running_under_wine = !strcmp( winetest_platform, "wine" ); test_data->winetest_report_success = winetest_report_success; test_data->winetest_debug = winetest_debug;
okfile = CreateFileW( L"C:\windows\winetest_dinput_okfile", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL ); - ok( okfile != INVALID_HANDLE_VALUE, "failed to create file, error %lu\n", GetLastError() ); + ok_(file, line)( okfile != INVALID_HANDLE_VALUE, "failed to create file, error %lu\n", GetLastError() );
- subtest( "driver" ); - subtest( "driver_bus" ); - subtest( "driver_hid" ); - subtest( "driver_hid_poll" ); - return TRUE; + subtest_(file, line)( "driver" ); + subtest_(file, line)( "driver_bus" ); + subtest_(file, line)( "driver_hid" ); + subtest_(file, line)( "driver_hid_poll" ); }
void dinput_test_exit(void) @@ -3520,6 +3529,8 @@ void dinput_test_exit(void) CloseHandle( monitor_stop ); CloseHandle( device_removed ); CloseHandle( device_added ); + + CoUninitialize(); }
BOOL CALLBACK find_test_device( const DIDEVICEINSTANCEW *devinst, void *context ) @@ -3931,7 +3942,7 @@ done:
START_TEST( hid ) { - if (!dinput_test_init()) return; + dinput_test_init();
test_bus_driver();
diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c index 885d0e036e0..9896e7b480e 100644 --- a/dlls/dinput/tests/hotplug.c +++ b/dlls/dinput/tests/hotplug.c @@ -1218,10 +1218,9 @@ next:
START_TEST( hotplug ) { - if (!dinput_test_init()) return; + dinput_test_init(); if (!bus_device_start()) goto done;
- CoInitialize( NULL ); if (test_input_lost( 0x500 )) { test_input_lost( 0x700 ); @@ -1230,7 +1229,6 @@ START_TEST( hotplug ) test_RegisterDeviceNotification(); test_windows_gaming_input(); } - CoUninitialize();
done: bus_device_stop(); diff --git a/dlls/dinput/tests/joystick.c b/dlls/dinput/tests/joystick.c index 8647b42cc94..1b85f13f9a7 100644 --- a/dlls/dinput/tests/joystick.c +++ b/dlls/dinput/tests/joystick.c @@ -18,18 +18,19 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS -#include <windows.h> - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> +#include <stdarg.h> +#include <stddef.h>
-#include "wine/test.h" +#include "ntstatus.h" +#define WIN32_NO_STATUS #include "windef.h" -#include "wingdi.h" +#include "winbase.h" + +#define COBJMACROS #include "dinput.h"
+#include "dinput_test.h" + typedef struct tagUserData { IDirectInputA *pDI; DWORD version; @@ -317,7 +318,6 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef) LPDIRECTINPUTEFFECT effect = NULL; LONG cnt1, cnt2; HWND real_hWnd; - HINSTANCE hInstance = GetModuleHandleW(NULL); DIPROPDWORD dip_gain_set, dip_gain_get; struct effect_enum effect_data;
@@ -549,7 +549,7 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef) * - a visible window */ real_hWnd = CreateWindowExA(0, "EDIT", "Test text", 0, 10, 10, 300, 300, NULL, NULL, - hInstance, NULL); + instance, NULL); ok(real_hWnd!=0,"CreateWindowExA failed: %p\n", real_hWnd); ShowWindow(real_hWnd, SW_SHOW); hr = IDirectInputDevice_Unacquire(pJoystick); @@ -598,7 +598,7 @@ static BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCEA *lpddi, void *pvRef) GUID guid = {0}; DIEFFECT effect_empty;
- hr = IDirectInputEffect_Initialize(effect, hInstance, data->version, + hr = IDirectInputEffect_Initialize(effect, instance, data->version, &effect_data.guid); ok(hr==DI_OK,"IDirectInputEffect_Initialize failed: %#lx\n", hr);
@@ -915,10 +915,9 @@ static void joystick_tests(DWORD version) HRESULT hr; IDirectInputA *pDI; ULONG ref; - HINSTANCE hInstance = GetModuleHandleW(NULL);
trace("-- Testing Direct Input Version %#lx --\n", version); - hr = DirectInputCreateA(hInstance, version, &pDI, NULL); + hr = DirectInputCreateA(instance, version, &pDI, NULL); ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateA() failed: %#lx\n", hr); if (hr==DI_OK && pDI!=0) { UserData data; @@ -938,9 +937,8 @@ static void test_enum_feedback(void) HRESULT hr; IDirectInputA *pDI; ULONG ref; - HINSTANCE hInstance = GetModuleHandleW(NULL);
- hr = DirectInputCreateA(hInstance, 0x0700, &pDI, NULL); + hr = DirectInputCreateA(instance, 0x0700, &pDI, NULL); ok(hr==DI_OK||hr==DIERR_OLDDIRECTINPUTVERSION, "DirectInputCreateA() failed: %#lx\n", hr); if (hr==DI_OK && pDI!=0) { hr = IDirectInput_EnumDevices(pDI, 0, EnumAllFeedback, NULL, DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK); @@ -953,7 +951,7 @@ static void test_enum_feedback(void)
START_TEST(joystick) { - CoInitialize(NULL); + dinput_test_init();
joystick_tests(0x0700); joystick_tests(0x0500); @@ -961,5 +959,5 @@ START_TEST(joystick)
test_enum_feedback();
- CoUninitialize(); + dinput_test_exit(); } diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index 070d9cc2361..62b915af0fa 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -4162,10 +4162,9 @@ done:
START_TEST( joystick8 ) { - if (!dinput_test_init()) return; + dinput_test_init(); if (!bus_device_start()) goto done;
- CoInitialize( NULL ); if (test_device_types( 0x800 )) { /* This needs to be done before doing anything involving dinput.dll @@ -4183,7 +4182,6 @@ START_TEST( joystick8 ) test_driving_wheel_axes(); test_windows_gaming_input(); } - CoUninitialize();
done: bus_device_stop(); diff --git a/dlls/dinput/tests/keyboard.c b/dlls/dinput/tests/keyboard.c index 251a12073df..0d3cf7b10c2 100644 --- a/dlls/dinput/tests/keyboard.c +++ b/dlls/dinput/tests/keyboard.c @@ -18,20 +18,18 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS -#include <windows.h> - -#include <math.h> -#include <stdio.h> -#include <stdlib.h> +#include <stdarg.h> +#include <stddef.h>
-#include "wine/test.h" +#include "ntstatus.h" +#define WIN32_NO_STATUS #include "windef.h" -#include "wingdi.h" +#include "winbase.h" + +#define COBJMACROS #include "dinput.h"
-/* to make things easier with PSDK without a dinput.lib */ -static HRESULT (WINAPI *pDirectInputCreateA)(HINSTANCE,DWORD,IDirectInputA **,IUnknown *); +#include "dinput_test.h"
static void pump_messages(void) { @@ -513,11 +511,10 @@ static void keyboard_tests(DWORD version) { HRESULT hr; IDirectInputA *pDI = NULL; - HINSTANCE hInstance = GetModuleHandleW(NULL); HWND hwnd; ULONG ref = 0;
- hr = pDirectInputCreateA(hInstance, version, &pDI, NULL); + hr = DirectInputCreateA(instance, version, &pDI, NULL); if (hr == DIERR_OLDDIRECTINPUTVERSION) { skip("Tests require a newer dinput version\n"); @@ -554,11 +551,9 @@ static void keyboard_tests(DWORD version)
START_TEST(keyboard) { - pDirectInputCreateA = (void *)GetProcAddress(GetModuleHandleA("dinput.dll"), "DirectInputCreateA"); - - CoInitialize(NULL); + dinput_test_init();
keyboard_tests(0x0700);
- CoUninitialize(); + dinput_test_exit(); } diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index 8be808e5da6..2d92fe2b14c 100644 --- a/dlls/dinput/tests/mouse.c +++ b/dlls/dinput/tests/mouse.c @@ -19,17 +19,19 @@
#define DIRECTINPUT_VERSION 0x0700
-#define COBJMACROS -#include <windows.h> - -#include <math.h> -#include <stdlib.h> +#include <stdarg.h> +#include <stddef.h>
-#include "wine/test.h" +#include "ntstatus.h" +#define WIN32_NO_STATUS #include "windef.h" -#include "wingdi.h" +#include "winbase.h" + +#define COBJMACROS #include "dinput.h"
+#include "dinput_test.h" + static const HRESULT SetCoop_null_window[16] = { E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG, @@ -290,11 +292,10 @@ static void mouse_tests(void) { HRESULT hr; IDirectInputA *pDI = NULL; - HINSTANCE hInstance = GetModuleHandleW(NULL); HWND hwnd; ULONG ref = 0;
- hr = DirectInputCreateA(hInstance, DIRECTINPUT_VERSION, &pDI, NULL); + hr = DirectInputCreateA(instance, DIRECTINPUT_VERSION, &pDI, NULL); if (hr == DIERR_OLDDIRECTINPUTVERSION) { skip("Tests require a newer dinput version\n"); @@ -323,9 +324,9 @@ static void mouse_tests(void)
START_TEST(mouse) { - CoInitialize(NULL); + dinput_test_init();
mouse_tests();
- CoUninitialize(); + dinput_test_exit(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116466
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w7u_el (32 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w864 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w1064v1507 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w1064v1809 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w1064 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w1064_2qxl (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64_en_AE_u8 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64_ar (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64_ja (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w7u_2qxl (32 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w7u_el (32 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w864 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w1064v1507 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w1064v1809 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w1064 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w1064_2qxl (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64_en_AE_u8 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64_ar (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64_ja (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w7u_2qxl (32 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w7u_el (32 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w8 (32 bit report) ===
dinput: joystick8.c:1267: Test failed: 0x500: Acquire returned: 0x80070005 joystick8.c:1269: Test failed: 0x500: SetCooperativeLevel returned: 0 joystick8.c:1685: Test failed: 0x800: got lY 16853
=== w864 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w1064v1507 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w1064v1809 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w1064 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w1064_2qxl (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64_en_AE_u8 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64_ar (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64_ja (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== debian11 (32 bit report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Arabic:Morocco report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit German report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit French report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Hebrew:Israel report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Hindi:India report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Japanese:Japan report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Chinese:China report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (64 bit WoW report) ===
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/Makefile.in | 1 - dlls/dinput/tests/device.c | 533 ---------------------------------- dlls/dinput/tests/device8.c | 366 ++++++++++++++++++++++- 3 files changed, 355 insertions(+), 545 deletions(-) delete mode 100644 dlls/dinput/tests/device.c
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in index 73d8a2fc2a6..1556f3cda37 100644 --- a/dlls/dinput/tests/Makefile.in +++ b/dlls/dinput/tests/Makefile.in @@ -9,7 +9,6 @@ driver_hid_poll_IMPORTS = winecrt0 ntoskrnl hal hidclass driver_hid_poll_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
SOURCES = \ - device.c \ device8.c \ dinput.c \ driver_bus.c \ diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c deleted file mode 100644 index 6e1e94ba9c2..00000000000 --- a/dlls/dinput/tests/device.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * Copyright (c) 2006 Vitaliy Margolen - * - * 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 - */ - -#define DIRECTINPUT_VERSION 0x0700 - -#include <stdarg.h> -#include <stddef.h> -#include <limits.h> - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winbase.h" - -#define COBJMACROS -#include "dinput.h" - -#include "dinput_test.h" - -static const DIOBJECTDATAFORMAT obj_data_format[] = { - { &GUID_YAxis, 16, DIDFT_OPTIONAL|DIDFT_AXIS |DIDFT_MAKEINSTANCE(1), 0}, - { &GUID_Button,15, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(3), 0}, - { &GUID_Key, 0, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(16),0}, - { &GUID_Key, 1, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(17),0}, - { &GUID_Key, 2, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(18),0}, - { &GUID_Key, 3, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(19),0}, - { &GUID_Key, 4, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(20),0}, - { &GUID_Key, 5, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(21),0}, - { &GUID_Key, 6, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(22),0}, - { &GUID_Key, 7, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(23),0}, - { &GUID_Key, 8, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(24),0}, - { &GUID_Key, 9, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(25),0}, - { &GUID_Key, 10, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(26),0}, - { &GUID_Key, 11, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(27),0}, - { &GUID_Key, 12, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(28),0}, - { NULL, 13, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(5),0}, - - { &GUID_Button,14, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(32),0} -}; - -static const DIDATAFORMAT data_format = { - sizeof(DIDATAFORMAT), - sizeof(DIOBJECTDATAFORMAT), - DIDF_ABSAXIS, - 32, - ARRAY_SIZE(obj_data_format), - (LPDIOBJECTDATAFORMAT)obj_data_format -}; - -static BOOL CALLBACK enum_callback(const DIDEVICEOBJECTINSTANCEA *oi, void *info) -{ - if (winetest_debug > 1) - trace(" Type:%#lx Ofs:%3ld Flags:%#lx Name:%s\n", - oi->dwType, oi->dwOfs, oi->dwFlags, oi->tszName); - (*(int*)info)++; - return DIENUM_CONTINUE; -} - -static BOOL CALLBACK enum_type_callback(const DIDEVICEOBJECTINSTANCEA *oi, void *info) -{ - DWORD expected = *(DWORD*)info; - ok (expected & DIDFT_GETTYPE(oi->dwType), "EnumObjects() enumerated wrong type for obj %s, expected: %#lx got: %#lx\n", oi->tszName, expected, oi->dwType); - return DIENUM_CONTINUE; -} - -static void test_object_info(IDirectInputDeviceA *device, HWND hwnd) -{ - HRESULT hr; - DIPROPDWORD dp; - DIDEVICEOBJECTINSTANCEA obj_info; - DWORD obj_types[] = {DIDFT_BUTTON, DIDFT_AXIS, DIDFT_POV}; - int type_index; - int cnt1 = 0; - DWORD cnt = 0; - DIDEVICEOBJECTDATA buffer[5]; - - hr = IDirectInputDevice_EnumObjects(device, NULL, &cnt, DIDFT_ALL); - ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_EnumObjects returned %#lx, expected %#lx\n", hr, DIERR_INVALIDPARAM); - - hr = IDirectInputDevice_EnumObjects(device, enum_callback, &cnt, DIDFT_ALL); - ok(SUCCEEDED(hr), "EnumObjects() failed: %#lx\n", hr); - - hr = IDirectInputDevice_SetDataFormat(device, &data_format); - ok(SUCCEEDED(hr), "SetDataFormat() failed: %#lx\n", hr); - - hr = IDirectInputDevice_EnumObjects(device, enum_callback, &cnt1, DIDFT_ALL); - ok(SUCCEEDED(hr), "EnumObjects() failed: %#lx\n", hr); - if (0) /* fails for joystick only */ - ok(cnt == cnt1, "Enum count changed from %lu to %u\n", cnt, cnt1); - - /* Testing EnumObjects with different types of device objects */ - for (type_index=0; type_index < ARRAY_SIZE(obj_types); type_index++) - { - hr = IDirectInputDevice_EnumObjects(device, enum_type_callback, &obj_types[type_index], obj_types[type_index]); - ok(SUCCEEDED(hr), "EnumObjects() failed: %#lx\n", hr); - } - - /* Test buffered mode */ - memset(&dp, 0, sizeof(dp)); - dp.diph.dwSize = sizeof(DIPROPDWORD); - dp.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dp.diph.dwHow = DIPH_DEVICE; - dp.diph.dwObj = 0; - dp.dwData = UINT_MAX; - - hr = IDirectInputDevice_GetProperty(device, DIPROP_BUFFERSIZE, &dp.diph); - ok(hr == DI_OK, "Failed: %#lx\n", hr); - ok(dp.dwData == 0, "got %ld\n", dp.dwData); - - dp.dwData = UINT_MAX; - hr = IDirectInputDevice_SetProperty(device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&dp.diph); - ok(hr == DI_OK, "SetProperty() failed: %#lx\n", hr); - - dp.dwData = 0; - hr = IDirectInputDevice_GetProperty(device, DIPROP_BUFFERSIZE, &dp.diph); - ok(hr == DI_OK, "Failed: %#lx\n", hr); - ok(dp.dwData == UINT_MAX, "got %ld\n", dp.dwData); - - dp.dwData = 0; - hr = IDirectInputDevice_SetProperty(device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&dp.diph); - ok(hr == DI_OK, "SetProperty() failed: %#lx\n", hr); - cnt = 5; - hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer[0]), buffer, &cnt, 0); - ok(hr == DI_OK && cnt == 5, "GetDeviceData() failed: %#lx cnt: %ld\n", hr, cnt); - hr = IDirectInputDevice_GetDeviceData(device, sizeof(DIDEVICEOBJECTDATA_DX3), buffer, &cnt, 0); - ok(hr == DIERR_NOTBUFFERED, "GetDeviceData() should have failed: %#lx\n", hr); - IDirectInputDevice_Acquire(device); - hr = IDirectInputDevice_GetDeviceData(device, sizeof(DIDEVICEOBJECTDATA_DX3), buffer, &cnt, 0); - ok(hr == DIERR_NOTBUFFERED, "GetDeviceData() should have failed: %#lx\n", hr); - IDirectInputDevice_Unacquire(device); - - dp.dwData = 20; - hr = IDirectInputDevice_SetProperty(device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&dp.diph); - ok(hr == DI_OK, "SetProperty() failed: %#lx\n", hr); - cnt = 5; - hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer[0]), buffer, &cnt, 0); - ok(hr == DI_OK, "GetDeviceData() failed: %#lx\n", hr); - hr = IDirectInputDevice_GetDeviceData(device, sizeof(DIDEVICEOBJECTDATA_DX3), buffer, &cnt, 0); - ok(hr == DIERR_NOTACQUIRED, "GetDeviceData() should have failed: %#lx\n", hr); - hr = IDirectInputDevice_Acquire(device); - ok(hr == DI_OK, "Acquire() failed: %#lx\n", hr); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer[0]), buffer, &cnt, 0); - ok(hr == DI_OK, "GetDeviceData() failed: %#lx\n", hr); - hr = IDirectInputDevice_Unacquire(device); - ok(hr == DI_OK, "Unacquire() failed: %#lx\n", hr); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(device, sizeof(buffer[0]), buffer, &cnt, 0); - ok(hr == DI_OK, "GetDeviceData() failed: %#lx\n", hr); - - hr = IDirectInputDevice_GetObjectInfo(device, NULL, 16, DIPH_BYOFFSET); - ok(hr == E_POINTER, "IDirectInputDevice_GetObjectInfo returned %#lx, expected %#lx\n", hr, E_POINTER); - - obj_info.dwSize = 1; - hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET); - ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetObjectInfo returned %#lx, expected %#lx\n", hr, DIERR_INVALIDPARAM); - obj_info.dwSize = 0xdeadbeef; - hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET); - ok(hr == DIERR_INVALIDPARAM, "IDirectInputDevice_GetObjectInfo returned %#lx, expected %#lx\n", hr, DIERR_INVALIDPARAM); - - /* No need to test devices without axis */ - obj_info.dwSize = sizeof(obj_info); - hr = IDirectInputDevice_GetObjectInfo(device, &obj_info, 16, DIPH_BYOFFSET); - if (SUCCEEDED(hr)) - { - /* No device supports per axis relative/absolute mode */ - dp.diph.dwHow = DIPH_BYOFFSET; - dp.diph.dwObj = 16; - dp.dwData = DIPROPAXISMODE_ABS; - hr = IDirectInputDevice_SetProperty(device, DIPROP_AXISMODE, &dp.diph); - ok(hr == DIERR_UNSUPPORTED, "SetProperty() returned: %#lx\n", hr); - dp.diph.dwHow = DIPH_DEVICE; - hr = IDirectInputDevice_SetProperty(device, DIPROP_AXISMODE, &dp.diph); - ok(hr == DIERR_INVALIDPARAM, "SetProperty() returned: %#lx\n", hr); - dp.diph.dwObj = 0; - hr = IDirectInputDevice_SetProperty(device, DIPROP_AXISMODE, &dp.diph); - ok(hr == DI_OK, "SetProperty() failed: %#lx\n", hr); - - /* Cannot change mode while acquired */ - hr = IDirectInputDevice_Acquire(device); - ok(hr == DI_OK, "Acquire() failed: %#lx\n", hr); - - hr = IDirectInputDevice_SetProperty(device, DIPROP_AXISMODE, &dp.diph); - ok(hr == DIERR_ACQUIRED, "SetProperty() returned: %#lx\n", hr); - hr = IDirectInputDevice_Unacquire(device); - ok(hr == DI_OK, "Unacquire() failed: %#lx\n", hr); - } - - /* Reset buffer size */ - dp.diph.dwSize = sizeof(DIPROPDWORD); - dp.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dp.diph.dwHow = DIPH_DEVICE; - dp.diph.dwObj = 0; - dp.dwData = 0; - hr = IDirectInputDevice_SetProperty(device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&dp.diph); - ok(hr == DI_OK, "SetProperty() failed: %#lx\n", hr); -} - -struct enum_data -{ - IDirectInputA *pDI; - HWND hwnd; - BOOL tested_product_creation; -}; - -static BOOL CALLBACK enum_devices(const DIDEVICEINSTANCEA *lpddi, void *pvRef) -{ - struct enum_data *data = pvRef; - IDirectInputDeviceA *device, *obj = NULL; - DIDEVICEINSTANCEA ddi2; - HRESULT hr; - IUnknown *iface, *tmp_iface; - - hr = IDirectInput_GetDeviceStatus(data->pDI, &lpddi->guidInstance); - ok(hr == DI_OK, "IDirectInput_GetDeviceStatus() failed: %#lx\n", hr); - - if (hr == DI_OK) - { - hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, &device, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr); - trace("Testing device %p "%s"\n", device, lpddi->tszInstanceName); - - hr = IUnknown_QueryInterface(device, &IID_IDirectInputDevice2A, (LPVOID*)&obj); - ok(SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice2A) failed: %#lx\n", hr); - test_object_info(obj, data->hwnd); - IUnknown_Release(obj); - obj = NULL; - - hr = IUnknown_QueryInterface(device, &IID_IDirectInputDevice2W, (LPVOID*)&obj); - ok(SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice2W) failed: %#lx\n", hr); - test_object_info(obj, data->hwnd); - IUnknown_Release(obj); - - hr = IUnknown_QueryInterface( device, &IID_IDirectInputDeviceA, (void **)&iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDeviceA) failed: %#lx\n", hr ); - hr = IUnknown_QueryInterface( device, &IID_IDirectInputDevice2A, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice2A) failed: %#lx\n", hr ); - ok( tmp_iface == iface, "IDirectInputDevice2A iface differs from IDirectInputDeviceA\n" ); - IUnknown_Release( tmp_iface ); - hr = IUnknown_QueryInterface( device, &IID_IDirectInputDevice7A, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice7A) failed: %#lx\n", hr ); - ok( tmp_iface == iface, "IDirectInputDevice7A iface differs from IDirectInputDeviceA\n" ); - IUnknown_Release( tmp_iface ); - IUnknown_Release( iface ); - - hr = IUnknown_QueryInterface( device, &IID_IUnknown, (void **)&iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IUnknown) failed: %#lx\n", hr ); - hr = IUnknown_QueryInterface( device, &IID_IDirectInputDeviceW, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDeviceW) failed: %#lx\n", hr ); - ok( tmp_iface == iface, "IDirectInputDeviceW iface differs from IUnknown\n" ); - IUnknown_Release( tmp_iface ); - hr = IUnknown_QueryInterface( device, &IID_IDirectInputDevice2W, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice2W) failed: %#lx\n", hr ); - ok( tmp_iface == iface, "IDirectInputDevice2W iface differs from IUnknown\n" ); - IUnknown_Release( tmp_iface ); - hr = IUnknown_QueryInterface( device, &IID_IDirectInputDevice7W, (void **)&tmp_iface ); - ok( SUCCEEDED(hr), "IUnknown_QueryInterface(IID_IDirectInputDevice7W) failed: %#lx\n", hr ); - ok( tmp_iface == iface, "IDirectInputDevice7W iface differs from IUnknown\n" ); - IUnknown_Release( tmp_iface ); - IUnknown_Release( iface ); - - IUnknown_Release(device); - - if (!IsEqualGUID(&lpddi->guidInstance, &lpddi->guidProduct)) - { - data->tested_product_creation = TRUE; - hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidProduct, &device, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr); - - ddi2.dwSize = sizeof(ddi2); - hr = IDirectInputDevice_GetDeviceInfo(device, &ddi2); - ok(SUCCEEDED(hr), "IDirectInput_GetDeviceInfo failed: %#lx\n", hr); - - ok(IsEqualGUID(&lpddi->guidProduct, &ddi2.guidProduct), "Product GUIDs do not match. Expected %s, got %s\n", debugstr_guid(&lpddi->guidProduct), debugstr_guid(&ddi2.guidProduct)); - ok(IsEqualGUID(&ddi2.guidProduct, &ddi2.guidInstance), "Instance GUID should equal product GUID. Expected %s, got %s\n", debugstr_guid(&ddi2.guidProduct), debugstr_guid(&ddi2.guidInstance)); - /* we cannot compare guidInstances as we may get a different device */ - - IUnknown_Release(device); - } - - } - return DIENUM_CONTINUE; -} - -struct overlapped_state -{ - BYTE keys[4]; - DWORD extra_element; -}; - -static const DIOBJECTDATAFORMAT obj_overlapped_slider_format[] = { - { &GUID_Key, 0, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_A),0}, - { &GUID_Key, 1, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_S),0}, - { &GUID_Key, 2, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_D),0}, - { &GUID_Key, 3, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_F),0}, - { &GUID_Slider, 0, DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION}, -}; - -static const DIDATAFORMAT overlapped_slider_format = { - sizeof(DIDATAFORMAT), - sizeof(DIOBJECTDATAFORMAT), - DIDF_ABSAXIS, - sizeof(struct overlapped_state), - ARRAY_SIZE(obj_overlapped_slider_format), - (LPDIOBJECTDATAFORMAT)obj_overlapped_slider_format -}; - -static const DIOBJECTDATAFORMAT obj_overlapped_pov_format[] = { - { &GUID_Key, 0, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_A),0}, - { &GUID_Key, 1, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_S),0}, - { &GUID_Key, 2, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_D),0}, - { &GUID_Key, 3, DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(DIK_F),0}, - { &GUID_POV, 0, DIDFT_OPTIONAL|DIDFT_POV|DIDFT_ANYINSTANCE,0}, -}; - -static const DIDATAFORMAT overlapped_pov_format = { - sizeof(DIDATAFORMAT), - sizeof(DIOBJECTDATAFORMAT), - DIDF_ABSAXIS, - sizeof(struct overlapped_state), - ARRAY_SIZE(obj_overlapped_pov_format), - (LPDIOBJECTDATAFORMAT)obj_overlapped_pov_format -}; - -static void pump_messages(void) -{ - MSG msg; - - while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessageA(&msg); - } -} - -#define wait_for_device_data_and_discard(device) wait_for_device_data_and_discard_(__LINE__, device) -static BOOL wait_for_device_data_and_discard_(int line, IDirectInputDeviceA *device) -{ - DWORD cnt; - HRESULT hr; - DWORD start_time; - - pump_messages(); - - start_time = GetTickCount(); - do - { - cnt = 10; - hr = IDirectInputDevice_GetDeviceData(device, sizeof(DIDEVICEOBJECTDATA_DX3), NULL, &cnt, 0); - ok_(__FILE__, line)(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceData() failed: %#lx\n", hr); - ok_(__FILE__, line)(cnt == 0 || cnt == 1, "Unexpected number of events: %lu\n", cnt); - } while (cnt != 1 && (GetTickCount() - start_time < 500)); - - return cnt == 1; -} - -#define acquire_and_wait(device, valid_dik) acquire_and_wait_(__LINE__, device, valid_dik) -static void acquire_and_wait_(int line, IDirectInputDeviceA *device, DWORD valid_dik) -{ - HRESULT hr; - int tries = 2; - - hr = IDirectInputDevice_Acquire(device); - ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %#lx\n", hr); - - do - { - keybd_event(0, valid_dik, KEYEVENTF_SCANCODE, 0); - } while (!wait_for_device_data_and_discard(device) && tries--); - - keybd_event(0, valid_dik, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0); - ok_(__FILE__, line)(wait_for_device_data_and_discard(device), - "Timed out while waiting for injected events to be picked up by DirectInput.\n"); -} - -void overlapped_format_tests(IDirectInputA *pDI, HWND hwnd) -{ - HRESULT hr; - struct overlapped_state state; - IDirectInputDeviceA *keyboard = NULL; - DIPROPDWORD dp; - - SetFocus(hwnd); - - hr = IDirectInput_CreateDevice(pDI, &GUID_SysKeyboard, &keyboard, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr); - - /* test overlapped slider - default value 0 */ - hr = IDirectInputDevice_SetDataFormat(keyboard, &overlapped_slider_format); - ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %#lx\n", hr); - - dp.diph.dwSize = sizeof(DIPROPDWORD); - dp.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dp.diph.dwHow = DIPH_DEVICE; - dp.diph.dwObj = 0; - dp.dwData = 10; - hr = IDirectInputDevice_SetProperty(keyboard, DIPROP_BUFFERSIZE, &dp.diph); - ok(SUCCEEDED(hr), "IDirectInputDevice_SetProperty() failed: %#lx\n", hr); - - acquire_and_wait(keyboard, DIK_F); - - /* press D */ - keybd_event(0, DIK_D, KEYEVENTF_SCANCODE, 0); - ok(wait_for_device_data_and_discard(keyboard), - "Timed out while waiting for injected events to be picked up by DirectInput.\n"); - - memset(&state, 0xFF, sizeof(state)); - hr = IDirectInputDevice_GetDeviceState(keyboard, sizeof(state), &state); - ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %#lx\n", hr); - - ok(state.keys[0] == 0x00, "key A should be still up\n"); - ok(state.keys[1] == 0x00, "key S should be still up\n"); - ok(state.keys[2] == 0x80, "keydown for D did not register\n"); - ok(state.keys[3] == 0x00, "key F should be still up\n"); - ok(state.extra_element == 0, "State struct was not memset to zero\n"); - - /* release D */ - keybd_event(0, DIK_D, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0); - ok(wait_for_device_data_and_discard(keyboard), - "Timed out while waiting for injected events to be picked up by DirectInput.\n"); - - hr = IDirectInputDevice_Unacquire(keyboard); - ok(SUCCEEDED(hr), "IDirectInputDevice_Unacquire() failed: %#lx\n", hr); - - /* test overlapped pov - default value - 0xFFFFFFFF */ - hr = IDirectInputDevice_SetDataFormat(keyboard, &overlapped_pov_format); - ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %#lx\n", hr); - - acquire_and_wait(keyboard, DIK_F); - - /* press D */ - keybd_event(0, DIK_D, KEYEVENTF_SCANCODE, 0); - ok(wait_for_device_data_and_discard(keyboard), - "Timed out while waiting for injected events to be picked up by DirectInput.\n"); - - memset(&state, 0xFF, sizeof(state)); - hr = IDirectInputDevice_GetDeviceState(keyboard, sizeof(state), &state); - ok(SUCCEEDED(hr), "IDirectInputDevice_GetDeviceState() failed: %#lx\n", hr); - - ok(state.keys[0] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[1] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[2] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.keys[3] == 0xFF, "key state should have been overwritten by the overlapped POV\n"); - ok(state.extra_element == 0, "State struct was not memset to zero\n"); - - /* release D */ - keybd_event(0, DIK_D, KEYEVENTF_SCANCODE|KEYEVENTF_KEYUP, 0); - ok(wait_for_device_data_and_discard(keyboard), - "Timed out while waiting for injected events to be picked up by DirectInput.\n"); - - if (keyboard) IUnknown_Release(keyboard); -} - -static void device_tests(void) -{ - HRESULT hr; - IDirectInputA *pDI = NULL, *obj = NULL; - HWND hwnd; - struct enum_data data; - - hr = CoCreateInstance(&CLSID_DirectInput, 0, 1, &IID_IDirectInput2A, (LPVOID*)&pDI); - if (hr == DIERR_OLDDIRECTINPUTVERSION || hr == DIERR_DEVICENOTREG) - { - skip("Tests require a newer dinput version\n"); - return; - } - ok(SUCCEEDED(hr), "DirectInputCreateA() failed: %#lx\n", hr); - if (FAILED(hr)) return; - - hr = IDirectInput_Initialize(pDI, instance, DIRECTINPUT_VERSION); - ok(SUCCEEDED(hr), "Initialize() failed: %#lx\n", hr); - if (FAILED(hr)) return; - - hr = IUnknown_QueryInterface(pDI, &IID_IDirectInput2W, (LPVOID*)&obj); - ok(SUCCEEDED(hr), "QueryInterface(IDirectInput7W) failed: %#lx\n", hr); - - hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW, 10, 10, 200, 200, NULL, NULL, - NULL, NULL); - ok(hwnd != NULL, "err: %ld\n", GetLastError()); - if (hwnd) - { - ShowWindow(hwnd, SW_SHOW); - - data.pDI = pDI; - data.hwnd = hwnd; - data.tested_product_creation = FALSE; - hr = IDirectInput_EnumDevices(pDI, 0, enum_devices, &data, DIEDFL_ALLDEVICES); - ok(SUCCEEDED(hr), "IDirectInput_EnumDevices() failed: %#lx\n", hr); - - if (!data.tested_product_creation) winetest_skip("Device creation using product GUID not tested\n"); - - /* If GetDeviceStatus returns DI_OK the device must exist */ - hr = IDirectInput_GetDeviceStatus(pDI, &GUID_Joystick); - if (hr == DI_OK) - { - IDirectInputDeviceA *device = NULL; - - hr = IDirectInput_CreateDevice(pDI, &GUID_Joystick, &device, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr); - if (device) IUnknown_Release(device); - } - - overlapped_format_tests(pDI, hwnd); - - DestroyWindow(hwnd); - } - if (obj) IUnknown_Release(obj); - if (pDI) IUnknown_Release(pDI); -} - -START_TEST(device) -{ - dinput_test_init(); - - device_tests(); - - dinput_test_exit(); -} diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c index 70c3e516f17..96f641f0d95 100644 --- a/dlls/dinput/tests/device8.c +++ b/dlls/dinput/tests/device8.c @@ -21,6 +21,7 @@
#include <stdarg.h> #include <stddef.h> +#include <limits.h>
#include "ntstatus.h" #define WIN32_NO_STATUS @@ -33,13 +34,20 @@
#include "dinput_test.h"
-struct enum_data { - IDirectInput8A *pDI; +struct enum_data +{ + DWORD version; + union + { + IDirectInput8A *dinput8; + IDirectInputA *dinput; + }; DIACTIONFORMATA *lpdiaf; IDirectInputDevice8A *keyboard; IDirectInputDevice8A *mouse; - const char* username; + const char *username; int ndevices; + HWND hwnd; };
/* Dummy GUID */ @@ -74,19 +82,337 @@ static DIACTIONA actionMapping[]=
static void flush_events(void) { - int diff = 200; - int min_timeout = 100; + int min_timeout = 100, diff = 200; DWORD time = GetTickCount() + diff; + MSG msg;
while (diff > 0) { - if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) - break; + if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break; + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageA( &msg ); + } diff = time - GetTickCount(); - min_timeout = 50; } }
+static HRESULT direct_input_create( DWORD version, IDirectInputA **out ) +{ + HRESULT hr; + if (version < 0x800) hr = DirectInputCreateA( instance, version, out, NULL ); + else hr = DirectInput8Create( instance, version, &IID_IDirectInput8A, (void **)out, NULL ); + if (FAILED(hr)) win_skip( "Failed to instantiate a IDirectInput instance, hr %#lx\n", hr ); + return hr; +} + +#define check_interface( a, b, c ) check_interface_( __LINE__, a, b, c ) +static void check_interface_( unsigned int line, void *iface_ptr, REFIID iid, BOOL supported ) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected; + IUnknown *unk; + + expected = supported ? S_OK : E_NOINTERFACE; + hr = IUnknown_QueryInterface( iface, iid, (void **)&unk ); + ok_(__FILE__, line)( hr == expected, "got hr %#lx, expected %#lx.\n", hr, expected ); + if (SUCCEEDED(hr)) IUnknown_Release( unk ); +} + +static BOOL CALLBACK check_device_query_interface( const DIDEVICEINSTANCEA *instance, void *context ) +{ + struct enum_data *data = context; + IUnknown *device; + HRESULT hr; + LONG ref; + + if (data->version < 0x800) + { + hr = IDirectInput_GetDeviceStatus( data->dinput, &instance->guidInstance ); + ok( hr == DI_OK, "GetDeviceStatus returned %#lx\n", hr ); + hr = IDirectInput_GetDeviceStatus( data->dinput, &instance->guidProduct ); + ok( hr == DI_OK, "GetDeviceStatus returned %#lx\n", hr ); + + hr = IDirectInput_CreateDevice( data->dinput, &instance->guidProduct, (IDirectInputDeviceA **)&device, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr ); + ref = IUnknown_Release( device ); + ok( ref == 0, "Release returned %ld\n", ref ); + + hr = IDirectInput_CreateDevice( data->dinput, &instance->guidInstance, (IDirectInputDeviceA **)&device, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr ); + } + else + { + hr = IDirectInput8_GetDeviceStatus( data->dinput8, &instance->guidInstance ); + ok( hr == DI_OK, "GetDeviceStatus returned %#lx\n", hr ); + hr = IDirectInput8_GetDeviceStatus( data->dinput8, &instance->guidProduct ); + ok( hr == DI_OK, "GetDeviceStatus returned %#lx\n", hr ); + + hr = IDirectInput8_CreateDevice( data->dinput8, &instance->guidProduct, (IDirectInputDevice8A **)&device, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr ); + ref = IUnknown_Release( device ); + ok( ref == 0, "Release returned %ld\n", ref ); + + hr = IDirectInput8_CreateDevice( data->dinput8, &instance->guidInstance, (IDirectInputDevice8A **)&device, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr ); + } + + check_interface( device, &IID_IDirectInputDeviceA, data->version < 0x800 ); + check_interface( device, &IID_IDirectInputDevice2A, data->version < 0x800 ); + check_interface( device, &IID_IDirectInputDevice7A, data->version < 0x800 ); + check_interface( device, &IID_IDirectInputDevice8A, data->version >= 0x800 ); + + check_interface( device, &IID_IDirectInputDeviceW, data->version < 0x800 ); + check_interface( device, &IID_IDirectInputDevice2W, data->version < 0x800 ); + check_interface( device, &IID_IDirectInputDevice7W, data->version < 0x800 ); + check_interface( device, &IID_IDirectInputDevice8W, data->version >= 0x800 ); + + ref = IUnknown_Release( device ); + ok( ref == 0, "Release returned %ld\n", ref ); + + return DIENUM_CONTINUE; +} + +static void test_QueryInterface( DWORD version ) +{ + struct enum_data data = {.version = version}; + HRESULT hr; + ULONG ref; + + if (FAILED(hr = direct_input_create( version, &data.dinput ))) return; + + winetest_push_context( "%#lx", version ); + + if (version < 0x800) + { + hr = IDirectInput_EnumDevices( data.dinput, 0, check_device_query_interface, &data, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned %#lx\n", hr ); + } + else + { + hr = IDirectInput8_EnumDevices( data.dinput8, 0, check_device_query_interface, &data, DIEDFL_ALLDEVICES ); + ok( hr == DI_OK, "EnumDevices returned %#lx\n", hr ); + } + + ref = IDirectInput_Release( data.dinput ); + todo_wine_if( version < 0x800 ) + ok( ref == 0, "Release returned %lu\n", ref ); + + winetest_pop_context(); +} + +struct overlapped_state +{ + BYTE keys[4]; + DWORD extra_element; +}; + +static DIOBJECTDATAFORMAT obj_overlapped_slider_format[] = +{ + {&GUID_Key, 0, DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_MAKEINSTANCE( DIK_A ), 0}, + {&GUID_Key, 1, DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_MAKEINSTANCE( DIK_S ), 0}, + {&GUID_Key, 2, DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_MAKEINSTANCE( DIK_D ), 0}, + {&GUID_Key, 3, DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_MAKEINSTANCE( DIK_F ), 0}, + {&GUID_Slider, 0, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION}, +}; + +static const DIDATAFORMAT overlapped_slider_format = +{ + sizeof(DIDATAFORMAT), + sizeof(DIOBJECTDATAFORMAT), + DIDF_ABSAXIS, + sizeof(struct overlapped_state), + ARRAY_SIZE(obj_overlapped_slider_format), + obj_overlapped_slider_format, +}; + +static DIOBJECTDATAFORMAT obj_overlapped_pov_format[] = +{ + {&GUID_Key, 0, DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_MAKEINSTANCE( DIK_A ), 0}, + {&GUID_Key, 1, DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_MAKEINSTANCE( DIK_S ), 0}, + {&GUID_Key, 2, DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_MAKEINSTANCE( DIK_D ), 0}, + {&GUID_Key, 3, DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_MAKEINSTANCE( DIK_F ), 0}, + {&GUID_POV, 0, DIDFT_OPTIONAL | DIDFT_POV | DIDFT_ANYINSTANCE, 0}, +}; + +static const DIDATAFORMAT overlapped_pov_format = +{ + sizeof(DIDATAFORMAT), + sizeof(DIOBJECTDATAFORMAT), + DIDF_ABSAXIS, + sizeof(struct overlapped_state), + ARRAY_SIZE(obj_overlapped_pov_format), + obj_overlapped_pov_format, +}; + +void test_overlapped_format( DWORD version ) +{ + static const DIPROPDWORD buffer_size = + { + .diph = + { + .dwSize = sizeof(DIPROPDWORD), + .dwHeaderSize = sizeof(DIPROPHEADER), + .dwHow = DIPH_DEVICE, + }, + .dwData = 10, + }; + SIZE_T data_size = version < 0x800 ? sizeof(DIDEVICEOBJECTDATA_DX3) : sizeof(DIDEVICEOBJECTDATA); + struct overlapped_state state; + IDirectInputDeviceA *keyboard; + IDirectInputA *dinput; + DWORD res, count; + HANDLE event; + HRESULT hr; + HWND hwnd; + + if (FAILED(hr = direct_input_create( version, &dinput ))) return; + + winetest_push_context( "%#lx", version ); + + event = CreateEventW( NULL, FALSE, FALSE, NULL ); + ok( !!event, "CreateEventW failed, error %lu\n", GetLastError() ); + hwnd = CreateWindowW( L"static", L"Title", WS_POPUP | WS_VISIBLE, 10, 10, 200, 200, NULL, NULL, NULL, NULL ); + ok( !!hwnd, "CreateWindowW failed, error %lu\n", GetLastError() ); + flush_events(); + + hr = IDirectInput_CreateDevice( dinput, &GUID_SysKeyboard, &keyboard, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( keyboard, hwnd, DISCL_FOREGROUND|DISCL_EXCLUSIVE ); + ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetEventNotification( keyboard, event ); + ok( hr == DI_OK, "SetEventNotification returned %#lx\n", hr ); + + /* test overlapped slider - default value 0 */ + hr = IDirectInputDevice_SetDataFormat( keyboard, &overlapped_slider_format ); + ok( hr == DI_OK, "SetDataFormat returned %#lx\n", hr ); + hr = IDirectInputDevice_SetProperty( keyboard, DIPROP_BUFFERSIZE, &buffer_size.diph ); + ok( hr == DI_OK, "SetProperty returned %#lx\n", hr ); + + + hr = IDirectInputDevice_Acquire( keyboard ); + ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + + keybd_event( 0, DIK_F, KEYEVENTF_SCANCODE, 0 ); + res = WaitForSingleObject( event, 100 ); + if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */ + { + keybd_event( 0, DIK_F, KEYEVENTF_SCANCODE, 0 ); + res = WaitForSingleObject( event, 100 ); + } + ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res ); + + keybd_event( 0, DIK_F, KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP, 0 ); + res = WaitForSingleObject( event, 100 ); + ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res ); + + count = 10; + hr = IDirectInputDevice_GetDeviceData( keyboard, data_size, NULL, &count, 0 ); + ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); + ok( count > 0, "got count %lu\n", count ); + + + /* press D */ + keybd_event( 0, DIK_D, KEYEVENTF_SCANCODE, 0 ); + res = WaitForSingleObject( event, 100 ); + ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res ); + + count = 10; + hr = IDirectInputDevice_GetDeviceData( keyboard, data_size, NULL, &count, 0 ); + ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); + ok( count == 1, "got count %lu\n", count ); + + memset( &state, 0xFF, sizeof(state) ); + hr = IDirectInputDevice_GetDeviceState( keyboard, sizeof(state), &state ); + ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr ); + + ok( state.keys[0] == 0x00, "key A should be still up\n" ); + ok( state.keys[1] == 0x00, "key S should be still up\n" ); + ok( state.keys[2] == 0x80, "keydown for D did not register\n" ); + ok( state.keys[3] == 0x00, "key F should be still up\n" ); + ok( state.extra_element == 0, "State struct was not memset to zero\n" ); + + /* release D */ + keybd_event( 0, DIK_D, KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP, 0 ); + res = WaitForSingleObject( event, 100 ); + ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res ); + + count = 10; + hr = IDirectInputDevice_GetDeviceData( keyboard, data_size, NULL, &count, 0 ); + ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); + ok( count == 1, "got count %lu\n", count ); + + + hr = IDirectInputDevice_Unacquire( keyboard ); + ok( hr == DI_OK, "Unacquire returned %#lx\n", hr ); + + /* test overlapped pov - default value - 0xFFFFFFFF */ + hr = IDirectInputDevice_SetDataFormat( keyboard, &overlapped_pov_format ); + ok( hr == DI_OK, "SetDataFormat returned %#lx\n", hr ); + + + hr = IDirectInputDevice_Acquire( keyboard ); + ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + + keybd_event( 0, DIK_F, KEYEVENTF_SCANCODE, 0 ); + res = WaitForSingleObject( event, 100 ); + if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */ + { + keybd_event( 0, DIK_F, KEYEVENTF_SCANCODE, 0 ); + res = WaitForSingleObject( event, 100 ); + } + ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res ); + + keybd_event( 0, DIK_F, KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP, 0 ); + res = WaitForSingleObject( event, 100 ); + ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res ); + + count = 10; + hr = IDirectInputDevice_GetDeviceData( keyboard, data_size, NULL, &count, 0 ); + ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); + ok( count > 0, "got count %lu\n", count ); + + + /* press D */ + keybd_event( 0, DIK_D, KEYEVENTF_SCANCODE, 0 ); + res = WaitForSingleObject( event, 100 ); + ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res ); + + count = 10; + hr = IDirectInputDevice_GetDeviceData( keyboard, data_size, NULL, &count, 0 ); + ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); + ok( count == 1, "got count %lu\n", count ); + + memset( &state, 0xFF, sizeof(state) ); + hr = IDirectInputDevice_GetDeviceState( keyboard, sizeof(state), &state ); + ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr ); + + ok( state.keys[0] == 0xFF, "key state should have been overwritten by the overlapped POV\n" ); + ok( state.keys[1] == 0xFF, "key state should have been overwritten by the overlapped POV\n" ); + ok( state.keys[2] == 0xFF, "key state should have been overwritten by the overlapped POV\n" ); + ok( state.keys[3] == 0xFF, "key state should have been overwritten by the overlapped POV\n" ); + ok( state.extra_element == 0, "State struct was not memset to zero\n" ); + + /* release D */ + keybd_event( 0, DIK_D, KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP, 0 ); + res = WaitForSingleObject( event, 100 ); + ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res ); + + count = 10; + hr = IDirectInputDevice_GetDeviceData( keyboard, data_size, NULL, &count, 0 ); + ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); + ok( count == 1, "got count %lu\n", count ); + + + IUnknown_Release( keyboard ); + + DestroyWindow( hwnd ); + CloseHandle( event ); + + winetest_pop_context(); +} + static void test_device_input( IDirectInputDevice8A *device, DWORD type, DWORD code, UINT_PTR expected ) { HRESULT hr; @@ -110,6 +436,11 @@ static void test_device_input( IDirectInputDevice8A *device, DWORD type, DWORD c { keybd_event( 0, code, KEYEVENTF_SCANCODE, 0 ); res = WaitForSingleObject( event, 100 ); + if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */ + { + keybd_event( 0, code, KEYEVENTF_SCANCODE, 0 ); + res = WaitForSingleObject( event, 100 ); + } ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res );
keybd_event( 0, code, KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP, 0 ); @@ -120,6 +451,11 @@ static void test_device_input( IDirectInputDevice8A *device, DWORD type, DWORD c { mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); res = WaitForSingleObject( event, 100 ); + if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */ + { + mouse_event( MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + } ok( res == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", res );
mouse_event( MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); @@ -255,7 +591,7 @@ static BOOL CALLBACK enumeration_callback(const DIDEVICEINSTANCEA *lpddi, IDirec }
/* Creating second device object to check if it has the same username */ - hr = IDirectInput_CreateDevice(data->pDI, &lpddi->guidInstance, &lpdid2, NULL); + hr = IDirectInput_CreateDevice(data->dinput8, &lpddi->guidInstance, &lpdid2, NULL); ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr);
/* Building and setting an action map */ @@ -382,7 +718,7 @@ static void test_action_mapping(void) IDirectInput8A *pDI = NULL; DIACTIONFORMATA af; DIPROPSTRING dps; - struct enum_data data = {pDI, &af, NULL, NULL, NULL, 0}; + struct enum_data data = {.version = 0x800, .lpdiaf = &af}; HWND hwnd;
hr = CoCreateInstance(&CLSID_DirectInput8, 0, CLSCTX_INPROC_SERVER, &IID_IDirectInput8A, (LPVOID*)&pDI); @@ -416,7 +752,7 @@ static void test_action_mapping(void) af.dwBufferSize = 32;
/* This enumeration builds and sets the action map for all devices */ - data.pDI = pDI; + data.dinput8 = pDI; hr = IDirectInput8_EnumDevicesBySemantics(pDI, 0, &af, enumeration_callback, &data, DIEDBSFL_ATTACHEDONLY); ok (SUCCEEDED(hr), "EnumDevicesBySemantics failed: hr=%#lx\n", hr);
@@ -1816,6 +2152,14 @@ START_TEST(device8) { dinput_test_init();
+ test_QueryInterface( 0x300 ); + test_QueryInterface( 0x500 ); + test_QueryInterface( 0x700 ); + test_QueryInterface( 0x800 ); + + test_overlapped_format( 0x700 ); + test_overlapped_format( 0x800 ); + test_mouse_info(); test_keyboard_info(); test_action_mapping();
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116467
Your paranoid android.
=== w864 (64 bit report) ===
Report validation errors: dinput:device8 crashed (c0000008)
=== w7u_2qxl (32 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w7u_el (32 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w864 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w1064v1507 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w1064v1809 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w1064 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w1064_2qxl (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64_en_AE_u8 (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64_ar (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64_ja (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: dinput:force_feedback is missing some skip messages
=== w7u_2qxl (32 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w7u_el (32 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w864 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w1064v1507 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w1064v1809 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w1064 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w1064_2qxl (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64_en_AE_u8 (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64_ar (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64_ja (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: dinput:hotplug is missing some skip messages
=== w7u_2qxl (32 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w7u_el (32 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w864 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w1064v1507 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w1064v1809 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w1064 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w1064_2qxl (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64_en_AE_u8 (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64_ar (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64_ja (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== w10pro64_zh_CN (64 bit report) ===
Report validation errors: dinput:joystick8 is missing some skip messages
=== debian11 (32 bit report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Arabic:Morocco report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit German report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit French report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Hebrew:Israel report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Hindi:India report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Japanese:Japan report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit Chinese:China report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
=== debian11 (32 bit WoW report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:295: Test failed: 0x800: Acquire returned 0x80070005 device8.c:304: Test failed: 0x800: WaitForSingleObject returned 0x102 device8.c:308: Test failed: 0x800: WaitForSingleObject returned 0x102 device8.c:312: Test failed: 0x800: GetDeviceData returned 0x8007000c device8.c:319: Test failed: 0x800: WaitForSingleObject returned 0x102 device8.c:323: Test failed: 0x800: GetDeviceData returned 0x8007000c device8.c:324: Test failed: 0x800: got count 10 device8.c:328: Test failed: 0x800: GetDeviceState returned 0x8007000c device8.c:330: Test failed: 0x800: key A should be still up device8.c:331: Test failed: 0x800: key S should be still up device8.c:332: Test failed: 0x800: keydown for D did not register device8.c:333: Test failed: 0x800: key F should be still up device8.c:334: Test failed: 0x800: State struct was not memset to zero device8.c:339: Test failed: 0x800: WaitForSingleObject returned 0x102 device8.c:343: Test failed: 0x800: GetDeviceData returned 0x8007000c device8.c:344: Test failed: 0x800: got count 10 device8.c:348: Test failed: 0x800: Unacquire returned 0x1 device8.c:356: Test failed: 0x800: Acquire returned 0x80070005 device8.c:365: Test failed: 0x800: WaitForSingleObject returned 0x102 device8.c:369: Test failed: 0x800: WaitForSingleObject returned 0x102 device8.c:373: Test failed: 0x800: GetDeviceData returned 0x8007000c device8.c:380: Test failed: 0x800: WaitForSingleObject returned 0x102 device8.c:384: Test failed: 0x800: GetDeviceData returned 0x8007000c device8.c:385: Test failed: 0x800: got count 10 device8.c:389: Test failed: 0x800: GetDeviceState returned 0x8007000c device8.c:395: Test failed: 0x800: State struct was not memset to zero device8.c:400: Test failed: 0x800: WaitForSingleObject returned 0x102 device8.c:404: Test failed: 0x800: GetDeviceData returned 0x8007000c device8.c:405: Test failed: 0x800: got count 10
=== debian11 (64 bit WoW report) ===
dinput: device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x300: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x300: Release returned 0 device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x500: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x500: Release returned 0 device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:164: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:169: Test failed: 0x700: got hr 0, expected 0x80004002. device8.c:200: Test succeeded inside todo block: 0x700: Release returned 0 device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:161: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:162: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:163: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:166: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:167: Test failed: 0x800: got hr 0, expected 0x80004002. device8.c:168: Test failed: 0x800: got hr 0, expected 0x80004002.
Report validation errors: dinput:force_feedback contains a misplaced todo line for hid dinput:hotplug contains a misplaced todo line for hid dinput:joystick8 contains a misplaced todo line for hid
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/Makefile.in | 2 +- dlls/dinput/tests/{device8.c => device.c} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename dlls/dinput/tests/{device8.c => device.c} (99%)
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in index 1556f3cda37..b8d0f1c4335 100644 --- a/dlls/dinput/tests/Makefile.in +++ b/dlls/dinput/tests/Makefile.in @@ -9,7 +9,7 @@ driver_hid_poll_IMPORTS = winecrt0 ntoskrnl hal hidclass driver_hid_poll_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
SOURCES = \ - device8.c \ + device.c \ dinput.c \ driver_bus.c \ driver_bus.spec \ diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device.c similarity index 99% rename from dlls/dinput/tests/device8.c rename to dlls/dinput/tests/device.c index 96f641f0d95..41a0299e70e 100644 --- a/dlls/dinput/tests/device8.c +++ b/dlls/dinput/tests/device.c @@ -2148,7 +2148,7 @@ static void test_keyboard_info(void) ok( ref == 0, "Release returned %ld\n", ref ); }
-START_TEST(device8) +START_TEST(device) { dinput_test_init();
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116468
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 2 +- dlls/dinput/tests/device.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 9e7cb20453c..f4bdce51633 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1394,9 +1394,9 @@ static HRESULT WINAPI dinput_device_set_property( IDirectInputDevice8W *iface, c case (DWORD_PTR)DIPROP_FFGAIN: { const DIPROPDWORD *value = (const DIPROPDWORD *)header; - if (!impl->vtbl->send_device_gain) return DIERR_UNSUPPORTED; impl->device_gain = value->dwData; if (!is_exclusively_acquired( impl )) return DI_OK; + if (!impl->vtbl->send_device_gain) return DI_OK; return impl->vtbl->send_device_gain( iface, impl->device_gain ); } case (DWORD_PTR)DIPROP_AXISMODE: diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c index 41a0299e70e..6bb1111b2ce 100644 --- a/dlls/dinput/tests/device.c +++ b/dlls/dinput/tests/device.c @@ -1739,14 +1739,14 @@ static void test_mouse_info(void) hr = IDirectInputDevice8_GetProperty( device, DIPROP_KEYNAME, &prop_string.diph ); ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_KEYNAME returned %#lx\n", hr );
- prop_range.diph.dwHow = DIPH_DEVICE; - prop_range.diph.dwObj = 0; + prop_dword.diph.dwHow = DIPH_DEVICE; + prop_dword.diph.dwObj = 0; prop_dword.dwData = 0xdeadbeef; hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); - ok( hr == DIERR_UNSUPPORTED, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr ); + ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr ); prop_dword.dwData = 1000; hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); - ok( hr == DIERR_UNSUPPORTED, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr ); + ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
res = 0; hr = IDirectInputDevice8_EnumObjects( device, check_object_count, &res, DIDFT_AXIS | DIDFT_PSHBUTTON ); @@ -2074,14 +2074,14 @@ static void test_keyboard_info(void) hr = IDirectInputDevice8_GetProperty( device, DIPROP_RANGE, &prop_range.diph ); ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_RANGE returned %#lx\n", hr );
- prop_range.diph.dwHow = DIPH_DEVICE; - prop_range.diph.dwObj = 0; + prop_dword.diph.dwHow = DIPH_DEVICE; + prop_dword.diph.dwObj = 0; prop_dword.dwData = 0xdeadbeef; hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); - ok( hr == DIERR_UNSUPPORTED, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr ); + ok( hr == DIERR_INVALIDPARAM, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr ); prop_dword.dwData = 1000; hr = IDirectInputDevice8_SetProperty( device, DIPROP_FFGAIN, &prop_dword.diph ); - ok( hr == DIERR_UNSUPPORTED, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr ); + ok( hr == DI_OK, "SetProperty DIPROP_FFGAIN returned %#lx\n", hr );
res = 0; hr = IDirectInputDevice8_EnumObjects( device, check_object_count, &res, DIDFT_AXIS | DIDFT_PSHBUTTON );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116469
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/device.c | 82 +++++++++++++++++++++++++++------- dlls/dinput/tests/mouse.c | 90 -------------------------------------- 2 files changed, 65 insertions(+), 107 deletions(-)
diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c index 6bb1111b2ce..84a993f958d 100644 --- a/dlls/dinput/tests/device.c +++ b/dlls/dinput/tests/device.c @@ -98,6 +98,30 @@ static void flush_events(void) } }
+static HRESULT create_dinput_device( DWORD version, const GUID *guid, IDirectInputDevice8W **device ) +{ + IDirectInputW *dinput; + HRESULT hr; + ULONG ref; + + if (version < 0x800) hr = DirectInputCreateW( instance, version, &dinput, NULL ); + else hr = DirectInput8Create( instance, version, &IID_IDirectInput8W, (void **)&dinput, NULL ); + if (FAILED(hr)) + { + win_skip( "Failed to instantiate a IDirectInput instance, hr %#lx\n", hr ); + return hr; + } + + hr = IDirectInput_CreateDevice( dinput, guid, (IDirectInputDeviceW **)device, NULL ); + ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr ); + + ref = IDirectInput_Release( dinput ); + todo_wine + ok( ref == 0, "Release returned %ld\n", ref ); + + return DI_OK; +} + static HRESULT direct_input_create( DWORD version, IDirectInputA **out ) { HRESULT hr; @@ -1445,13 +1469,14 @@ static BOOL CALLBACK check_object_count( const DIDEVICEOBJECTINSTANCEW *obj, voi return DIENUM_CONTINUE; }
-static void test_mouse_info(void) +static void test_sys_mouse( DWORD version ) { - static const DIDEVCAPS expect_caps = + const DIDEVCAPS expect_caps = { .dwSize = sizeof(DIDEVCAPS), .dwFlags = DIDC_ATTACHED | DIDC_EMULATED, - .dwDevType = (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE, + .dwDevType = version < 0x800 ? (DIDEVTYPEMOUSE_UNKNOWN << 8) | DIDEVTYPE_MOUSE + : (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE, .dwAxes = 3, .dwButtons = 5, }; @@ -1460,7 +1485,8 @@ static void test_mouse_info(void) .dwSize = sizeof(DIDEVICEINSTANCEW), .guidInstance = GUID_SysMouse, .guidProduct = GUID_SysMouse, - .dwDevType = (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE, + .dwDevType = version < 0x800 ? (DIDEVTYPEMOUSE_UNKNOWN << 8) | DIDEVTYPE_MOUSE + : (DI8DEVTYPEMOUSE_UNKNOWN << 8) | DI8DEVTYPE_MOUSE, .tszInstanceName = L"Mouse", .tszProductName = L"Mouse", .guidFFDriver = GUID_NULL, @@ -1573,21 +1599,19 @@ static void test_mouse_info(void) }; DIDEVICEOBJECTINSTANCEW objinst = {0}; DIDEVICEINSTANCEW devinst = {0}; + BOOL old_localized = localized; IDirectInputDevice8W *device; DIDEVCAPS caps = {0}; - IDirectInput8W *di; ULONG res, ref; HRESULT hr; GUID guid;
- localized = LOWORD( GetKeyboardLayout( 0 ) ) != 0x0409; + if (FAILED(create_dinput_device( version, &GUID_SysMouse, &device ))) return;
- hr = DirectInput8Create( instance, DIRECTINPUT_VERSION, &IID_IDirectInput8W, (void **)&di, NULL ); - ok( hr == DI_OK, "DirectInput8Create returned %#lx\n", hr ); - hr = IDirectInput8_CreateDevice( di, &GUID_SysMouse, &device, NULL ); - ok( hr == DI_OK, "CreateDevice returned %#lx\n", hr ); + localized = LOWORD( GetKeyboardLayout( 0 ) ) != 0x0409; + winetest_push_context( "%#lx", version );
- hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_SysMouseEm ); + hr = IDirectInputDevice8_Initialize( device, instance, version, &GUID_SysMouseEm ); ok( hr == DI_OK, "Initialize returned %#lx\n", hr ); guid = GUID_SysMouseEm; memset( &devinst, 0, sizeof(devinst) ); @@ -1597,7 +1621,7 @@ static void test_mouse_info(void) ok( IsEqualGUID( &guid, &GUID_SysMouseEm ), "got %s expected %s\n", debugstr_guid( &guid ), debugstr_guid( &GUID_SysMouseEm ) );
- hr = IDirectInputDevice8_Initialize( device, instance, DIRECTINPUT_VERSION, &GUID_SysMouse ); + hr = IDirectInputDevice8_Initialize( device, instance, version, &GUID_SysMouse ); ok( hr == DI_OK, "Initialize returned %#lx\n", hr );
memset( &devinst, 0, sizeof(devinst) ); @@ -1615,6 +1639,16 @@ static void test_mouse_info(void) check_member( devinst, expect_devinst, "%04x", wUsagePage ); check_member( devinst, expect_devinst, "%04x", wUsage );
+ devinst.dwSize = sizeof(DIDEVICEINSTANCE_DX3W); + hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst ); + ok( hr == DI_OK, "GetDeviceInfo returned %#lx\n", hr ); + check_member_guid( devinst, expect_devinst, guidInstance ); + check_member_guid( devinst, expect_devinst, guidProduct ); + todo_wine + check_member( devinst, expect_devinst, "%#lx", dwDevType ); + if (!localized) check_member_wstr( devinst, expect_devinst, tszInstanceName ); + if (!localized) todo_wine check_member_wstr( devinst, expect_devinst, tszProductName ); + caps.dwSize = sizeof(DIDEVCAPS); hr = IDirectInputDevice8_GetCapabilities( device, &caps ); ok( hr == DI_OK, "GetCapabilities returned %#lx\n", hr ); @@ -1689,8 +1723,13 @@ static void test_mouse_info(void) hr = IDirectInputDevice8_GetProperty( device, DIPROP_TYPENAME, &prop_string.diph ); ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_TYPENAME returned %#lx\n", hr ); hr = IDirectInputDevice8_GetProperty( device, DIPROP_USERNAME, &prop_string.diph ); - ok( hr == S_FALSE, "GetProperty DIPROP_USERNAME returned %#lx\n", hr ); - ok( !wcscmp( prop_string.wsz, L"" ), "got user %s\n", debugstr_w(prop_string.wsz) ); + if (version < 0x0800) + ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_USERNAME returned %#lx\n", hr ); + else + { + ok( hr == DI_NOEFFECT, "GetProperty DIPROP_USERNAME returned %#lx\n", hr ); + ok( !wcscmp( prop_string.wsz, L"" ), "got user %s\n", debugstr_w(prop_string.wsz) ); + }
hr = IDirectInputDevice8_GetProperty( device, DIPROP_JOYSTICKID, &prop_dword.diph ); ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_VIDPID returned %#lx\n", hr ); @@ -1711,6 +1750,12 @@ static void test_mouse_info(void) hr = IDirectInputDevice8_GetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph ); ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_GRANULARITY returned %#lx\n", hr );
+ prop_dword.diph.dwHow = DIPH_BYID; + prop_dword.diph.dwObj = DIDFT_MAKEINSTANCE(1) | DIDFT_RELAXIS; + prop_dword.dwData = 0xdeadbeef; + hr = IDirectInputDevice8_GetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph ); + ok( hr == DI_OK, "GetProperty DIPROP_GRANULARITY returned %#lx\n", hr ); + ok( prop_dword.dwData == 1, "got %ld expected 1\n", prop_dword.dwData ); prop_dword.diph.dwHow = DIPH_BYOFFSET; prop_dword.diph.dwObj = DIMOFS_X; prop_dword.dwData = 0xdeadbeef; @@ -1810,8 +1855,8 @@ static void test_mouse_info(void) ref = IDirectInputDevice8_Release( device ); ok( ref == 0, "Release returned %ld\n", ref );
- ref = IDirectInput8_Release( di ); - ok( ref == 0, "Release returned %ld\n", ref ); + winetest_pop_context(); + localized = old_localized; }
static void test_keyboard_info(void) @@ -2160,7 +2205,10 @@ START_TEST(device) test_overlapped_format( 0x700 ); test_overlapped_format( 0x800 );
- test_mouse_info(); + test_sys_mouse( 0x500 ); + test_sys_mouse( 0x700 ); + test_sys_mouse( 0x800 ); + test_keyboard_info(); test_action_mapping(); test_save_settings(); diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c index 2d92fe2b14c..2079c5e1408 100644 --- a/dlls/dinput/tests/mouse.c +++ b/dlls/dinput/tests/mouse.c @@ -195,99 +195,11 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt);
- /* Check for granularity property using BYOFFSET */ - memset(&di_op, 0, sizeof(di_op)); - di_op.diph.dwHow = DIPH_BYOFFSET; - di_op.diph.dwObj = DIMOFS_Y; - di_op.diph.dwSize = sizeof(DIPROPDWORD); - di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); - hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph); - /* Granularity of Y axis should be 1! */ - ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %#lx, dwData: %lu but should be 1.\n", hr, di_op.dwData); - - /* Check for granularity property using BYID */ - memset(&di_op, 0, sizeof(di_op)); - di_op.diph.dwHow = DIPH_BYID; - /* WINE_MOUSE_Y_AXIS_INSTANCE := 1 */ - di_op.diph.dwObj = (DIDFT_MAKEINSTANCE(1) | DIDFT_RELAXIS); - di_op.diph.dwSize = sizeof(DIPROPDWORD); - di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); - hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_GRANULARITY, &di_op.diph); - /* Granularity of Y axis should be 1! */ - ok(hr == S_OK && di_op.dwData == 1, "GetProperty(): %#lx, dwData: %lu but should be 1.\n", hr, di_op.dwData); - - memset(&di_op, 0, sizeof(di_op)); - di_op.diph.dwSize = sizeof(DIPROPDWORD); - di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); - di_op.diph.dwHow = DIPH_DEVICE; - di_op.diph.dwObj = 0; - hr = IDirectInputDevice_GetProperty(pMouse, DIPROP_VIDPID, &di_op.diph); - ok(hr == DIERR_UNSUPPORTED, "got %#lx\n", hr); - IUnknown_Release(pMouse);
DestroyWindow( hwnd2 ); }
-static void test_GetDeviceInfo(IDirectInputA *pDI) -{ - HRESULT hr; - IDirectInputDeviceA *pMouse = NULL; - DIDEVICEINSTANCEA instA; - DIDEVICEINSTANCE_DX3A inst3A; - - hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr); - if (FAILED(hr)) return; - - instA.dwSize = sizeof(instA); - hr = IDirectInputDevice_GetDeviceInfo(pMouse, &instA); - ok(SUCCEEDED(hr), "got %#lx\n", hr); - - inst3A.dwSize = sizeof(inst3A); - hr = IDirectInputDevice_GetDeviceInfo(pMouse, (DIDEVICEINSTANCEA *)&inst3A); - ok(SUCCEEDED(hr), "got %#lx\n", hr); - - ok(instA.dwSize != inst3A.dwSize, "got %lu, %lu\n", instA.dwSize, inst3A.dwSize); - ok(IsEqualGUID(&instA.guidInstance, &inst3A.guidInstance), "got %s, %s\n", - wine_dbgstr_guid(&instA.guidInstance), wine_dbgstr_guid(&inst3A.guidInstance) ); - ok(IsEqualGUID(&instA.guidProduct, &inst3A.guidProduct), "got %s, %s\n", - wine_dbgstr_guid(&instA.guidProduct), wine_dbgstr_guid(&inst3A.guidProduct) ); - ok(instA.dwDevType == inst3A.dwDevType, "got %lu, %lu\n", instA.dwDevType, inst3A.dwDevType); - - IUnknown_Release(pMouse); -} - -static BOOL CALLBACK EnumAxes(const DIDEVICEOBJECTINSTANCEA *pdidoi, void *pContext) -{ - if (IsEqualIID(&pdidoi->guidType, &GUID_XAxis) || - IsEqualIID(&pdidoi->guidType, &GUID_YAxis) || - IsEqualIID(&pdidoi->guidType, &GUID_ZAxis)) - { - ok(pdidoi->dwFlags & DIDOI_ASPECTPOSITION, "Missing DIDOI_ASPECTPOSITION, flags are %#lx\n", - pdidoi->dwFlags); - } - else - ok(pdidoi->dwFlags == 0, "Flags are %#lx\n", pdidoi->dwFlags); - - return DIENUM_CONTINUE; -} - -static void test_mouse_EnumObjects(IDirectInputA *pDI) -{ - HRESULT hr; - IDirectInputDeviceA *pMouse = NULL; - - hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr); - if (FAILED(hr)) return; - - hr = IDirectInputDevice_EnumObjects(pMouse, EnumAxes, NULL, DIDFT_ALL); - ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %#lx\n", hr); - - IUnknown_Release(pMouse); -} - static void mouse_tests(void) { HRESULT hr; @@ -313,8 +225,6 @@ static void mouse_tests(void)
test_set_coop(pDI, hwnd); test_acquire(pDI, hwnd); - test_GetDeviceInfo(pDI); - test_mouse_EnumObjects(pDI);
DestroyWindow(hwnd); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116470
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/Makefile.in | 3 +- dlls/dinput/tests/device.c | 182 +++++++++++++++++++++++++ dlls/dinput/tests/mouse.c | 242 ---------------------------------- 3 files changed, 183 insertions(+), 244 deletions(-) delete mode 100644 dlls/dinput/tests/mouse.c
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in index b8d0f1c4335..32cfb306524 100644 --- a/dlls/dinput/tests/Makefile.in +++ b/dlls/dinput/tests/Makefile.in @@ -22,5 +22,4 @@ SOURCES = \ hotplug.c \ joystick.c \ joystick8.c \ - keyboard.c \ - mouse.c + keyboard.c diff --git a/dlls/dinput/tests/device.c b/dlls/dinput/tests/device.c index 84a993f958d..339f4a025b9 100644 --- a/dlls/dinput/tests/device.c +++ b/dlls/dinput/tests/device.c @@ -1598,13 +1598,19 @@ static void test_sys_mouse( DWORD version ) }, }; DIDEVICEOBJECTINSTANCEW objinst = {0}; + DIDEVICEOBJECTDATA objdata = {0}; DIDEVICEINSTANCEW devinst = {0}; BOOL old_localized = localized; IDirectInputDevice8W *device; + HWND hwnd, tmp_hwnd, child; DIDEVCAPS caps = {0}; + DIMOUSESTATE state; ULONG res, ref; + HANDLE event; + DWORD count; HRESULT hr; GUID guid; + int i;
if (FAILED(create_dinput_device( version, &GUID_SysMouse, &device ))) return;
@@ -1852,6 +1858,182 @@ static void test_sys_mouse( DWORD version ) check_member( objinst, expect_objects[3], "%#04x", wExponent ); check_member( objinst, expect_objects[3], "%u", wReportId );
+ + SetCursorPos( 60, 60 ); + + hwnd = CreateWindowW( L"static", L"static", WS_POPUP | WS_VISIBLE, + 50, 50, 200, 200, NULL, NULL, NULL, NULL ); + ok( !!hwnd, "CreateWindowW failed, error %lu\n", GetLastError() ); + flush_events(); + + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND ); + ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND|DISCL_EXCLUSIVE ); + ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE ); + ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr ); + + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND ); + ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND|DISCL_EXCLUSIVE ); + ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, NULL, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE ); + ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr ); + + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND ); + ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND|DISCL_EXCLUSIVE ); + ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE ); + ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr ); + + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND ); + ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND|DISCL_EXCLUSIVE ); + ok( hr == DIERR_UNSUPPORTED, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE ); + ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr ); + + child = CreateWindowW( L"static", L"static", WS_CHILD | WS_VISIBLE, + 10, 10, 50, 50, hwnd, NULL, NULL, NULL ); + ok( !!child, "CreateWindowW failed, error %lu\n", GetLastError() ); + flush_events(); + + hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND ); + ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND|DISCL_EXCLUSIVE ); + ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_FOREGROUND|DISCL_NONEXCLUSIVE ); + ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr ); + + hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND ); + ok( hr == DIERR_INVALIDPARAM, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND|DISCL_EXCLUSIVE ); + ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, child, DISCL_BACKGROUND|DISCL_NONEXCLUSIVE ); + ok( hr == E_HANDLE, "SetCooperativeLevel returned %#lx\n", hr ); + + DestroyWindow( child ); + + + event = CreateEventW( NULL, FALSE, FALSE, NULL ); + ok( !!event, "CreateEventW failed, error %lu\n", GetLastError() ); + hr = IDirectInputDevice8_SetEventNotification( device, event ); + ok( hr == DI_OK, "SetEventNotification returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND ); + ok( hr == DI_OK, "SetCooperativeLevel returned %#lx\n", hr ); + + prop_dword.dwData = 5; + prop_dword.diph.dwHow = DIPH_DEVICE; + prop_dword.diph.dwObj = 0; + hr = IDirectInputDevice8_SetProperty( device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&prop_dword ); + ok( hr == DI_OK, "SetProperty returned %#lx\n", hr ); + hr = IDirectInputDevice8_SetDataFormat( device, &c_dfDIMouse ); + ok( hr == DI_OK, "SetDataFormat returned %#lx\n", hr ); + hr = IDirectInputDevice8_Unacquire( device ); + ok( hr == DI_NOEFFECT, "Unacquire returned %#lx\n", hr ); + hr = IDirectInputDevice8_Acquire( device ); + ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + hr = IDirectInputDevice8_Acquire( device ); + ok( hr == DI_NOEFFECT, "Acquire returned %#lx\n", hr ); + + + tmp_hwnd = CreateWindowW( L"static", L"static", WS_POPUP | WS_VISIBLE, + 50, 250, 200, 200, NULL, NULL, NULL, NULL ); + ok( !!tmp_hwnd, "CreateWindowW failed, error %lu\n", GetLastError() ); + flush_events(); + + hr = IDirectInputDevice8_GetDeviceState( device, sizeof(state), &state ); + ok( hr == DIERR_NOTACQUIRED, "GetDeviceState returned %#lx\n", hr ); + + hr = IDirectInputDevice8_Acquire( device ); + ok( hr == DIERR_OTHERAPPHASPRIO, "Acquire returned %#lx\n", hr ); + + SetActiveWindow( hwnd ); + flush_events(); + + hr = IDirectInputDevice8_SetProperty( device, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&prop_dword ); + ok( hr == DI_OK, "SetProperty returned %#lx\n", hr ); + + hr = IDirectInputDevice8_Acquire( device ); + ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + + mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */ + { + mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + } + ok( !res, "WaitForSingleObject returned %#lx\n", res ); + + count = 1; + hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 ); + ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); + ok( count == 1, "got count %lu\n", count ); + + mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + ok( !res, "WaitForSingleObject returned %#lx\n", res ); + + hr = IDirectInputDevice8_Unacquire( device ); + ok( hr == DI_OK, "Unacquire returned %#lx\n", hr ); + count = 1; + hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 ); + ok( hr == (version < 0x800 ? DI_OK : DIERR_NOTACQUIRED), "GetDeviceData returned %#lx\n", hr ); + ok( count == 1, "got count %lu\n", count ); + + hr = IDirectInputDevice8_Acquire( device ); + ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + + mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */ + { + mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + } + ok( !res, "WaitForSingleObject returned %#lx\n", res ); + + hr = IDirectInputDevice8_Unacquire( device ); + ok( hr == DI_OK, "Unacquire returned %#lx\n", hr ); + + hr = IDirectInputDevice8_Acquire( device ); + ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + count = 1; + hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 ); + ok( hr == (version < 0x800 ? DI_OK : DI_BUFFEROVERFLOW), "GetDeviceData returned %#lx\n", hr ); + ok( count == 1, "got count %lu\n", count ); + + mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + if (res == WAIT_TIMEOUT) /* Acquire is asynchronous */ + { + mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + } + ok( !res, "WaitForSingleObject returned %#lx\n", res ); + + for (i = 0; i < 2; i++) + { + mouse_event( MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0 ); + res = WaitForSingleObject( event, 100 ); + ok( !res, "WaitForSingleObject returned %#lx\n", res ); + } + + count = 1; + hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 ); + ok( hr == (version < 0x800 ? DI_OK : DI_BUFFEROVERFLOW), "GetDeviceData returned %#lx\n", hr ); + count = 1; + hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 ); + ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); + ok( count == 1, "got count %lu\n", count ); + + DestroyWindow( tmp_hwnd ); + + CloseHandle( event ); + DestroyWindow( hwnd ); + ref = IDirectInputDevice8_Release( device ); ok( ref == 0, "Release returned %ld\n", ref );
diff --git a/dlls/dinput/tests/mouse.c b/dlls/dinput/tests/mouse.c deleted file mode 100644 index 2079c5e1408..00000000000 --- a/dlls/dinput/tests/mouse.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2005 Robert Reif - * Copyright (c) 2006 Vitaliy Margolen - * - * 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 - */ - -#define DIRECTINPUT_VERSION 0x0700 - -#include <stdarg.h> -#include <stddef.h> - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winbase.h" - -#define COBJMACROS -#include "dinput.h" - -#include "dinput_test.h" - -static const HRESULT SetCoop_null_window[16] = { - E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, - E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG, - E_INVALIDARG, E_HANDLE, S_OK, E_INVALIDARG, - E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG}; - -static const HRESULT SetCoop_real_window[16] = { - E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, - E_INVALIDARG, S_OK, S_OK, E_INVALIDARG, - E_INVALIDARG, E_NOTIMPL, S_OK, E_INVALIDARG, - E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG}; - -static const HRESULT SetCoop_child_window[16] = { - E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, - E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG, - E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG, - E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG}; - -static void flush_events(void) -{ - MSG msg; - int diff = 200; - int min_timeout = 100; - DWORD time = GetTickCount() + diff; - - while (diff > 0) - { - if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break; - while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); - diff = time - GetTickCount(); - } -} - -static void test_set_coop(IDirectInputA *pDI, HWND hwnd) -{ - HRESULT hr; - IDirectInputDeviceA *pMouse = NULL; - int i; - HWND child; - - hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr); - if (FAILED(hr)) return; - - for (i=0; i<16; i++) - { - hr = IDirectInputDevice_SetCooperativeLevel(pMouse, NULL, i); - ok(hr == SetCoop_null_window[i], "SetCooperativeLevel(NULL, %d): %#lx\n", i, hr); - } - for (i=0; i<16; i++) - { - hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, i); - ok(hr == SetCoop_real_window[i], "SetCooperativeLevel(hwnd, %d): %#lx\n", i, hr); - } - - child = CreateWindowA("static", "Title", WS_CHILD | WS_VISIBLE, 10, 10, 50, 50, hwnd, NULL, - NULL, NULL); - ok(child != NULL, "err: %lu\n", GetLastError()); - - for (i=0; i<16; i++) - { - hr = IDirectInputDevice_SetCooperativeLevel(pMouse, child, i); - ok(hr == SetCoop_child_window[i], "SetCooperativeLevel(child, %d): %#lx\n", i, hr); - } - - DestroyWindow(child); - if (pMouse) IUnknown_Release(pMouse); -} - -static void test_acquire(IDirectInputA *pDI, HWND hwnd) -{ - HRESULT hr; - IDirectInputDeviceA *pMouse = NULL; - DIMOUSESTATE m_state; - HWND hwnd2; - DIPROPDWORD di_op; - DIDEVICEOBJECTDATA mouse_state; - DWORD cnt; - int i; - - if (! SetForegroundWindow(hwnd)) - { - skip("Not running as foreground app, skipping acquire tests\n"); - return; - } - - hr = IDirectInput_CreateDevice(pDI, &GUID_SysMouse, &pMouse, NULL); - ok(SUCCEEDED(hr), "IDirectInput_CreateDevice() failed: %#lx\n", hr); - if (FAILED(hr)) return; - - hr = IDirectInputDevice_SetCooperativeLevel(pMouse, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND); - ok(hr == S_OK, "SetCooperativeLevel: %#lx\n", hr); - - memset(&di_op, 0, sizeof(di_op)); - di_op.dwData = 5; - di_op.diph.dwHow = DIPH_DEVICE; - di_op.diph.dwSize = sizeof(DIPROPDWORD); - di_op.diph.dwHeaderSize = sizeof(DIPROPHEADER); - hr = IDirectInputDevice_SetProperty(pMouse, DIPROP_BUFFERSIZE, (LPCDIPROPHEADER)&di_op); - ok(hr == S_OK, "SetProperty() failed: %#lx\n", hr); - - hr = IDirectInputDevice_SetDataFormat(pMouse, &c_dfDIMouse); - ok(SUCCEEDED(hr), "IDirectInputDevice_SetDataFormat() failed: %#lx\n", hr); - hr = IDirectInputDevice_Unacquire(pMouse); - ok(hr == S_FALSE, "IDirectInputDevice_Unacquire() should have failed: %#lx\n", hr); - hr = IDirectInputDevice_Acquire(pMouse); - ok(SUCCEEDED(hr), "IDirectInputDevice_Acquire() failed: %#lx\n", hr); - hr = IDirectInputDevice_Acquire(pMouse); - ok(hr == S_FALSE, "IDirectInputDevice_Acquire() should have failed: %#lx\n", hr); - - /* Foreground coop level requires window to have focus */ - /* Create a temporary window, this should make dinput - * lose mouse input */ - hwnd2 = CreateWindowA("static", "Temporary", WS_VISIBLE, 10, 210, 200, 200, NULL, NULL, NULL, - NULL); - ok(hwnd2 != NULL, "CreateWindowA failed with %lu\n", GetLastError()); - flush_events(); - - hr = IDirectInputDevice_GetDeviceState(pMouse, sizeof(m_state), &m_state); - ok(hr == DIERR_NOTACQUIRED, "GetDeviceState() should have failed: %#lx\n", hr); - - hr = IDirectInputDevice_Acquire(pMouse); - ok(hr == DIERR_OTHERAPPHASPRIO, "Acquire() should have failed: %#lx\n", hr); - - SetActiveWindow( hwnd ); - hr = IDirectInputDevice_Acquire(pMouse); - ok(hr == S_OK, "Acquire() failed: %#lx\n", hr); - - mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt); - - mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); - hr = IDirectInputDevice_Unacquire(pMouse); - ok(hr == S_OK, "Failed: %#lx\n", hr); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt); - - hr = IDirectInputDevice_Acquire(pMouse); - ok(hr == S_OK, "Failed: %#lx\n", hr); - mouse_event(MOUSEEVENTF_MOVE, 10, 10, 0, 0); - hr = IDirectInputDevice_Unacquire(pMouse); - ok(hr == S_OK, "Failed: %#lx\n", hr); - - hr = IDirectInputDevice_Acquire(pMouse); - ok(hr == S_OK, "Failed: %#lx\n", hr); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == S_OK && cnt > 0, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt); - - /* Check for buffer overflow */ - for (i = 0; i < 6; i++) - mouse_event(MOUSEEVENTF_MOVE, 10 + i, 10 + i, 0, 0); - - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == DI_OK, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt); - cnt = 1; - hr = IDirectInputDevice_GetDeviceData(pMouse, sizeof(mouse_state), &mouse_state, &cnt, 0); - ok(hr == DI_OK && cnt == 1, "GetDeviceData() failed: %#lx cnt:%lu\n", hr, cnt); - - IUnknown_Release(pMouse); - - DestroyWindow( hwnd2 ); -} - -static void mouse_tests(void) -{ - HRESULT hr; - IDirectInputA *pDI = NULL; - HWND hwnd; - ULONG ref = 0; - - hr = DirectInputCreateA(instance, DIRECTINPUT_VERSION, &pDI, NULL); - if (hr == DIERR_OLDDIRECTINPUTVERSION) - { - skip("Tests require a newer dinput version\n"); - return; - } - ok(SUCCEEDED(hr), "DirectInputCreateA() failed: %#lx\n", hr); - if (FAILED(hr)) return; - - hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW, 10, 10, 200, 200, NULL, NULL, - NULL, NULL); - ok(hwnd != NULL, "err: %lu\n", GetLastError()); - if (hwnd) - { - ShowWindow(hwnd, SW_SHOW); - - test_set_coop(pDI, hwnd); - test_acquire(pDI, hwnd); - - DestroyWindow(hwnd); - } - if (pDI) ref = IUnknown_Release(pDI); - ok(!ref, "IDirectInput_Release() reference count = %lu\n", ref); -} - -START_TEST(mouse) -{ - dinput_test_init(); - - mouse_tests(); - - dinput_test_exit(); -}
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=116471
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/device8.c:2148 Task: Patch failed to apply
This isn't ready, I'll fix the test failures.