From 523f2c90d7f09d5a4b712dc7e64cd9cd88a68361 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 3 Oct 2011 19:49:16 +0000 Subject: [PATCH] [USER32_WINETEST] * Sync with Wine 1.3.29. svn path=/trunk/; revision=53976 --- rostests/winetests/user32/combo.c | 31 ++++++++++ rostests/winetests/user32/cursoricon.c | 10 +-- rostests/winetests/user32/edit.c | 38 +++++++++++- rostests/winetests/user32/msg.c | 49 +++++++++++++++ rostests/winetests/user32/resource.rc | 35 +++++------ rostests/winetests/user32/static.c | 18 +++++- rostests/winetests/user32/win.c | 2 +- rostests/winetests/user32/winstation.c | 84 +++++++++++++++----------- 8 files changed, 205 insertions(+), 62 deletions(-) diff --git a/rostests/winetests/user32/combo.c b/rostests/winetests/user32/combo.c index fd852d13df7..af23f96d1c1 100644 --- a/rostests/winetests/user32/combo.c +++ b/rostests/winetests/user32/combo.c @@ -404,6 +404,37 @@ static void test_changesize( DWORD style) ok( rc.bottom - rc.top == clheight + 2, "drop-down rect height is %d vs %d\n", rc.bottom - rc.top, clheight + 2); } + + ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, -1, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + + ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + + ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth - 1, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + + ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, clwidth << 1, 0); + ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); + ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); + ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); + + ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 0, 0); + ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); + ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); + ok( ddwidth == (clwidth << 1), "drop-width is %d vs %d\n", ddwidth, clwidth << 1); + + ddwidth = SendMessageA(hCombo, CB_SETDROPPEDWIDTH, 1, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + ddwidth = SendMessageA(hCombo, CB_GETDROPPEDWIDTH, 0, 0); + ok( ddwidth == clwidth + 2, "drop-width is %d vs %d\n", ddwidth, clwidth + 2); + DestroyWindow(hCombo); } diff --git a/rostests/winetests/user32/cursoricon.c b/rostests/winetests/user32/cursoricon.c index 2cfbc22f149..cc47a25952f 100644 --- a/rostests/winetests/user32/cursoricon.c +++ b/rostests/winetests/user32/cursoricon.c @@ -1405,6 +1405,7 @@ static int check_cursor_data( HDC hdc, HCURSOR hCursor, void *data, int length) BITMAPINFO *info; ICONINFO iinfo; DWORD ret; + int i; ret = GetIconInfo( hCursor, &iinfo ); ok(ret, "GetIconInfo() failed\n"); @@ -1430,10 +1431,11 @@ static int check_cursor_data( HDC hdc, HCURSOR hCursor, void *data, int length) 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); - + for (i = 0; ret && i < length / sizeof(COLORREF); i++) + { + ret = color_match( ((COLORREF *)data)[i], ((COLORREF *)image)[i] ); + ok(ret, "%04x: Expected 0x%x, actually 0x%x\n", i, ((COLORREF *)data)[i], ((COLORREF *)image)[i] ); + } cleanup: HeapFree( GetProcessHeap(), 0, image ); HeapFree( GetProcessHeap(), 0, info ); diff --git a/rostests/winetests/user32/edit.c b/rostests/winetests/user32/edit.c index c6c815a369c..c1ca3a3ddab 100755 --- a/rostests/winetests/user32/edit.c +++ b/rostests/winetests/user32/edit.c @@ -736,9 +736,10 @@ static void test_edit_control_1(void) */ static void test_edit_control_2(void) { - HWND hwndMain; + HWND hwndMain, phwnd; char szLocalString[MAXLEN]; - LONG r; + LONG r, w = 150, h = 50; + POINT cpos; /* Create main and edit windows. */ hwndMain = CreateWindow(szEditTest2Class, "ET2", WS_OVERLAPPEDWINDOW, @@ -749,7 +750,7 @@ static void test_edit_control_2(void) hwndET2 = CreateWindow("EDIT", NULL, WS_CHILD|WS_BORDER|ES_LEFT|ES_AUTOHSCROLL, - 0, 0, 150, 50, /* important this not be 0 size. */ + 0, 0, w, h, /* important this not be 0 size. */ hwndMain, (HMENU) ID_EDITTEST2, hinst, NULL); assert(hwndET2); if (winetest_interactive) @@ -768,6 +769,37 @@ static void test_edit_control_2(void) ok(lstrcmp(szLocalString, "bar")==0, "Wrong contents of edit: %s\n", szLocalString); + /* try setting the caret before it's visible */ + r = SetCaretPos(0, 0); + todo_wine ok(0 == r, "SetCaretPos succeeded unexpectedly, expected: 0, got: %d\n", r); + phwnd = SetFocus(hwndET2); + ok(phwnd != NULL, "SetFocus failed unexpectedly, expected non-zero, got NULL\n"); + r = SetCaretPos(0, 0); + ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + r = GetCaretPos(&cpos); + ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + ok(cpos.x == 0 && cpos.y == 0, "Wrong caret position, expected: (0,0), got: (%d,%d)\n", cpos.x, cpos.y); + r = SetCaretPos(-1, -1); + ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + r = GetCaretPos(&cpos); + ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + ok(cpos.x == -1 && cpos.y == -1, "Wrong caret position, expected: (-1,-1), got: (%d,%d)\n", cpos.x, cpos.y); + r = SetCaretPos(w << 1, h << 1); + ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + r = GetCaretPos(&cpos); + ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + ok(cpos.x == (w << 1) && cpos.y == (h << 1), "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w << 1, h << 1, cpos.x, cpos.y); + r = SetCaretPos(w, h); + ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + r = GetCaretPos(&cpos); + ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + ok(cpos.x == w && cpos.y == h, "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w, h, cpos.x, cpos.y); + r = SetCaretPos(w - 1, h - 1); + ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + r = GetCaretPos(&cpos); + ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r); + ok(cpos.x == (w - 1) && cpos.y == (h - 1), "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w - 1, h - 1, cpos.x, cpos.y); + /* OK, done! */ DestroyWindow (hwndET2); DestroyWindow (hwndMain); diff --git a/rostests/winetests/user32/msg.c b/rostests/winetests/user32/msg.c index cdb8206e0f7..2e11d8e7fa2 100755 --- a/rostests/winetests/user32/msg.c +++ b/rostests/winetests/user32/msg.c @@ -7608,6 +7608,21 @@ static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam return ret; } +static INT_PTR CALLBACK StopQuitMsgCheckProcA(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) +{ + if (message == WM_CREATE) + PostMessage(hwnd, WM_CLOSE, 0, 0); + else if (message == WM_CLOSE) + { + /* Only the first WM_QUIT will survive the window destruction */ + PostMessage(hwnd, WM_USER, 0x1234, 0x5678); + PostMessage(hwnd, WM_QUIT, 0x1234, 0x5678); + PostMessage(hwnd, WM_QUIT, 0x4321, 0x8765); + } + + return DefWindowProcA(hwnd, message, wp, lp); +} + static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; @@ -7790,6 +7805,10 @@ static BOOL RegisterWindowClasses(void) cls.lpszClassName = "TestParentClass"; if(!RegisterClassA(&cls)) return FALSE; + cls.lpfnWndProc = StopQuitMsgCheckProcA; + cls.lpszClassName = "StopQuitClass"; + if(!RegisterClassA(&cls)) return FALSE; + cls.lpfnWndProc = DefWindowProcA; cls.lpszClassName = "SimpleWindowClass"; if(!RegisterClassA(&cls)) return FALSE; @@ -10131,6 +10150,13 @@ static const struct message WmQuitDialogSeq[] = { { 0 } }; +static const struct message WmStopQuitSeq[] = { + { WM_DWMNCRENDERINGCHANGED, posted|optional }, + { WM_CLOSE, posted }, + { WM_QUIT, posted|wparam|lparam, 0x1234, 0 }, + { 0 } +}; + static void test_quit_message(void) { MSG msg; @@ -10193,6 +10219,29 @@ static void test_quit_message(void) ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message); ok(msg.wParam == 0x1234, "wParam was 0x%lx instead of 0x1234\n", msg.wParam); ok(msg.lParam == 0, "lParam was 0x%lx instead of 0\n", msg.lParam); + + /* Check what happens to a WM_QUIT message posted to a window that gets + * destroyed. + */ + CreateWindowExA(0, "StopQuitClass", "Stop Quit Test", WS_OVERLAPPEDWINDOW, + 0, 0, 100, 100, NULL, NULL, NULL, NULL); + flush_sequence(); + while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + { + struct recvd_message rmsg; + rmsg.hwnd = msg.hwnd; + rmsg.message = msg.message; + rmsg.flags = posted|wparam|lparam; + rmsg.wParam = msg.wParam; + rmsg.lParam = msg.lParam; + rmsg.descr = "stop/quit"; + if (msg.message == WM_QUIT) + /* The hwnd can only be checked here */ + ok(!msg.hwnd, "The WM_QUIT hwnd was %p instead of NULL\n", msg.hwnd); + add_message(&rmsg); + DispatchMessage(&msg); + } + ok_sequence(WmStopQuitSeq, "WmStopQuitSeq", FALSE); } static const struct message WmMouseHoverSeq[] = { diff --git a/rostests/winetests/user32/resource.rc b/rostests/winetests/user32/resource.rc index 1869475f4a6..43417100f08 100755 --- a/rostests/winetests/user32/resource.rc +++ b/rostests/winetests/user32/resource.rc @@ -45,7 +45,7 @@ STRINGTABLE 65534 "Test high id" } -TEST_DIALOG DIALOG DISCARDABLE 0, 0, 60, 30 +TEST_DIALOG DIALOG 0, 0, 60, 30 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE CAPTION "Test dialog" FONT 8, "MS Shell Dlg" @@ -65,7 +65,7 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "Cancel", IDCANCEL,109,20,50,14, WS_TABSTOP | WS_GROUP } -CLASS_TEST_DIALOG DIALOG DISCARDABLE 0, 0, 91, 28 +CLASS_TEST_DIALOG DIALOG 0, 0, 91, 28 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "CreateDialogParams Test" CLASS "TestDialog" @@ -73,7 +73,7 @@ FONT 8, "MS Shell Dlg" { } -CLASS_TEST_DIALOG_2 DIALOG DISCARDABLE 0, 0, 100, 100 +CLASS_TEST_DIALOG_2 DIALOG 0, 0, 100, 100 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "CreateDialogParams Test" CLASS "MyDialogClass" @@ -81,7 +81,7 @@ FONT 8, "MS Shell Dlg" { } -FOCUS_TEST_DIALOG DIALOG DISCARDABLE 0, 0, 60, 30 +FOCUS_TEST_DIALOG DIALOG 0, 0, 60, 30 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CONTROL CAPTION "Test dialog" FONT 8, "MS Shell Dlg" @@ -89,7 +89,7 @@ FONT 8, "MS Shell Dlg" EDITTEXT 200,4,4,50,14 } -IDD_DIALOG DIALOG DISCARDABLE 0, 0, 186, 95 +IDD_DIALOG DIALOG 0, 0, 186, 95 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 8, "MS Sans Serif" @@ -98,14 +98,14 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14 END -TEST_EMPTY_DIALOG DIALOG DISCARDABLE 0, 0, 186, 95 +TEST_EMPTY_DIALOG DIALOG 0, 0, 186, 95 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" FONT 8, "MS Sans Serif" BEGIN END -MULTI_EDIT_DIALOG DIALOG DISCARDABLE 0, 0, 160, 75 +MULTI_EDIT_DIALOG DIALOG 0, 0, 160, 75 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER CAPTION "Multiple Edit Test" FONT 8, "MS Shell Dlg" @@ -115,52 +115,52 @@ FONT 8, "MS Shell Dlg" EDITTEXT 1002, 5, 45, 150, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP } -EDIT_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80 +EDIT_DIALOG DIALOG 0, 0, 160, 80 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER CAPTION "Edit Test" FONT 8, "MS Shell Dlg" { - PUSHBUTTON "Ok", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "Cancel", IDCANCEL, 100, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP EDITTEXT 1000, 5, 5, 150, 50, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL } -EDIT_SINGLELINE_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80 +EDIT_SINGLELINE_DIALOG DIALOG 0, 0, 160, 80 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER CAPTION "Edit Test" FONT 8, "MS Shell Dlg" { - PUSHBUTTON "Ok", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "Cancel", IDCANCEL, 100, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP EDITTEXT 1000, 5, 5, 150, 50, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_AUTOVSCROLL } -EDIT_SINGLELINE_WANTRETURN_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80 +EDIT_SINGLELINE_WANTRETURN_DIALOG DIALOG 0, 0, 160, 80 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER CAPTION "Edit Test" FONT 8, "MS Shell Dlg" { - PUSHBUTTON "Ok", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "Cancel", IDCANCEL, 100, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP EDITTEXT 1000, 5, 5, 150, 50, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_AUTOVSCROLL | ES_WANTRETURN } -EDIT_WANTRETURN_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80 +EDIT_WANTRETURN_DIALOG DIALOG 0, 0, 160, 80 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER CAPTION "Edit Test" FONT 8, "MS Shell Dlg" { - PUSHBUTTON "Ok", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "Cancel", IDCANCEL, 100, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP EDITTEXT 1000, 5, 5, 150, 50, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_WANTRETURN } -EDIT_READONLY_DIALOG DIALOG DISCARDABLE 0, 0, 160, 80 +EDIT_READONLY_DIALOG DIALOG 0, 0, 160, 80 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | DS_CENTER CAPTION "Edit Readonly Test" FONT 8, "MS Shell Dlg" { - PUSHBUTTON "Ok", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "OK", IDOK, 20, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP PUSHBUTTON "Cancel", IDCANCEL, 100, 60, 50, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP EDITTEXT 1000, 5, 5, 150, 50, WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL | ES_READONLY } @@ -190,4 +190,5 @@ FONT 8, "MS Shell Dlg" MENUITEM "&Paste", 203 MENUITEM "&Delete", 204 } + MENUITEM "&Quit", 300 } diff --git a/rostests/winetests/user32/static.c b/rostests/winetests/user32/static.c index b7613563104..62089bd46c2 100644 --- a/rostests/winetests/user32/static.c +++ b/rostests/winetests/user32/static.c @@ -40,6 +40,22 @@ static HWND hMainWnd; static int g_nReceivedColorStatic = 0; +/* try to make sure pending X events have been processed before continuing */ +static void flush_events(void) +{ + MSG msg; + int diff = 200; + int min_timeout = 100; + DWORD time = GetTickCount() + diff; + + while (diff > 0) + { + if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break; + while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + diff = time - GetTickCount(); + } +} + static HWND build_static(DWORD style) { return CreateWindow("static", "Test", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)CTRL_ID, NULL, 0); @@ -70,6 +86,7 @@ static void test_updates(int style, int flags) HWND hStatic = build_static(style); int exp; + flush_events(); trace("Testing style 0x%x\n", style); g_nReceivedColorStatic = 0; /* during each update parent WndProc will test the WM_CTLCOLORSTATIC message */ @@ -122,7 +139,6 @@ START_TEST(static) hMainWnd = CreateWindow(szClassName, "Test", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL, GetModuleHandle(NULL), NULL); ShowWindow(hMainWnd, SW_SHOW); - UpdateWindow(hMainWnd); test_updates(0, 0); test_updates(SS_SIMPLE, 0); diff --git a/rostests/winetests/user32/win.c b/rostests/winetests/user32/win.c index 94f7c638612..365f6ef3f40 100644 --- a/rostests/winetests/user32/win.c +++ b/rostests/winetests/user32/win.c @@ -6701,7 +6701,7 @@ START_TEST(win) if(!winetest_interactive) skip("bug 5957: skipping test_shell_window, it crashes ros/win7 explorer\n"); else - test_shell_window(); + test_shell_window(); test_handles( hwndMain ); test_winregion(); diff --git a/rostests/winetests/user32/winstation.c b/rostests/winetests/user32/winstation.c index 7be74f25f9f..30eeff14ead 100755 --- a/rostests/winetests/user32/winstation.c +++ b/rostests/winetests/user32/winstation.c @@ -108,7 +108,7 @@ static void test_handles(void) HWINSTA w1, w2, w3; HDESK d1, d2, d3; HANDLE hthread; - DWORD id, flags; + DWORD id, flags, le; ATOM atom; char buffer[20]; @@ -137,16 +137,22 @@ static void test_handles(void) ok( CloseHandle(w2), "closing dup win station handle failed\n" ); w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); - ok( w2 != 0, "CreateWindowStation failed\n" ); - ok( w2 != w1, "CreateWindowStation returned default handle\n" ); - SetLastError( 0xdeadbeef ); - ok( !CloseDesktop( (HDESK)w2 ), "CloseDesktop succeeded on win station\n" ); - ok( GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == 0xdeadbeef), /* wow64 */ - "bad last error %d\n", GetLastError() ); - ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); + le = GetLastError(); + ok( w2 != 0 || le == ERROR_ACCESS_DENIED, "CreateWindowStation failed (%u)\n", le ); + if (w2 != 0) + { + ok( w2 != w1, "CreateWindowStation returned default handle\n" ); + SetLastError( 0xdeadbeef ); + ok( !CloseDesktop( (HDESK)w2 ), "CloseDesktop succeeded on win station\n" ); + ok( GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == 0xdeadbeef), /* wow64 */ + "bad last error %d\n", GetLastError() ); + ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); - w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); - ok( CloseHandle( w2 ), "CloseHandle failed\n" ); + w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); + ok( CloseHandle( w2 ), "CloseHandle failed\n" ); + } + else if (le == ERROR_ACCESS_DENIED) + win_skip( "Not enough privileges for CreateWindowStation\n" ); w2 = OpenWindowStation("winsta0", TRUE, WINSTA_ALL_ACCESS ); ok( w2 != 0, "OpenWindowStation failed\n" ); @@ -158,38 +164,43 @@ static void test_handles(void) CreateMutexA( NULL, 0, "foobar" ); w2 = CreateWindowStation("foobar", 0, WINSTA_ALL_ACCESS, NULL ); - ok( w2 != 0, "create foobar station failed\n" ); + le = GetLastError(); + ok( w2 != 0 || le == ERROR_ACCESS_DENIED, "create foobar station failed (%u)\n", le ); - w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); - ok( w3 != 0, "open foobar station failed\n" ); - ok( w3 != w2, "open foobar station returned same handle\n" ); - ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); - ok( CloseWindowStation( w3 ), "CloseWindowStation failed\n" ); + if (w2 != 0) + { + w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); + ok( w3 != 0, "open foobar station failed\n" ); + ok( w3 != w2, "open foobar station returned same handle\n" ); + ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); + ok( CloseWindowStation( w3 ), "CloseWindowStation failed\n" ); - w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); - ok( !w3, "open foobar station succeeded\n" ); + w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); + ok( !w3, "open foobar station succeeded\n" ); - w2 = CreateWindowStation("foobar1", 0, WINSTA_ALL_ACCESS, NULL ); - ok( w2 != 0, "create foobar station failed\n" ); - w3 = CreateWindowStation("foobar2", 0, WINSTA_ALL_ACCESS, NULL ); - ok( w3 != 0, "create foobar station failed\n" ); - ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); - ok( GetHandleInformation( w3, &flags ), "GetHandleInformation failed\n" ); + w2 = CreateWindowStation("foobar1", 0, WINSTA_ALL_ACCESS, NULL ); + ok( w2 != 0, "create foobar station failed\n" ); + w3 = CreateWindowStation("foobar2", 0, WINSTA_ALL_ACCESS, NULL ); + ok( w3 != 0, "create foobar station failed\n" ); + ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); + ok( GetHandleInformation( w3, &flags ), "GetHandleInformation failed\n" ); - SetProcessWindowStation( w2 ); - register_class(); - atom = GlobalAddAtomA("foo"); - ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" ); - ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer ); + SetProcessWindowStation( w2 ); + atom = GlobalAddAtomA("foo"); + ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" ); + ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer ); - ok( !CloseWindowStation( w2 ), "CloseWindowStation succeeded\n" ); - ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); + ok( !CloseWindowStation( w2 ), "CloseWindowStation succeeded\n" ); + ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); - SetProcessWindowStation( w3 ); - ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); - ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); - ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" ); - ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer ); + SetProcessWindowStation( w3 ); + ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); + ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); + ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" ); + ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer ); + } + else if (le == ERROR_ACCESS_DENIED) + win_skip( "Not enough privileges for CreateWindowStation\n" ); /* desktops */ d1 = GetThreadDesktop(GetCurrentThreadId()); @@ -251,6 +262,7 @@ static void test_handles(void) d2 = GetThreadDesktop(GetCurrentThreadId()); ok( d1 == d2, "got different handles after close\n" ); + register_class(); trace( "thread 1 desktop: %p\n", d1 ); print_object( d1 ); hthread = CreateThread( NULL, 0, thread, (LPVOID)2, 0, &id );