[SHLWAPI_APITEST] Add test for SHAreIconsEqual
authorMark Jansen <mark.jansen@reactos.org>
Mon, 5 Mar 2018 21:18:21 +0000 (22:18 +0100)
committerMark Jansen <mark.jansen@reactos.org>
Mon, 5 Mar 2018 21:43:17 +0000 (22:43 +0100)
modules/rostests/apitests/shlwapi/16_32_black.ico [new file with mode: 0644]
modules/rostests/apitests/shlwapi/16_32_red.ico [new file with mode: 0644]
modules/rostests/apitests/shlwapi/16_8_black.ico [new file with mode: 0644]
modules/rostests/apitests/shlwapi/16_8_red.ico [new file with mode: 0644]
modules/rostests/apitests/shlwapi/32_32.ico [new file with mode: 0644]
modules/rostests/apitests/shlwapi/32_8.ico [new file with mode: 0644]
modules/rostests/apitests/shlwapi/CMakeLists.txt
modules/rostests/apitests/shlwapi/SHAreIconsEqual.c [new file with mode: 0644]
modules/rostests/apitests/shlwapi/resource.h [new file with mode: 0644]
modules/rostests/apitests/shlwapi/testdata.rc [new file with mode: 0644]
modules/rostests/apitests/shlwapi/testlist.c

diff --git a/modules/rostests/apitests/shlwapi/16_32_black.ico b/modules/rostests/apitests/shlwapi/16_32_black.ico
new file mode 100644 (file)
index 0000000..f93cf06
Binary files /dev/null and b/modules/rostests/apitests/shlwapi/16_32_black.ico differ
diff --git a/modules/rostests/apitests/shlwapi/16_32_red.ico b/modules/rostests/apitests/shlwapi/16_32_red.ico
new file mode 100644 (file)
index 0000000..f6aadcd
Binary files /dev/null and b/modules/rostests/apitests/shlwapi/16_32_red.ico differ
diff --git a/modules/rostests/apitests/shlwapi/16_8_black.ico b/modules/rostests/apitests/shlwapi/16_8_black.ico
new file mode 100644 (file)
index 0000000..5efc283
Binary files /dev/null and b/modules/rostests/apitests/shlwapi/16_8_black.ico differ
diff --git a/modules/rostests/apitests/shlwapi/16_8_red.ico b/modules/rostests/apitests/shlwapi/16_8_red.ico
new file mode 100644 (file)
index 0000000..5b73a5d
Binary files /dev/null and b/modules/rostests/apitests/shlwapi/16_8_red.ico differ
diff --git a/modules/rostests/apitests/shlwapi/32_32.ico b/modules/rostests/apitests/shlwapi/32_32.ico
new file mode 100644 (file)
index 0000000..e49a3e2
Binary files /dev/null and b/modules/rostests/apitests/shlwapi/32_32.ico differ
diff --git a/modules/rostests/apitests/shlwapi/32_8.ico b/modules/rostests/apitests/shlwapi/32_8.ico
new file mode 100644 (file)
index 0000000..e098f7f
Binary files /dev/null and b/modules/rostests/apitests/shlwapi/32_8.ico differ
index 104f50b..da4c6a8 100644 (file)
@@ -5,11 +5,13 @@ list(APPEND SOURCE
     PathIsUNCServer.c
     PathIsUNCServerShare.c
     PathUnExpandEnvStrings.c
+    SHAreIconsEqual.c
     StrFormatByteSizeW.c
+    testdata.rc
     testlist.c)
 
 add_executable(shlwapi_apitest ${SOURCE})
 set_module_type(shlwapi_apitest win32cui)
 target_link_libraries(shlwapi_apitest ${PSEH_LIB})
-add_importlibs(shlwapi_apitest shlwapi msvcrt kernel32)
+add_importlibs(shlwapi_apitest shlwapi user32 msvcrt kernel32)
 add_rostests_file(TARGET shlwapi_apitest)
