ReactOS  0.4.14-dev-49-gfb4591c
NtUserGetIconInfo.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL - See COPYING in the top level directory
4  * PURPOSE: Test for NtUserGetIconInfo
5  * PROGRAMMERS:
6  */
7 
8 #include <win32nt.h>
9 
10 START_TEST(NtUserGetIconInfo)
11 {
12  HICON hIcon;
13  ICONINFO iinfo;
15  UNICODE_STRING hInstStr;
16  UNICODE_STRING ResourceStr;
17  DWORD bpp = 0;
18 
19  ZeroMemory(&iinfo, sizeof(ICONINFO));
20 
21  /* BASIC TESTS */
23  TEST(hIcon != NULL);
24 
25  /* Last param is unknown */
26  TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, FALSE) == FALSE);
27  TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, TRUE) == FALSE);
28 
30 
31  mask = CreateBitmap(16,16,1,1,NULL);
32  color = CreateBitmap(16,16,1,16,NULL);
33 
34  iinfo.hbmMask = mask;
35  iinfo.hbmColor = color ;
36  iinfo.fIcon = TRUE;
37  iinfo.xHotspot = 8;
38  iinfo.yHotspot = 8;
39 
40  hIcon = CreateIconIndirect(&iinfo);
41  TEST(hIcon!=NULL);
42 
43  // TODO : test last parameter...
44  TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, FALSE) == TRUE);
45 
46  TEST(iinfo.hbmMask != NULL);
47  TEST(iinfo.hbmColor != NULL);
48  TEST(iinfo.fIcon == TRUE);
49  TEST(iinfo.yHotspot == 8);
50  TEST(iinfo.xHotspot == 8);
51 
52  TEST(iinfo.hbmMask != mask);
53  TEST(iinfo.hbmColor != color);
54 
55  /* Does it make a difference? */
56  TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, TRUE) == TRUE);
57 
58  TEST(iinfo.hbmMask != NULL);
59  TEST(iinfo.hbmColor != NULL);
60  TEST(iinfo.fIcon == TRUE);
61  TEST(iinfo.yHotspot == 8);
62  TEST(iinfo.xHotspot == 8);
63 
64  TEST(iinfo.hbmMask != mask);
65  TEST(iinfo.hbmColor != color);
66 
69 
71 
72  /* Test full param, with local icon */
75  IMAGE_ICON,
76  0,
77  0,
79 
80  TEST(hIcon != NULL);
81 
82  RtlInitUnicodeString(&hInstStr, NULL);
83  RtlInitUnicodeString(&ResourceStr, NULL);
84 
85  TEST(NtUserGetIconInfo(hIcon,
86  &iinfo,
87  &hInstStr,
88  &ResourceStr,
89  &bpp,
90  FALSE) == TRUE);
91 
92  ok(hInstStr.Buffer == NULL, "hInstStr.buffer : %p\n", hInstStr.Buffer);
93  TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(IDI_ICON));
94  TEST(bpp == 32);
95 
96  /* Last param doesn't seem to matter*/
97  TEST(NtUserGetIconInfo(hIcon,
98  &iinfo,
99  &hInstStr,
100  &ResourceStr,
101  &bpp,
102  TRUE) == TRUE);
103 
104  ok(hInstStr.Buffer == NULL, "hInstStr.buffer : %p\n", hInstStr.Buffer);
105  TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(IDI_ICON));
106  TEST(bpp == 32);
107 
109 
110  /* Test full param, with foreign icon */
111  hIcon = LoadImageA(GetModuleHandleA("shell32.dll"),
112  MAKEINTRESOURCE(293),
113  IMAGE_ICON,
114  0,
115  0,
117 
118  TEST(hIcon != NULL);
119 
120  hInstStr.Buffer = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
121  hInstStr.MaximumLength = MAX_PATH;
122  hInstStr.Length = 0;
123  RtlInitUnicodeString(&ResourceStr, NULL);
124 
125  TEST(NtUserGetIconInfo(hIcon,
126  &iinfo,
127  &hInstStr,
128  &ResourceStr,
129  &bpp,
130  FALSE) == TRUE);
131 
132  TEST(hInstStr.Length != 0);
133  hInstStr.Buffer[hInstStr.Length] = 0;
134  printf("%s,%i: hInstStr.buffer : %S\n", __FUNCTION__, __LINE__, hInstStr.Buffer);
135  TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(293));
136  TEST(ResourceStr.Length == 0);
137  TEST(ResourceStr.MaximumLength == 0);
138  TEST(bpp == 32);
139 
140  ZeroMemory(hInstStr.Buffer, MAX_PATH*sizeof(WCHAR));
141  hInstStr.Length = 0;
142  RtlInitUnicodeString(&ResourceStr, NULL);
143 
144  TEST(NtUserGetIconInfo(hIcon,
145  &iinfo,
146  &hInstStr,
147  &ResourceStr,
148  &bpp,
149  TRUE) == TRUE);
150 
151  TEST(hInstStr.Length != 0);
152  hInstStr.Buffer[hInstStr.Length] = 0;
153  printf("%s,%i: hInstStr.buffer : %S\n", __FUNCTION__, __LINE__, hInstStr.Buffer);
154  TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(293));
155  TEST(bpp == 32);
156 
158 
159 }
#define IDI_ICON
Definition: resource.h:5
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define IMAGE_ICON
Definition: winuser.h:212
USHORT MaximumLength
Definition: env_spec_w32.h:370
BOOL NTAPI NtUserDestroyCursor(_In_ HANDLE Handle, _In_ BOOL bForce)
Definition: cursoricon.c:793
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
DWORD yHotspot
Definition: winuser.h:3099
DWORD_PTR NTAPI NtUserCallOneParam(DWORD_PTR Param, DWORD Routine)
Definition: simplecall.c:145
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
START_TEST(NtUserGetIconInfo)
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint color
Definition: glext.h:6243
HBITMAP hbmMask
Definition: winuser.h:3100
smooth NULL
Definition: ftsmooth.c:416
HBITMAP hbmColor
Definition: winuser.h:3101
BOOL fIcon
Definition: winuser.h:3097
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define LR_DEFAULTSIZE
Definition: winuser.h:1084
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TEST(x)
Definition: precomp.h:20
DWORD xHotspot
Definition: winuser.h:3098
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2546
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
HANDLE WINAPI LoadImageA(_In_opt_ HINSTANCE, _In_ LPCSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2147
#define GetModuleHandle
Definition: winbase.h:3644
HICON hIcon
Definition: msconfig.c:44
#define ok(value,...)
Definition: atltest.h:57
#define _ONEPARAM_ROUTINE_CREATEEMPTYCUROBJECT
Definition: w32knapi.h:63
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
DWORD bpp
Definition: surface.c:181
static HBITMAP
Definition: button.c:44
#define __FUNCTION__
Definition: types.h:112
#define printf
Definition: config.h:203
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)