Author: fireball Date: Sun Apr 4 15:47:45 2010 New Revision: 46717
URL: http://svn.reactos.org/svn/reactos?rev=46717&view=rev Log: - Sync user32 and gdi32 winetests to Wine-1.1.42.
Modified: trunk/rostests/winetests/user32/combo.c trunk/rostests/winetests/user32/cursoricon.c trunk/rostests/winetests/user32/menu.c trunk/rostests/winetests/user32/msg.c trunk/rostests/winetests/user32/scroll.c trunk/rostests/winetests/user32/win.c
Modified: trunk/rostests/winetests/user32/combo.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/user32/combo.c?r... ============================================================================== --- trunk/rostests/winetests/user32/combo.c [iso-8859-1] (original) +++ trunk/rostests/winetests/user32/combo.c [iso-8859-1] Sun Apr 4 15:47:45 2010 @@ -461,7 +461,7 @@ ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len)); ok(HIWORD(len)==1, "Unexpected end position for selection %d\n", HIWORD(len));
- /* Now what happens when it gets more focus a second time - it doesnt reselect */ + /* Now what happens when it gets more focus a second time - it doesn't reselect */ SendMessage(hCombo, WM_SETFOCUS, 0, (LPARAM)hEdit); len = SendMessage(hCombo, CB_GETEDITSEL, 0,0); ok(LOWORD(len)==1, "Unexpected start position for selection %d\n", LOWORD(len));
Modified: trunk/rostests/winetests/user32/cursoricon.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/user32/cursorico... ============================================================================== --- trunk/rostests/winetests/user32/cursoricon.c [iso-8859-1] (original) +++ trunk/rostests/winetests/user32/cursoricon.c [iso-8859-1] Sun Apr 4 15:47:45 2010 @@ -64,6 +64,8 @@
#define PROC_INIT (WM_USER+1)
+static BOOL (WINAPI *pGetCursorInfo)(CURSORINFO *); + static LRESULT CALLBACK callback_child(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL ret; @@ -961,7 +963,7 @@ { ICONINFO iconInfo; BITMAPINFO bitmapInfo; - UINT32 *buffer = NULL; + void *buffer = NULL; UINT32 mask = maskvalue ? 0xFFFFFFFF : 0x00000000;
memset(&bitmapInfo, 0, sizeof(bitmapInfo)); @@ -980,7 +982,7 @@ iconInfo.hbmMask = CreateBitmap( width, height, 1, 1, &mask ); if(!iconInfo.hbmMask) return NULL;
- iconInfo.hbmColor = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, (void**)&buffer, NULL, 0); + iconInfo.hbmColor = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, &buffer, NULL, 0); if(!iconInfo.hbmColor || !buffer) { DeleteObject(iconInfo.hbmMask); @@ -1072,7 +1074,7 @@ HDC hdcDst = NULL; HBITMAP bmpDst = NULL; HBITMAP bmpOld = NULL; - UINT32 *bits = 0; + void *bits = 0;
hdcDst = CreateCompatibleDC(0); ok(hdcDst != 0, "CreateCompatibleDC(0) failed to return a valid DC\n"); @@ -1094,7 +1096,7 @@ bitmapInfo.bmiHeader.biCompression = BI_RGB; bitmapInfo.bmiHeader.biSizeImage = sizeof(UINT32);
- bmpDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + bmpDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, &bits, NULL, 0); ok (bmpDst && bits, "CreateDIBSection failed to return a valid bitmap and buffer\n"); if (!bmpDst || !bits) goto cleanup; @@ -1156,7 +1158,7 @@ HDC hdcDst = NULL; HBITMAP bmpDst = NULL; HBITMAP bmpOld = NULL; - UINT32 bits = 0; + void *bits = 0;
hdcDst = CreateCompatibleDC(0); ok(hdcDst != 0, "CreateCompatibleDC(0) failed to return a valid DC\n"); @@ -1177,7 +1179,7 @@ bitmapInfo.bmiHeader.biPlanes = 1; bitmapInfo.bmiHeader.biCompression = BI_RGB; bitmapInfo.bmiHeader.biSizeImage = sizeof(UINT32); - bmpDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + bmpDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, &bits, NULL, 0); ok (bmpDst && bits, "CreateDIBSection failed to return a valid bitmap and buffer\n"); if (!bmpDst || !bits) goto cleanup; @@ -1308,7 +1310,7 @@ HDC hdcDst = NULL; HBITMAP bmpDst = NULL; HBITMAP bmpOld = NULL; - UINT32 bits = 0; + void *bits = 0;
hdcDst = CreateCompatibleDC(0); ok(hdcDst != 0, "CreateCompatibleDC(0) failed to return a valid DC\n"); @@ -1329,7 +1331,7 @@ bitmapInfo.bmiHeader.biPlanes = 1; bitmapInfo.bmiHeader.biCompression = BI_RGB; bitmapInfo.bmiHeader.biSizeImage = sizeof(UINT32); - bmpDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + bmpDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, &bits, NULL, 0); ok (bmpDst && bits, "CreateDIBSection failed to return a valid bitmap and buffer\n"); if (!bmpDst || !bits) goto cleanup; @@ -1352,6 +1354,250 @@ if(hdcDst) DeleteDC(hdcDst); } + +static DWORD parent_id; + +static DWORD CALLBACK set_cursor_thread( void *arg ) +{ + HCURSOR ret; + + PeekMessage( 0, 0, 0, 0, PM_NOREMOVE ); /* create a msg queue */ + if (parent_id) + { + BOOL ret = AttachThreadInput( GetCurrentThreadId(), parent_id, TRUE ); + ok( ret, "AttachThreadInput failed\n" ); + } + if (arg) ret = SetCursor( (HCURSOR)arg ); + else ret = GetCursor(); + return (DWORD_PTR)ret; +} + +static void test_SetCursor(void) +{ + static const BYTE bmp_bits[4096]; + ICONINFO cursorInfo; + HCURSOR cursor, old_cursor, global_cursor = 0; + DWORD error, id, result; + UINT display_bpp; + HDC hdc; + HANDLE thread; + CURSORINFO info; + + if (pGetCursorInfo) + { + memset( &info, 0, sizeof(info) ); + info.cbSize = sizeof(info); + if (!pGetCursorInfo( &info )) + { + win_skip( "GetCursorInfo not working\n" ); + pGetCursorInfo = NULL; + } + else global_cursor = info.hCursor; + } + cursor = GetCursor(); + thread = CreateThread( NULL, 0, set_cursor_thread, 0, 0, &id ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == (DWORD_PTR)cursor, "wrong thread cursor %x/%p\n", result, cursor ); + + hdc = GetDC(0); + display_bpp = GetDeviceCaps(hdc, BITSPIXEL); + ReleaseDC(0, hdc); + + cursorInfo.fIcon = FALSE; + cursorInfo.xHotspot = 0; + cursorInfo.yHotspot = 0; + cursorInfo.hbmMask = CreateBitmap(32, 32, 1, 1, bmp_bits); + cursorInfo.hbmColor = CreateBitmap(32, 32, 1, display_bpp, bmp_bits); + + cursor = CreateIconIndirect(&cursorInfo); + ok(cursor != NULL, "CreateIconIndirect returned %p\n", cursor); + old_cursor = SetCursor( cursor ); + + if (pGetCursorInfo) + { + info.cbSize = sizeof(info); + ok( pGetCursorInfo( &info ), "GetCursorInfo failed\n" ); + /* global cursor doesn't change since we don't have a window */ + ok( info.hCursor == global_cursor || broken(info.hCursor != cursor), /* win9x */ + "wrong info cursor %p/%p\n", info.hCursor, global_cursor ); + } + thread = CreateThread( NULL, 0, set_cursor_thread, 0, 0, &id ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == (DWORD_PTR)old_cursor, "wrong thread cursor %x/%p\n", result, old_cursor ); + + SetCursor( 0 ); + ok( GetCursor() == 0, "wrong cursor %p\n", GetCursor() ); + thread = CreateThread( NULL, 0, set_cursor_thread, 0, 0, &id ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == (DWORD_PTR)old_cursor, "wrong thread cursor %x/%p\n", result, old_cursor ); + + thread = CreateThread( NULL, 0, set_cursor_thread, cursor, 0, &id ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == (DWORD_PTR)old_cursor, "wrong thread cursor %x/%p\n", result, old_cursor ); + ok( GetCursor() == 0, "wrong cursor %p/0\n", GetCursor() ); + + parent_id = GetCurrentThreadId(); + thread = CreateThread( NULL, 0, set_cursor_thread, cursor, 0, &id ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == (DWORD_PTR)old_cursor, "wrong thread cursor %x/%p\n", result, old_cursor ); + ok( GetCursor() == cursor, "wrong cursor %p/0\n", cursor ); + + if (pGetCursorInfo) + { + info.cbSize = sizeof(info); + ok( pGetCursorInfo( &info ), "GetCursorInfo failed\n" ); + ok( info.hCursor == global_cursor || broken(info.hCursor != cursor), /* win9x */ + "wrong info cursor %p/%p\n", info.hCursor, global_cursor ); + } + SetCursor( old_cursor ); + DestroyCursor( cursor ); + + SetLastError( 0xdeadbeef ); + cursor = SetCursor( (HCURSOR)0xbadbad ); + error = GetLastError(); + ok( cursor == 0, "wrong cursor %p/0\n", cursor ); + ok( error == ERROR_INVALID_CURSOR_HANDLE || broken( error == 0xdeadbeef ), /* win9x */ + "wrong error %u\n", error ); + + if (pGetCursorInfo) + { + info.cbSize = sizeof(info); + ok( pGetCursorInfo( &info ), "GetCursorInfo failed\n" ); + ok( info.hCursor == global_cursor || broken(info.hCursor != cursor), /* win9x */ + "wrong info cursor %p/%p\n", info.hCursor, global_cursor ); + } +} + +static HANDLE event_start, event_next; + +static DWORD CALLBACK show_cursor_thread( void *arg ) +{ + DWORD count = (DWORD_PTR)arg; + int ret; + + PeekMessage( 0, 0, 0, 0, PM_NOREMOVE ); /* create a msg queue */ + if (parent_id) + { + BOOL ret = AttachThreadInput( GetCurrentThreadId(), parent_id, TRUE ); + ok( ret, "AttachThreadInput failed\n" ); + } + if (!count) ret = ShowCursor( FALSE ); + else while (count--) ret = ShowCursor( TRUE ); + SetEvent( event_start ); + WaitForSingleObject( event_next, 2000 ); + return ret; +} + +static void test_ShowCursor(void) +{ + int count; + DWORD id, result; + HANDLE thread; + CURSORINFO info; + + if (pGetCursorInfo) + { + memset( &info, 0, sizeof(info) ); + info.cbSize = sizeof(info); + ok( pGetCursorInfo( &info ), "GetCursorInfo failed\n" ); + ok( info.flags & CURSOR_SHOWING, "cursor not shown in info\n" ); + } + + event_start = CreateEvent( NULL, FALSE, FALSE, NULL ); + event_next = CreateEvent( NULL, FALSE, FALSE, NULL ); + + count = ShowCursor( TRUE ); + ok( count == 1, "wrong count %d\n", count ); + count = ShowCursor( TRUE ); + ok( count == 2, "wrong count %d\n", count ); + count = ShowCursor( FALSE ); + ok( count == 1, "wrong count %d\n", count ); + count = ShowCursor( FALSE ); + ok( count == 0, "wrong count %d\n", count ); + count = ShowCursor( FALSE ); + ok( count == -1, "wrong count %d\n", count ); + count = ShowCursor( FALSE ); + ok( count == -2, "wrong count %d\n", count ); + + if (pGetCursorInfo) + { + info.cbSize = sizeof(info); + ok( pGetCursorInfo( &info ), "GetCursorInfo failed\n" ); + /* global show count is not affected since we don't have a window */ + ok( info.flags & CURSOR_SHOWING, "cursor not shown in info\n" ); + } + + parent_id = 0; + thread = CreateThread( NULL, 0, show_cursor_thread, NULL, 0, &id ); + WaitForSingleObject( event_start, 1000 ); + count = ShowCursor( FALSE ); + ok( count == -3, "wrong count %d\n", count ); + SetEvent( event_next ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == -1, "wrong thread count %d\n", result ); + count = ShowCursor( FALSE ); + ok( count == -4, "wrong count %d\n", count ); + + thread = CreateThread( NULL, 0, show_cursor_thread, (void *)1, 0, &id ); + WaitForSingleObject( event_start, 1000 ); + count = ShowCursor( TRUE ); + ok( count == -3, "wrong count %d\n", count ); + SetEvent( event_next ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == 1, "wrong thread count %d\n", result ); + count = ShowCursor( TRUE ); + ok( count == -2, "wrong count %d\n", count ); + + parent_id = GetCurrentThreadId(); + thread = CreateThread( NULL, 0, show_cursor_thread, NULL, 0, &id ); + WaitForSingleObject( event_start, 1000 ); + count = ShowCursor( TRUE ); + ok( count == -2, "wrong count %d\n", count ); + SetEvent( event_next ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == -3, "wrong thread count %d\n", result ); + count = ShowCursor( FALSE ); + ok( count == -2, "wrong count %d\n", count ); + + thread = CreateThread( NULL, 0, show_cursor_thread, (void *)3, 0, &id ); + WaitForSingleObject( event_start, 1000 ); + count = ShowCursor( TRUE ); + ok( count == 2, "wrong count %d\n", count ); + SetEvent( event_next ); + WaitForSingleObject( thread, 1000 ); + GetExitCodeThread( thread, &result ); + ok( result == 1, "wrong thread count %d\n", result ); + count = ShowCursor( FALSE ); + ok( count == -2, "wrong count %d\n", count ); + + if (pGetCursorInfo) + { + info.cbSize = sizeof(info); + ok( pGetCursorInfo( &info ), "GetCursorInfo failed\n" ); + ok( info.flags & CURSOR_SHOWING, "cursor not shown in info\n" ); + } + + count = ShowCursor( TRUE ); + ok( count == -1, "wrong count %d\n", count ); + count = ShowCursor( TRUE ); + ok( count == 0, "wrong count %d\n", count ); + + if (pGetCursorInfo) + { + info.cbSize = sizeof(info); + ok( pGetCursorInfo( &info ), "GetCursorInfo failed\n" ); + ok( info.flags & CURSOR_SHOWING, "cursor not shown in info\n" ); + } +} +
static void test_DestroyCursor(void) { @@ -1435,6 +1681,7 @@
START_TEST(cursoricon) { + pGetCursorInfo = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetCursorInfo" ); test_argc = winetest_get_mainargs(&test_argv);
if (test_argc >= 3) @@ -1463,6 +1710,8 @@ test_DrawIcon(); test_DrawIconEx(); test_DrawState(); + test_SetCursor(); + test_ShowCursor(); test_DestroyCursor(); do_parent(); test_child_process();
Modified: trunk/rostests/winetests/user32/menu.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/user32/menu.c?re... ============================================================================== --- trunk/rostests/winetests/user32/menu.c [iso-8859-1] (original) +++ trunk/rostests/winetests/user32/menu.c [iso-8859-1] Sun Apr 4 15:47:45 2010 @@ -3218,7 +3218,7 @@
test_menu_hilitemenuitem(); test_menu_trackpopupmenu(); -// test_menu_cancelmode(); + test_menu_cancelmode(); test_menu_maxdepth(); test_menu_circref(); }
Modified: trunk/rostests/winetests/user32/msg.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/user32/msg.c?rev... ============================================================================== --- trunk/rostests/winetests/user32/msg.c [iso-8859-1] (original) +++ trunk/rostests/winetests/user32/msg.c [iso-8859-1] Sun Apr 4 15:47:45 2010 @@ -12434,17 +12434,17 @@ test_quit_message(); test_SetActiveWindow();
-// if (!pTrackMouseEvent) + if (!pTrackMouseEvent) win_skip("TrackMouseEvent is not available\n"); -// else -// test_TrackMouseEvent(); + else + test_TrackMouseEvent();
test_SetWindowRgn(); test_sys_menu(); test_dialog_messages(); test_nullCallback(); test_dbcs_wm_char(); -// test_menu_messages(); + test_menu_messages(); test_paintingloop(); test_defwinproc(); test_clipboard_viewers();
Modified: trunk/rostests/winetests/user32/scroll.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/user32/scroll.c?... ============================================================================== --- trunk/rostests/winetests/user32/scroll.c [iso-8859-1] (original) +++ trunk/rostests/winetests/user32/scroll.c [iso-8859-1] Sun Apr 4 15:47:45 2010 @@ -42,11 +42,24 @@ case WM_DESTROY: PostQuitMessage(0); break; - + case WM_HSCROLL: + case WM_VSCROLL: + /* stop tracking */ + ReleaseCapture(); + return 0; default: return DefWindowProcA(hWnd, msg, wParam, lParam); } return 0; +} +static void scrollbar_test_track(void) +{ + /* test that scrollbar tracking is terminated when + * the control looses mouse capture */ + SendMessage( hScroll, WM_LBUTTONDOWN, 0, MAKELPARAM( 1, 1)); + /* a normal return from the sendmessage */ + /* not normal for instance by closing the windws */ + ok( IsWindow( hScroll), "Scrollbar has gone!\n"); }
static void scrollbar_test1(void) @@ -420,6 +433,7 @@ scrollbar_test2(); scrollbar_test3(); scrollbar_test4(); + scrollbar_test_track();
/* Some test results vary depending of theming being active or not */ hUxtheme = LoadLibraryA("uxtheme.dll");
Modified: trunk/rostests/winetests/user32/win.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/user32/win.c?rev... ============================================================================== --- trunk/rostests/winetests/user32/win.c [iso-8859-1] (original) +++ trunk/rostests/winetests/user32/win.c [iso-8859-1] Sun Apr 4 15:47:45 2010 @@ -2476,10 +2476,39 @@ check_wnd_state(hwnd, hwnd, hwnd, 0); }
+struct create_window_thread_params +{ + HWND window; + HANDLE window_created; + HANDLE test_finished; +}; + +static DWORD WINAPI create_window_thread(void *param) +{ + struct create_window_thread_params *p = param; + DWORD res; + BOOL ret; + + p->window = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0); + + ret = SetEvent(p->window_created); + ok(ret, "SetEvent failed, last error %#x.\n", GetLastError()); + + res = WaitForSingleObject(p->test_finished, INFINITE); + ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError()); + + DestroyWindow(p->window); + return 0; +} + static void test_SetForegroundWindow(HWND hwnd) { + struct create_window_thread_params thread_params; + HANDLE thread; + DWORD res, tid; BOOL ret; HWND hwnd2; + MSG msg;
flush_events( TRUE ); ShowWindow(hwnd, SW_HIDE); @@ -2552,6 +2581,34 @@
DestroyWindow(hwnd2); check_wnd_state(hwnd, hwnd, hwnd, 0); + + hwnd2 = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0); + check_wnd_state(hwnd2, hwnd2, hwnd2, 0); + + thread_params.window_created = CreateEvent(NULL, FALSE, FALSE, NULL); + ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError()); + thread_params.test_finished = CreateEvent(NULL, FALSE, FALSE, NULL); + ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError()); + thread = CreateThread(NULL, 0, create_window_thread, &thread_params, 0, &tid); + ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError()); + res = WaitForSingleObject(thread_params.window_created, INFINITE); + ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError()); + check_wnd_state(hwnd2, thread_params.window, hwnd2, 0); + + SetForegroundWindow(hwnd2); + check_wnd_state(hwnd2, hwnd2, hwnd2, 0); + + while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg); + if (0) check_wnd_state(hwnd2, hwnd2, hwnd2, 0); + todo_wine ok(GetActiveWindow() == hwnd2, "Expected active window %p, got %p.\n", hwnd2, GetActiveWindow()); + todo_wine ok(GetFocus() == hwnd2, "Expected focus window %p, got %p.\n", hwnd2, GetFocus()); + + SetEvent(thread_params.test_finished); + WaitForSingleObject(thread, INFINITE); + CloseHandle(thread_params.test_finished); + CloseHandle(thread_params.window_created); + CloseHandle(thread); + DestroyWindow(hwnd2); }
static WNDPROC old_button_proc; @@ -2953,7 +3010,7 @@ BOOL ret; LRESULT res;
- ShowWindow(hwnd, SW_SHOW); + ShowWindow(hwnd, SW_SHOWNORMAL); UpdateWindow(hwnd); SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
@@ -5161,6 +5218,7 @@ NULL, NULL, 0, &flags); ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); + flush_events( FALSE ); while(PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE) != 0) { if (msg.message == WM_PAINT) loopcount++; @@ -5979,7 +6037,7 @@ test_capture_1(); test_capture_2(); test_capture_3(hwndMain, hwndMain2); -// test_capture_4(); + test_capture_4();
test_CreateWindow(); test_parent_owner(); @@ -6019,7 +6077,7 @@ test_layered_window();
test_SetForegroundWindow(hwndMain); -// test_shell_window(); + test_shell_window(); test_handles( hwndMain ); test_winregion();