- Sync user32 and gdi32 winetests to Wine-1.1.42.

svn path=/trunk/; revision=46717
This commit is contained in:
Aleksey Bragin 2010-04-04 13:47:45 +00:00
parent 917fa8ad14
commit 08f73a5234
6 changed files with 339 additions and 18 deletions

View file

@ -461,7 +461,7 @@ static void test_editselection(void)
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));

View file

@ -64,6 +64,8 @@ static HANDLE child_process;
#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 @@ static HICON create_test_icon(HDC hdc, int width, int height, int bpp,
{
ICONINFO iconInfo;
BITMAPINFO bitmapInfo;
UINT32 *buffer = NULL;
void *buffer = NULL;
UINT32 mask = maskvalue ? 0xFFFFFFFF : 0x00000000;
memset(&bitmapInfo, 0, sizeof(bitmapInfo));
@ -980,7 +982,7 @@ static HICON create_test_icon(HDC hdc, int width, int height, int bpp,
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 @@ static void test_DrawIcon(void)
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 @@ static void test_DrawIcon(void)
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 @@ static void test_DrawIconEx(void)
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 @@ static void test_DrawIconEx(void)
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 @@ static void test_DrawState(void)
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 @@ static void test_DrawState(void)
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;
@ -1353,6 +1355,250 @@ cleanup:
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)
{
static const BYTE bmp_bits[4096];
@ -1435,6 +1681,7 @@ static void test_DestroyCursor(void)
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 @@ START_TEST(cursoricon)
test_DrawIcon();
test_DrawIconEx();
test_DrawState();
test_SetCursor();
test_ShowCursor();
test_DestroyCursor();
do_parent();
test_child_process();

View file

@ -3218,7 +3218,7 @@ START_TEST(menu)
test_menu_hilitemenuitem();
test_menu_trackpopupmenu();
// test_menu_cancelmode();
test_menu_cancelmode();
test_menu_maxdepth();
test_menu_circref();
}

View file

@ -12434,17 +12434,17 @@ START_TEST(msg)
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();

View file

@ -42,12 +42,25 @@ static LRESULT CALLBACK MyWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
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 @@ START_TEST ( scroll )
scrollbar_test2();
scrollbar_test3();
scrollbar_test4();
scrollbar_test_track();
/* Some test results vary depending of theming being active or not */
hUxtheme = LoadLibraryA("uxtheme.dll");

View file

@ -2476,10 +2476,39 @@ static void test_SetActiveWindow(HWND hwnd)
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 @@ static void test_SetForegroundWindow(HWND hwnd)
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 @@ static void test_mouse_input(HWND hwnd)
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 @@ static void run_NCRedrawLoop(UINT flags)
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 @@ START_TEST(win)
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 @@ START_TEST(win)
test_layered_window();
test_SetForegroundWindow(hwndMain);
// test_shell_window();
test_shell_window();
test_handles( hwndMain );
test_winregion();