From 5b99cd433dcd9bc16299133dc26404b68b58511c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Wed, 31 Oct 2012 14:08:31 +0000 Subject: [PATCH] [USER32_APITESTS] - Add some more test for DrawIconEx and CreateIconFromResourceEx svn path=/trunk/; revision=57655 --- rostests/apitests/user32/CMakeLists.txt | 2 + .../user32/CreateIconFromResourceEx.c | 48 ++++++++++++++++ rostests/apitests/user32/DrawIconEx.c | 57 +++++++++++++++++++ rostests/apitests/user32/testlist.c | 6 +- 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 rostests/apitests/user32/CreateIconFromResourceEx.c create mode 100644 rostests/apitests/user32/DrawIconEx.c diff --git a/rostests/apitests/user32/CMakeLists.txt b/rostests/apitests/user32/CMakeLists.txt index 8bb6e912b45..f23bd29b1c8 100644 --- a/rostests/apitests/user32/CMakeLists.txt +++ b/rostests/apitests/user32/CMakeLists.txt @@ -2,8 +2,10 @@ list(APPEND SOURCE AttachThreadInput.c helper.c + CreateIconFromResourceEx.c DeferWindowPos.c DestroyCursorIcon.c + DrawIconEx.c desktop.c GetIconInfo.c GetKeyState.c diff --git a/rostests/apitests/user32/CreateIconFromResourceEx.c b/rostests/apitests/user32/CreateIconFromResourceEx.c new file mode 100644 index 00000000000..baf3b6b9a35 --- /dev/null +++ b/rostests/apitests/user32/CreateIconFromResourceEx.c @@ -0,0 +1,48 @@ +#include +#include +#include +#include "resource.h" + +START_TEST(CreateIconFromResourceEx) +{ + HCURSOR hcur1, hcur2; + HMODULE hMod; + HRSRC hResource; // handle to FindResource + HRSRC hMem; // handle to LoadResource + BYTE *lpResource; // pointer to resource data + + hMod = GetModuleHandle(NULL); + ok(hMod != NULL, "\n"); + /* Create a shared cursor */ + hcur1 = LoadCursor(hMod, "TESTCURSOR"); + ok(hcur1 != NULL, "\n"); + + /* Create it manually using CreateIconFromResourceEx */ + hResource = FindResourceA(hMod, + "TESTCURSOR", + RT_GROUP_CURSOR); + ok(hResource != NULL, "\n"); + + hMem = LoadResource(hMod, hResource); + ok(hMem != NULL, "\n"); + + lpResource = LockResource(hMem); + ok(lpResource != NULL, "\n"); + + /* MSDN states that LR_SHARED permits to not load twice the same cursor again. + * But CreateIconFromResourceEx still returns two different handles */ + hcur2 = CreateIconFromResourceEx(lpResource, SizeofResource(hMod, hResource), FALSE, 0x00030000, 0, 0, LR_SHARED); + ok(hcur2 != NULL, "\n"); + ok(hcur2 != hcur1, "\n"); + hcur1 = CreateIconFromResourceEx(lpResource, SizeofResource(hMod, hResource), FALSE, 0x00030000, 0, 0, LR_SHARED); + ok(hcur1 != NULL, "\n"); + ok(hcur2 != hcur1, "\n"); + + /* Try to destroy them multiple times (see DestroyCursor test) */ + ok(DestroyCursor(hcur1), "\n"); + ok(DestroyCursor(hcur1), "\n"); + ok(DestroyCursor(hcur2), "\n"); + ok(DestroyCursor(hcur2), "\n"); + + FreeResource(hResource); +} \ No newline at end of file diff --git a/rostests/apitests/user32/DrawIconEx.c b/rostests/apitests/user32/DrawIconEx.c new file mode 100644 index 00000000000..820e713e591 --- /dev/null +++ b/rostests/apitests/user32/DrawIconEx.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include "resource.h" + +START_TEST(DrawIconEx) +{ + HCURSOR hcursor; + HBITMAP hbmp; + ICONINFO ii; + HDC hdcScreen, hdc; + BOOL ret; + HBRUSH hbrush; + + ZeroMemory(&ii, sizeof(ii)); + + ii.hbmMask = CreateBitmap(8, 16, 1, 1, NULL); + ok(ii.hbmMask != NULL, "\n"); + hcursor = CreateIconIndirect(&ii); + ok(hcursor != NULL, "\n"); + DeleteObject(ii.hbmMask); + + hdcScreen = GetDC(0); + hbmp = CreateCompatibleBitmap(hdcScreen, 8, 8); + ok(hbmp != NULL, "\n"); + hdc = CreateCompatibleDC(hdcScreen); + ok(hdc != NULL, "\n"); + ReleaseDC(0, hdcScreen); + + hbmp = SelectObject(hdc, hbmp); + ok(hbmp != NULL, "\n"); + + hbrush = GetStockObject(DKGRAY_BRUSH); + ok(hbrush != NULL, "\n"); + + ret = DrawIconEx(hdc, 0, 0, hcursor, 8, 8, 0, hbrush, DI_NORMAL); + ok(ret, "\n"); + DestroyCursor(hcursor); + + /* Try with color */ + ii.hbmMask = CreateBitmap(8, 8, 1, 1, NULL); + ok(ii.hbmMask != NULL, "\n"); + ii.hbmColor = CreateBitmap(8, 8, 16, 1, NULL); + ok(ii.hbmColor != NULL, "\n"); + hcursor = CreateIconIndirect(&ii); + ok(hcursor != NULL, "\n"); + DeleteObject(ii.hbmMask); + DeleteObject(ii.hbmColor); + + ret = DrawIconEx(hdc, 0, 0, hcursor, 8, 8, 0, hbrush, DI_NORMAL); + ok(ret, "\n"); + DestroyCursor(hcursor); + + hbmp = SelectObject(hdc, hbmp); + DeleteObject(hbmp); + DeleteDC(hdc); +} \ No newline at end of file diff --git a/rostests/apitests/user32/testlist.c b/rostests/apitests/user32/testlist.c index 9e86083bcc7..2b030a13a3c 100644 --- a/rostests/apitests/user32/testlist.c +++ b/rostests/apitests/user32/testlist.c @@ -6,8 +6,10 @@ #include "wine/test.h" extern void func_AttachThreadInput(void); +extern void func_CreateIconFromResourceEx(void); extern void func_DeferWindowPos(void); extern void func_DestroyCursorIcon(void); +extern void func_DrawIconEx(void); extern void func_desktop(void); extern void func_GetIconInfo(void); extern void func_GetKeyState(void); @@ -28,9 +30,11 @@ extern void func_wsprintf(void); const struct test winetest_testlist[] = { { "AttachThreadInput", func_AttachThreadInput }, - { "desktop", func_desktop }, + { "CreateIconFromResourceEx", func_CreateIconFromResourceEx }, { "DeferWindowPos", func_DeferWindowPos }, { "DestroyCursorIcon", func_DestroyCursorIcon }, + { "DrawIconEx", func_DrawIconEx }, + { "desktop", func_desktop }, { "GetIconInfo", func_GetIconInfo }, { "GetKeyState", func_GetKeyState }, { "GetPeekMessage", func_GetPeekMessage },