From 7a4c65a6b96eca5c0625b277ea43aa3f5be65bf6 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Mon, 22 Aug 2011 21:33:49 +0000 Subject: [PATCH] [WineTest:User32] - Up the rest to 1.3.26. svn path=/trunk/; revision=53387 --- rostests/winetests/user32/broadcast.c | 2 +- rostests/winetests/user32/class.c | 88 +-- rostests/winetests/user32/clipboard.c | 34 +- rostests/winetests/user32/combo.c | 14 +- rostests/winetests/user32/cursoricon.c | 794 ++++++++++++++++++++++++- rostests/winetests/user32/dce.c | 93 ++- rostests/winetests/user32/dde.c | 46 +- rostests/winetests/user32/dialog.c | 44 +- rostests/winetests/user32/edit.c | 53 +- rostests/winetests/user32/generated.c | 6 +- rostests/winetests/user32/input.c | 45 +- rostests/winetests/user32/listbox.c | 11 +- rostests/winetests/user32/menu.c | 101 +++- rostests/winetests/user32/monitor.c | 8 + rostests/winetests/user32/resource.c | 12 +- rostests/winetests/user32/scroll.c | 6 +- rostests/winetests/user32/static.c | 4 +- rostests/winetests/user32/sysparams.c | 4 +- rostests/winetests/user32/text.c | 11 +- rostests/winetests/user32/wsprintf.c | 70 ++- 20 files changed, 1241 insertions(+), 205 deletions(-) diff --git a/rostests/winetests/user32/broadcast.c b/rostests/winetests/user32/broadcast.c index 48f1318a879..21d38e3cc40 100644 --- a/rostests/winetests/user32/broadcast.c +++ b/rostests/winetests/user32/broadcast.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define _WIN32_WINNT 0x0501 +//#define _WIN32_WINNT 0x0501 #include #include diff --git a/rostests/winetests/user32/class.c b/rostests/winetests/user32/class.c index 7149163fbd3..f9d1aef8325 100755 --- a/rostests/winetests/user32/class.c +++ b/rostests/winetests/user32/class.c @@ -617,6 +617,7 @@ static void test_builtinproc(void) static const WCHAR classW[] = {'d','e','f','t','e','s','t',0}; WCHAR unistring[] = {0x142, 0x40e, 0x3b4, 0}; /* a string that would be destroyed by a W->A->W conversion */ WNDPROC pDefWindowProcA, pDefWindowProcW; + WNDPROC pNtdllDefWindowProcA, pNtdllDefWindowProcW; WNDPROC oldproc; WNDCLASSEXA cls; /* the memory layout of WNDCLASSEXA and WNDCLASSEXW is the same */ WCHAR buf[128]; @@ -626,45 +627,56 @@ static void test_builtinproc(void) pDefWindowProcA = (void *)GetProcAddress(GetModuleHandle("user32.dll"), "DefWindowProcA"); pDefWindowProcW = (void *)GetProcAddress(GetModuleHandle("user32.dll"), "DefWindowProcW"); + pNtdllDefWindowProcA = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtdllDefWindowProc_A"); + pNtdllDefWindowProcW = (void *)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtdllDefWindowProc_W"); - for (i = 0; i < 4; i++) + /* On Vista+, the user32.dll export DefWindowProcA/W is forwarded to */ + /* ntdll.NtdllDefWindowProc_A/W. However, the wndproc returned by */ + /* GetClassLong/GetWindowLong points to an unexported user32 function */ + if (pDefWindowProcA == pNtdllDefWindowProcA && + pDefWindowProcW == pNtdllDefWindowProcW) + skip("user32.DefWindowProcX forwarded to ntdll.NtdllDefWindowProc_X\n"); + else { - ZeroMemory(&cls, sizeof(cls)); - cls.cbSize = sizeof(cls); - cls.hInstance = GetModuleHandle(NULL); - cls.hbrBackground = GetStockObject (WHITE_BRUSH); - if (i & 1) - cls.lpfnWndProc = pDefWindowProcA; - else - cls.lpfnWndProc = pDefWindowProcW; - - if (i & 2) + for (i = 0; i < 4; i++) { - cls.lpszClassName = classA; - atom = RegisterClassExA(&cls); + ZeroMemory(&cls, sizeof(cls)); + cls.cbSize = sizeof(cls); + cls.hInstance = GetModuleHandle(NULL); + cls.hbrBackground = GetStockObject (WHITE_BRUSH); + if (i & 1) + cls.lpfnWndProc = pDefWindowProcA; + else + cls.lpfnWndProc = pDefWindowProcW; + + if (i & 2) + { + cls.lpszClassName = classA; + atom = RegisterClassExA(&cls); + } + else + { + cls.lpszClassName = (LPCSTR)classW; + atom = RegisterClassExW((WNDCLASSEXW *)&cls); + } + ok(atom != 0, "Couldn't register class, i=%d, %d\n", i, GetLastError()); + + hwnd = CreateWindowA(classA, NULL, 0, 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), NULL); + ok(hwnd != NULL, "Couldn't create window i=%d\n", i); + + ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n", + (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), pDefWindowProcA); + ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n", + (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), pDefWindowProcA); + + ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n", + (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), pDefWindowProcW); + ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n", + (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), pDefWindowProcW); + + DestroyWindow(hwnd); + UnregisterClass((LPSTR)(DWORD_PTR)atom, GetModuleHandle(NULL)); } - else - { - cls.lpszClassName = (LPCSTR)classW; - atom = RegisterClassExW((WNDCLASSEXW *)&cls); - } - ok(atom != 0, "Couldn't register class, i=%d, %d\n", i, GetLastError()); - - hwnd = CreateWindowA(classA, NULL, 0, 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), NULL); - ok(hwnd != NULL, "Couldn't create window i=%d\n", i); - - ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n", - (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), pDefWindowProcA); - ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n", - (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), pDefWindowProcA); - - ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n", - (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), pDefWindowProcW); - ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (ULONG_PTR)pDefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n", - (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), pDefWindowProcW); - - DestroyWindow(hwnd); - UnregisterClass((LPSTR)(DWORD_PTR)atom, GetModuleHandle(NULL)); } /* built-in winproc - window A/W type automatically detected */ @@ -942,22 +954,28 @@ if (0) { /* crashes under XP */ "expected ERROR_NOACCESS, got %d\n", GetLastError()); wcx.cbSize = 0; + wcx.lpfnWndProc = NULL; SetLastError(0xdeadbeef); ret = GetClassInfoExA(0, "static", &wcx); ok(ret, "GetClassInfoExA() error %d\n", GetLastError()); ok(wcx.cbSize == 0, "expected 0, got %u\n", wcx.cbSize); + ok(wcx.lpfnWndProc != NULL, "got null proc\n"); wcx.cbSize = sizeof(wcx) - 1; + wcx.lpfnWndProc = NULL; SetLastError(0xdeadbeef); ret = GetClassInfoExA(0, "static", &wcx); ok(ret, "GetClassInfoExA() error %d\n", GetLastError()); ok(wcx.cbSize == sizeof(wcx) - 1, "expected sizeof(wcx)-1, got %u\n", wcx.cbSize); + ok(wcx.lpfnWndProc != NULL, "got null proc\n"); wcx.cbSize = sizeof(wcx) + 1; + wcx.lpfnWndProc = NULL; SetLastError(0xdeadbeef); ret = GetClassInfoExA(0, "static", &wcx); ok(ret, "GetClassInfoExA() error %d\n", GetLastError()); ok(wcx.cbSize == sizeof(wcx) + 1, "expected sizeof(wcx)+1, got %u\n", wcx.cbSize); + ok(wcx.lpfnWndProc != NULL, "got null proc\n"); } START_TEST(class) diff --git a/rostests/winetests/user32/clipboard.c b/rostests/winetests/user32/clipboard.c index a0d0fe97745..266f629aa23 100755 --- a/rostests/winetests/user32/clipboard.c +++ b/rostests/winetests/user32/clipboard.c @@ -68,8 +68,8 @@ static void test_ClipboardOwner(void) ok(OpenClipboard(hWnd1), "OpenClipboard failed\n"); SetLastError(0xdeadbeef); - ok(!OpenClipboard(hWnd2) && - (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED), + ret = OpenClipboard(hWnd2); + ok(!ret && (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED), "OpenClipboard should fail without setting last error value, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError()); SetLastError(0xdeadbeef); @@ -79,9 +79,9 @@ static void test_ClipboardOwner(void) ok(GetClipboardOwner() == hWnd1, "clipboard should be owned by %p, not by %p\n", hWnd1, GetClipboardOwner()); SetLastError(0xdeadbeef); - ok(!OpenClipboard(hWnd2) && - (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED), - "OpenClipboard should fail without setting last error valuei, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError()); + ret = OpenClipboard(hWnd2); + ok(!ret && (GetLastError() == 0xdeadbeef || GetLastError() == ERROR_ACCESS_DENIED), + "OpenClipboard should fail without setting last error value, or with ERROR_ACCESS_DENIED, got error %d\n", GetLastError()); ret = CloseClipboard(); ok( ret, "CloseClipboard error %d\n", GetLastError()); @@ -140,6 +140,7 @@ todo_wine atom_id = GlobalFindAtomA("my_cool_clipboard_format"); ok(atom_id == 0, "GlobalFindAtomA should fail\n"); test_last_error(ERROR_FILE_NOT_FOUND); + } for (format_id = 0; format_id < 0xffff; format_id++) { @@ -147,18 +148,9 @@ todo_wine len = GetClipboardFormatNameA(format_id, buf, 256); if (format_id < 0xc000) - { ok(!len, "GetClipboardFormatNameA should fail, but it returned %d (%s)\n", len, buf); - test_last_error(ERROR_INVALID_PARAMETER); - } else - { - if (len) - trace("%04x: %s\n", format_id, len ? buf : ""); - else - test_last_error(ERROR_INVALID_HANDLE); - } - } + if (len) trace("%04x: %s\n", format_id, len ? buf : ""); } ret = OpenClipboard(0); @@ -191,6 +183,9 @@ todo_wine ok(!EmptyClipboard(), "EmptyClipboard should fail if clipboard wasn't open\n"); ok(GetLastError() == ERROR_CLIPBOARD_NOT_OPEN || broken(GetLastError() == 0xdeadbeef), /* wow64 */ "Wrong error %u\n", GetLastError()); + + format_id = RegisterClipboardFormatA("#1234"); + ok(format_id == 1234, "invalid clipboard format id %04x\n", format_id); } static HGLOBAL create_text(void) @@ -216,6 +211,7 @@ static void test_synthesized(void) HENHMETAFILE emf; BOOL r; UINT cf; + HANDLE data; htext = create_text(); emf = create_emf(); @@ -235,15 +231,21 @@ static void test_synthesized(void) ok(r, "gle %d\n", GetLastError()); cf = EnumClipboardFormats(0); ok(cf == CF_TEXT, "cf %08x\n", cf); + data = GetClipboardData(cf); + ok(data != NULL, "couldn't get data, cf %08x\n", cf); cf = EnumClipboardFormats(cf); ok(cf == CF_ENHMETAFILE, "cf %08x\n", cf); + data = GetClipboardData(cf); + ok(data != NULL, "couldn't get data, cf %08x\n", cf); cf = EnumClipboardFormats(cf); todo_wine ok(cf == CF_LOCALE, "cf %08x\n", cf); if(cf == CF_LOCALE) cf = EnumClipboardFormats(cf); ok(cf == CF_OEMTEXT, "cf %08x\n", cf); + data = GetClipboardData(cf); + ok(data != NULL, "couldn't get data, cf %08x\n", cf); cf = EnumClipboardFormats(cf); ok(cf == CF_UNICODETEXT || @@ -253,6 +255,8 @@ static void test_synthesized(void) if(cf == CF_UNICODETEXT) cf = EnumClipboardFormats(cf); ok(cf == CF_METAFILEPICT, "cf %08x\n", cf); + data = GetClipboardData(cf); + todo_wine ok(data != NULL, "couldn't get data, cf %08x\n", cf); cf = EnumClipboardFormats(cf); ok(cf == 0, "cf %08x\n", cf); diff --git a/rostests/winetests/user32/combo.c b/rostests/winetests/user32/combo.c index b7fa63f8e3d..fd852d13df7 100644 --- a/rostests/winetests/user32/combo.c +++ b/rostests/winetests/user32/combo.c @@ -77,7 +77,7 @@ static void test_setitemheight(DWORD style) trace("Style %x\n", style); GetClientRect(hCombo, &r); - expect_rect(r, 0, 0, 100, 24); + expect_rect(r, 0, 0, 100, font_height(GetStockObject(SYSTEM_FONT)) + 8); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); todo_wine expect_rect(r, 5, 5, 105, 105); @@ -112,11 +112,15 @@ static void test_setfont(DWORD style) hFont2 = CreateFont(8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett"); GetClientRect(hCombo, &r); - expect_rect(r, 0, 0, 100, 24); + expect_rect(r, 0, 0, 100, font_height(GetStockObject(SYSTEM_FONT)) + 8); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); todo_wine expect_rect(r, 5, 5, 105, 105); + /* The size of the dropped control is initially equal to the size + of the window when it was created. The size of the calculated + dropped area changes only by how much the selection area + changes, not by how much the list area changes. */ if (font_height(hFont1) == 10 && font_height(hFont2) == 8) { SendMessage(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE); @@ -124,21 +128,21 @@ static void test_setfont(DWORD style) expect_rect(r, 0, 0, 100, 18); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); - todo_wine expect_rect(r, 5, 5, 105, 99); + todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont1))); SendMessage(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE); GetClientRect(hCombo, &r); expect_rect(r, 0, 0, 100, 16); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); - todo_wine expect_rect(r, 5, 5, 105, 97); + todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont2))); SendMessage(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE); GetClientRect(hCombo, &r); expect_rect(r, 0, 0, 100, 18); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); - todo_wine expect_rect(r, 5, 5, 105, 99); + todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont1))); } else { diff --git a/rostests/winetests/user32/cursoricon.c b/rostests/winetests/user32/cursoricon.c index b2e1d842aa3..ddf37ef7b53 100644 --- a/rostests/winetests/user32/cursoricon.c +++ b/rostests/winetests/user32/cursoricon.c @@ -54,6 +54,243 @@ typedef struct CURSORICONFILEDIRENTRY idEntries[1]; } CURSORICONFILEDIR; +#define RIFF_FOURCC( c0, c1, c2, c3 ) \ + ( (DWORD)(BYTE)(c0) | ( (DWORD)(BYTE)(c1) << 8 ) | \ + ( (DWORD)(BYTE)(c2) << 16 ) | ( (DWORD)(BYTE)(c3) << 24 ) ) + +#define ANI_RIFF_ID RIFF_FOURCC('R', 'I', 'F', 'F') +#define ANI_LIST_ID RIFF_FOURCC('L', 'I', 'S', 'T') +#define ANI_ACON_ID RIFF_FOURCC('A', 'C', 'O', 'N') +#define ANI_anih_ID RIFF_FOURCC('a', 'n', 'i', 'h') +#define ANI_seq__ID RIFF_FOURCC('s', 'e', 'q', ' ') +#define ANI_fram_ID RIFF_FOURCC('f', 'r', 'a', 'm') +#define ANI_icon_ID RIFF_FOURCC('i', 'c', 'o', 'n') +#define ANI_rate_ID RIFF_FOURCC('r', 'a', 't', 'e') + +#define ANI_FLAG_ICON 0x1 +#define ANI_FLAG_SEQUENCE 0x2 + +typedef struct { + DWORD header_size; + DWORD num_frames; + DWORD num_steps; + DWORD width; + DWORD height; + DWORD bpp; + DWORD num_planes; + DWORD display_rate; + DWORD flags; +} ani_header; + +typedef struct { + BYTE data[32*32*4]; +} ani_data32x32x32; + +typedef struct { + CURSORICONFILEDIR icon_info; /* animated cursor frame information */ + BITMAPINFOHEADER bmi_header; /* animated cursor frame header */ + ani_data32x32x32 bmi_data; /* animated cursor frame DIB data */ +} ani_frame32x32x32; + +typedef struct { + DWORD chunk_id; /* ANI_anih_ID */ + DWORD chunk_size; /* actual size of data */ + ani_header header; /* animated cursor header */ +} riff_header_t; + +typedef struct { + DWORD chunk_id; /* ANI_LIST_ID */ + DWORD chunk_size; /* actual size of data */ + DWORD chunk_type; /* ANI_fram_ID */ +} riff_list_t; + +typedef struct { + DWORD chunk_id; /* ANI_icon_ID */ + DWORD chunk_size; /* actual size of data */ + ani_frame32x32x32 data; /* animated cursor frame */ +} riff_icon32x32x32_t; + +typedef struct { + DWORD chunk_id; /* ANI_RIFF_ID */ + DWORD chunk_size; /* actual size of data */ + DWORD chunk_type; /* ANI_ACON_ID */ + riff_header_t header; /* RIFF animated cursor header */ + riff_list_t frame_list; /* RIFF animated cursor frame list info */ + riff_icon32x32x32_t frames[1]; /* array of animated cursor frames */ +} riff_cursor1_t; + +typedef struct { + DWORD chunk_id; /* ANI_RIFF_ID */ + DWORD chunk_size; /* actual size of data */ + DWORD chunk_type; /* ANI_ACON_ID */ + riff_header_t header; /* RIFF animated cursor header */ + riff_list_t frame_list; /* RIFF animated cursor frame list info */ + riff_icon32x32x32_t frames[3]; /* array of three animated cursor frames */ +} riff_cursor3_t; + +typedef struct { + DWORD chunk_id; /* ANI_rate_ID */ + DWORD chunk_size; /* actual size of data */ + DWORD rate[3]; /* animated cursor rate data */ +} riff_rate3_t; + +typedef struct { + DWORD chunk_id; /* ANI_seq__ID */ + DWORD chunk_size; /* actual size of data */ + DWORD order[3]; /* animated cursor sequence data */ +} riff_seq3_t; + +typedef struct { + DWORD chunk_id; /* ANI_RIFF_ID */ + DWORD chunk_size; /* actual size of data */ + DWORD chunk_type; /* ANI_ACON_ID */ + riff_header_t header; /* RIFF animated cursor header */ + riff_seq3_t seq; /* sequence data for three cursor frames */ + riff_rate3_t rates; /* rate data for three cursor frames */ + riff_list_t frame_list; /* RIFF animated cursor frame list info */ + riff_icon32x32x32_t frames[3]; /* array of three animated cursor frames */ +} riff_cursor3_seq_t; + +#define EMPTY_ICON32 \ +{ \ + ANI_icon_ID, \ + sizeof(ani_frame32x32x32), \ + { \ + { \ + 0x0, /* reserved */ \ + 0, /* type: icon(1), cursor(2) */ \ + 1, /* count */ \ + { \ + { \ + 32, /* width */ \ + 32, /* height */ \ + 0, /* color count */ \ + 0x0, /* reserved */ \ + 16, /* x hotspot */ \ + 16, /* y hotspot */ \ + sizeof(ani_data32x32x32), /* DIB size */ \ + sizeof(CURSORICONFILEDIR) /* DIB offset */ \ + } \ + } \ + }, \ + { \ + sizeof(BITMAPINFOHEADER), /* structure for DIB-type data */ \ + 32, /* width */ \ + 32*2, /* actual height times two */ \ + 1, /* planes */ \ + 32, /* bpp */ \ + BI_RGB, /* compression */ \ + 0, /* image size */ \ + 0, /* biXPelsPerMeter */ \ + 0, /* biYPelsPerMeter */ \ + 0, /* biClrUsed */ \ + 0 /* biClrImportant */ \ + }, \ + { /* DIB data: left uninitialized */ } \ + } \ +} + +riff_cursor1_t empty_anicursor = { + ANI_RIFF_ID, + sizeof(empty_anicursor) - sizeof(DWORD)*2, + ANI_ACON_ID, + { + ANI_anih_ID, + sizeof(ani_header), + { + sizeof(ani_header), + 1, /* frames */ + 1, /* steps */ + 32, /* width */ + 32, /* height */ + 32, /* depth */ + 1, /* planes */ + 10, /* display rate in jiffies */ + ANI_FLAG_ICON /* flags */ + } + }, + { + ANI_LIST_ID, + sizeof(riff_icon32x32x32_t)*(1 /*frames*/) + sizeof(DWORD), + ANI_fram_ID, + }, + { + EMPTY_ICON32 + } +}; + +riff_cursor3_t empty_anicursor3 = { + ANI_RIFF_ID, + sizeof(empty_anicursor3) - sizeof(DWORD)*2, + ANI_ACON_ID, + { + ANI_anih_ID, + sizeof(ani_header), + { + sizeof(ani_header), + 3, /* frames */ + 3, /* steps */ + 32, /* width */ + 32, /* height */ + 32, /* depth */ + 1, /* planes */ + 0xbeef, /* display rate in jiffies */ + ANI_FLAG_ICON /* flags */ + } + }, + { + ANI_LIST_ID, + sizeof(riff_icon32x32x32_t)*(3 /*frames*/) + sizeof(DWORD), + ANI_fram_ID, + }, + { + EMPTY_ICON32, + EMPTY_ICON32, + EMPTY_ICON32 + } +}; + +riff_cursor3_seq_t empty_anicursor3_seq = { + ANI_RIFF_ID, + sizeof(empty_anicursor3_seq) - sizeof(DWORD)*2, + ANI_ACON_ID, + { + ANI_anih_ID, + sizeof(ani_header), + { + sizeof(ani_header), + 3, /* frames */ + 3, /* steps */ + 32, /* width */ + 32, /* height */ + 32, /* depth */ + 1, /* planes */ + 0xbeef, /* display rate in jiffies */ + ANI_FLAG_ICON|ANI_FLAG_SEQUENCE /* flags */ + } + }, + { + ANI_seq__ID, + sizeof(riff_seq3_t) - sizeof(DWORD)*2, + { 2, 0, 1} /* show frames in a uniquely identifiable order */ + }, + { + ANI_rate_ID, + sizeof(riff_rate3_t) - sizeof(DWORD)*2, + { 0xc0de, 0xcafe, 0xbabe} + }, + { + ANI_LIST_ID, + sizeof(riff_icon32x32x32_t)*(3 /*frames*/) + sizeof(DWORD), + ANI_fram_ID, + }, + { + EMPTY_ICON32, + EMPTY_ICON32, + EMPTY_ICON32 + } +}; + #include "poppack.h" static char **test_argv; @@ -65,6 +302,10 @@ static HANDLE child_process; #define PROC_INIT (WM_USER+1) static BOOL (WINAPI *pGetCursorInfo)(CURSORINFO *); +static BOOL (WINAPI *pGetIconInfoExA)(HICON,ICONINFOEXA *); +static BOOL (WINAPI *pGetIconInfoExW)(HICON,ICONINFOEXW *); + +static const int is_win64 = (sizeof(void *) > sizeof(int)); static LRESULT CALLBACK callback_child(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -78,7 +319,7 @@ static LRESULT CALLBACK callback_child(HWND hwnd, UINT msg, WPARAM wParam, LPARA SetLastError(0xdeadbeef); ret = DestroyCursor((HCURSOR) lParam); error = GetLastError(); - todo_wine ok(!ret || broken(ret) /* win9x */, "DestroyCursor on the active cursor succeeded.\n"); + ok(!ret || broken(ret) /* win9x */, "DestroyCursor on the active cursor succeeded.\n"); ok(error == ERROR_DESTROY_OBJECT_OF_OTHER_THREAD || error == 0xdeadbeef, /* vista */ "Last error: %u\n", error); @@ -504,6 +745,37 @@ static void test_icon_info_dbg(HICON hIcon, UINT exp_cx, UINT exp_cy, UINT exp_b ok_(__FILE__, line)(bmMask.bmWidth == exp_cx, "bmMask.bmWidth = %d\n", bmMask.bmWidth); ok_(__FILE__, line)(bmMask.bmHeight == exp_cy * 2, "bmMask.bmHeight = %d\n", bmMask.bmHeight); } + if (pGetIconInfoExA) + { + ICONINFOEXA infoex; + + memset( &infoex, 0xcc, sizeof(infoex) ); + SetLastError( 0xdeadbeef ); + infoex.cbSize = sizeof(infoex) - 1; + ret = pGetIconInfoExA( hIcon, &infoex ); + ok_(__FILE__, line)(!ret, "GetIconInfoEx succeeded\n"); + ok_(__FILE__, line)(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %d\n", GetLastError()); + + SetLastError( 0xdeadbeef ); + infoex.cbSize = sizeof(infoex) + 1; + ret = pGetIconInfoExA( hIcon, &infoex ); + ok_(__FILE__, line)(!ret, "GetIconInfoEx succeeded\n"); + ok_(__FILE__, line)(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %d\n", GetLastError()); + + SetLastError( 0xdeadbeef ); + infoex.cbSize = sizeof(infoex); + ret = pGetIconInfoExA( (HICON)0xdeadbabe, &infoex ); + ok_(__FILE__, line)(!ret, "GetIconInfoEx succeeded\n"); + ok_(__FILE__, line)(GetLastError() == ERROR_INVALID_CURSOR_HANDLE, + "wrong error %d\n", GetLastError()); + + infoex.cbSize = sizeof(infoex); + ret = pGetIconInfoExA( hIcon, &infoex ); + ok_(__FILE__, line)(ret, "GetIconInfoEx failed err %d\n", GetLastError()); + ok_(__FILE__, line)(infoex.wResID == 0, "GetIconInfoEx wrong resid %x\n", infoex.wResID); + ok_(__FILE__, line)(infoex.szModName[0] == 0, "GetIconInfoEx wrong module %s\n", infoex.szModName); + ok_(__FILE__, line)(infoex.szResName[0] == 0, "GetIconInfoEx wrong name %s\n", infoex.szResName); + } } #define test_icon_info(a,b,c,d) test_icon_info_dbg((a),(b),(c),(d),__LINE__) @@ -730,6 +1002,24 @@ static unsigned char gif4pixel[42] = { 0x02,0x00,0x00,0x02,0x03,0x14,0x16,0x05,0x00,0x3b }; +static const DWORD biSize_tests[] = { + 0, + sizeof(BITMAPCOREHEADER) - 1, + sizeof(BITMAPCOREHEADER) + 1, + sizeof(BITMAPINFOHEADER) - 1, + sizeof(BITMAPINFOHEADER) + 1, + sizeof(BITMAPV4HEADER) - 1, + sizeof(BITMAPV4HEADER) + 1, + sizeof(BITMAPV5HEADER) - 1, + sizeof(BITMAPV5HEADER) + 1, + (sizeof(BITMAPCOREHEADER) + sizeof(BITMAPINFOHEADER)) / 2, + (sizeof(BITMAPV4HEADER) + sizeof(BITMAPV5HEADER)) / 2, + 0xdeadbeef, + 0xffffffff +}; + +#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) + static void test_LoadImageBitmap(const char * test_desc, HBITMAP hbm) { BITMAP bm; @@ -819,8 +1109,9 @@ static void test_LoadImage(void) DWORD error, bytes_written; CURSORICONFILEDIR *icon_data; CURSORICONFILEDIRENTRY *icon_entry; - BITMAPINFOHEADER *icon_header; + BITMAPINFOHEADER *icon_header, *bitmap_header; ICONINFO icon_info; + int i; #define ICON_WIDTH 32 #define ICON_HEIGHT 32 @@ -889,6 +1180,18 @@ static void test_LoadImage(void) ok(icon_info.hbmMask != NULL, "No hbmMask!\n"); } + if (pGetIconInfoExA) + { + ICONINFOEXA infoex; + infoex.cbSize = sizeof(infoex); + ret = pGetIconInfoExA( handle, &infoex ); + ok( ret, "GetIconInfoEx failed err %d\n", GetLastError() ); + ok( infoex.wResID == 0, "GetIconInfoEx wrong resid %x\n", infoex.wResID ); + ok( infoex.szModName[0] == 0, "GetIconInfoEx wrong module %s\n", infoex.szModName ); + ok( infoex.szResName[0] == 0, "GetIconInfoEx wrong name %s\n", infoex.szResName ); + } + else win_skip( "GetIconInfoEx not available\n" ); + /* Clean up. */ SetLastError(0xdeadbeef); ret = DestroyCursor(handle); @@ -899,21 +1202,62 @@ static void test_LoadImage(void) HeapFree(GetProcessHeap(), 0, icon_data); DeleteFileA("icon.ico"); + /* Test a system icon */ + handle = LoadIcon( 0, IDI_HAND ); + ok(handle != NULL, "LoadImage() failed.\n"); + if (pGetIconInfoExA) + { + ICONINFOEXA infoexA; + ICONINFOEXW infoexW; + infoexA.cbSize = sizeof(infoexA); + ret = pGetIconInfoExA( handle, &infoexA ); + ok( ret, "GetIconInfoEx failed err %d\n", GetLastError() ); + ok( infoexA.wResID == (UINT_PTR)IDI_HAND, "GetIconInfoEx wrong resid %x\n", infoexA.wResID ); + /* the A version is broken on 64-bit, it truncates the string after the first char */ + if (is_win64 && infoexA.szModName[0] && infoexA.szModName[1] == 0) + trace( "GetIconInfoExA broken on Win64\n" ); + else + ok( GetModuleHandleA(infoexA.szModName) == GetModuleHandleA("user32.dll"), + "GetIconInfoEx wrong module %s\n", infoexA.szModName ); + ok( infoexA.szResName[0] == 0, "GetIconInfoEx wrong name %s\n", infoexA.szResName ); + infoexW.cbSize = sizeof(infoexW); + ret = pGetIconInfoExW( handle, &infoexW ); + ok( ret, "GetIconInfoEx failed err %d\n", GetLastError() ); + ok( infoexW.wResID == (UINT_PTR)IDI_HAND, "GetIconInfoEx wrong resid %x\n", infoexW.wResID ); + ok( GetModuleHandleW(infoexW.szModName) == GetModuleHandleA("user32.dll"), + "GetIconInfoEx wrong module %s\n", wine_dbgstr_w(infoexW.szModName) ); + ok( infoexW.szResName[0] == 0, "GetIconInfoEx wrong name %s\n", wine_dbgstr_w(infoexW.szResName) ); + } + SetLastError(0xdeadbeef); + DestroyIcon(handle); + test_LoadImageFile("BMP", bmpimage, sizeof(bmpimage), "bmp", 1); test_LoadImageFile("BMP (coreinfo)", bmpcoreimage, sizeof(bmpcoreimage), "bmp", 1); test_LoadImageFile("GIF", gifimage, sizeof(gifimage), "gif", 0); test_LoadImageFile("GIF (2x2 pixel)", gif4pixel, sizeof(gif4pixel), "gif", 0); test_LoadImageFile("JPG", jpgimage, sizeof(jpgimage), "jpg", 0); test_LoadImageFile("PNG", pngimage, sizeof(pngimage), "png", 0); + /* Check failure for broken BMP images */ - bmpimage[0x14]++; /* biHeight > 65535 */ + bitmap_header = (BITMAPINFOHEADER *)(bmpimage + sizeof(BITMAPFILEHEADER)); + + bitmap_header->biHeight = 65536; test_LoadImageFile("BMP (too high)", bmpimage, sizeof(bmpimage), "bmp", 0); - bmpimage[0x14]--; - bmpimage[0x18]++; /* biWidth > 65535 */ + bitmap_header->biHeight = 1; + + bitmap_header->biWidth = 65536; test_LoadImageFile("BMP (too wide)", bmpimage, sizeof(bmpimage), "bmp", 0); - bmpimage[0x18]--; + bitmap_header->biWidth = 1; + + for (i = 0; i < ARRAY_SIZE(biSize_tests); i++) { + bitmap_header->biSize = biSize_tests[i]; + test_LoadImageFile("BMP (broken biSize)", bmpimage, sizeof(bmpimage), "bmp", 0); + } + bitmap_header->biSize = sizeof(BITMAPINFOHEADER); } +#undef ARRAY_SIZE + static void test_CreateIconFromResource(void) { HANDLE handle; @@ -968,6 +1312,17 @@ static void test_CreateIconFromResource(void) ok(icon_info.hbmMask != NULL, "No hbmMask!\n"); } + if (pGetIconInfoExA) + { + ICONINFOEXA infoex; + infoex.cbSize = sizeof(infoex); + ret = pGetIconInfoExA( handle, &infoex ); + ok( ret, "GetIconInfoEx failed err %d\n", GetLastError() ); + ok( infoex.wResID == 0, "GetIconInfoEx wrong resid %x\n", infoex.wResID ); + ok( infoex.szModName[0] == 0, "GetIconInfoEx wrong module %s\n", infoex.szModName ); + ok( infoex.szResName[0] == 0, "GetIconInfoEx wrong name %s\n", infoex.szResName ); + } + /* Clean up. */ SetLastError(0xdeadbeef); ret = DestroyCursor(handle); @@ -1005,7 +1360,331 @@ static void test_CreateIconFromResource(void) error = GetLastError(); ok(error == 0xdeadbeef, "Last error: %u\n", error); + /* Rejection of NULL pointer crashes at least on WNT4WSSP6, W2KPROSP4, WXPPROSP3 + * + * handle = CreateIconFromResource(NULL, ICON_RES_SIZE, TRUE, 0x00030000); + * ok(handle == NULL, "Invalid pointer accepted (%p)\n", handle); + */ HeapFree(GetProcessHeap(), 0, hotspot); + + /* Test creating an animated cursor. */ + empty_anicursor.frames[0].data.icon_info.idType = 2; /* type: cursor */ + empty_anicursor.frames[0].data.icon_info.idEntries[0].xHotspot = 3; + empty_anicursor.frames[0].data.icon_info.idEntries[0].yHotspot = 3; + handle = CreateIconFromResource((PBYTE) &empty_anicursor, sizeof(empty_anicursor), FALSE, 0x00030000); + ok(handle != NULL, "Create cursor failed.\n"); + + /* Test the animated cursor's information. */ + SetLastError(0xdeadbeef); + ret = GetIconInfo(handle, &icon_info); + ok(ret, "GetIconInfo() failed.\n"); + error = GetLastError(); + ok(error == 0xdeadbeef, "Last error: %u\n", error); + + if (ret) + { + ok(icon_info.fIcon == FALSE, "fIcon != FALSE.\n"); + ok(icon_info.xHotspot == 3, "xHotspot is %u.\n", icon_info.xHotspot); + ok(icon_info.yHotspot == 3, "yHotspot is %u.\n", icon_info.yHotspot); + ok(icon_info.hbmColor != NULL || broken(!icon_info.hbmColor) /* no color cursor support */, + "No hbmColor!\n"); + ok(icon_info.hbmMask != NULL, "No hbmMask!\n"); + } + + /* Clean up. */ + SetLastError(0xdeadbeef); + ret = DestroyCursor(handle); + ok(ret, "DestroyCursor() failed.\n"); + error = GetLastError(); + ok(error == 0xdeadbeef, "Last error: %u\n", error); +} + +static int check_cursor_data( HDC hdc, HCURSOR hCursor, void *data, int length) +{ + char *image = NULL; + BITMAPINFO *info; + ICONINFO iinfo; + DWORD ret; + + ret = GetIconInfo( hCursor, &iinfo ); + ok(ret, "GetIconInfo() failed\n"); + if (!ret) return 0; + ret = 0; + info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )); + ok(info != NULL, "HeapAlloc() failed\n"); + if (!info) return 0; + + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biWidth = 32; + info->bmiHeader.biHeight = 32; + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = 32; + info->bmiHeader.biCompression = BI_RGB; + info->bmiHeader.biSizeImage = 32 * 32 * 4; + info->bmiHeader.biXPelsPerMeter = 0; + info->bmiHeader.biYPelsPerMeter = 0; + info->bmiHeader.biClrUsed = 0; + info->bmiHeader.biClrImportant = 0; + image = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ); + ok(image != NULL, "HeapAlloc() failed\n"); + if (!image) goto cleanup; + ret = GetDIBits( hdc, iinfo.hbmColor, 0, 32, image, info, DIB_RGB_COLORS ); + ok(ret, "GetDIBits() failed\n"); + if (!ret) goto cleanup; + ret = (memcmp(image, data, length) == 0); + ok(ret, "Expected 0x%x, actually 0x%x (first 4 bytes only)\n", *(DWORD *)data, *(DWORD *)image); + +cleanup: + HeapFree( GetProcessHeap(), 0, image ); + HeapFree( GetProcessHeap(), 0, info ); + return ret; +} + +static HCURSOR (WINAPI *pGetCursorFrameInfo)(HCURSOR hCursor, DWORD unk1, DWORD istep, DWORD *rate, DWORD *steps); +static void test_GetCursorFrameInfo(void) +{ + DWORD frame_identifier[] = { 0x10Ad, 0xc001, 0x1c05 }; + HBITMAP bmp = NULL, bmpOld = NULL; + DWORD rate, steps; + BITMAPINFOHEADER *icon_header; + BITMAPINFO bitmapInfo; + HDC hdc = NULL; + void *bits = 0; + INT16 *hotspot; + HANDLE h1, h2; + BOOL ret; + int i; + + if (!pGetCursorFrameInfo) + { + win_skip( "GetCursorFrameInfo not supported, skipping tests.\n" ); + return; + } + + hdc = CreateCompatibleDC(0); + ok(hdc != 0, "CreateCompatibleDC(0) failed to return a valid DC\n"); + if (!hdc) + return; + + memset(&bitmapInfo, 0, sizeof(bitmapInfo)); + bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bitmapInfo.bmiHeader.biWidth = 3; + bitmapInfo.bmiHeader.biHeight = 3; + bitmapInfo.bmiHeader.biBitCount = 32; + bitmapInfo.bmiHeader.biPlanes = 1; + bitmapInfo.bmiHeader.biCompression = BI_RGB; + bitmapInfo.bmiHeader.biSizeImage = sizeof(UINT32); + bmp = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, &bits, NULL, 0); + ok (bmp && bits, "CreateDIBSection failed to return a valid bitmap and buffer\n"); + if (!bmp || !bits) + goto cleanup; + bmpOld = SelectObject(hdc, bmp); + +#define ICON_RES_WIDTH 32 +#define ICON_RES_HEIGHT 32 +#define ICON_RES_AND_SIZE (ICON_WIDTH*ICON_HEIGHT/8) +#define ICON_RES_BPP 32 +#define ICON_RES_SIZE \ + (sizeof(BITMAPINFOHEADER) + ICON_AND_SIZE + ICON_AND_SIZE*ICON_BPP) +#define CRSR_RES_SIZE (2*sizeof(INT16) + ICON_RES_SIZE) + + /* Set icon data. */ + hotspot = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, CRSR_RES_SIZE); + + /* Cursor resources have an extra hotspot, icon resources not. */ + hotspot[0] = 3; + hotspot[1] = 3; + + icon_header = (BITMAPINFOHEADER *) (hotspot + 2); + icon_header->biSize = sizeof(BITMAPINFOHEADER); + icon_header->biWidth = ICON_WIDTH; + icon_header->biHeight = ICON_HEIGHT*2; + icon_header->biPlanes = 1; + icon_header->biBitCount = ICON_BPP; + icon_header->biSizeImage = 0; /* Uncompressed bitmap. */ + + /* Creating a static cursor. */ + SetLastError(0xdeadbeef); + h1 = CreateIconFromResource((PBYTE) hotspot, CRSR_RES_SIZE, FALSE, 0x00030000); + ok(h1 != NULL, "Create cursor failed (error = %d).\n", GetLastError()); + + /* Check GetCursorFrameInfo behavior on a static cursor */ + rate = steps = 0xdead; + h2 = pGetCursorFrameInfo(h1, 0xdead, 0xdead, &rate, &steps); + ok(h1 == h2, "GetCursorFrameInfo() failed: (%p != %p).\n", h1, h2); + ok(rate == 0, "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0x0).\n", rate); + ok(steps == 1, "GetCursorFrameInfo() unexpected param 5 value (%d != 1).\n", steps); + + /* Clean up static cursor. */ + SetLastError(0xdeadbeef); + ret = DestroyCursor(h1); + ok(ret, "DestroyCursor() failed (error = %d).\n", GetLastError()); + + /* Creating a single-frame animated cursor. */ + empty_anicursor.frames[0].data.icon_info.idType = 2; /* type: cursor */ + empty_anicursor.frames[0].data.icon_info.idEntries[0].xHotspot = 3; + empty_anicursor.frames[0].data.icon_info.idEntries[0].yHotspot = 3; + memcpy( &empty_anicursor.frames[0].data.bmi_data.data[0], &frame_identifier[0], sizeof(DWORD) ); + SetLastError(0xdeadbeef); + h1 = CreateIconFromResource((PBYTE) &empty_anicursor, sizeof(empty_anicursor), FALSE, 0x00030000); + ok(h1 != NULL, "Create cursor failed (error = %d).\n", GetLastError()); + + /* Check GetCursorFrameInfo behavior on a single-frame animated cursor */ + rate = steps = 0xdead; + h2 = pGetCursorFrameInfo(h1, 0xdead, 0, &rate, &steps); + ok(h1 == h2, "GetCursorFrameInfo() failed: (%p != %p).\n", h1, h2); + ret = check_cursor_data( hdc, h2, &frame_identifier[0], sizeof(DWORD) ); + ok(ret, "GetCursorFrameInfo() returned wrong cursor data for frame 0.\n"); + ok(rate == 0x0, "GetCursorFrameInfo() unexpected param 4 value (0x%x != 0x0).\n", rate); + ok(steps == empty_anicursor.header.header.num_steps, + "GetCursorFrameInfo() unexpected param 5 value (%d != 1).\n", steps); + + /* Clean up single-frame animated cursor. */ + SetLastError(0xdeadbeef); + ret = DestroyCursor(h1); + ok(ret, "DestroyCursor() failed (error = %d).\n", GetLastError()); + + /* Creating a multi-frame animated cursor. */ + for (i=0; i= 3) @@ -1741,6 +2484,7 @@ START_TEST(cursoricon) test_CreateIcon(); test_LoadImage(); test_CreateIconFromResource(); + test_GetCursorFrameInfo(); test_DrawIcon(); test_DrawIconEx(); test_DrawState(); diff --git a/rostests/winetests/user32/dce.c b/rostests/winetests/user32/dce.c index cfa07e51408..4aacd64a593 100755 --- a/rostests/winetests/user32/dce.c +++ b/rostests/winetests/user32/dce.c @@ -66,10 +66,7 @@ static void test_dc_attributes(void) hdc = hdcs[i] = GetDCEx( hwnd_cache, 0, DCX_USESTYLE | DCX_NORESETATTRS ); if (!hdc) break; rop = GetROP2( hdc ); - if (hdc == old_hdc) - todo_wine ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc ); - else - ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc ); + ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc ); if (hdc == old_hdc) { found_dc = 1; @@ -104,8 +101,8 @@ static void test_dc_attributes(void) rop = GetROP2( hdc ); if (hdc == old_hdc) { - todo_wine ok( rop == R2_WHITE || broken( rop == def_rop), - "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc ); + ok( rop == R2_WHITE || broken( rop == def_rop), + "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc ); SetROP2( old_hdc, def_rop ); } else @@ -226,7 +223,7 @@ static void test_dc_visrgn(void) SetRectEmpty( &rect ); GetClipBox( hdc, &rect ); ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20), - "clip box sould have been reset %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom ); + "clip box should have been reset %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom ); ReleaseDC( hwnd_cache, hdc ); /* window DC */ @@ -427,6 +424,87 @@ static void test_invisible_create(void) DestroyWindow(hwnd_owndc); } +static void test_dc_layout(void) +{ + DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout); + DWORD (WINAPI *pGetLayout)(HDC hdc); + HWND hwnd_cache_rtl, hwnd_owndc_rtl, hwnd_classdc_rtl, hwnd_classdc2_rtl; + HDC hdc; + DWORD layout; + HMODULE mod = GetModuleHandleA("gdi32.dll"); + + pGetLayout = (void *)GetProcAddress( mod, "GetLayout" ); + pSetLayout = (void *)GetProcAddress( mod, "SetLayout" ); + if (!pGetLayout || !pSetLayout) + { + win_skip( "Don't have SetLayout\n" ); + return; + } + + hdc = GetDC( hwnd_cache ); + pSetLayout( hdc, LAYOUT_RTL ); + layout = pGetLayout( hdc ); + ReleaseDC( hwnd_cache, hdc ); + if (!layout) + { + win_skip( "SetLayout not supported\n" ); + return; + } + + hwnd_cache_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "cache_class", NULL, WS_OVERLAPPED | WS_VISIBLE, + 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL ); + hwnd_owndc_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "owndc_class", NULL, WS_OVERLAPPED | WS_VISIBLE, + 0, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL ); + hwnd_classdc_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE, + 200, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL ); + hwnd_classdc2_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE, + 200, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL ); + hdc = GetDC( hwnd_cache_rtl ); + layout = pGetLayout( hdc ); + + ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); + pSetLayout( hdc, 0 ); + ReleaseDC( hwnd_cache_rtl, hdc ); + hdc = GetDC( hwnd_owndc_rtl ); + layout = pGetLayout( hdc ); + ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); + ReleaseDC( hwnd_cache_rtl, hdc ); + + hdc = GetDC( hwnd_cache ); + layout = pGetLayout( hdc ); + ok( layout == 0, "wrong layout %x\n", layout ); + ReleaseDC( hwnd_cache, hdc ); + + hdc = GetDC( hwnd_owndc_rtl ); + layout = pGetLayout( hdc ); + ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); + pSetLayout( hdc, 0 ); + ReleaseDC( hwnd_owndc_rtl, hdc ); + hdc = GetDC( hwnd_owndc_rtl ); + layout = pGetLayout( hdc ); + ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); + ReleaseDC( hwnd_owndc_rtl, hdc ); + + hdc = GetDC( hwnd_classdc_rtl ); + layout = pGetLayout( hdc ); + ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); + pSetLayout( hdc, 0 ); + ReleaseDC( hwnd_classdc_rtl, hdc ); + hdc = GetDC( hwnd_classdc2_rtl ); + layout = pGetLayout( hdc ); + ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); + ReleaseDC( hwnd_classdc2_rtl, hdc ); + hdc = GetDC( hwnd_classdc ); + layout = pGetLayout( hdc ); + ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); + ReleaseDC( hwnd_classdc_rtl, hdc ); + + DestroyWindow(hwnd_classdc2_rtl); + DestroyWindow(hwnd_classdc_rtl); + DestroyWindow(hwnd_owndc_rtl); + DestroyWindow(hwnd_cache_rtl); +} + static void test_destroyed_window(void) { HDC dc; @@ -483,6 +561,7 @@ START_TEST(dce) test_dc_visrgn(); test_begin_paint(); test_invisible_create(); + test_dc_layout(); DestroyWindow(hwnd_classdc2); DestroyWindow(hwnd_classdc); diff --git a/rostests/winetests/user32/dde.c b/rostests/winetests/user32/dde.c index 529c527f2e2..e273de21379 100755 --- a/rostests/winetests/user32/dde.c +++ b/rostests/winetests/user32/dde.c @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include #include @@ -63,17 +62,19 @@ static void flush_events(void) static void create_dde_window(HWND *hwnd, LPCSTR name, WNDPROC wndproc) { WNDCLASSA wcA; + ATOM aclass; memset(&wcA, 0, sizeof(wcA)); wcA.lpfnWndProc = wndproc; wcA.lpszClassName = name; wcA.hInstance = GetModuleHandleA(0); - assert(RegisterClassA(&wcA)); + aclass = RegisterClassA(&wcA); + ok (aclass, "RegisterClass failed\n"); *hwnd = CreateWindowExA(0, name, NULL, WS_POPUP, 500, 500, CW_USEDEFAULT, CW_USEDEFAULT, GetDesktopWindow(), 0, GetModuleHandleA(0), NULL); - assert(*hwnd); + ok(*hwnd != NULL, "CreateWindowExA failed\n"); } static void destroy_dde_window(HWND *hwnd, LPCSTR name) @@ -1000,7 +1001,7 @@ static LRESULT WINAPI dde_msg_client_wndproc(HWND hwnd, UINT msg, WPARAM wparam, ok(data->fAckReq == 0, "Expected 0, got %d\n", data->fAckReq); ok(data->cfFormat == CF_TEXT, "Expected CF_TEXT, got %d\n", data->cfFormat); ok(!lstrcmpA((LPSTR)data->Value, "requested data\r\n"), - "Expeted 'requested data\\r\\n', got %s\n", data->Value); + "Expected 'requested data\\r\\n', got %s\n", data->Value); GlobalUnlock((HGLOBAL)lo); size = GlobalGetAtomNameA(hi, str, MAX_PATH); @@ -1295,7 +1296,7 @@ static LRESULT WINAPI dde_server_wndprocA(HWND hwnd, UINT msg, WPARAM wparam, LP if (!conv_unicode) ok( !lstrcmpA(cmd, exec_cmdA), "server A got wrong command '%s'\n", cmd ); else /* we get garbage as the A command was mapped W->A */ - ok( cmd[0] == '?', "server A got wrong command '%s'\n", cmd ); + ok( cmd[0] != exec_cmdA[0], "server A got wrong command '%s'\n", cmd ); break; case 2: /* ANSI command in Unicode format */ @@ -1316,7 +1317,7 @@ static LRESULT WINAPI dde_server_wndprocA(HWND hwnd, UINT msg, WPARAM wparam, LP if (!conv_unicode) ok( !lstrcmpA(cmd, exec_cmdWA), "server A got wrong command '%s'\n", cmd ); else /* we get garbage as the A command was mapped W->A */ - ok( cmd[0] == '?', "server A got wrong command '%s'\n", cmd ); + ok( cmd[0] != exec_cmdWA[0], "server A got wrong command '%s'\n", cmd ); break; } GlobalUnlock((HGLOBAL)hi); @@ -1430,7 +1431,7 @@ static LRESULT WINAPI dde_server_wndprocW(HWND hwnd, UINT msg, WPARAM wparam, LP case 1: /* ANSI command */ if (conv_unicode && !client_unicode) /* W->A mapping -> garbage */ - ok( cmd[0] == '?', "server W got wrong command '%s'\n", cmd ); + ok( cmd[0] != exec_cmdA[0], "server W got wrong command '%s'\n", cmd ); else if (!conv_unicode && client_unicode) /* A->W mapping */ ok( !lstrcmpW((LPCWSTR)cmd, exec_cmdAW), "server W got wrong command '%s'\n", cmd ); else @@ -1457,7 +1458,7 @@ static LRESULT WINAPI dde_server_wndprocW(HWND hwnd, UINT msg, WPARAM wparam, LP case 4: /* Unicode command in ANSI format */ if (conv_unicode && !client_unicode) /* W->A mapping -> garbage */ - ok( cmd[0] == '?', "server W got wrong command '%s'\n", cmd ); + ok( cmd[0] != exec_cmdWA[0], "server W got wrong command '%s'\n", cmd ); else if (!conv_unicode && client_unicode) /* A->W mapping */ ok( !lstrcmpW((LPCWSTR)cmd, exec_cmdW), "server W got wrong command '%s'\n", cmd ); else @@ -1571,6 +1572,7 @@ static void test_dde_aw_transaction( BOOL client_unicode, BOOL server_unicode ) CONVINFO info; HDDEDATA hdata; BOOL conv_unicode = client_unicode; + BOOL got; static char test_cmd[] = "test dde command"; if (!(hwnd_server = create_dde_server( server_unicode ))) return; @@ -1709,7 +1711,8 @@ todo_wine { ok(err == DMLERR_NOTPROCESSED, "DdeClientTransaction returned error %x\n", err); } - ok(DdeDisconnect(hconv), "DdeDisconnect error %x\n", DdeGetLastError(dde_inst)); + got = DdeDisconnect(hconv); + ok(got, "DdeDisconnect error %x\n", DdeGetLastError(dde_inst)); info.cb = sizeof(info); ret = DdeQueryConvInfo(hconv, QID_SYNC, &info); @@ -1719,7 +1722,8 @@ todo_wine { ok(err == DMLERR_INVALIDPARAMETER, "wrong dde error %x\n", err); } - ok(DdeFreeStringHandle(dde_inst, hsz_server), "DdeFreeStringHandle error %x\n", DdeGetLastError(dde_inst)); + got = DdeFreeStringHandle(dde_inst, hsz_server); + ok(got, "DdeFreeStringHandle error %x\n", DdeGetLastError(dde_inst)); /* This call hangs on win2k SP4 and XP SP1. DdeUninitialize(dde_inst);*/ @@ -1757,7 +1761,7 @@ static void test_initialisation(void) item = DdeCreateStringHandleA(client_pid, "request", CP_WINANSI); - /* There is no converstation so an invalild parameter results */ + /* There is no conversation so an invalid parameter results */ res = 0xdeadbeef; DdeGetLastError(client_pid); hdata = DdeClientTransaction(NULL, 0, conversation, item, CF_TEXT, XTYP_REQUEST, default_timeout, &res); @@ -2043,12 +2047,6 @@ static void test_DdeCreateStringHandle(void) dde_inst = 0xdeadbeef; SetLastError(0xdeadbeef); ret = DdeInitializeW(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0); - if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) - { - win_skip("DdeInitializeW is unimplemented\n"); - return; - } - ok(ret == DMLERR_INVALIDPARAMETER, "DdeInitializeW should fail, but got %04x instead\n", ret); ok(DdeGetLastError(dde_inst) == DMLERR_INVALIDPARAMETER, "expected DMLERR_INVALIDPARAMETER\n"); @@ -2493,8 +2491,6 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV else if (unicode_client) { /* ASCII string mapped W->A -> garbage */ - ok(size == size_a / sizeof(WCHAR) || size == size_a / sizeof(WCHAR) + 1, - "Wrong size %d, msg_index=%d\n", size, msg_index); } else { @@ -2536,7 +2532,8 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV DWORD nt_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, size_w, test_cmd_a_to_w, sizeof(test_cmd_a_to_w)/sizeof(WCHAR) ) * sizeof(WCHAR); DWORD xp_size = MultiByteToWideChar( CP_ACP, 0, (char *)cmd_w, -1, NULL, 0 ) * sizeof(WCHAR); - ok(size == xp_size || broken(size == nt_size), + ok(size == xp_size || broken(size == nt_size) || + broken(str_index == 4 && IsDBCSLeadByte(cmd_w[0])) /* East Asian */, "Wrong size %d/%d, msg_index=%d\n", size, size_a_to_w, msg_index); ok(!lstrcmpW((WCHAR*)buffer, test_cmd_a_to_w), "Expected %s, msg_index=%d\n", wine_dbgstr_w(test_cmd_a_to_w), msg_index); @@ -2696,6 +2693,7 @@ START_TEST(dde) char buffer[MAX_PATH]; STARTUPINFO startup; PROCESS_INFORMATION proc; + DWORD dde_inst = 0xdeadbeef; argc = winetest_get_mainargs(&argv); if (argc == 3) @@ -2714,6 +2712,14 @@ START_TEST(dde) test_initialisation(); + SetLastError(0xdeadbeef); + DdeInitializeW(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0); + if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + win_skip("Skipping tests on win9x because of brokenness\n"); + return; + } + ZeroMemory(&startup, sizeof(STARTUPINFO)); sprintf(buffer, "%s dde ddeml", argv[0]); startup.cb = sizeof(startup); diff --git a/rostests/winetests/user32/dialog.c b/rostests/winetests/user32/dialog.c index 736c99d784e..8e4ffb577de 100755 --- a/rostests/winetests/user32/dialog.c +++ b/rostests/winetests/user32/dialog.c @@ -50,7 +50,7 @@ static HWND g_hwndTestDlg, g_hwndTestDlgBut1, g_hwndTestDlgBut2, g_hwndTestDlgEd static HWND g_hwndInitialFocusT1, g_hwndInitialFocusT2, g_hwndInitialFocusGroupBox; static LONG g_styleInitialFocusT1, g_styleInitialFocusT2; -static BOOL g_bInitialFocusInitDlgResult; +static BOOL g_bInitialFocusInitDlgResult, g_bReceivedCommand; static int g_terminated; @@ -209,7 +209,7 @@ static BOOL CreateWindows (HINSTANCE hinst) /* Form the lParam of a WM_KEYDOWN message */ static DWORD KeyDownData (int repeat, int scancode, int extended, int wasdown) { - return ((repeat & 0x0000FFFF) | ((scancode & 0x00FF) >> 16) | + return ((repeat & 0x0000FFFF) | ((scancode & 0x00FF) << 16) | (extended ? 0x01000000 : 0) | (wasdown ? 0x40000000 : 0)); } @@ -539,6 +539,8 @@ static LRESULT CALLBACK testDlgWinProc (HWND hwnd, UINT uiMsg, WPARAM wParam, case WM_CREATE: return (OnTestDlgCreate (hwnd, (LPCREATESTRUCTA) lParam) ? 0 : (LRESULT) -1); + case WM_COMMAND: + if(LOWORD(wParam) == 300) g_bReceivedCommand = TRUE; } return DefDlgProcA (hwnd, uiMsg, wParam, lParam); @@ -576,6 +578,8 @@ static BOOL RegisterWindowClasses (void) static void test_WM_NEXTDLGCTL(void) { + HWND child1, child2, child3; + MSG msg; DWORD dwVal; g_hwndTestDlg = CreateWindowEx( WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR @@ -638,7 +642,7 @@ static void test_WM_NEXTDLGCTL(void) "Button1 style not set to BS_DEFPUSHBUTTON\n" ); ok ( !((GetWindowLong( g_hwndTestDlgBut2, GWL_STYLE)) & BS_DEFPUSHBUTTON), - "Button2's style not chaged to BS_PUSHBUTTON\n" ); + "Button2's style not changed to BS_PUSHBUTTON\n" ); } /* @@ -663,7 +667,7 @@ static void test_WM_NEXTDLGCTL(void) "Button2 style not set to BS_DEFPUSHBUTTON\n" ); ok ( !((GetWindowLong( g_hwndTestDlgBut1, GWL_STYLE)) & BS_DEFPUSHBUTTON), - "Button1's style not chaged to BS_PUSHBUTTON\n" ); + "Button1's style not changed to BS_PUSHBUTTON\n" ); } /* @@ -678,6 +682,38 @@ static void test_WM_NEXTDLGCTL(void) dwVal = DefDlgProcA(g_hwndTestDlg, DM_GETDEFID, 0, 0); ok ( IDCANCEL == (LOWORD(dwVal)), "WM_NEXTDLGCTL changed default button\n"); } + + /* test nested default buttons */ + + child1 = CreateWindowA("button", "child1", WS_VISIBLE|WS_CHILD, 0, 0, 50, 50, + g_hwndTestDlg, (HMENU)100, g_hinst, NULL); + ok(child1 != NULL, "failed to create first child\n"); + child2 = CreateWindowA("button", "child2", WS_VISIBLE|WS_CHILD, 60, 60, 30, 30, + g_hwndTestDlg, (HMENU)200, g_hinst, NULL); + ok(child2 != NULL, "failed to create second child\n"); + /* create nested child */ + child3 = CreateWindowA("button", "child3", WS_VISIBLE|WS_CHILD, 10, 10, 10, 10, + child1, (HMENU)300, g_hinst, NULL); + ok(child3 != NULL, "failed to create subchild\n"); + + DefDlgProcA( g_hwndTestDlg, DM_SETDEFID, 200, 0); + dwVal = DefDlgProcA( g_hwndTestDlg, DM_GETDEFID, 0, 0); + ok(LOWORD(dwVal) == 200, "expected 200, got %x\n", dwVal); + + DefDlgProcA( g_hwndTestDlg, DM_SETDEFID, 300, 0); + dwVal = DefDlgProcA( g_hwndTestDlg, DM_GETDEFID, 0, 0); + ok(LOWORD(dwVal) == 300, "expected 300, got %x\n", dwVal); + ok(SendMessageW( child3, WM_GETDLGCODE, 0, 0) != DLGC_DEFPUSHBUTTON, + "expected child3 not to be marked as DLGC_DEFPUSHBUTTON\n"); + + g_bReceivedCommand = FALSE; + FormEnterMsg (&msg, child3); + ok(IsDialogMessage (g_hwndTestDlg, &msg), "Did not handle the ENTER\n"); + ok(g_bReceivedCommand, "Did not trigger the default Button action\n"); + + DestroyWindow(child3); + DestroyWindow(child2); + DestroyWindow(child1); DestroyWindow(g_hwndTestDlg); } diff --git a/rostests/winetests/user32/edit.c b/rostests/winetests/user32/edit.c index fb74143ecd2..c6c815a369c 100755 --- a/rostests/winetests/user32/edit.c +++ b/rostests/winetests/user32/edit.c @@ -559,6 +559,7 @@ static HWND create_editcontrol (DWORD style, DWORD exstyle) style, 10, 10, 300, 300, NULL, NULL, hinst, NULL); + ok (handle != NULL, "CreateWindow EDIT Control failed\n"); assert (handle); if (winetest_interactive) ShowWindow (handle, SW_SHOW); @@ -570,12 +571,14 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle) HWND parentWnd; HWND editWnd; RECT rect; + BOOL b; rect.left = 0; rect.top = 0; rect.right = 300; rect.bottom = 300; - assert(AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE)); + b = AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE); + ok(b, "AdjustWindowRect failed\n"); parentWnd = CreateWindowEx(0, szEditTextPositionClass, @@ -584,6 +587,7 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle) CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, hinst, NULL); + ok (parentWnd != NULL, "CreateWindow EDIT Test failed\n"); assert(parentWnd); editWnd = CreateWindowEx(exstyle, @@ -592,6 +596,7 @@ static HWND create_child_editcontrol (DWORD style, DWORD exstyle) WS_CHILD | style, 0, 0, 300, 300, parentWnd, NULL, hinst, NULL); + ok (editWnd != NULL, "CreateWindow EDIT Test Text failed\n"); assert(editWnd); if (winetest_interactive) ShowWindow (parentWnd, SW_SHOW); @@ -837,10 +842,15 @@ static void test_edit_control_3(void) { HWND hWnd; HWND hParent; - int len; + HDC hDC; + int len, dpi; static const char *str = "this is a long string."; static const char *str2 = "this is a long string.\r\nthis is a long string.\r\nthis is a long string.\r\nthis is a long string."; + hDC = GetDC(NULL); + dpi = GetDeviceCaps(hDC, LOGPIXELSY); + ReleaseDC(NULL, hDC); + trace("EDIT: Test notifications\n"); hParent = CreateWindowExA(0, @@ -947,7 +957,7 @@ static void test_edit_control_3(void) "EDIT", NULL, ES_MULTILINE, - 10, 10, 50, 50, + 10, 10, (50 * dpi) / 96, (50 * dpi) / 96, hParent, NULL, NULL, NULL); assert(hWnd); @@ -992,7 +1002,7 @@ static void test_edit_control_3(void) "EDIT", NULL, ES_MULTILINE | ES_AUTOHSCROLL, - 10, 10, 50, 50, + 10, 10, (50 * dpi) / 96, (50 * dpi) / 96, hParent, NULL, NULL, NULL); assert(hWnd); @@ -1308,9 +1318,7 @@ static void test_edit_control_limittext(void) ok(r == 30000, "Incorrect default text limit, expected 30000 got %u\n", r); SendMessage(hwEdit, EM_SETLIMITTEXT, 0, 0); r = SendMessage(hwEdit, EM_GETLIMITTEXT, 0, 0); - /* Win9x+ME: 32766; WinNT: 2147483646UL */ - ok( (r == 32766) || (r == 2147483646UL), - "got limit %u (expected 32766 or 2147483646)\n", r); + ok( r == 2147483646, "got limit %u (expected 2147483646)\n", r); DestroyWindow(hwEdit); /* Test default limit for multi-line control */ @@ -1320,9 +1328,7 @@ static void test_edit_control_limittext(void) ok(r == 30000, "Incorrect default text limit, expected 30000 got %u\n", r); SendMessage(hwEdit, EM_SETLIMITTEXT, 0, 0); r = SendMessage(hwEdit, EM_GETLIMITTEXT, 0, 0); - /* Win9x+ME: 65535; WinNT: 4294967295UL */ - ok( (r == 65535) || (r == 4294967295UL), - "got limit %u (expected 65535 or 4294967295)\n", r); + ok( r == 4294967295U, "got limit %u (expected 4294967295)\n", r); DestroyWindow(hwEdit); } @@ -1527,6 +1533,7 @@ static void test_margins_font_change(void) ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins)); SendMessageA(hwEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(EC_USEFONTINFO,EC_USEFONTINFO)); + SendMessageA(hwEdit, WM_SETFONT, (WPARAM)hfont, 0); margins = SendMessage(hwEdit, EM_GETMARGINS, 0, 0); ok(LOWORD(margins) == LOWORD(font_margins), "got %d\n", LOWORD(margins)); ok(HIWORD(margins) == HIWORD(font_margins), "got %d\n", HIWORD(margins)); @@ -1566,7 +1573,7 @@ static void test_text_position_style(DWORD style) HDC dc; TEXTMETRIC metrics; INT b, bm, b2, b3; - BOOL single_line = !(style & ES_MULTILINE); + BOOL xb, single_line = !(style & ES_MULTILINE); b = GetSystemMetrics(SM_CYBORDER) + 1; b2 = 2 * b; @@ -1574,10 +1581,13 @@ static void test_text_position_style(DWORD style) bm = b2 - 1; /* Get a stock font for which we can determine the metrics */ - assert(font = GetStockObject(SYSTEM_FONT)); - assert(dc = GetDC(NULL)); + font = GetStockObject(SYSTEM_FONT); + ok (font != NULL, "GetStockObjcet SYSTEM_FONT failed\n"); + dc = GetDC(NULL); + ok (dc != NULL, "GetDC() failed\n"); oldFont = SelectObject(dc, font); - assert(GetTextMetrics(dc, &metrics)); + xb = GetTextMetrics(dc, &metrics); + ok (xb, "GetTextMetrics failed\n"); SelectObject(dc, oldFont); ReleaseDC(NULL, dc); @@ -2212,9 +2222,15 @@ static void test_fontsize(void) { HWND hwEdit; HFONT hfont; + HDC hDC; LOGFONT lf; LONG r; char szLocalString[MAXLEN]; + int dpi; + + hDC = GetDC(NULL); + dpi = GetDeviceCaps(hDC, LOGPIXELSY); + ReleaseDC(NULL, hDC); memset(&lf,0,sizeof(LOGFONTA)); strcpy(lf.lfFaceName,"Arial"); @@ -2224,7 +2240,8 @@ static void test_fontsize(void) trace("EDIT: Oversized font (Multi line)\n"); hwEdit= CreateWindow("EDIT", NULL, ES_MULTILINE|ES_AUTOHSCROLL, - 0, 0, 150, 50, NULL, NULL, hinst, NULL); + 0, 0, (150 * dpi) / 96, (50 * dpi) / 96, NULL, NULL, + hinst, NULL); SendMessage(hwEdit,WM_SETFONT,(WPARAM)hfont,0); @@ -2435,10 +2452,14 @@ static void test_dialogmode(void) START_TEST(edit) { + BOOL b; + init_function_pointers(); hinst = GetModuleHandleA(NULL); - assert(RegisterWindowClasses()); + b = RegisterWindowClasses(); + ok (b, "RegisterWindowClasses failed\n"); + if (!b) return; test_edit_control_1(); test_edit_control_2(); diff --git a/rostests/winetests/user32/generated.c b/rostests/winetests/user32/generated.c index e7c08cf9143..c8e8b5542be 100644 --- a/rostests/winetests/user32/generated.c +++ b/rostests/winetests/user32/generated.c @@ -5,9 +5,9 @@ * Unit tests for data structure packing */ -#define WINVER 0x0501 -#define _WIN32_IE 0x0501 -#define _WIN32_WINNT 0x0501 +//#define WINVER 0x0501 +//#define _WIN32_IE 0x0501 +//#define _WIN32_WINNT 0x0501 #define WINE_NOWINSOCK diff --git a/rostests/winetests/user32/input.c b/rostests/winetests/user32/input.c index d81240cb384..60904afa24d 100755 --- a/rostests/winetests/user32/input.c +++ b/rostests/winetests/user32/input.c @@ -43,10 +43,9 @@ * if it is a problem. * */ -#undef _WIN32_WINNT -#undef _WIN32_IE -#define _WIN32_IE 0x0500 -#define _WIN32_WINNT 0x500 + +//#define _WIN32_WINNT 0x401 +//#define _WIN32_IE 0x0500 #include #include @@ -234,14 +233,15 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] ) ADDTOINPUTS(td[i]) strcat(buf, getdesc[td[i]]); if(td[i]) - expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam)); /* see queue_kbd_event() */ + expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam)); else expmsg[i].message = 0; } for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++) ; - assert( evtctr <= MAXKEYEVENTS ); - assert( evtctr == pSendInput(evtctr, &inputs[0], sizeof(INPUT))); + ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" ); + if( evtctr != pSendInput(evtctr, &inputs[0], sizeof(INPUT))) + ok (FALSE, "SendInput failed to send some events\n"); i = 0; if (winetest_debug > 1) trace("======== key stroke sequence #%d: %s =============\n", @@ -369,6 +369,16 @@ static void test_Input_whitebox(void) DestroyWindow(hWndTest); } +static inline BOOL is_keyboard_message( UINT message ) +{ + return (message >= WM_KEYFIRST && message <= WM_KEYLAST); +} + +static inline BOOL is_mouse_message( UINT message ) +{ + return (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST); +} + /* try to make sure pending X events have been processed before continuing */ static void empty_message_queue(void) { @@ -382,6 +392,9 @@ static void empty_message_queue(void) if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break; while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { + if (is_keyboard_message(msg.message) || is_mouse_message(msg.message)) + ok(msg.time != 0, "message %#x has time set to 0\n", msg.message); + TranslateMessage(&msg); DispatchMessage(&msg); } @@ -415,7 +428,7 @@ struct message { LPARAM lParam; /* expected value of lParam */ }; -struct sendinput_test_s { +static const struct sendinput_test_s { WORD wVk; DWORD dwFlags; BOOL _todo_wine; @@ -675,10 +688,10 @@ static struct message sent_messages[MAXKEYMESSAGES]; static UINT sent_messages_cnt; /* Verify that only specified key state transitions occur */ -static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, struct sendinput_test_s *test) +static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test) { int i, failcount = 0; - struct transition_s *t = test->expected_transitions; + const struct transition_s *t = test->expected_transitions; UINT actual_cnt = 0; const struct message *expected = test->expected_messages; @@ -1140,6 +1153,8 @@ static void test_Input_unicode(void) WNDCLASSW wclass; HANDLE hInstance = GetModuleHandleW(NULL); HHOOK hook; + HMODULE hModuleImm32; + BOOL (WINAPI *pImmDisableIME)(DWORD); wclass.lpszClassName = classNameW; wclass.style = CS_HREDRAW | CS_VREDRAW; @@ -1155,6 +1170,16 @@ static void test_Input_unicode(void) win_skip("Unicode functions not supported\n"); return; } + + hModuleImm32 = LoadLibrary("imm32.dll"); + if (hModuleImm32) { + pImmDisableIME = (void *)GetProcAddress(hModuleImm32, "ImmDisableIME"); + if (pImmDisableIME) + pImmDisableIME(0); + } + pImmDisableIME = NULL; + FreeLibrary(hModuleImm32); + /* create the test window that will receive the keystrokes */ hWndTest = CreateWindowW(wclass.lpszClassName, windowNameW, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100, diff --git a/rostests/winetests/user32/listbox.c b/rostests/winetests/user32/listbox.c index 06c41d41531..1d6e8a34ed8 100644 --- a/rostests/winetests/user32/listbox.c +++ b/rostests/winetests/user32/listbox.c @@ -291,7 +291,7 @@ static void test_ownerdraw(void) cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "main_window_class"; - assert(RegisterClass(&cls)); + ok (RegisterClass(&cls), "RegisterClass failed\n"); parent = CreateWindowEx(0, "main_window_class", NULL, WS_POPUP | WS_VISIBLE, @@ -840,7 +840,6 @@ static void test_listbox_LB_DIR(void) memset(pathBuffer, 0, MAX_PATH); driveletter = '\0'; SendMessage(hList, LB_GETTEXT, i, (LPARAM)pathBuffer); - p = pathBuffer + strlen(pathBuffer); if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) { ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter); } @@ -951,7 +950,6 @@ static void test_listbox_LB_DIR(void) memset(pathBuffer, 0, MAX_PATH); driveletter = '\0'; SendMessage(hList, LB_GETTEXT, i, (LPARAM)pathBuffer); - p = pathBuffer + strlen(pathBuffer); if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) { ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter); } else { @@ -987,7 +985,6 @@ static void test_listbox_LB_DIR(void) memset(pathBuffer, 0, MAX_PATH); driveletter = '\0'; SendMessage(hList, LB_GETTEXT, i, (LPARAM)pathBuffer); - p = pathBuffer + strlen(pathBuffer); ok (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1, "Element %d (%s) does not fit [-X-]\n", i, pathBuffer); ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter); } @@ -996,8 +993,8 @@ static void test_listbox_LB_DIR(void) DeleteFileA( "wtest1.tmp.c" ); } -HWND g_listBox; -HWND g_label; +static HWND g_listBox; +static HWND g_label; #define ID_TEST_LABEL 1001 #define ID_TEST_LISTBOX 1002 @@ -1181,7 +1178,6 @@ static void test_listbox_dlgdir(void) for (i = 0; i < itemCount; i++) { memset(pathBuffer, 0, MAX_PATH); SendMessage(g_listBox, LB_GETTEXT, i, (LPARAM)pathBuffer); - p = pathBuffer + strlen(pathBuffer); ok( pathBuffer[0] == '[' && pathBuffer[strlen(pathBuffer)-1] == ']', "Element %d (%s) does not fit requested [...]\n", i, pathBuffer); } @@ -1321,7 +1317,6 @@ static void test_listbox_dlgdir(void) memset(pathBuffer, 0, MAX_PATH); driveletter = '\0'; SendMessage(g_listBox, LB_GETTEXT, i, (LPARAM)pathBuffer); - p = pathBuffer + strlen(pathBuffer); if (sscanf(pathBuffer, "[-%c-]", &driveletter) == 1) { ok( driveletter >= 'a' && driveletter <= 'z', "Drive letter not in range a..z, got ascii %d\n", driveletter); } else { diff --git a/rostests/winetests/user32/menu.c b/rostests/winetests/user32/menu.c index deecbe8dd03..2d308c48178 100755 --- a/rostests/winetests/user32/menu.c +++ b/rostests/winetests/user32/menu.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#define _WIN32_WINNT 0x0501 +//#define _WIN32_WINNT 0x0501 #include #include @@ -169,6 +169,8 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, if( winetest_debug) trace("WM_MEASUREITEM received data %lx size %dx%d\n", pmis->itemData, pmis->itemWidth, pmis->itemHeight); + ok( !wparam, "wrong wparam %lx\n", wparam ); + ok( pmis->CtlType == ODT_MENU, "wrong type %x\n", pmis->CtlType ); MOD_odheight = pmis->itemHeight; pmis->itemWidth = MODsizes[pmis->itemData].cx; pmis->itemHeight = MODsizes[pmis->itemData].cy; @@ -197,6 +199,8 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, pdis->rcItem.right,pdis->rcItem.bottom ); SelectObject( pdis->hDC, oldpen); } + ok( !wparam, "wrong wparam %lx\n", wparam ); + ok( pdis->CtlType == ODT_MENU, "wrong type %x\n", pdis->CtlType ); /* calculate widths of some menu texts */ if( ! MOD_txtsizes[0].size.cx) for(i = 0; MOD_txtsizes[i].text; i++) { @@ -217,7 +221,7 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, } if( pdis->itemData > MOD_maxid) return TRUE; - /* store the rectangl */ + /* store the rectangle */ MOD_rc[pdis->itemData] = pdis->rcItem; /* calculate average character width */ GetTextExtentPoint( pdis->hDC, chrs, 52, &sz ); @@ -404,6 +408,7 @@ static void test_menu_ownerdraw(void) int i,j,k; BOOL ret; HMENU hmenu; + MENUITEMINFO mii; LONG leftcol; HWND hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, @@ -425,7 +430,7 @@ static void test_menu_ownerdraw(void) MOD_maxid = k-1; assert( k <= sizeof(MOD_rc)/sizeof(RECT)); /* display the menu */ - ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); + TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); /* columns have a 4 pixel gap between them */ ok( MOD_rc[0].right + 4 == MOD_rc[2].left, @@ -449,7 +454,7 @@ static void test_menu_ownerdraw(void) leftcol= MOD_rc[0].left; ModifyMenu( hmenu, 0, MF_BYCOMMAND| MF_OWNERDRAW| MF_SEPARATOR, 0, 0); /* display the menu */ - ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); + TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); /* left should be 4 pixels less now */ ok( leftcol == MOD_rc[0].left + 4, "columns should be 4 pixels to the left (actual %d).\n", @@ -463,6 +468,18 @@ static void test_menu_ownerdraw(void) "Height is incorrect. Got %d expected %d\n", MOD_rc[0].bottom - MOD_rc[0].top, MOD_SIZE); + /* test owner-drawn callback bitmap */ + ModifyMenu( hmenu, 1, MF_BYPOSITION | MFT_BITMAP, 1, (LPCSTR)HBMMENU_CALLBACK ); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_BITMAP | MIIM_FTYPE | MIIM_ID; + if (GetMenuItemInfoA( hmenu, 1, TRUE, &mii )) + { + ok( mii.fType == MFT_BITMAP, "wrong type %x\n", mii.fType ); + ok( mii.wID == 1, "wrong id %x\n", mii.wID ); + ok( mii.hbmpItem == HBMMENU_CALLBACK, "wrong data %p\n", mii.hbmpItem ); + } + TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); + /* test width/height of an ownerdraw menu bar as well */ ret = DestroyMenu(hmenu); ok(ret, "DestroyMenu failed with error %d\n", GetLastError()); @@ -562,13 +579,15 @@ static void test_mbs_help( int ispop, int hassub, int mnuopt, ReleaseDC( hwnd, hdc); } if(ispop) - ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); + TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); else { ret = SetMenu( hwnd, hmenu); ok(ret, "SetMenu failed with error %d\n", GetLastError()); DrawMenuBar( hwnd); } ret = GetMenuItemRect( hwnd, hmenu, 0, &rc); + ok(ret, "GetMenuItemRect failed with error %d\n", GetLastError()); + if (0) /* comment out menu size checks, behavior is different in almost every Windows version */ /* the tests should however succeed on win2000, XP and Wine (at least up to 1.1.15) */ /* with a variety of dpis and desktop font sizes */ @@ -660,6 +679,7 @@ static void test_menu_bmp_and_string(void) MENUINFO mi= {sizeof(MENUINFO)}; MENUITEMINFOA mii= {sizeof(MENUITEMINFOA)}; int count, szidx, txtidx, bmpidx, hassub, mnuopt, ispop; + BOOL got; if( !pGetMenuInfo) { @@ -681,12 +701,14 @@ static void test_menu_bmp_and_string(void) ok( hsysmenu != NULL, "GetSystemMenu failed with error %d\n", GetLastError()); mi.fMask = MIM_STYLE; mi.dwStyle = 0; - ok( pGetMenuInfo( hsysmenu, &mi), "GetMenuInfo failed gle=%d\n", GetLastError()); + got = pGetMenuInfo( hsysmenu, &mi); + ok( got, "GetMenuInfo failed gle=%d\n", GetLastError()); ok( MNS_CHECKORBMP == mi.dwStyle, "System Menu Style is %08x, without the bit %08x\n", mi.dwStyle, MNS_CHECKORBMP); mii.fMask = MIIM_BITMAP; mii.hbmpItem = NULL; - ok( GetMenuItemInfoA( hsysmenu, SC_CLOSE, FALSE, &mii), "GetMenuItemInfoA failed gle=%d\n", GetLastError()); + got = GetMenuItemInfoA( hsysmenu, SC_CLOSE, FALSE, &mii); + ok( got, "GetMenuItemInfoA failed gle=%d\n", GetLastError()); ok( HBMMENU_POPUP_CLOSE == mii.hbmpItem, "Item info did not get the right hbitmap: got %p expected %p\n", mii.hbmpItem, HBMMENU_POPUP_CLOSE); @@ -954,7 +976,9 @@ static void check_menu_item_info( int line, HMENU hmenu, BOOL ansi, UINT mask, U "wrong bmpitem %p/%p\n", info.hbmpItem, item ); ok_(__FILE__, line)( info.dwTypeData == type_data || (ULONG_PTR)info.dwTypeData == LOWORD(type_data), "wrong type data %p/%p\n", info.dwTypeData, type_data ); - ok_(__FILE__, line)( info.cch == out_len, "wrong len %x/%x\n", info.cch, out_len ); + ok_(__FILE__, line)( info.cch == out_len || + broken(! ansi && info.cch == 2 * out_len) /* East-Asian */, + "wrong len %x/%x\n", info.cch, out_len ); if (expname) { if(ansi) @@ -1058,7 +1082,7 @@ static void test_menu_iteminfo( void ) void *txt, *init, *empty, *string; HBITMAP hbm = CreateBitmap(1,1,1,1,NULL); char stringA[0x80]; - HMENU hmenu, submenu=CreateMenu(); + HMENU hmenu, submenu; HBITMAP dummy_hbm = (HBITMAP)(ULONG_PTR)0xdeadbeef; do { @@ -2031,6 +2055,7 @@ static void test_menu_input(void) { HINSTANCE hInstance = GetModuleHandleA( NULL ); HANDLE hThread, hWnd; DWORD tid; + ATOM aclass; if (!pSendInput) { @@ -2048,11 +2073,14 @@ static void test_menu_input(void) { wclass.lpszMenuName = 0; wclass.cbClsExtra = 0; wclass.cbWndExtra = 0; - assert (RegisterClassA( &wclass )); - assert (hWnd = CreateWindowA( wclass.lpszClassName, "MenuTest", - WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, - 400, 200, NULL, NULL, hInstance, NULL) ); - + aclass = RegisterClassA( &wclass ); + ok (aclass, "MenuTest class not created\n"); + if (!aclass) return; + hWnd = CreateWindowA( wclass.lpszClassName, "MenuTest", + WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, + 400, 200, NULL, NULL, hInstance, NULL); + ok (hWnd != NULL, "MenuTest window not created\n"); + if (!hWnd) return; /* fixed menus */ hMenus[3] = CreatePopupMenu(); AppendMenu(hMenus[3], MF_STRING, 0, "&Enabled"); @@ -2118,6 +2146,7 @@ static void test_menu_hilitemenuitem( void ) HMENU hMenu, hPopupMenu; WNDCLASSA wclass; HWND hWnd; + ATOM aclass; wclass.lpszClassName = "HiliteMenuTestClass"; wclass.style = CS_HREDRAW | CS_VREDRAW; @@ -2129,10 +2158,14 @@ static void test_menu_hilitemenuitem( void ) wclass.lpszMenuName = 0; wclass.cbClsExtra = 0; wclass.cbWndExtra = 0; - assert (RegisterClassA( &wclass )); - assert (hWnd = CreateWindowA( wclass.lpszClassName, "HiliteMenuTest", - WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, - 400, 200, NULL, NULL, wclass.hInstance, NULL) ); + aclass = RegisterClassA( &wclass ); + ok (aclass, "HiliteMenuTest class could not be created\n"); + if (!aclass) return; + hWnd = CreateWindowA( wclass.lpszClassName, "HiliteMenuTest", + WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, + 400, 200, NULL, NULL, wclass.hInstance, NULL); + ok (hWnd != NULL, "HiliteMenuTest window could not be created\n"); + if (!hWnd) return; hMenu = CreateMenu(); hPopupMenu = CreatePopupMenu(); @@ -2884,7 +2917,8 @@ static void test_menu_trackpopupmenu(void) } /* display the menu */ /* start with an invalid menu handle */ - gle = 0xdeadbeef; + SetLastError(0xdeadbeef); + gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = 0; ret = MyTrackPopupMenu( Ex, NULL, TPM_RETURNCMD, 100,100, hwnd, NULL); gle = GetLastError(); @@ -2900,7 +2934,7 @@ static void test_menu_trackpopupmenu(void) gflag_entermenuloop ? "WM_INITMENULOOP ": "", gflag_initmenu ? "WM_INITMENU": ""); /* another one but not NULL */ - gle = 0xdeadbeef; + SetLastError(0xdeadbeef); gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = 0; ret = MyTrackPopupMenu( Ex, (HMENU)hwnd, TPM_RETURNCMD, 100,100, hwnd, NULL); gle = GetLastError(); @@ -2915,8 +2949,22 @@ static void test_menu_trackpopupmenu(void) gflag_initmenupopup ? " WM_INITMENUPOPUP ": " ", gflag_entermenuloop ? "WM_INITMENULOOP ": "", gflag_initmenu ? "WM_INITMENU": ""); + + /* invalid window */ + SetLastError(0xdeadbeef); + gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = 0; + ret = MyTrackPopupMenu( Ex, hmenu, TPM_RETURNCMD, 100,100, 0, NULL); + gle = GetLastError(); + ok( !ret, "TrackPopupMenu%s should have failed\n", Ex ? "Ex" : ""); + ok( gle == ERROR_INVALID_WINDOW_HANDLE, "TrackPopupMenu%s error got %u\n", Ex ? "Ex" : "", gle ); + ok( !(gflag_initmenupopup || gflag_entermenuloop || gflag_initmenu), + "got unexpected message(s)%s%s%s\n", + gflag_initmenupopup ? " WM_INITMENUPOPUP ": " ", + gflag_entermenuloop ? "WM_INITMENULOOP ": "", + gflag_initmenu ? "WM_INITMENU": ""); + /* now a somewhat successful call */ - gle = 0xdeadbeef; + SetLastError(0xdeadbeef); gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = 0; ret = MyTrackPopupMenu( Ex, hmenu, TPM_RETURNCMD, 100,100, hwnd, NULL); gle = GetLastError(); @@ -2934,7 +2982,7 @@ static void test_menu_trackpopupmenu(void) /* and another */ ret = AppendMenuA( hmenu, MF_STRING, 1, "winetest"); ok( ret, "AppendMenA has failed!\n"); - gle = 0xdeadbeef; + SetLastError(0xdeadbeef); gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = 0; ret = MyTrackPopupMenu( Ex, hmenu, TPM_RETURNCMD, 100,100, hwnd, NULL); gle = GetLastError(); @@ -3055,21 +3103,21 @@ static void test_menu_cancelmode(void) {MSG msg; while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);} /* test the effect of sending a WM_CANCELMODE message in the WM_INITMENULOOP * handler of the menu owner */ - /* test results is exctracted from variable g_got_enteridle. Possible values: + /* test results is extracted from variable g_got_enteridle. Possible values: * 0 : complete conformance. Sending WM_CANCELMODE cancels a menu initializing tracking * 1 : Sending WM_CANCELMODE cancels a menu that is in tracking state * 2 : Sending WM_CANCELMODE does not work */ /* menu owner is top level window */ g_hwndtosend = hwnd; - ret = TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); + TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); todo_wine { ok( g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); } ok( g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); /* menu owner is child window */ g_hwndtosend = hwndchild; - ret = TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); + TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); todo_wine { ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); } @@ -3077,7 +3125,7 @@ static void test_menu_cancelmode(void) /* now send the WM_CANCELMODE messages to the WRONG window */ /* those should fail ( to have any effect) */ g_hwndtosend = hwnd; - ret = TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); + TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); ok( g_got_enteridle == 2, "received %d WM_ENTERIDLE messages, should be 2\n", g_got_enteridle); /* cleanup */ DestroyMenu( menu); @@ -3177,6 +3225,7 @@ static void test_menualign(void) if( pGetMenuInfo) { mi.fMask = MIM_STYLE; ret = pGetMenuInfo( menu, &mi); + ok( ret, "GetMenuInfo failed: %d\n", GetLastError()); ok( menu != NULL, "GetMenuInfo() failed\n"); ok( 0 == mi.dwStyle, "menuinfo style is %x\n", mi.dwStyle); } diff --git a/rostests/winetests/user32/monitor.c b/rostests/winetests/user32/monitor.c index daa303585bd..e31019f6708 100644 --- a/rostests/winetests/user32/monitor.c +++ b/rostests/winetests/user32/monitor.c @@ -267,6 +267,14 @@ static void test_ChangeDisplaySettingsEx(void) ok(ClipCursor(&r1), "ClipCursor() failed\n"); ok(GetClipCursor(&r), "GetClipCursor() failed\n"); ok(EqualRect(&r, &r1), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom); + SetRect(&r1, 10, 10, 10, 10); + ok(ClipCursor(&r1), "ClipCursor() failed\n"); + ok(GetClipCursor(&r), "GetClipCursor() failed\n"); + ok(EqualRect(&r, &r1), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom); + SetRect(&r1, 10, 10, 10, 9); + ok(!ClipCursor(&r1), "ClipCursor() succeeded\n"); + /* Windows bug: further clipping fails once an empty rect is set, so we have to reset it */ + ClipCursor(NULL); SetRect(&r1, virt.left - 10, virt.top - 10, virt.right + 20, virt.bottom + 20); ok(ClipCursor(&r1), "ClipCursor() failed\n"); diff --git a/rostests/winetests/user32/resource.c b/rostests/winetests/user32/resource.c index c64aff0a60e..5bc2d7a34d0 100755 --- a/rostests/winetests/user32/resource.c +++ b/rostests/winetests/user32/resource.c @@ -180,12 +180,10 @@ static void test_accel1(void) ok( hAccel != NULL, "create accelerator table\n"); r = CopyAcceleratorTable( hAccel, NULL, 0 ); - ok( r == n || broken(r == 2), /* win9x */ - "two entries in table %u/%u\n", r, n); + ok( r == n, "two entries in table %u/%u\n", r, n); r = CopyAcceleratorTable( hAccel, &ac[0], n ); - ok( r == n || broken(r == 2), /* win9x */ - "still should be two entries in table %u/%u\n", r, n); + ok( r == n, "still should be two entries in table %u/%u\n", r, n); n=0; ok( ac[n].cmd == 1000, "cmd 0 not preserved got %x\n", ac[n].cmd); @@ -262,11 +260,11 @@ static void test_accel2(void) hac = CreateAcceleratorTable( &ac[0], 2); ok( hac != NULL , "fail\n"); res = CopyAcceleratorTable( hac, NULL, 100 ); - ok( res == 2 || broken(res == 0), /* win9x */ "copy null failed %d\n", res); + ok( res == 2, "copy null failed %d\n", res); res = CopyAcceleratorTable( hac, NULL, 0 ); ok( res == 2, "copy null failed %d\n", res); res = CopyAcceleratorTable( hac, NULL, 1 ); - ok( res == 2 || broken(res == 0), /* win9x */ "copy null failed %d\n", res); + ok( res == 2, "copy null failed %d\n", res); ok( 1 == CopyAcceleratorTable( hac, out, 1 ), "copy 1 failed\n"); ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n"); ok( DestroyAcceleratorTable( hac ), "destroy failed\n"); @@ -318,7 +316,7 @@ static void test_accel2(void) hac = CreateAcceleratorTable( &ac[0], 2); ok( hac != NULL , "fail\n"); res = CopyAcceleratorTable( hac, out, 2 ); - ok( res == 2 || broken(res == 1), /* win9x */ "copy 2 failed %d\n", res); + ok( res == 2, "copy 2 failed %d\n", res); /* ok( memcmp( ac, out, sizeof ac ), "tables not different\n"); */ ok( out[0].cmd == ac[0].cmd, "cmd modified\n"); ok( out[0].fVirt == (ac[0].fVirt&0x7f), "fVirt not modified\n"); diff --git a/rostests/winetests/user32/scroll.c b/rostests/winetests/user32/scroll.c index e3f6938129c..e4bfdb15de5 100644 --- a/rostests/winetests/user32/scroll.c +++ b/rostests/winetests/user32/scroll.c @@ -259,7 +259,7 @@ todo_wine "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* test GetScrollInfo, vist for vertical SB */ ret = GetScrollInfo( hwnd, SB_VERT, &si); - /* should fail if no H orV scroll bar styles are present. Succeed otherwise */ + /* should fail if no H or V scroll bar styles are present. Succeed otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); else @@ -269,7 +269,7 @@ todo_wine "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* Same for Horizontal SB */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); - /* should fail if no H orV scroll bar styles are present. Succeed otherwise */ + /* should fail if no H or V scroll bar styles are present. Succeed otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); else @@ -316,7 +316,7 @@ todo_wine hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style, 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); - /* Set Horizonta Scroll range to something that could be the default value it + /* Set Horizontal Scroll range to something that could be the default value it * already has */; ret = SetScrollRange( hwnd, SB_HORZ, 0, 100, FALSE); ok( ret, "SetScrollRange failed.\n"); diff --git a/rostests/winetests/user32/static.c b/rostests/winetests/user32/static.c index d04f725138a..b7613563104 100644 --- a/rostests/winetests/user32/static.c +++ b/rostests/winetests/user32/static.c @@ -95,9 +95,7 @@ static void test_updates(int style, int flags) if (flags & TODO_COUNT) todo_wine { expect_eq(g_nReceivedColorStatic, exp, int, "%d"); } else if ((style & SS_TYPEMASK) == SS_ICON || (style & SS_TYPEMASK) == SS_BITMAP) - ok( g_nReceivedColorStatic == exp || - broken(g_nReceivedColorStatic == 0), /* win9x */ - "expected %u got %u\n", exp, g_nReceivedColorStatic ); + ok( g_nReceivedColorStatic == exp, "expected %u got %u\n", exp, g_nReceivedColorStatic ); else expect_eq(g_nReceivedColorStatic, exp, int, "%d"); DestroyWindow(hStatic); diff --git a/rostests/winetests/user32/sysparams.c b/rostests/winetests/user32/sysparams.c index ba1c8026a89..1de3da0300f 100755 --- a/rostests/winetests/user32/sysparams.c +++ b/rostests/winetests/user32/sysparams.c @@ -24,7 +24,7 @@ #undef _WIN32_WINNT #define _WIN32_WINNT 0x0600 /* For SPI_GETMOUSEHOVERWIDTH and more */ -#define _WIN32_IE 0x0700 +//#define _WIN32_IE 0x0700 #include "wine/test.h" #include "windef.h" @@ -2463,7 +2463,7 @@ static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam ) * not all metrics are properly restored. Problems are * SM_CXMAXTRACK, SM_CYMAXTRACK * Fortunately setting the Non-Client metrics like in - * test_SPI_SETNONCLIENTMETRICS will corect this. That is why + * test_SPI_SETNONCLIENTMETRICS will correct this. That is why * we do the DISPLAY change now... */ test_WM_DISPLAYCHANGE(); test_SPI_SETNONCLIENTMETRICS(); /* 42 */ diff --git a/rostests/winetests/user32/text.c b/rostests/winetests/user32/text.c index 88ea6b566c0..1874b1572e0 100755 --- a/rostests/winetests/user32/text.c +++ b/rostests/winetests/user32/text.c @@ -114,13 +114,7 @@ static void test_DrawTextCalcRect(void) heightcheck = textheight = DrawTextExA(hdc, text, 0, &rect, DT_CALCRECT, NULL ); ok( !EMPTY(rect) && !MODIFIED(rect), "rectangle should NOT be empty got %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom ); - if (textheight != 0) /* Windows 98 */ - { - win_skip("XP conformity failed, skipping XP tests. Probably win9x\n"); - conform_xp = FALSE; - } - else - ok(textheight==0,"Got textheight from DrawTextExA\n"); + ok(textheight==0,"Got textheight from DrawTextExA\n"); SetRect( &rect, 10,10, 100, 100); textheight = DrawTextA(hdc, text, 0, &rect, DT_CALCRECT); @@ -617,6 +611,9 @@ static void test_TabbedText(void) ret = GetTextMetricsA( hdc, &tm); ok( ret, "GetTextMetrics error %u\n", GetLastError()); + extent = GetTabbedTextExtentA( hdc, "x", 0, 1, tabs); + ok( extent == 0, "GetTabbedTextExtentA returned non-zero on nCount == 0\n"); + extent = GetTabbedTextExtentA( hdc, "x", 1, 1, tabs); cx = LOWORD( extent); cy = HIWORD( extent); diff --git a/rostests/winetests/user32/wsprintf.c b/rostests/winetests/user32/wsprintf.c index bca16bd9f86..5370df4636a 100755 --- a/rostests/winetests/user32/wsprintf.c +++ b/rostests/winetests/user32/wsprintf.c @@ -23,39 +23,93 @@ #include "windef.h" #include "winbase.h" #include "winuser.h" +#include "winnls.h" + +static const struct +{ + const char *fmt; + ULONGLONG value; + const char *res; +} i64_formats[] = +{ + { "%I64X", ((ULONGLONG)0x12345 << 32) | 0x67890a, "123450067890A" }, + { "%I32X", ((ULONGLONG)0x12345 << 32) | 0x67890a, "67890A" }, + { "%I64d", (ULONGLONG)543210 * 1000000, "543210000000" }, + { "%I64X", (LONGLONG)-0x12345, "FFFFFFFFFFFEDCBB" }, + { "%I32x", (LONGLONG)-0x12345, "fffedcbb" }, + { "%I64u", (LONGLONG)-123, "18446744073709551493" }, + { "%Id", (LONGLONG)-12345, "-12345" }, +#ifdef _WIN64 + { "%Ix", ((ULONGLONG)0x12345 << 32) | 0x67890a, "123450067890a" }, + { "%Ix", (LONGLONG)-0x12345, "fffffffffffedcbb" }, + { "%p", (LONGLONG)-0x12345, "FFFFFFFFFFFEDCBB" }, +#else + { "%Ix", ((ULONGLONG)0x12345 << 32) | 0x67890a, "67890a" }, + { "%Ix", (LONGLONG)-0x12345, "fffedcbb" }, + { "%p", (LONGLONG)-0x12345, "FFFEDCBB" }, +#endif +}; static void wsprintfATest(void) { char buf[25]; + unsigned int i; int rc; rc=wsprintfA(buf, "%010ld", -1); - ok(rc == 10, "wsPrintfA length failure: rc=%d error=%d\n",rc,GetLastError()); + ok(rc == 10, "wsprintfA length failure: rc=%d error=%d\n",rc,GetLastError()); ok((lstrcmpA(buf, "-000000001") == 0), "wsprintfA zero padded negative value failure: buf=[%s]\n",buf); + rc = wsprintfA(buf, "%I64X", (ULONGLONG)0); + if (rc == 4 && !lstrcmpA(buf, "I64X")) + { + win_skip( "I64 formats not supported\n" ); + return; + } + for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++) + { + rc = wsprintfA(buf, i64_formats[i].fmt, i64_formats[i].value); + ok(rc == strlen(i64_formats[i].res), "%u: wsprintfA length failure: rc=%d\n", i, rc); + ok(!strcmp(buf, i64_formats[i].res), "%u: wrong result [%s]\n", i, buf); + } } static void wsprintfWTest(void) { - static const WCHAR fmt[] = {'%','0','1','0','l','d','\0'}; - static const WCHAR target[] = {'-','0','0','0','0','0','0','0','0','1', '\0'}; - WCHAR buf[25]; + static const WCHAR fmt_010ld[] = {'%','0','1','0','l','d','\0'}; + static const WCHAR res_010ld[] = {'-','0','0','0','0','0','0','0','0','1', '\0'}; + static const WCHAR fmt_I64x[] = {'%','I','6','4','x',0}; + WCHAR buf[25], fmt[25], res[25]; + unsigned int i; int rc; - rc=wsprintfW(buf, fmt, -1); + rc=wsprintfW(buf, fmt_010ld, -1); if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) { win_skip("wsprintfW is not implemented\n"); return; } ok(rc == 10, "wsPrintfW length failure: rc=%d error=%d\n",rc,GetLastError()); - ok((lstrcmpW(buf, target) == 0), + ok((lstrcmpW(buf, res_010ld) == 0), "wsprintfW zero padded negative value failure\n"); + rc = wsprintfW(buf, fmt_I64x, (ULONGLONG)0 ); + if (rc == 4 && !lstrcmpW(buf, fmt_I64x + 1)) + { + win_skip( "I64 formats not supported\n" ); + return; + } + for (i = 0; i < sizeof(i64_formats)/sizeof(i64_formats[0]); i++) + { + MultiByteToWideChar( CP_ACP, 0, i64_formats[i].fmt, -1, fmt, sizeof(fmt)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, i64_formats[i].res, -1, res, sizeof(res)/sizeof(WCHAR) ); + rc = wsprintfW(buf, fmt, i64_formats[i].value); + ok(rc == lstrlenW(res), "%u: wsprintfW length failure: rc=%d\n", i, rc); + ok(!lstrcmpW(buf, res), "%u: wrong result [%s]\n", i, wine_dbgstr_w(buf)); + } } /* Test if the CharUpper / CharLower functions return true 16 bit results, - if the input is a 16 bit input value. Up to Wine 11-2003 the input value - 0xff returns 0xffffffff. */ + if the input is a 16 bit input value. */ static void CharUpperTest(void) {