From 6213505227adaf491885797305c2a3e5f93a0530 Mon Sep 17 00:00:00 2001 From: Andrew Riedi Date: Wed, 26 Dec 2007 17:41:10 -0800 Subject: [PATCH] user32: Test destroying the cursor of a parent process. --- dlls/user32/tests/cursoricon.c | 73 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index 781282c..b28d3a5 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -32,6 +32,77 @@ #include "wingdi.h" #include "winuser.h" +static char **test_argv; +static int test_argc; + +static void do_child_tests(HCURSOR cursor) +{ + BOOL ret; + DWORD error; + + /* Test destroying the cursor of a parent process. */ + SetLastError(0xdeadbeef); + ret = DestroyCursor(cursor); + todo_wine { + ok(!ret, "DestroyCursor on the active cursor succeeded.\n"); + error = GetLastError(); + ok(error == ERROR_DESTROY_OBJECT_OF_OTHER_THREAD, "Last error: 0x%x\n", error); + } +} + +static void init(void) +{ + test_argc = winetest_get_mainargs(&test_argv); + + /* Child process. */ + if (test_argc >= 3) + { + HCURSOR handle; + + sscanf(test_argv[2], "%x", (unsigned int *) &handle); + do_child_tests(handle); + exit(0); + } +} + +void test_child_process(void) +{ + static const BYTE bmp_bits[4096]; + char path_name[MAX_PATH]; + PROCESS_INFORMATION info; + STARTUPINFOA startup; + HCURSOR cursor; + ICONINFO cursorInfo; + UINT display_bpp; + HDC hdc; + + /* Create and set a dummy 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); + + SetCursor(cursor); + + /* Start child process and pass 'cursor' along. */ + memset(&startup, 0, sizeof(startup)); + startup.cb = sizeof(startup); + startup.dwFlags = STARTF_USESHOWWINDOW; + startup.wShowWindow = SW_SHOWNORMAL; + + sprintf(path_name, "%s cursoricon %x", test_argv[0], (unsigned int) cursor); + ok(CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess failed.\n"); + ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination failed.\n"); +} + static void test_CopyImage_Check(HBITMAP bitmap, UINT flags, INT copyWidth, INT copyHeight, INT expectedWidth, INT expectedHeight, WORD expectedDepth, BOOL dibExpected) { @@ -471,6 +542,7 @@ static void test_DestroyCursor(void) START_TEST(cursoricon) { + init(); test_CopyImage_Bitmap(1); test_CopyImage_Bitmap(4); test_CopyImage_Bitmap(8); @@ -480,4 +552,5 @@ START_TEST(cursoricon) test_initial_cursor(); test_CreateIcon(); test_DestroyCursor(); + test_child_process(); } -- 1.4.4.2