diff --git a/modules/rostests/apitests/shlwapi/SHAreIconsEqual.c b/modules/rostests/apitests/shlwapi/SHAreIconsEqual.c
new file mode 100644 (file)
index 0000000..2759232
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * PROJECT:     ReactOS api tests
+ * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE:     Tests for SHAreIconsEqual
+ * COPYRIGHT:   Copyright 2018 Mark Jansen (mark.jansen@reactos.org)
+ */
+
+#include <apitest.h>
+#include <shlwapi.h>
+#include "resource.h"
+
+static BOOL (WINAPI *pSHAreIconsEqual)(HICON hIcon1, HICON hIcon2);
+
+static const char* names[] =
+{
+    "16_8_black",
+    "16_8_red",
+    "16_32_black",
+    "16_32_red",
+    "32_8",
+    "32_32",
+};
+
+void compare_icons_imp(int id1, int id2, BOOL expected)
+{
+    HICON icon1 = LoadImageA(GetModuleHandle(NULL), MAKEINTRESOURCEA(id1), IMAGE_ICON, 0, 0, 0);
+    HICON icon2 = LoadImageA(GetModuleHandle(NULL), MAKEINTRESOURCEA(id2), IMAGE_ICON, 0, 0, 0);
+
+    BOOL result = pSHAreIconsEqual(icon1, icon2);
+
+    winetest_ok(icon1 != icon2, "Expected two different handles for %s==%s\n", names[id1-1], names[id2-1]);
+    winetest_ok(result == expected, "Expected %d, got %d for %s==%s\n", expected, result, names[id1-1], names[id2-1]);
+
+    DestroyIcon(icon1);
+    DestroyIcon(icon2);
+}
+
+#define compare_icons  (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : compare_icons_imp
+
+
+
+START_TEST(SHAreIconsEqual)
+{
+    HMODULE module = LoadLibraryA("shlwapi.dll");
+    BOOL Continue = FALSE;
+    pSHAreIconsEqual = (void*)GetProcAddress(module, MAKEINTRESOURCEA(548));
+    if (!pSHAreIconsEqual)
+    {
+        skip("SHAreIconsEqual not exported\n");
+        return;
+    }
+
+    _SEH2_TRY
+    {
+        pSHAreIconsEqual((HICON)IDC_APPSTARTING, (HICON)IDC_APPSTARTING);
+        Continue = TRUE;
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        Continue = FALSE;
+        trace("SHAreIconsEqual not implemented?\n");
+    }
+    _SEH2_END;
+
+    if (!Continue)
+    {
+        return;
+    }
+
+    ok(pSHAreIconsEqual((HICON)NULL, (HICON)NULL) == FALSE, "NULL\n");
+    ok(pSHAreIconsEqual((HICON)IDC_APPSTARTING, (HICON)IDC_APPSTARTING) == FALSE, "IDC_APPSTARTING\n");
+    ok(pSHAreIconsEqual((HICON)IDC_ARROW, (HICON)IDC_ARROW) == FALSE, "IDC_ARROW\n");
+    ok(pSHAreIconsEqual((HICON)IDC_SIZENESW, (HICON)IDC_SIZENESW) == FALSE, "IDC_SIZENESW\n");
+
+    compare_icons(ICON_16_8_BLACK, ICON_16_8_BLACK, TRUE);
+    compare_icons(ICON_16_8_BLACK, ICON_16_8_RED, FALSE);
+    compare_icons(ICON_16_8_BLACK, ICON_16_32_BLACK, FALSE);
+    compare_icons(ICON_16_8_BLACK, ICON_16_32_RED, FALSE);
+    compare_icons(ICON_16_8_BLACK, ICON_32_8, FALSE);
+    compare_icons(ICON_16_8_BLACK, ICON_32_32, FALSE);
+}
diff --git a/modules/rostests/apitests/shlwapi/resource.h b/modules/rostests/apitests/shlwapi/resource.h
new file mode 100644 (file)
index 0000000..1e22985
--- /dev/null
@@ -0,0 +1,9 @@
+
+#define ICON_16_8_BLACK     1
+#define ICON_16_8_RED       2
+#define ICON_16_32_BLACK    3
+#define ICON_16_32_RED      4
+#define ICON_32_8           5
+#define ICON_32_32          6
+
+
diff --git a/modules/rostests/apitests/shlwapi/testdata.rc b/modules/rostests/apitests/shlwapi/testdata.rc
new file mode 100644 (file)
index 0000000..b6aa191
--- /dev/null
@@ -0,0 +1,10 @@
+
+#include "resource.h"
+
+ICON_16_8_BLACK     ICON "16_8_black.ico"
+ICON_16_8_RED       ICON "16_8_red.ico"
+ICON_16_32_BLACK    ICON "16_32_black.ico"
+ICON_16_32_RED      ICON "16_32_red.ico"
+ICON_32_8           ICON "32_8.ico"
+ICON_32_32          ICON "32_32.ico"
+
index 1f3fc39..793385e 100644 (file)
@@ -6,6 +6,7 @@ extern void func_isuncpath(void);
 extern void func_isuncpathserver(void);
 extern void func_isuncpathservershare(void);
 extern void func_PathUnExpandEnvStrings(void);
+extern void func_SHAreIconsEqual(void);
 extern void func_StrFormatByteSizeW(void);
 
 const struct test winetest_testlist[] =
@@ -15,6 +16,7 @@ const struct test winetest_testlist[] =
     { "PathIsUNCServer", func_isuncpathserver },
     { "PathIsUNCServerShare", func_isuncpathservershare },
     { "PathUnExpandEnvStrings", func_PathUnExpandEnvStrings },
+    { "SHAreIconsEqual", func_SHAreIconsEqual },
     { "StrFormatByteSizeW", func_StrFormatByteSizeW },
     { 0, 0 }
 };