[USER32_APITEST] Add a test for PrivateExtractIcons(A/W) that shows that this API...
[reactos.git] / modules / rostests / apitests / user32 / PrivateExtractIcons.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for PrivateExtractIcons
5 * PROGRAMMER: Hermes Belusca-Maito
6 */
7
8 #include "precomp.h"
9
10 static struct
11 {
12 PCWSTR FilePath;
13 UINT cIcons; // Return value from PrivateExtractIconsW
14 BOOL bhIconValid; // Whether or not the returned icon handle is not NULL.
15 } IconTests[] =
16 {
17 /* Executables with icons */
18 {L"notepad.exe", 1, TRUE},
19 {L"%SystemRoot%\\System32\\cmd.exe", 1, TRUE},
20
21 /* Executable without icon */
22 {L"%SystemRoot%\\System32\\autochk.exe", 0, FALSE},
23
24 /* Existing file */
25 {L"%SystemRoot%\\System32\\shell32.dll", 1, TRUE},
26
27 /* Non-existing files */
28 {L"%SystemRoot%\\non-existent-file.sdf", 0xFFFFFFFF, FALSE},
29 };
30
31 START_TEST(PrivateExtractIcons)
32 {
33 HICON ahIcon;
34 UINT i, aIconId, cIcons;
35
36 for (i = 0; i < _countof(IconTests); ++i)
37 {
38 /* Always test extraction of the FIRST icon (index 0) */
39 ahIcon = (HICON)0xdeadbeef;
40 aIconId = 0xdeadbeef;
41 cIcons = PrivateExtractIconsW(IconTests[i].FilePath, 0, 16, 16, &ahIcon, &aIconId, 1, 0);
42 ok(cIcons == IconTests[i].cIcons, "PrivateExtractIconsW(%u): got %u, expected %u\n", i, cIcons, IconTests[i].cIcons);
43 ok(ahIcon != (HICON)0xdeadbeef, "PrivateExtractIconsW(%u): icon not set\n", i);
44 ok((IconTests[i].bhIconValid && ahIcon) || (!IconTests[i].bhIconValid && !ahIcon),
45 "PrivateExtractIconsW(%u): icon expected to be %s, but got 0x%p\n",
46 i, IconTests[i].bhIconValid ? "valid" : "not valid", ahIcon);
47 ok(aIconId != 0xdeadbeef, "PrivateExtractIconsW(%u): id not set\n", i);
48 if (ahIcon && ahIcon != (HICON)0xdeadbeef)
49 DestroyIcon(ahIcon);
50 }
51 }