From c47d138515aed4fd2e1a029c35a283a45d3df464 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 17 Oct 2014 13:49:22 +0000 Subject: [PATCH 1/1] [USER32_WINETEST] * Sync with Wine 1.7.27. * Jim! help! CORE-8540 svn path=/trunk/; revision=64785 --- rostests/winetests/user32/cursoricon.c | 13 +- rostests/winetests/user32/menu.c | 132 +++++++++++++++- rostests/winetests/user32/monitor.c | 87 ++++++++++- rostests/winetests/user32/msg.c | 95 ++++++++++-- rostests/winetests/user32/resource.c | 7 + rostests/winetests/user32/win.c | 202 +++++++++++++++++++++---- rostests/winetests/user32/winstation.c | 2 +- 7 files changed, 488 insertions(+), 50 deletions(-) diff --git a/rostests/winetests/user32/cursoricon.c b/rostests/winetests/user32/cursoricon.c index a7c3ca47599..54d7963ecc4 100644 --- a/rostests/winetests/user32/cursoricon.c +++ b/rostests/winetests/user32/cursoricon.c @@ -955,14 +955,14 @@ static void test_CreateIcon(void) /* Shamelessly ripped from dlls/oleaut32/tests/olepicture.c */ /* 1x1 pixel gif */ -static unsigned char gifimage[35] = { +static const unsigned char gifimage[35] = { 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff, 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44, 0x01,0x00,0x3b }; /* 1x1 pixel jpg */ -static unsigned char jpgimage[285] = { +static const unsigned char jpgimage[285] = { 0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2c, 0x01,0x2c,0x00,0x00,0xff,0xdb,0x00,0x43,0x00,0x05,0x03,0x04,0x04,0x04,0x03,0x05, 0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x07,0x0c,0x08,0x07,0x07,0x07,0x07,0x0f,0x0b, @@ -984,7 +984,7 @@ static unsigned char jpgimage[285] = { }; /* 1x1 pixel png */ -static unsigned char pngimage[285] = { +static const unsigned char pngimage[285] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53, 0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b, @@ -1005,14 +1005,14 @@ static unsigned char bmpimage[70] = { }; /* 1x1 pixel bmp using BITMAPCOREHEADER */ -static unsigned char bmpcoreimage[38] = { +static const unsigned char bmpcoreimage[38] = { 0x42,0x4d,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x22,0x00,0x00,0x00,0x0c,0x00, 0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xff,0xff,0xff,0x00,0x55,0x55, 0x55,0x00,0x00,0x00,0x00,0x00 }; /* 2x2 pixel gif */ -static unsigned char gif4pixel[42] = { +static const unsigned char gif4pixel[42] = { 0x47,0x49,0x46,0x38,0x37,0x61,0x02,0x00,0x02,0x00,0xa1,0x00,0x00,0x00,0x00,0x00, 0x39,0x62,0xfc,0xff,0x1a,0xe5,0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x02,0x00, 0x02,0x00,0x00,0x02,0x03,0x14,0x16,0x05,0x00,0x3b @@ -1059,7 +1059,7 @@ static void test_LoadImageBitmap(const char * test_desc, HBITMAP hbm) ok(color_match(pixel, 0x00ffffff), "%s: Pixel is 0x%08x\n", test_desc, pixel); } -static void test_LoadImageFile(const char * test_desc, unsigned char * image_data, +static void test_LoadImageFile(const char * test_desc, const unsigned char * image_data, unsigned int image_size, const char * ext, BOOL expect_success) { HANDLE handle; @@ -1699,6 +1699,7 @@ static void test_GetCursorFrameInfo(void) ret = DestroyCursor(h1); ok(ret, "DestroyCursor() failed (error = %d).\n", GetLastError()); + HeapFree(GetProcessHeap(), 0, hotspot); cleanup: if(bmpOld) SelectObject(hdc, bmpOld); if(bmp) DeleteObject(bmp); diff --git a/rostests/winetests/user32/menu.c b/rostests/winetests/user32/menu.c index 23922053b08..b15273c7c85 100755 --- a/rostests/winetests/user32/menu.c +++ b/rostests/winetests/user32/menu.c @@ -172,7 +172,7 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, case WM_MEASUREITEM: { MEASUREITEMSTRUCT* pmis = (MEASUREITEMSTRUCT*)lparam; - if( winetest_debug) + if (winetest_debug > 1) trace("WM_MEASUREITEM received data %lx size %dx%d\n", pmis->itemData, pmis->itemWidth, pmis->itemHeight); ok( !wparam, "wrong wparam %lx\n", wparam ); @@ -191,7 +191,7 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, SIZE sz; int i; pdis = (DRAWITEMSTRUCT *) lparam; - if( winetest_debug) { + if (winetest_debug > 1) { RECT rc; GetMenuItemRect( hwnd, (HMENU)pdis->hwndItem, pdis->itemData ,&rc); trace("WM_DRAWITEM received hwnd %p hmenu %p itemdata %ld item %d rc %d,%d-%d,%d itemrc: %d,%d-%d,%d\n", @@ -1369,6 +1369,11 @@ static void test_menu_iteminfo( void ) MFT_SEPARATOR, 0, 0, 0, 0, 0, 0, string, 0, 0, empty, OK, ER ); TMII_DONE + TMII_INSMI( MIIM_STRING|MIIM_FTYPE, MFT_STRING, -1, -1, 0, 0, 0, -1, NULL, 0, 0, OK ); + TMII_GMII ( MIIM_STRING|MIIM_FTYPE, 80, + MFT_SEPARATOR, 0, 0, 0, 0, 0, 0, NULL, 0, 0, + NULL, OK, ER ); + TMII_DONE /* How is that with bitmaps? */ TMII_INSMI( MIIM_BITMAP, -1, -1, -1, 0, 0, 0, -1, 0, -1, hbm, OK ); @@ -2510,6 +2515,11 @@ if (0) if (mii.hSubMenu) { ok(mii.wID == (UINT_PTR)mii.hSubMenu, "id %u: wID should be equal to hSubMenu\n", checked_cmd); + if (!GetMenuItemCount(mii.hSubMenu)) + { + ok(mii.fType == checked_type, "id %u: expected fType %04x, got %04x\n", checked_cmd, checked_type, mii.fType); + ok(mii.fState == checked_state, "id %u: expected fState %04x, got %04x\n", checked_cmd, checked_state, mii.fState); + } check_menu_items(mii.hSubMenu, checked_cmd, checked_type, checked_state); } else @@ -3618,6 +3628,123 @@ static void test_emptypopup(void) ok(ret, "DestroyMenu failed with error %d\n", GetLastError()); } +static void test_AppendMenu(void) +{ + MENUITEMINFOA mii; + HMENU hmenu, hsubmenu; + BOOL ret; + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + ret = AppendMenuA(hmenu, MF_OWNERDRAW, 201, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, 201, MF_OWNERDRAW, 0); + DestroyMenu(hmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + ret = AppendMenuA(hmenu, MF_POPUP, 202, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, 202, MF_STRING, 0); + DestroyMenu(hmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, 203, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, 203, MF_OWNERDRAW, 0); + DestroyMenu(hmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + hsubmenu = CreateMenu(); + ok(hsubmenu != 0, "CreateMenu failed\n"); + ret = AppendMenuA(hmenu, MF_OWNERDRAW, (UINT_PTR)hsubmenu, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0); + DestroyMenu(hmenu); + DestroyMenu(hsubmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + hsubmenu = CreateMenu(); + ok(hsubmenu != 0, "CreateMenu failed\n"); + ret = AppendMenuA(hmenu, MF_POPUP, (UINT_PTR)hsubmenu, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0); + DestroyMenu(hmenu); + DestroyMenu(hsubmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + hsubmenu = CreateMenu(); + ok(hsubmenu != 0, "CreateMenu failed\n"); + ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, (UINT_PTR)hsubmenu, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0); + DestroyMenu(hmenu); + DestroyMenu(hsubmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + hsubmenu = CreatePopupMenu(); + ok(hsubmenu != 0, "CreatePopupMenu failed\n"); + ret = AppendMenuA(hmenu, MF_OWNERDRAW, (UINT_PTR)hsubmenu, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0); + DestroyMenu(hmenu); + DestroyMenu(hsubmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + hsubmenu = CreatePopupMenu(); + ok(hsubmenu != 0, "CreatePopupMenu failed\n"); + ret = AppendMenuA(hmenu, MF_POPUP, (UINT_PTR)hsubmenu, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_STRING, 0); + DestroyMenu(hmenu); + DestroyMenu(hsubmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + hsubmenu = CreatePopupMenu(); + ok(hsubmenu != 0, "CreatePopupMenu failed\n"); + ret = AppendMenuA(hmenu, MF_OWNERDRAW | MF_POPUP, (UINT_PTR)hsubmenu, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, (UINT_PTR)hsubmenu, MF_OWNERDRAW, 0); + DestroyMenu(hmenu); + DestroyMenu(hsubmenu); + + hmenu = CreateMenu(); + ok(hmenu != 0, "CreateMenu failed\n"); + ret = AppendMenuA(hmenu, MF_STRING, 204, "item 1"); + ok(ret, "AppendMenu failed\n"); + check_menu_items(hmenu, 204, MF_STRING, 0); + ret = ModifyMenuA(hmenu, 0, MF_POPUP | MF_BYPOSITION, 205, "item 2"); + ok(ret, "ModifyMenu failed\n"); + check_menu_items(hmenu, 205, MF_STRING, 0); + memset(&mii, 0, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_SUBMENU; + mii.hSubMenu = (HMENU)204; + ret = InsertMenuItemA(hmenu, 0, TRUE, &mii); + ok(!ret, "InsertMenuItem should fail\n"); + ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii); + ok(!ret, "SetMenuItemInfo should fail\n"); + mii.fMask = MIIM_ID; + mii.wID = 206; + ret = InsertMenuItemA(hmenu, 0, TRUE, &mii); + ok(ret, "InsertMenuItem failed\n"); +if (0) /* FIXME: uncomment once Wine is fixed */ + check_menu_items(hmenu, 206, MF_SEPARATOR, MFS_GRAYED); + mii.wID = 207; + ret = SetMenuItemInfoA(hmenu, 0, TRUE, &mii); + ok(ret, "SetMenuItemInfo failed\n"); +if (0) /* FIXME: uncomment once Wine is fixed */ + check_menu_items(hmenu, 207, MF_SEPARATOR, MFS_GRAYED); + DestroyMenu(hmenu); +} + START_TEST(menu) { init_function_pointers(); @@ -3655,4 +3782,5 @@ START_TEST(menu) test_menu_maxdepth(); test_menu_circref(); test_emptypopup(); + test_AppendMenu(); } diff --git a/rostests/winetests/user32/monitor.c b/rostests/winetests/user32/monitor.c index a2df20eba9d..42ae88380b0 100644 --- a/rostests/winetests/user32/monitor.c +++ b/rostests/winetests/user32/monitor.c @@ -30,6 +30,7 @@ static LONG (WINAPI *pChangeDisplaySettingsExW)(LPCWSTR, LPDEVMODEW, HWND, DWORD static BOOL (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,LPDISPLAY_DEVICEA,DWORD); static BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM); static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO); +static BOOL (WINAPI *pGetMonitorInfoW)(HMONITOR,LPMONITORINFO); static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD); static HMONITOR (WINAPI *pMonitorFromRect)(LPCRECT,DWORD); static HMONITOR (WINAPI *pMonitorFromWindow)(HWND,DWORD); @@ -48,6 +49,7 @@ static void init_function_pointers(void) GET_PROC(EnumDisplayDevicesA) GET_PROC(EnumDisplayMonitors) GET_PROC(GetMonitorInfoA) + GET_PROC(GetMonitorInfoW) GET_PROC(MonitorFromPoint) GET_PROC(MonitorFromRect) GET_PROC(MonitorFromWindow) @@ -296,6 +298,40 @@ static void test_monitors(void) HMONITOR monitor, primary, nearest; POINT pt; RECT rc; + MONITORINFO mi; + MONITORINFOEXA miexa; + MONITORINFOEXW miexw; + BOOL ret; + DWORD i; + + static const struct + { + DWORD cbSize; + BOOL ret; + } testdatami[] = { + {0, FALSE}, + {sizeof(MONITORINFO)+1, FALSE}, + {sizeof(MONITORINFO)-1, FALSE}, + {sizeof(MONITORINFO), TRUE}, + {-1, FALSE}, + {0xdeadbeef, FALSE}, + }, + testdatamiexa[] = { + {0, FALSE}, + {sizeof(MONITORINFOEXA)+1, FALSE}, + {sizeof(MONITORINFOEXA)-1, FALSE}, + {sizeof(MONITORINFOEXA), TRUE}, + {-1, FALSE}, + {0xdeadbeef, FALSE}, + }, + testdatamiexw[] = { + {0, FALSE}, + {sizeof(MONITORINFOEXW)+1, FALSE}, + {sizeof(MONITORINFOEXW)-1, FALSE}, + {sizeof(MONITORINFOEXW), TRUE}, + {-1, FALSE}, + {0xdeadbeef, FALSE}, + }; if (!pMonitorFromPoint || !pMonitorFromWindow || !pMonitorFromRect) { @@ -351,8 +387,6 @@ static void test_monitors(void) nearest = primary; while (monitor != NULL) { - MONITORINFO mi; - BOOL ret; ok( monitor != primary, "got primary %p\n", monitor ); nearest = monitor; mi.cbSize = sizeof(mi); @@ -362,6 +396,55 @@ static void test_monitors(void) monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); } + /* tests for cbSize in MONITORINFO */ + monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY ); + for (i = 0; i < (sizeof(testdatami) / sizeof(testdatami[0])); i++) + { + memset( &mi, 0, sizeof(mi) ); + mi.cbSize = testdatami[i].cbSize; + ret = pGetMonitorInfoA( monitor, &mi ); + ok( ret == testdatami[i].ret, "GetMonitorInfo returned wrong value\n" ); + if (ret) + ok( (mi.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" ); + else + ok( !(mi.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag is set\n" ); + + memset( &miexw, 0, sizeof(miexw) ); + miexw.cbSize = testdatamiexw[i].cbSize; + ret = pGetMonitorInfoW( monitor, (LPMONITORINFO)&miexw ); + ok( ret == testdatamiexw[i].ret, "GetMonitorInfo returned wrong value\n" ); + if (ret) + ok( (miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" ); + else + ok( !(miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag is set\n" ); + } + + /* tests for cbSize in MONITORINFOEXA */ + for (i = 0; i < (sizeof(testdatamiexa) / sizeof(testdatamiexa[0])); i++) + { + memset( &miexa, 0, sizeof(miexa) ); + miexa.cbSize = testdatamiexa[i].cbSize; + ret = pGetMonitorInfoA( monitor, (LPMONITORINFO)&miexa ); + ok( ret == testdatamiexa[i].ret, "GetMonitorInfo returned wrong value\n" ); + if (ret) + ok( (miexa.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" ); + else + ok( !(miexa.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag is set\n" ); + } + + /* tests for cbSize in MONITORINFOEXW */ + for (i = 0; i < (sizeof(testdatamiexw) / sizeof(testdatamiexw[0])); i++) + { + memset( &miexw, 0, sizeof(miexw) ); + miexw.cbSize = testdatamiexw[i].cbSize; + ret = pGetMonitorInfoW( monitor, (LPMONITORINFO)&miexw ); + ok( ret == testdatamiexw[i].ret, "GetMonitorInfo returned wrong value\n" ); + if (ret) + ok( (miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" ); + else + ok( !(miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag is set\n" ); + } + SetRect( &rc, rc.left+1, rc.top+1, rc.left+2, rc.top+2 ); monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); diff --git a/rostests/winetests/user32/msg.c b/rostests/winetests/user32/msg.c index 9ed7e2ef2ce..bb45ced0317 100755 --- a/rostests/winetests/user32/msg.c +++ b/rostests/winetests/user32/msg.c @@ -1747,6 +1747,24 @@ static const struct message WmTrackPopupMenu[] = { { 0 } }; +static const struct message WmTrackPopupMenuCapture[] = { + { HCBT_CREATEWND, hook }, + { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, + { WM_CAPTURECHANGED, sent }, + { WM_INITMENU, sent|lparam, 0, 0 }, + { WM_INITMENUPOPUP, sent|lparam, 0, 0 }, + { 0x0093, sent|optional }, + { 0x0094, sent|optional }, + { 0x0094, sent|optional }, + { WM_ENTERIDLE, sent|wparam, 2 }, + { WM_CAPTURECHANGED, sent }, + { HCBT_DESTROYWND, hook }, + { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, + { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 }, + { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 }, + { 0 } +}; + static const struct message WmTrackPopupMenuEmpty[] = { { HCBT_CREATEWND, hook }, { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, @@ -1762,6 +1780,22 @@ static const struct message WmTrackPopupMenuEmpty[] = { { 0 } }; +static const struct message WmTrackPopupMenuAbort[] = { + { HCBT_CREATEWND, hook }, + { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, + { WM_INITMENU, sent|lparam, 0, 0 }, + { WM_INITMENUPOPUP, sent|lparam, 0, 0 }, + { 0x0093, sent|optional }, + { 0x0094, sent|optional }, + { 0x0094, sent|optional }, + { WM_CAPTURECHANGED, sent }, + { HCBT_DESTROYWND, hook }, + { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, + { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 }, + { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 }, + { 0 } +}; + static BOOL after_end_dialog, test_def_id, paint_loop_done; static int sequence_cnt, sequence_size; static struct recvd_message* sequence; @@ -6990,6 +7024,7 @@ static void test_interthread_messages(void) ret = pGetCurrentActCtx(&handle); ok(ret, "GetCurentActCtx failed: %u\n", GetLastError()); ok(handle != 0, "active context %p\n", handle); + pReleaseActCtx(handle); /* destination window will test for active context */ ret = SendMessageA(wnd_event.hwnd, WM_USER+10, 0, 0); @@ -8356,8 +8391,8 @@ static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime) } #define TIMER_ID 0x19 -#define TIMER_COUNT_EXPECTED 64 -#define TIMER_COUNT_TOLERANCE 9 +#define TIMER_COUNT_EXPECTED 100 +#define TIMER_COUNT_TOLERANCE 10 static int count = 0; static void CALLBACK callback_count(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) @@ -8408,8 +8443,9 @@ static void test_timers(void) ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n"); /* Check the minimum allowed timeout for a timer. MSDN indicates that it should be 10.0 ms, - * but testing indicates that the minimum timeout is actually about 15.6 ms. Since there is - * some measurement error between test runs we're allowing for ±8 counts (~2 ms). + * which occurs sometimes, but most testing on the VMs indicates a minimum timeout closer to + * 15.6 ms. Since there is some measurement error between test runs we are allowing for + * ±9 counts (~4 ms) around the expected value. */ count = 0; id = SetTimer(info.hWnd, TIMER_ID, 0, callback_count); @@ -8418,8 +8454,9 @@ static void test_timers(void) start = GetTickCount(); while (GetTickCount()-start < 1001 && GetMessageA(&msg, info.hWnd, 0, 0)) DispatchMessageA(&msg); - ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE - || broken(abs(count-43) < TIMER_COUNT_TOLERANCE) /* w2k3 */, + ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE /* xp */ + || broken(abs(count-64) < TIMER_COUNT_TOLERANCE) /* most common */ + || broken(abs(count-43) < TIMER_COUNT_TOLERANCE) /* w2k3, win8 */, "did not get expected count for minimum timeout (%d != ~%d).\n", count, TIMER_COUNT_EXPECTED); ok(KillTimer(info.hWnd, id), "KillTimer failed\n"); @@ -8439,7 +8476,9 @@ static void test_timers(void) syscount++; DispatchMessageA(&msg); } - ok(abs(syscount-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE, + ok(abs(syscount-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE + || broken(abs(syscount-64) < TIMER_COUNT_TOLERANCE) /* most common */ + || broken(syscount > 4000 && syscount < 12000) /* win2k3sp0 */, "did not get expected count for minimum timeout (%d != ~%d).\n", syscount, TIMER_COUNT_EXPECTED); todo_wine ok(count == 0, "did not get expected count for callback timeout (%d != 0).\n", @@ -8473,8 +8512,9 @@ static void test_timers_no_wnd(void) ok(count == 1, "killing replaced timer did not work (%i).\n", count); /* Check the minimum allowed timeout for a timer. MSDN indicates that it should be 10.0 ms, - * but testing indicates that the minimum timeout is actually about 15.6 ms. Since there is - * some measurement error between test runs we're allowing for ±8 counts (~2 ms). + * which occurs sometimes, but most testing on the VMs indicates a minimum timeout closer to + * 15.6 ms. Since there is some measurement error between test runs we are allowing for + * ±9 counts (~4 ms) around the expected value. */ count = 0; id = SetTimer(NULL, 0, 0, callback_count); @@ -8482,7 +8522,8 @@ static void test_timers_no_wnd(void) start = GetTickCount(); while (GetTickCount()-start < 1001 && GetMessageA(&msg, NULL, 0, 0)) DispatchMessageA(&msg); - ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE, + ok(abs(count-TIMER_COUNT_EXPECTED) < TIMER_COUNT_TOLERANCE /* xp */ + || broken(abs(count-64) < TIMER_COUNT_TOLERANCE) /* most common */, "did not get expected count for minimum timeout (%d != ~%d).\n", count, TIMER_COUNT_EXPECTED); KillTimer(NULL, id); @@ -14337,6 +14378,22 @@ static LRESULT WINAPI cancel_popup_proc(HWND hwnd, UINT message, WPARAM wParam, case WM_UNINITMENUPOPUP: ok((HMENU)wParam == hpopupmenu, "expected %p, got %lx\n", hpopupmenu, wParam); break; + case WM_CAPTURECHANGED: + todo_wine ok(!lParam || (HWND)lParam == hwnd, "lost capture to %lx\n", lParam); + break; + } + + return MsgCheckProc (FALSE, hwnd, message, wParam, lParam); +} + +static LRESULT WINAPI cancel_init_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (ignore_message( message )) return 0; + + switch (message) { + case WM_ENTERMENULOOP: + ok(EndMenu() == TRUE, "EndMenu() failed\n"); + break; } return MsgCheckProc (FALSE, hwnd, message, wParam, lParam); @@ -14366,6 +14423,24 @@ static void test_TrackPopupMenu(void) ok_sequence(WmTrackPopupMenu, "TrackPopupMenu", TRUE); ok(ret == 1, "TrackPopupMenu failed with error %i\n", GetLastError()); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)cancel_init_proc); + + flush_events(); + flush_sequence(); + ret = TrackPopupMenu(hpopupmenu, 0, 100,100, 0, hwnd, NULL); + ok_sequence(WmTrackPopupMenuAbort, "WmTrackPopupMenuAbort", TRUE); + ok(ret == TRUE, "TrackPopupMenu failed\n"); + + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)cancel_popup_proc); + + SetCapture(hwnd); + + flush_events(); + flush_sequence(); + ret = TrackPopupMenu(hpopupmenu, 0, 100,100, 0, hwnd, NULL); + ok_sequence(WmTrackPopupMenuCapture, "TrackPopupMenuCapture", TRUE); + ok(ret == 1, "TrackPopupMenuCapture failed with error %i\n", GetLastError()); + DestroyMenu(hpopupmenu); DestroyWindow(hwnd); } diff --git a/rostests/winetests/user32/resource.c b/rostests/winetests/user32/resource.c index 9cb73807641..2388adb64f3 100755 --- a/rostests/winetests/user32/resource.c +++ b/rostests/winetests/user32/resource.c @@ -126,6 +126,13 @@ static void test_LoadStringA (void) ok( ret == -1 || broken(ret == 0), "LoadStringA did not return -1 when called with buflen = 0, got %d, err %d\n", ret, GetLastError()); + + SetLastError(0xdeadbeef); + buf[0] = 'a'; + ret = LoadStringA(hInst, 1, buf, 1); + ok( !ret, "LoadString returned %d\n", ret); + ok( buf[0] == 0, "buf[0] = %c (%x)\n", buf[0], buf[0]); + ok( GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError()); } static void test_accel1(void) diff --git a/rostests/winetests/user32/win.c b/rostests/winetests/user32/win.c index 7b5007b0720..ddd697bd748 100644 --- a/rostests/winetests/user32/win.c +++ b/rostests/winetests/user32/win.c @@ -705,19 +705,12 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR { case WM_GETMINMAXINFO: { - MINMAXINFO* minmax = (MINMAXINFO *)lparam; - - trace("WM_GETMINMAXINFO: hwnd %p, %08lx, %08lx\n", hwnd, wparam, lparam); - dump_minmax_info( minmax ); SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0x20031021); break; } case WM_WINDOWPOSCHANGING: { WINDOWPOS *winpos = (WINDOWPOS *)lparam; - trace("main: WM_WINDOWPOSCHANGING %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n", - winpos->hwnd, winpos->hwndInsertAfter, - winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags); if (!(winpos->flags & SWP_NOMOVE)) { ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x); @@ -739,9 +732,6 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR { RECT rc1, rc2; WINDOWPOS *winpos = (WINDOWPOS *)lparam; - trace("main: WM_WINDOWPOSCHANGED %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n", - winpos->hwnd, winpos->hwndInsertAfter, - winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags); ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x); ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y); @@ -775,10 +765,6 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021; CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam; - trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd, cs->hwndParent, cs->style); - if (got_getminmaxinfo) - trace("%p got WM_GETMINMAXINFO\n", hwnd); - if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) ok(got_getminmaxinfo, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n"); else @@ -803,10 +789,6 @@ static LRESULT WINAPI tool_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR { case WM_GETMINMAXINFO: { - MINMAXINFO* minmax = (MINMAXINFO *)lparam; - - trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd, wparam, lparam); - dump_minmax_info( minmax ); SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0x20031021); break; } @@ -815,10 +797,6 @@ static LRESULT WINAPI tool_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021; CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam; - trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd, cs->hwndParent, cs->style); - if (got_getminmaxinfo) - trace("%p got WM_GETMINMAXINFO\n", hwnd); - if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) ok(got_getminmaxinfo, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n"); else @@ -1665,12 +1643,7 @@ static LRESULT WINAPI mdi_child_wnd_proc_1(HWND hwnd, UINT msg, WPARAM wparam, L style = GetWindowLongA(hwnd, GWL_STYLE); exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE); - GetWindowRect(client, &rc); - trace("MDI client %p window size = (%d x %d)\n", client, rc.right-rc.left, rc.bottom-rc.top); GetClientRect(client, &rc); - trace("MDI client %p client size = (%d x %d)\n", client, rc.right, rc.bottom); - trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN), - GetSystemMetrics(SM_CYSCREEN)); GetClientRect(client, &rc); if ((style & WS_CAPTION) == WS_CAPTION) @@ -3098,6 +3071,9 @@ static LRESULT CALLBACK test_capture_4_proc(HWND hWnd, UINT msg, WPARAM wParam, } cap_wnd = GetCapture(); + ok(cap_wnd == (HWND)lParam, "capture window %p does not match lparam %lx\n", cap_wnd, lParam); + todo_wine ok(cap_wnd == hWnd, "capture window %p does not match hwnd %p\n", cap_wnd, hWnd); + /* check that re-setting the capture for the menu fails */ set_cap_wnd = SetCapture(cap_wnd); ok(!set_cap_wnd || broken(set_cap_wnd == cap_wnd), /* nt4 */ @@ -3763,6 +3739,11 @@ static void test_SetParent(void) ok(bret, "SetForegroundWindow() failed\n"); check_active_state(popup, popup, popup); + ShowWindow(parent, SW_SHOW); + SetActiveWindow(popup); + ok(DestroyWindow(popup), "DestroyWindow() failed\n"); + check_active_state(parent, parent, parent); + ok(DestroyWindow(parent), "DestroyWindow() failed\n"); ok(!IsWindow(parent), "parent still exists\n"); @@ -6290,7 +6271,6 @@ static LRESULT CALLBACK fullscreen_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPAR case WM_NCCREATE: { CREATESTRUCTA *cs = (CREATESTRUCTA *)lp; - trace("WM_NCCREATE: rect %d,%d-%d,%d\n", cs->x, cs->y, cs->cx, cs->cy); ok(cs->x == mi.rcMonitor.left && cs->y == mi.rcMonitor.top && cs->cx == mi.rcMonitor.right && cs->cy == mi.rcMonitor.bottom, "expected %d,%d-%d,%d, got %d,%d-%d,%d\n", @@ -6301,7 +6281,6 @@ static LRESULT CALLBACK fullscreen_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPAR case WM_GETMINMAXINFO: { MINMAXINFO *minmax = (MINMAXINFO *)lp; - dump_minmax_info(minmax); ok(minmax->ptMaxPosition.x <= mi.rcMonitor.left, "%d <= %d\n", minmax->ptMaxPosition.x, mi.rcMonitor.left); ok(minmax->ptMaxPosition.y <= mi.rcMonitor.top, "%d <= %d\n", minmax->ptMaxPosition.y, mi.rcMonitor.top); ok(minmax->ptMaxSize.x >= mi.rcMonitor.right, "%d >= %d\n", minmax->ptMaxSize.x, mi.rcMonitor.right); @@ -7530,6 +7509,170 @@ static void test_window_without_child_style(void) DestroyWindow(hwnd); } + +struct smresult_thread_data +{ + HWND main_hwnd; + HWND thread_hwnd; + HANDLE thread_started; + HANDLE thread_got_wm_app; + HANDLE main_in_wm_app_1; + HANDLE thread_replied; +}; + + +static LRESULT WINAPI smresult_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch (msg) + { + case WM_APP: + { + struct smresult_thread_data *data = (struct smresult_thread_data*)lparam; + + ok(hwnd == data->thread_hwnd, "unexpected hwnd %p\n", hwnd); + + SendNotifyMessageA(data->main_hwnd, WM_APP+1, 0, lparam); + + /* Don't return until the main thread is processing our sent message. */ + ok(WaitForSingleObject(data->main_in_wm_app_1, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n"); + + /* Break the PeekMessage loop so we can notify the main thread after we return. */ + SetEvent(data->thread_got_wm_app); + + return 0x240408ea; + } + case WM_APP+1: + { + struct smresult_thread_data *data = (struct smresult_thread_data*)lparam; + LRESULT res; + + ok(hwnd == data->main_hwnd, "unexpected hwnd %p\n", hwnd); + + /* Ask the thread to reply to our WM_APP message. */ + SetEvent(data->main_in_wm_app_1); + + /* Wait until the thread has sent a reply. */ + ok(WaitForSingleObject(data->thread_replied, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n"); + + /* Send another message while we have a reply queued for the current one. */ + res = SendMessageA(data->thread_hwnd, WM_APP+2, 0, lparam); + ok(res == 0x449b0190, "unexpected result %lx\n", res); + + return 0; + } + case WM_APP+2: + { + struct smresult_thread_data *data = (struct smresult_thread_data*)lparam; + + ok(hwnd == data->thread_hwnd, "unexpected hwnd %p\n", hwnd); + + /* Don't return until we know the main thread is processing sent messages. */ + SendMessageA(data->main_hwnd, WM_NULL, 0, 0); + + return 0x449b0190; + } + case WM_CLOSE: + PostQuitMessage(0); + break; + } + return DefWindowProcA(hwnd, msg, wparam, lparam); +} + +static DWORD WINAPI smresult_thread_proc(void *param) +{ + MSG msg; + struct smresult_thread_data *data = param; + + data->thread_hwnd = CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok(data->thread_hwnd != 0, "Failed to create overlapped window\n"); + + SetEvent(data->thread_started); + + /* Loop until we've processed WM_APP. */ + while (WaitForSingleObject(data->thread_got_wm_app, 0) != WAIT_OBJECT_0) + { + if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + else + { + MsgWaitForMultipleObjects(1, &data->thread_got_wm_app, FALSE, INFINITE, QS_SENDMESSAGE); + } + } + + /* Notify the main thread that we replied to its WM_APP message. */ + SetEvent(data->thread_replied); + + while (GetMessageA(&msg, 0, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + + return 0; +} + +static void test_smresult(void) +{ + WNDCLASSA cls; + HANDLE hThread; + DWORD tid; + struct smresult_thread_data data; + BOOL ret; + LRESULT res; + + cls.style = CS_DBLCLKS; + cls.lpfnWndProc = smresult_wndproc; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleA(0); + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = "SmresultClass"; + + ret = RegisterClassA(&cls); + ok(ret, "RegisterClassA failed\n"); + + data.thread_started = CreateEventA(NULL, TRUE, FALSE, NULL); + ok(data.thread_started != NULL, "CreateEventA failed\n"); + + data.thread_got_wm_app = CreateEventA(NULL, TRUE, FALSE, NULL); + ok(data.thread_got_wm_app != NULL, "CreateEventA failed\n"); + + data.main_in_wm_app_1 = CreateEventA(NULL, TRUE, FALSE, NULL); + ok(data.main_in_wm_app_1 != NULL, "CreateEventA failed\n"); + + data.thread_replied = CreateEventA(NULL, TRUE, FALSE, NULL); + ok(data.thread_replied != NULL, "CreateEventA failed\n"); + + data.main_hwnd = CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW, + 100, 100, 200, 200, 0, 0, 0, NULL); + + hThread = CreateThread(NULL, 0, smresult_thread_proc, &data, 0, &tid); + ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError()); + + ok(WaitForSingleObject(data.thread_started, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n"); + + res = SendMessageA(data.thread_hwnd, WM_APP, 0, (LPARAM)&data); + ok(res == 0x240408ea, "unexpected result %lx\n", res); + + SendMessageA(data.thread_hwnd, WM_CLOSE, 0, 0); + + DestroyWindow(data.main_hwnd); + + ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n"); + + CloseHandle(data.thread_started); + CloseHandle(data.thread_got_wm_app); + CloseHandle(data.main_in_wm_app_1); + CloseHandle(data.thread_replied); +} + START_TEST(win) { HMODULE user32 = GetModuleHandleA( "user32.dll" ); @@ -7664,6 +7807,7 @@ START_TEST(win) test_map_points(); test_update_region(); test_window_without_child_style(); + test_smresult(); /* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook); diff --git a/rostests/winetests/user32/winstation.c b/rostests/winetests/user32/winstation.c index 7f91b8b2798..0889dac33ca 100755 --- a/rostests/winetests/user32/winstation.c +++ b/rostests/winetests/user32/winstation.c @@ -519,7 +519,7 @@ static void test_inputdesktop(void) ret = CloseDesktop(input_desk); ok(ret, "CloseDesktop failed!\n"); - /* by default, GetThreadDesktop is the input desktop, SendInput should success. */ + /* by default, GetThreadDesktop is the input desktop, SendInput should succeed. */ old_thread_desk = GetThreadDesktop(GetCurrentThreadId()); ok(old_thread_desk != NULL, "GetThreadDesktop faile!\n"); memset(name, 0, sizeof(name)); -- 2.17.1