ReactOS 0.4.15-dev-6069-g56a4501
PrivateExtractIcons.c
Go to the documentation of this file.
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
10static struct
11{
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
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)UlongToHandle(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)UlongToHandle(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 if (cIcons == 0xFFFFFFFF)
48 {
49 ok(aIconId == 0xdeadbeef, "PrivateExtractIconsW(%u): id should not be set\n", i);
50 }
51 else
52 {
53 ok(aIconId != 0xdeadbeef, "PrivateExtractIconsW(%u): id not set\n", i);
54 }
55 if (ahIcon && ahIcon != (HICON)UlongToHandle(0xdeadbeef))
56 DestroyIcon(ahIcon);
57 }
58}
static struct @1578 IconTests[]
BOOL bhIconValid
PCWSTR FilePath
UINT cIcons
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static HICON
Definition: imagelist.c:84
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:68
const uint16_t * PCWSTR
Definition: typedefs.h:57
UINT WINAPI PrivateExtractIconsW(_In_reads_(MAX_PATH) LPCWSTR szFileName, _In_ int nIconIndex, _In_ int cxIcon, _In_ int cyIcon, _Out_writes_opt_(nIcons) HICON *phicon, _Out_writes_opt_(nIcons) UINT *piconid, _In_ UINT nIcons, _In_ UINT flags)
#define PrivateExtractIcons
Definition: winuser.h:5824
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022