From 352cfbcf1bb0ccaa3e887bae9178ef5c693edb51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 12 Jan 2022 17:23:57 +0100 Subject: [PATCH] dinput/tests: Check that InputReportByteLength bytes are read. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regardless of how long the driver packet is. Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- dlls/dinput/tests/hid.c | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c index f8e8a275b09..d6232d578ca 100644 --- a/dlls/dinput/tests/hid.c +++ b/dlls/dinput/tests/hid.c @@ -2110,6 +2110,16 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle .ret_status = STATUS_SUCCESS, }, }; + struct hid_expect expect_small[] = + { + { + .code = IOCTL_HID_READ_REPORT, + .report_len = report_id ? 2 : caps.InputReportByteLength - 1, + .report_buf = {report_id ? report_id + 1 : 0x5a,0x5a,0x5a}, + .ret_length = report_id ? 2 : caps.InputReportByteLength - 1, + .ret_status = STATUS_SUCCESS, + }, + }; send_hid_input( file, expect, sizeof(expect) ); @@ -2190,6 +2200,21 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle value, (report_id ? 3 : 4) ); ok( !memcmp( report, buffer, caps.InputReportByteLength ), "expected identical reports\n" ); + send_hid_input( file, expect_small, sizeof(expect_small) ); + + Sleep( 600 ); + + SetLastError( 0xdeadbeef ); + memset( report, 0, sizeof(report) ); + ret = ReadFile( async_file, report, caps.InputReportByteLength, NULL, &overlapped ); + ok( !ret, "ReadFile succeeded\n" ); + ok( GetLastError() == ERROR_IO_PENDING, "ReadFile returned error %u\n", GetLastError() ); + + ret = GetOverlappedResult( async_file, &overlapped, &value, TRUE ); + ok( ret, "GetOverlappedResult failed, last error %u\n", GetLastError() ); + ok( value == report_id ? 2 : caps.InputReportByteLength - 1, + "got length %u, expected %u\n", value, report_id ? 2 : caps.InputReportByteLength - 1 ); + CloseHandle( overlapped.hEvent ); CloseHandle( overlapped2.hEvent ); } @@ -2212,6 +2237,16 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle .ret_status = STATUS_SUCCESS, }, }; + struct hid_expect expect_small[] = + { + { + .code = IOCTL_HID_READ_REPORT, + .report_len = report_id ? 2 : caps.InputReportByteLength - 1, + .report_buf = {report_id ? report_id + 1 : 0x5a,0x5a,0x5a}, + .ret_length = report_id ? 2 : caps.InputReportByteLength - 1, + .ret_status = STATUS_SUCCESS, + }, + }; overlapped.hEvent = CreateEventW( NULL, FALSE, FALSE, NULL ); overlapped2.hEvent = CreateEventW( NULL, FALSE, FALSE, NULL ); @@ -2269,6 +2304,19 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle ok( !memcmp( buffer + off, buffer + caps.InputReportByteLength, caps.InputReportByteLength - off ), "expected identical reports\n" ); + SetLastError( 0xdeadbeef ); + memset( report, 0, sizeof(report) ); + ret = ReadFile( async_file, report, caps.InputReportByteLength, NULL, &overlapped ); + ok( !ret, "ReadFile succeeded\n" ); + ok( GetLastError() == ERROR_IO_PENDING, "ReadFile returned error %u\n", GetLastError() ); + + send_hid_input( file, expect_small, sizeof(expect_small) ); + + ret = GetOverlappedResult( async_file, &overlapped, &value, TRUE ); + ok( ret, "GetOverlappedResult failed, last error %u\n", GetLastError() ); + todo_wine_if( report_id ) + ok( value == caps.InputReportByteLength, "got length %u, expected %u\n", value, caps.InputReportByteLength ); + CloseHandle( overlapped.hEvent ); CloseHandle( overlapped2.hEvent ); }