From d93c98ed58841fdffa2ef2824ead9c9215bbd1b5 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Wed, 31 Oct 2012 14:18:06 +0000 Subject: [PATCH] [user32_apitest] - Add some tests to see how SetCursorPos is affected by the current desktop svn path=/trunk/; revision=57656 --- rostests/apitests/user32/SetCursorPos.c | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/rostests/apitests/user32/SetCursorPos.c b/rostests/apitests/user32/SetCursorPos.c index c084f7721bb..3236f366aee 100644 --- a/rostests/apitests/user32/SetCursorPos.c +++ b/rostests/apitests/user32/SetCursorPos.c @@ -159,7 +159,48 @@ void Test_SetCursorPos() } +void Test_DesktopAccess() +{ + HDESK hDesk, hDeskInitial; + POINT curPoint, initialPoint; + BOOL ret; + + hDeskInitial = GetThreadDesktop(GetCurrentThreadId()); + ok(hDeskInitial != NULL, "Failed to retrieve the initial desktop\n"); + + ret = GetCursorPos(&initialPoint); + ok(ret == TRUE, "GetCursorPos should succed\n"); + + hDesk = CreateDesktopW(L"testDesktop", NULL, NULL, 0, 0x01ff, NULL); + ok(hDesk != 0, "Failed to create a new desktop\n"); + SetThreadDesktop(hDesk); + ok(GetThreadDesktop(GetCurrentThreadId()) == hDesk, "SetThreadDesktop had no effect\n"); + + SetLastError(0xdeadbeef); + + ret = GetCursorPos(&curPoint); + ok(ret == FALSE, "GetCursorPos should fail\n"); + + ok(GetLastError() == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED got 0x%lu\n", GetLastError()); + SetLastError(0xdeadbeef); + + ret = SetCursorPos(2,2); + ok(ret == FALSE, "SetCursorPos should fail\n"); + + ok(GetLastError() == 0xdeadbeef, "Wrong last error, got 0x%lu\n", GetLastError()); + + ret = GetCursorPos(&curPoint); + ok(ret == FALSE, "GetCursorPos should fail\n"); + + SetThreadDesktop(hDeskInitial); + + ret = GetCursorPos(&curPoint); + ok(ret == TRUE, "GetCursorPos should succed\n"); + ok(curPoint.x == initialPoint.x && curPoint.y == initialPoint.y, "Mouse position changed\n"); +} + START_TEST(SetCursorPos) { + Test_DesktopAccess(); Test_SetCursorPos(); } \ No newline at end of file