Various additional improvements to LoadIconMetric tests.

This commit is contained in:
Sebastian Lackner 2015-07-24 15:23:30 +02:00
parent 77d2d3e4e0
commit 2315442bb2

View File

@ -1,4 +1,4 @@
From c5fa9198dd9ab87266d6dc0c22504ccb9740b366 Mon Sep 17 00:00:00 2001
From 16706a9c1d322c48f94b51be8c0bbb52f3e4d0e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 7 Aug 2014 01:54:28 +0200
Subject: comctl32/tests: Add tests for LoadIconMetric function.
@ -7,13 +7,12 @@ Changes by Alistair Leslie-Hughes:
* Changed PCWSTR, CHAR, INT
* Changed LoadIconMetric to pLoadIconMetric
(caused a compile error since it's in the header).
---
dlls/comctl32/tests/misc.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
dlls/comctl32/tests/misc.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/dlls/comctl32/tests/misc.c b/dlls/comctl32/tests/misc.c
index 280b46c..d5d882d 100644
index 280b46c..b51873c 100644
--- a/dlls/comctl32/tests/misc.c
+++ b/dlls/comctl32/tests/misc.c
@@ -20,6 +20,7 @@
@ -33,94 +32,76 @@ index 280b46c..d5d882d 100644
static HMODULE hComctl32 = 0;
#define COMCTL32_GET_PROC(ordinal, func) \
@@ -205,6 +208,86 @@ static void test_TaskDialogIndirect(void)
@@ -205,6 +208,68 @@ static void test_TaskDialogIndirect(void)
ok(ptr == ptr2, "got wrong pointer for ordinal 345, %p expected %p\n", ptr2, ptr);
}
+static void test_LoadIconMetric(void)
+{
+ static const WCHAR nonExistingFile[] = {'d','o','e','s','n','o','t','e','x','i','s','t','.','i','c','o','\0'};
+ HINSTANCE hinst;
+ void *ptr;
+ HICON icon;
+ static const WCHAR non_existing_fileW[] = {'n','o','n','e','x','i','s','t','i','n','g','.','i','c','o','\0'};
+ HRESULT result;
+ ICONINFO info;
+ BOOL res;
+ int bytes;
+ HICON icon;
+ BITMAP bmp;
+ void *ptr;
+ int bytes;
+ BOOL res;
+
+ hinst = LoadLibraryA("comctl32.dll");
+
+ pLoadIconMetric = (void *)GetProcAddress(hinst, "LoadIconMetric");
+ pLoadIconMetric = (void *)GetProcAddress(hComctl32, "LoadIconMetric");
+ if (!pLoadIconMetric)
+ {
+ win_skip("LoadIconMetric not exported by name\n");
+ return;
+ }
+
+ ptr = GetProcAddress(hinst, (const char*)380);
+ ptr = GetProcAddress(hComctl32, (const char *)380);
+ ok(ptr == pLoadIconMetric, "got wrong pointer for ordinal 380, %p expected %p\n",
+ ptr, pLoadIconMetric);
+
+ result = pLoadIconMetric(NULL, (const WCHAR*)IDI_APPLICATION, LIM_SMALL, &icon);
+ ok(result == S_OK, "Expected S_OK, got %x\n", result);
+ if (result == S_OK)
+ {
+ res = GetIconInfo(icon, &info);
+ ok(res, "Failed to get icon info\n");
+ if (res && info.hbmColor)
+ {
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
+ if (bytes > 0)
+ {
+ ok(bmp.bmWidth == GetSystemMetrics( SM_CXSMICON ), "Wrong icon width\n");
+ ok(bmp.bmHeight == GetSystemMetrics( SM_CYSMICON ), "Wrong icon height\n");
+ }
+ }
+ DestroyIcon(icon);
+ }
+
+ result = pLoadIconMetric(NULL, (const WCHAR*)IDI_APPLICATION, LIM_LARGE, &icon);
+ ok(result == S_OK, "Expected S_OK, got %x\n", result);
+ if (result == S_OK)
+ {
+ res = GetIconInfo(icon, &info);
+ ok(res, "Failed to get icon info\n");
+ if (res && info.hbmColor)
+ {
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
+ if (bytes > 0)
+ {
+ ok(bmp.bmWidth == GetSystemMetrics( SM_CXICON ), "Wrong icon width\n");
+ ok(bmp.bmHeight == GetSystemMetrics( SM_CYICON ), "Wrong icon height\n");
+ }
+ }
+ DestroyIcon(icon);
+ }
+
+ result = pLoadIconMetric(NULL, (const WCHAR*)IDI_APPLICATION, 0x100, &icon);
+ result = pLoadIconMetric(NULL, (const WCHAR *)IDI_APPLICATION, 0x100, &icon);
+ ok(result == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", result);
+ if (result == S_OK) DestroyIcon(icon);
+
+ icon = (HICON)0x1234;
+ result = pLoadIconMetric(NULL, NULL, LIM_LARGE, &icon);
+ ok(result == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", result);
+ ok(icon == (HICON)0, "Expected 0x0, got %p\n", icon);
+ if (result == S_OK) DestroyIcon(icon);
+ ok(icon == NULL, "Expected NULL, got %p\n", icon);
+
+ result = pLoadIconMetric(NULL, nonExistingFile, LIM_LARGE, &icon);
+ result = pLoadIconMetric(NULL, non_existing_fileW, LIM_LARGE, &icon);
+ ok(result == HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND),
+ "Expected 80070715, got %x\n", result);
+ if (result == S_OK) DestroyIcon(icon);
+ "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %x\n", result);
+
+ result = pLoadIconMetric(NULL, (const WCHAR *)IDI_APPLICATION, LIM_SMALL, &icon);
+ ok(result == S_OK, "Expected S_OK, got %x\n", result);
+ res = GetIconInfo(icon, &info);
+ ok(res, "Failed to get icon info, error %d\n", GetLastError());
+ if (res && info.hbmColor)
+ {
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
+ ok(bmp.bmWidth == GetSystemMetrics(SM_CXSMICON), "Wrong icon width\n");
+ ok(bmp.bmHeight == GetSystemMetrics(SM_CYSMICON), "Wrong icon height\n");
+ }
+ DestroyIcon(icon);
+
+ result = pLoadIconMetric(NULL, (const WCHAR *)IDI_APPLICATION, LIM_LARGE, &icon);
+ ok(result == S_OK, "Expected S_OK, got %x\n", result);
+ res = GetIconInfo(icon, &info);
+ ok(res, "Failed to get icon info, error %d\n", GetLastError());
+ if (res && info.hbmColor)
+ {
+ bytes = GetObjectA(info.hbmColor, sizeof(bmp), &bmp);
+ ok(bytes > 0, "Failed to get bitmap info for icon\n");
+ ok(bmp.bmWidth == GetSystemMetrics(SM_CXICON), "Wrong icon width\n");
+ ok(bmp.bmHeight == GetSystemMetrics(SM_CYICON), "Wrong icon height\n");
+ }
+ DestroyIcon(icon);
+}
+
+
START_TEST(misc)
{
ULONG_PTR ctx_cookie;
@@ -220,6 +303,7 @@ START_TEST(misc)
@@ -220,6 +285,7 @@ START_TEST(misc)
return;
test_TaskDialogIndirect();