···11+/* Unit test suite for rawinput.
22+ *
33+ * Copyright 2019 Remi Bernon for CodeWeavers
44+ *
55+ * This library is free software; you can redistribute it and/or
66+ * modify it under the terms of the GNU Lesser General Public
77+ * License as published by the Free Software Foundation; either
88+ * version 2.1 of the License, or (at your option) any later version.
99+ *
1010+ * This library is distributed in the hope that it will be useful,
1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313+ * Lesser General Public License for more details.
1414+ *
1515+ * You should have received a copy of the GNU Lesser General Public
1616+ * License along with this library; if not, write to the Free Software
1717+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
1818+ */
1919+2020+#include <stdarg.h>
2121+#include <stdio.h>
2222+2323+#define STRICT
2424+#define WIN32_LEAN_AND_MEAN
2525+#include <windows.h>
2626+2727+#include "wine/test.h"
2828+2929+static void test_RegisterRawInputDevices(void)
3030+{
3131+ HWND hwnd;
3232+ RAWINPUTDEVICE raw_devices[1];
3333+ BOOL res;
3434+3535+ raw_devices[0].usUsagePage = 0x01;
3636+ raw_devices[0].usUsage = 0x05;
3737+3838+ hwnd = CreateWindowExA(WS_EX_TOPMOST, "static", "dinput", WS_POPUP | WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, NULL, NULL);
3939+ ok(hwnd != NULL, "CreateWindowExA failed\n");
4040+4141+4242+ res = RegisterRawInputDevices(NULL, 0, 0);
4343+ ok(res == FALSE, "RegisterRawInputDevices succeeded\n");
4444+4545+4646+ raw_devices[0].dwFlags = 0;
4747+ raw_devices[0].hwndTarget = 0;
4848+4949+ SetLastError(0xdeadbeef);
5050+ res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), 0);
5151+ ok(res == FALSE, "RegisterRawInputDevices succeeded\n");
5252+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
5353+5454+ SetLastError(0xdeadbeef);
5555+ res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
5656+ ok(res == TRUE, "RegisterRawInputDevices failed\n");
5757+ ok(GetLastError() == 0xdeadbeef, "RegisterRawInputDevices returned %08x\n", GetLastError());
5858+5959+6060+ /* RIDEV_REMOVE requires hwndTarget == NULL */
6161+ raw_devices[0].dwFlags = RIDEV_REMOVE;
6262+ raw_devices[0].hwndTarget = hwnd;
6363+6464+ SetLastError(0xdeadbeef);
6565+ res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
6666+ ok(res == FALSE, "RegisterRawInputDevices succeeded\n");
6767+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
6868+6969+ raw_devices[0].hwndTarget = 0;
7070+7171+ SetLastError(0xdeadbeef);
7272+ res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
7373+ ok(res == TRUE, "RegisterRawInputDevices failed\n");
7474+ ok(GetLastError() == 0xdeadbeef, "RegisterRawInputDevices returned %08x\n", GetLastError());
7575+7676+7777+ /* RIDEV_INPUTSINK requires hwndTarget != NULL */
7878+ raw_devices[0].dwFlags = RIDEV_INPUTSINK;
7979+ raw_devices[0].hwndTarget = 0;
8080+8181+ SetLastError(0xdeadbeef);
8282+ res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
8383+ todo_wine
8484+ ok(res == FALSE, "RegisterRawInputDevices failed\n");
8585+ todo_wine
8686+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
8787+8888+ raw_devices[0].hwndTarget = hwnd;
8989+9090+ SetLastError(0xdeadbeef);
9191+ res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
9292+ ok(res == TRUE, "RegisterRawInputDevices succeeded\n");
9393+ ok(GetLastError() == 0xdeadbeef, "RegisterRawInputDevices returned %08x\n", GetLastError());
9494+9595+ DestroyWindow(hwnd);
9696+}
9797+9898+START_TEST(rawinput)
9999+{
100100+ test_RegisterRawInputDevices();
101101+}
+2-2
modules/rostests/winetests/user32/resource.c
···5050 win_skip( "LoadStringW does not return a pointer to the resource\n" );
5151 return;
5252 }
5353- length2 = LoadStringW(hInst, 2, returnedstringw, sizeof(returnedstringw) /sizeof(WCHAR)); /* get resource string */
5353+ length2 = LoadStringW(hInst, 2, returnedstringw, ARRAY_SIZE(returnedstringw)); /* get resource string */
5454 ok(length2 > 0, "LoadStringW failed to load resource 2, ret %d, err %d\n", length2, GetLastError());
5555 ok(length1 == length2, "LoadStringW returned different values dependent on buflen. ret1 %d, ret2 %d\n",
5656 length1, length2);
···9393 int ret, ret2;
94949595 assert (sizeof str < sizeof buf);
9696- for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
9696+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
9797 const unsigned int bufsiz = tests[i].bufsiz;
9898 const unsigned int expected = tests[i].expected;
9999 const int len = LoadStringA (hInst, 0, buf, bufsiz);
···277277 ok(textheight==0,"Got textheight from DrawTextA\n");
278278 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
279279280280+ /* When offset to top is zero, return 1 */
281281+ SetRectEmpty(&rect);
282282+ textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_BOTTOM, NULL);
283283+ ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
284284+285285+ SetRect(&rect, 0, 100, 0, 100);
286286+ textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_BOTTOM, NULL);
287287+ ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
288288+289289+ SetRectEmpty(&rect);
290290+ textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_TOP, NULL);
291291+ /* Set top to text height and bottom zero, so bottom of drawn text to top is zero when DT_VCENTER is used */
292292+ SetRect(&rect, 0, textheight, 0, 0);
293293+ textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_VCENTER, NULL);
294294+ ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
280295281296 /* invalid dtp size test */
282297 dtp.cbSize = -1; /* Invalid */
···750765 char oem;
751766 WCHAR uni, expect;
752767753753- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
768768+ for (i = 0; i < ARRAY_SIZE(tests); i++)
754769 {
755770 const char *expected = tests[i].ret ? helloWorld : "";
756771 const char *src = tests[i].src ? helloWorld : NULL;
···777792 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
778793 }
779794780780- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
795795+ for (i = 0; i < ARRAY_SIZE(tests); i++)
781796 {
782797 const char *expected = tests[i].ret ? helloWorld : "";
783798 const WCHAR *src = tests[i].src ? helloWorldW : NULL;
···789804 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
790805791806 memset(buf, 0, sizeof(buf));
792792- ret = CharToOemBuffW(src, dst, sizeof(helloWorldW)/sizeof(WCHAR));
807807+ ret = CharToOemBuffW(src, dst, ARRAY_SIZE(helloWorldW));
793808 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
794809 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
795810 }
796811797797- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
812812+ for (i = 0; i < ARRAY_SIZE(tests); i++)
798813 {
799814 const WCHAR *expected = tests[i].ret ? helloWorldW : emptyW;
800815 const char *src = tests[i].src ? helloWorld : NULL;
+1-1
modules/rostests/winetests/user32/uitools.c
···175175 {{-109, -107, -103, -101}, FALSE},
176176 };
177177178178- for (i = 0; i < sizeof(rtest)/sizeof(rtest[0]); i++) {
178178+ for (i = 0; i < ARRAY_SIZE(rtest); i++) {
179179 ret = IsRectEmpty(&rtest[i].rect);
180180 ok(ret == rtest[i].ret, "Test %d: IsRectEmpty returned %s for %s\n", i,
181181 ret ? "TRUE" : "FALSE", wine_dbgstr_rect(&rtest[i].rect));
+4-4
modules/rostests/winetests/user32/wsprintf.c
···6666 win_skip( "I64 formats not supported\n" );
6767 return;
6868 }
6969- for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++)
6969+ for (i = 0; i < ARRAY_SIZE(i64_formats); i++)
7070 {
7171 rc = wsprintfA(buf, i64_formats[i].fmt, i64_formats[i].value);
7272 ok(rc == strlen(i64_formats[i].res), "%u: wsprintfA length failure: rc=%d\n", i, rc);
···9898 win_skip( "I64 formats not supported\n" );
9999 return;
100100 }
101101- for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++)
101101+ for (i = 0; i < ARRAY_SIZE(i64_formats); i++)
102102 {
103103- MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, sizeof(fmt)/sizeof(WCHAR) );
104104- MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, sizeof(res)/sizeof(WCHAR) );
103103+ MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, ARRAY_SIZE(fmt));
104104+ MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, ARRAY_SIZE(res));
105105 rc = wsprintfW(buf, fmt, i64_formats[i].value);
106106 ok(rc == lstrlenW(res), "%u: wsprintfW length failure: rc=%d\n", i, rc);
107107 ok(!lstrcmpW(buf, res), "%u: wrong result [%s]\n", i, wine_dbgstr_w(buf));