From 754a2fa8724a3efdd5055bff7e369604ac7e5205 Mon Sep 17 00:00:00 2001 From: Mark Jansen Date: Mon, 5 Mar 2018 22:18:21 +0100 Subject: [PATCH] [SHLWAPI_APITEST] Add test for SHAreIconsEqual --- .../rostests/apitests/shlwapi/16_32_black.ico | Bin 0 -> 1150 bytes .../rostests/apitests/shlwapi/16_32_red.ico | Bin 0 -> 1150 bytes .../rostests/apitests/shlwapi/16_8_black.ico | Bin 0 -> 1406 bytes .../rostests/apitests/shlwapi/16_8_red.ico | Bin 0 -> 1406 bytes modules/rostests/apitests/shlwapi/32_32.ico | Bin 0 -> 4286 bytes modules/rostests/apitests/shlwapi/32_8.ico | Bin 0 -> 2238 bytes .../rostests/apitests/shlwapi/CMakeLists.txt | 4 +- .../apitests/shlwapi/SHAreIconsEqual.c | 81 ++++++++++++++++++ modules/rostests/apitests/shlwapi/resource.h | 9 ++ modules/rostests/apitests/shlwapi/testdata.rc | 10 +++ modules/rostests/apitests/shlwapi/testlist.c | 2 + 11 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 modules/rostests/apitests/shlwapi/16_32_black.ico create mode 100644 modules/rostests/apitests/shlwapi/16_32_red.ico create mode 100644 modules/rostests/apitests/shlwapi/16_8_black.ico create mode 100644 modules/rostests/apitests/shlwapi/16_8_red.ico create mode 100644 modules/rostests/apitests/shlwapi/32_32.ico create mode 100644 modules/rostests/apitests/shlwapi/32_8.ico create mode 100644 modules/rostests/apitests/shlwapi/SHAreIconsEqual.c create mode 100644 modules/rostests/apitests/shlwapi/resource.h create mode 100644 modules/rostests/apitests/shlwapi/testdata.rc diff --git a/modules/rostests/apitests/shlwapi/16_32_black.ico b/modules/rostests/apitests/shlwapi/16_32_black.ico new file mode 100644 index 0000000000000000000000000000000000000000..f93cf06c1d70546c3895f0b5b96c6bb633e8cc09 GIT binary patch literal 1150 zcmd^6v5JF05M4px8qq?ou)0RLFGyvV4@f2c!a+X3#v+9_f^BNQAP7PbA%9@2jUZy3 zQc%;p+x1}4C8@4DZe+)qH}CDv&JrTgPuB_cALL6Wy_8bvV^YdxZm#!76btt$KiD` zV12Ch=kpnd!-3P9rh#D?JQo9Yhqd1KeYmd6X_w0drfKqA3`G6ubb_X7SkH&`^vXni zk|fyg_ZWr&RaIe{rl(R>Rnc|bGUq(cIj8S?$g+&KZ8`QVNYfOSWi9&K?Y5zWVYuK? l6d{gd>~_0NeVwpg*_oncSqAoYp68(`3bFiWbNXJtvTt9-hSLB5 literal 0 HcmV?d00001 diff --git a/modules/rostests/apitests/shlwapi/16_32_red.ico b/modules/rostests/apitests/shlwapi/16_32_red.ico new file mode 100644 index 0000000000000000000000000000000000000000..f6aadcd483a72f8fb5935398beba5556946e067e GIT binary patch literal 1150 zcmZQzU<5(|0R|wcz>vYhz#zuJz@P!dKp~(AL>x#lFmQlL6ypC70l$9z|Ns3vZpR8R z{{Jt)fQo=aXasvPVzj*@@>u&k~KRy&8 zkIn+Q16lvvY5)I6`Xf}`x&8mYk_dv2&I0)XS$}iQ|Nn{M2vwWb{r|5nh2W#J(Dk=B z{Qob@5A;7$_<-Dm3!v*?y5RqRKj;7dzkK=s|N7Pc|9||zu2Y)#|Nn;%AmO}w2SUx` zNB{o|v;6;m{~kgN8*9sk|No6tA^H#OMOD$$3K5^s_5c6m-v9p{%~0i$c_6of>_i9K aH~;?+io5#q|Nr;yLYE!6e3Zg~3=RM+h_I{x literal 0 HcmV?d00001 diff --git a/modules/rostests/apitests/shlwapi/16_8_black.ico b/modules/rostests/apitests/shlwapi/16_8_black.ico new file mode 100644 index 0000000000000000000000000000000000000000..5efc283ce2f2af302767ce9ece660ac9b39fb7c8 GIT binary patch literal 1406 zcmeH{y=uZx6vt0&(%RNEX`5P`erP{Z?bjWh+T9;5WF5XFfo!<|c%;vVX2i-@!p zAxRQsS%#u0P*oM0ra{+r7={7UG+|j5ve_(hxg7HOJPL&Zip3&Ir4q{JGAfk{s?{oL zwHoU6IvR}zn$0F!trpttHaeXSy4@~%y&n4gK5W~@U@(B=I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3w%>V!Z literal 0 HcmV?d00001 diff --git a/modules/rostests/apitests/shlwapi/CMakeLists.txt b/modules/rostests/apitests/shlwapi/CMakeLists.txt index 104f50bf860..da4c6a808f1 100644 --- a/modules/rostests/apitests/shlwapi/CMakeLists.txt +++ b/modules/rostests/apitests/shlwapi/CMakeLists.txt @@ -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 index 00000000000..27592325c79 --- /dev/null +++ b/modules/rostests/apitests/shlwapi/SHAreIconsEqual.c @@ -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 +#include +#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 index 00000000000..1e22985bdd3 --- /dev/null +++ b/modules/rostests/apitests/shlwapi/resource.h @@ -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 index 00000000000..b6aa19173ef --- /dev/null +++ b/modules/rostests/apitests/shlwapi/testdata.rc @@ -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" + diff --git a/modules/rostests/apitests/shlwapi/testlist.c b/modules/rostests/apitests/shlwapi/testlist.c index 1f3fc394983..793385e1a24 100644 --- a/modules/rostests/apitests/shlwapi/testlist.c +++ b/modules/rostests/apitests/shlwapi/testlist.c @@ -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 } };