Author: gadamopoulos Date: Wed Aug 15 19:37:29 2012 New Revision: 57079 URL: http://svn.reactos.org/svn/reactos?rev=57079&view=rev Log: [user32_apitest] - Hack around the fact that desktop handling in ros is awful. Now the child threads use the proper desktop. - Convert all calls to SendMessage to SendMessageTimeout to make sure it won't hang (it doesn't hang in windows but who knows what can happen in ros) - Add a few more tests
Modified: trunk/rostests/apitests/user32/AttachThreadInput.c Modified: trunk/rostests/apitests/user32/AttachThreadInput.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/AttachThreadInput.c?rev=57079&r1=57078&r2=57079&view=diff ============================================================================== --- trunk/rostests/apitests/user32/AttachThreadInput.c [iso-8859-1] (original) +++ trunk/rostests/apitests/user32/AttachThreadInput.c [iso-8859-1] Wed Aug 15 19:37:29 2012 @@ -26,7 +26,7 @@ } THREAD_DATA; DWORD tidMouseMove; -THREAD_DATA data[5]; +THREAD_DATA data[6]; HHOOK hMouseHookLL = NULL; HHOOK hKbdHookLL = NULL; @@ -66,6 +66,7 @@ static void FlushMessages() { MSG msg; + LRESULT res; while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) { @@ -76,10 +77,14 @@ } /* Use SendMessage to sync with the other queues */ - SendMessage(data[1].hWnd, WM_APP, 0,0); - SendMessage(data[2].hWnd, WM_APP, 0,0); - SendMessage(data[3].hWnd, WM_APP, 0,0); - SendMessage(data[4].hWnd, WM_APP, 0,0); + res = SendMessageTimeout(data[1].hWnd, WM_APP, 0,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); + res = SendMessageTimeout(data[2].hWnd, WM_APP, 0,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); + res = SendMessageTimeout(data[3].hWnd, WM_APP, 0,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); + res = SendMessageTimeout(data[4].hWnd, WM_APP, 0,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); } static DWORD WINAPI thread_proc(void *param) @@ -93,7 +98,6 @@ { hdesk = CreateDesktopW(current_data->Desktop, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); SetThreadDesktop(hdesk); - ok(GetThreadDesktop(current_data->tid) == hdesk, "Thread in wrong desktop. Following results may be bogus!\n"); } /* create test window */ @@ -196,6 +200,9 @@ /* create thread2(same desktop) */ if(!CreateTestThread(2, NULL)) return FALSE; + /* ugly ros hack to bypass desktop crapiness */ + if(!CreateTestThread(6, L"ThreadTestDesktop")) return FALSE; + /* create thread3(different desktop) */ if(!CreateTestThread(3, L"ThreadTestDesktop")) return FALSE; @@ -203,6 +210,21 @@ if(!CreateTestThread(4, L"ThreadTestDesktop")) return FALSE; return TRUE; +} + +static void cleanup_attachments() +{ + int i,j; + BOOL ret; + + for(i = 0; i< 4; i++); + { + for(j = 0; j< 4; j++); + { + ret = AttachThreadInput(data[i].tid,data[j].tid, FALSE); + ok(ret==0, "expected AttachThreadInput to fail\n"); + } + } } @@ -228,10 +250,14 @@ /* try to attach to a thread on another desktop*/ ret = AttachThreadInput( data[2].tid,data[3].tid, TRUE); ok(ret==0, "expected AttachThreadInput to fail\n"); + if(ret == 1 ) + AttachThreadInput( data[2].tid,data[3].tid, FALSE); /* test other desktop to this */ ret = AttachThreadInput( data[3].tid,data[2].tid, TRUE); ok(ret==0, "expected AttachThreadInput to fail\n"); + if(ret == 1 ) + AttachThreadInput( data[3].tid,data[2].tid, FALSE); /* attach two threads that are both in ThreadTestDesktop */ { @@ -253,21 +279,29 @@ ret = AttachThreadInput( data[1].tid,data[2].tid, TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); + /* attach in the opposite order */ + ret = AttachThreadInput( data[2].tid,data[1].tid, TRUE); + ok(ret==1, "expected AttachThreadInput to succeed\n"); + /* Now try to detach 0 from 1 */ ret = AttachThreadInput( data[0].tid,data[1].tid, FALSE); ok(ret==0, "expected AttachThreadInput to fail\n"); /* also try to detach 3 from 2 */ - ret = AttachThreadInput( data[2].tid,data[1].tid, FALSE); + ret = AttachThreadInput( data[3].tid,data[2].tid, FALSE); ok(ret==0, "expected AttachThreadInput to fail\n"); /* cleanup previous attachment */ ret = AttachThreadInput( data[1].tid,data[2].tid, FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); - } - - /*too bad this causes a crash in win32k */ -#if 0 + + ret = AttachThreadInput( data[2].tid,data[1].tid, FALSE); + ok(ret==1, "expected AttachThreadInput to succeed\n"); + + ret = AttachThreadInput( data[1].tid,data[2].tid, FALSE); + ok(ret==1, "expected AttachThreadInput to succeed\n"); + } + /* test triple attach */ { ret = AttachThreadInput( data[0].tid, data[1].tid, TRUE); @@ -294,7 +328,6 @@ ret = AttachThreadInput( data[1].tid, data[2].tid, FALSE); ok(ret==1, "expected AttachThreadInput to succeed\n"); } -#endif } void Test_Focus() //Focus Active Capture Foreground Capture @@ -408,6 +441,7 @@ void Test_UnaffectedMessages() { BOOL ret; + LRESULT res; EMPTY_CACHE_(&data[0].cache); EMPTY_CACHE_(&data[1].cache); @@ -444,8 +478,10 @@ } /* test messages send to the wrong thread */ - SendMessage(data[0].hWnd, WM_USER, 0,0); - SendMessage(data[1].hWnd, WM_USER, 1,0); + res = SendMessageTimeout(data[0].hWnd, WM_USER, 0,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); + res = SendMessageTimeout(data[1].hWnd, WM_USER, 1,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); { MSG_ENTRY Thread0_chain[]={ @@ -461,11 +497,14 @@ ret = AttachThreadInput( data[2].tid, data[1].tid , TRUE); ok(ret==1, "expected AttachThreadInput to succeed\n"); - SendMessage(data[0].hWnd, WM_USER, 2,0); - SendMessage(data[1].hWnd, WM_USER, 3,0); + res = SendMessageTimeout(data[0].hWnd, WM_USER, 2,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); + res = SendMessageTimeout(data[1].hWnd, WM_USER, 3,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); /* Try to send a fake input message */ - SendMessage(data[1].hWnd, WM_MOUSEMOVE, 0,0); + res = SendMessageTimeout(data[1].hWnd, WM_MOUSEMOVE, 0,0, SMTO_NORMAL, 1000, NULL); + ok (res != ERROR_TIMEOUT, "SendMessageTimeout timed out\n"); COMPARE_CACHE_(&data[0].cache, Thread0_chain); COMPARE_CACHE_(&data[1].cache, Thread1_chain); @@ -596,9 +635,13 @@ return; Test_SimpleParameters(); + cleanup_attachments(); Test_Focus(); + cleanup_attachments(); Test_UnaffectedMessages(); + cleanup_attachments(); Test_SendInput(); + cleanup_attachments(); if(hMouseHookLL) UnhookWindowsHookEx(hMouseHookLL);