Reactos

[SHLWAPI_APITEST] Add test for SHAreIconsEqual

+105 -1
modules/rostests/apitests/shlwapi/16_32_black.ico

This is a binary file and will not be displayed.

modules/rostests/apitests/shlwapi/16_32_red.ico

This is a binary file and will not be displayed.

modules/rostests/apitests/shlwapi/16_8_black.ico

This is a binary file and will not be displayed.

modules/rostests/apitests/shlwapi/16_8_red.ico

This is a binary file and will not be displayed.

modules/rostests/apitests/shlwapi/32_32.ico

This is a binary file and will not be displayed.

modules/rostests/apitests/shlwapi/32_8.ico

This is a binary file and will not be displayed.

+3 -1
modules/rostests/apitests/shlwapi/CMakeLists.txt
··· 5 5 PathIsUNCServer.c 6 6 PathIsUNCServerShare.c 7 7 PathUnExpandEnvStrings.c 8 + SHAreIconsEqual.c 8 9 StrFormatByteSizeW.c 10 + testdata.rc 9 11 testlist.c) 10 12 11 13 add_executable(shlwapi_apitest ${SOURCE}) 12 14 set_module_type(shlwapi_apitest win32cui) 13 15 target_link_libraries(shlwapi_apitest ${PSEH_LIB}) 14 - add_importlibs(shlwapi_apitest shlwapi msvcrt kernel32) 16 + add_importlibs(shlwapi_apitest shlwapi user32 msvcrt kernel32) 15 17 add_rostests_file(TARGET shlwapi_apitest)
+81
modules/rostests/apitests/shlwapi/SHAreIconsEqual.c
··· 1 + /* 2 + * PROJECT: ReactOS api tests 3 + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 + * PURPOSE: Tests for SHAreIconsEqual 5 + * COPYRIGHT: Copyright 2018 Mark Jansen (mark.jansen@reactos.org) 6 + */ 7 + 8 + #include <apitest.h> 9 + #include <shlwapi.h> 10 + #include "resource.h" 11 + 12 + static BOOL (WINAPI *pSHAreIconsEqual)(HICON hIcon1, HICON hIcon2); 13 + 14 + static const char* names[] = 15 + { 16 + "16_8_black", 17 + "16_8_red", 18 + "16_32_black", 19 + "16_32_red", 20 + "32_8", 21 + "32_32", 22 + }; 23 + 24 + void compare_icons_imp(int id1, int id2, BOOL expected) 25 + { 26 + HICON icon1 = LoadImageA(GetModuleHandle(NULL), MAKEINTRESOURCEA(id1), IMAGE_ICON, 0, 0, 0); 27 + HICON icon2 = LoadImageA(GetModuleHandle(NULL), MAKEINTRESOURCEA(id2), IMAGE_ICON, 0, 0, 0); 28 + 29 + BOOL result = pSHAreIconsEqual(icon1, icon2); 30 + 31 + winetest_ok(icon1 != icon2, "Expected two different handles for %s==%s\n", names[id1-1], names[id2-1]); 32 + winetest_ok(result == expected, "Expected %d, got %d for %s==%s\n", expected, result, names[id1-1], names[id2-1]); 33 + 34 + DestroyIcon(icon1); 35 + DestroyIcon(icon2); 36 + } 37 + 38 + #define compare_icons (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : compare_icons_imp 39 + 40 + 41 + 42 + START_TEST(SHAreIconsEqual) 43 + { 44 + HMODULE module = LoadLibraryA("shlwapi.dll"); 45 + BOOL Continue = FALSE; 46 + pSHAreIconsEqual = (void*)GetProcAddress(module, MAKEINTRESOURCEA(548)); 47 + if (!pSHAreIconsEqual) 48 + { 49 + skip("SHAreIconsEqual not exported\n"); 50 + return; 51 + } 52 + 53 + _SEH2_TRY 54 + { 55 + pSHAreIconsEqual((HICON)IDC_APPSTARTING, (HICON)IDC_APPSTARTING); 56 + Continue = TRUE; 57 + } 58 + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 59 + { 60 + Continue = FALSE; 61 + trace("SHAreIconsEqual not implemented?\n"); 62 + } 63 + _SEH2_END; 64 + 65 + if (!Continue) 66 + { 67 + return; 68 + } 69 + 70 + ok(pSHAreIconsEqual((HICON)NULL, (HICON)NULL) == FALSE, "NULL\n"); 71 + ok(pSHAreIconsEqual((HICON)IDC_APPSTARTING, (HICON)IDC_APPSTARTING) == FALSE, "IDC_APPSTARTING\n"); 72 + ok(pSHAreIconsEqual((HICON)IDC_ARROW, (HICON)IDC_ARROW) == FALSE, "IDC_ARROW\n"); 73 + ok(pSHAreIconsEqual((HICON)IDC_SIZENESW, (HICON)IDC_SIZENESW) == FALSE, "IDC_SIZENESW\n"); 74 + 75 + compare_icons(ICON_16_8_BLACK, ICON_16_8_BLACK, TRUE); 76 + compare_icons(ICON_16_8_BLACK, ICON_16_8_RED, FALSE); 77 + compare_icons(ICON_16_8_BLACK, ICON_16_32_BLACK, FALSE); 78 + compare_icons(ICON_16_8_BLACK, ICON_16_32_RED, FALSE); 79 + compare_icons(ICON_16_8_BLACK, ICON_32_8, FALSE); 80 + compare_icons(ICON_16_8_BLACK, ICON_32_32, FALSE); 81 + }
+9
modules/rostests/apitests/shlwapi/resource.h
··· 1 + 2 + #define ICON_16_8_BLACK 1 3 + #define ICON_16_8_RED 2 4 + #define ICON_16_32_BLACK 3 5 + #define ICON_16_32_RED 4 6 + #define ICON_32_8 5 7 + #define ICON_32_32 6 8 + 9 +
+10
modules/rostests/apitests/shlwapi/testdata.rc
··· 1 + 2 + #include "resource.h" 3 + 4 + ICON_16_8_BLACK ICON "16_8_black.ico" 5 + ICON_16_8_RED ICON "16_8_red.ico" 6 + ICON_16_32_BLACK ICON "16_32_black.ico" 7 + ICON_16_32_RED ICON "16_32_red.ico" 8 + ICON_32_8 ICON "32_8.ico" 9 + ICON_32_32 ICON "32_32.ico" 10 +
+2
modules/rostests/apitests/shlwapi/testlist.c
··· 6 6 extern void func_isuncpathserver(void); 7 7 extern void func_isuncpathservershare(void); 8 8 extern void func_PathUnExpandEnvStrings(void); 9 + extern void func_SHAreIconsEqual(void); 9 10 extern void func_StrFormatByteSizeW(void); 10 11 11 12 const struct test winetest_testlist[] = ··· 15 16 { "PathIsUNCServer", func_isuncpathserver }, 16 17 { "PathIsUNCServerShare", func_isuncpathservershare }, 17 18 { "PathUnExpandEnvStrings", func_PathUnExpandEnvStrings }, 19 + { "SHAreIconsEqual", func_SHAreIconsEqual }, 18 20 { "StrFormatByteSizeW", func_StrFormatByteSizeW }, 19 21 { 0, 0 } 20 22 };