ReactOS 0.4.16-dev-197-g92996da
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#include "../resource.h"
10
11START_TEST(NtUserGetIconInfo)
12{
14 ICONINFO iinfo;
16 UNICODE_STRING hInstStr;
17 UNICODE_STRING ResourceStr;
18 DWORD bpp = 0;
19
20 ZeroMemory(&iinfo, sizeof(ICONINFO));
21
22 /* BASIC TESTS */
24 TEST(hIcon != NULL);
25
26 /* Last param is unknown */
27 TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, FALSE) == FALSE);
28 TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, TRUE) == FALSE);
29
31
32 mask = CreateBitmap(16,16,1,1,NULL);
33 color = CreateBitmap(16,16,1,16,NULL);
34
35 iinfo.hbmMask = mask;
36 iinfo.hbmColor = color ;
37 iinfo.fIcon = TRUE;
38 iinfo.xHotspot = 8;
39 iinfo.yHotspot = 8;
40
41 hIcon = CreateIconIndirect(&iinfo);
42 TEST(hIcon!=NULL);
43
44 // TODO : test last parameter...
45 TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, FALSE) == TRUE);
46
47 TEST(iinfo.hbmMask != NULL);
48 TEST(iinfo.hbmColor != NULL);
49 TEST(iinfo.fIcon == TRUE);
50 TEST(iinfo.yHotspot == 8);
51 TEST(iinfo.xHotspot == 8);
52
53 TEST(iinfo.hbmMask != mask);
54 TEST(iinfo.hbmColor != color);
55
56 /* Does it make a difference? */
57 TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, TRUE) == TRUE);
58
59 TEST(iinfo.hbmMask != NULL);
60 TEST(iinfo.hbmColor != NULL);
61 TEST(iinfo.fIcon == TRUE);
62 TEST(iinfo.yHotspot == 8);
63 TEST(iinfo.xHotspot == 8);
64
65 TEST(iinfo.hbmMask != mask);
66 TEST(iinfo.hbmColor != color);
67
70
72
73 /* Test full param, with local icon */
77 0,
78 0,
80
81 TEST(hIcon != NULL);
82
83 RtlInitUnicodeString(&hInstStr, NULL);
84 RtlInitUnicodeString(&ResourceStr, NULL);
85
86 TEST(NtUserGetIconInfo(hIcon,
87 &iinfo,
88 &hInstStr,
89 &ResourceStr,
90 &bpp,
91 FALSE) == TRUE);
92
93 ok(hInstStr.Buffer == NULL, "hInstStr.buffer : %p\n", hInstStr.Buffer);
94 TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(IDI_ICON));
95 TEST(bpp == 32);
96
97 /* Last param doesn't seem to matter*/
98 TEST(NtUserGetIconInfo(hIcon,
99 &iinfo,
100 &hInstStr,
101 &ResourceStr,
102 &bpp,
103 TRUE) == TRUE);
104
105 ok(hInstStr.Buffer == NULL, "hInstStr.buffer : %p\n", hInstStr.Buffer);
106 TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(IDI_ICON));
107 TEST(bpp == 32);
108
110
111 /* Test full param, with foreign icon */
112 hIcon = LoadImageA(GetModuleHandleA("shell32.dll"),
113 MAKEINTRESOURCE(293),
115 0,
116 0,
118
119 TEST(hIcon != NULL);
120
121 hInstStr.Buffer = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
122 hInstStr.MaximumLength = MAX_PATH;
123 hInstStr.Length = 0;
124 RtlInitUnicodeString(&ResourceStr, NULL);
125
126 TEST(NtUserGetIconInfo(hIcon,
127 &iinfo,
128 &hInstStr,
129 &ResourceStr,
130 &bpp,
131 FALSE) == TRUE);
132
133 TEST(hInstStr.Length != 0);
134 hInstStr.Buffer[hInstStr.Length] = 0;
135 printf("%s,%i: hInstStr.buffer : %S\n", __FUNCTION__, __LINE__, hInstStr.Buffer);
136 TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(293));
137 TEST(ResourceStr.Length == 0);
138 TEST(ResourceStr.MaximumLength == 0);
139 TEST(bpp == 32);
140
141 ZeroMemory(hInstStr.Buffer, MAX_PATH*sizeof(WCHAR));
142 hInstStr.Length = 0;
143 RtlInitUnicodeString(&ResourceStr, NULL);
144
145 TEST(NtUserGetIconInfo(hIcon,
146 &iinfo,
147 &hInstStr,
148 &ResourceStr,
149 &bpp,
150 TRUE) == TRUE);
151
152 TEST(hInstStr.Length != 0);
153 hInstStr.Buffer[hInstStr.Length] = 0;
154 printf("%s,%i: hInstStr.buffer : %S\n", __FUNCTION__, __LINE__, hInstStr.Buffer);
155 TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(293));
156 TEST(bpp == 32);
157
159
160}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define IDI_ICON
Definition: resource.h:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD bpp
Definition: surface.c:185
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define __FUNCTION__
Definition: types.h:116
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
pKey DeleteObject()
GLuint color
Definition: glext.h:6243
GLenum GLint GLuint mask
Definition: glext.h:6028
BOOL NTAPI NtUserDestroyCursor(_In_ HANDLE Handle, _In_ BOOL bForce)
Definition: cursoricon.c:793
DWORD_PTR NTAPI NtUserCallOneParam(DWORD_PTR Param, DWORD Routine)
Definition: simplecall.c:153
#define TEST(x)
Definition: precomp.h:20
static HBITMAP
Definition: button.c:44
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
DWORD yHotspot
Definition: winuser.h:3128
BOOL fIcon
Definition: winuser.h:3126
DWORD xHotspot
Definition: winuser.h:3127
HBITMAP hbmColor
Definition: winuser.h:3130
HBITMAP hbmMask
Definition: winuser.h:3129
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define _ONEPARAM_ROUTINE_CREATEEMPTYCUROBJECT
Definition: w32knapi.h:62
#define ZeroMemory
Definition: winbase.h:1736
#define GetModuleHandle
Definition: winbase.h:3851
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2633
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageA(_In_opt_ HINSTANCE hInst, _In_ LPCSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2230
#define LR_DEFAULTSIZE
Definition: winuser.h:1097
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2105
__wchar_t WCHAR
Definition: xmlstorage.h:180
const CHAR * LPCTSTR
Definition: xmlstorage.h:193