[W32KNAPI] - Add some more NtUserGetIconInfo tests
[reactos.git] / rostests / apitests / w32knapi / ntuser / NtUserGetIconInfo.c
1 INT
2 Test_NtUserGetIconInfo(PTESTINFO pti)
3 {
4 HICON hIcon;
5 ICONINFO iinfo;
6 HBITMAP mask, color;
7 UNICODE_STRING hInstStr;
8 UNICODE_STRING ResourceStr;
9 DWORD bpp = 0;
10
11 ZeroMemory(&iinfo, sizeof(ICONINFO));
12
13 /* BASIC TESTS */
14 hIcon = (HICON) NtUserCallOneParam(0, _ONEPARAM_ROUTINE_CREATEEMPTYCUROBJECT);
15 TEST(hIcon != NULL);
16
17 /* Last param is unknown */
18 TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, FALSE) == FALSE);
19 TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, TRUE) == FALSE);
20
21 TEST(NtUserDestroyCursor(hIcon, 0) == TRUE);
22
23 mask = CreateBitmap(16,16,1,1,NULL);
24 color = CreateBitmap(16,16,1,16,NULL);
25
26 iinfo.hbmMask = mask;
27 iinfo.hbmColor = color ;
28 iinfo.fIcon = TRUE;
29 iinfo.xHotspot = 8;
30 iinfo.yHotspot = 8;
31
32 hIcon = CreateIconIndirect(&iinfo);
33 TEST(hIcon!=NULL);
34
35 // TODO : test last parameter...
36 TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, FALSE) == TRUE);
37
38 TEST(iinfo.hbmMask != NULL);
39 TEST(iinfo.hbmColor != NULL);
40 TEST(iinfo.fIcon == TRUE);
41 TEST(iinfo.yHotspot == 8);
42 TEST(iinfo.xHotspot == 8);
43
44 TEST(iinfo.hbmMask != mask);
45 TEST(iinfo.hbmColor != color);
46
47 /* Does it make a difference? */
48 TEST(NtUserGetIconInfo(hIcon, &iinfo, NULL, NULL, NULL, TRUE) == TRUE);
49
50 TEST(iinfo.hbmMask != NULL);
51 TEST(iinfo.hbmColor != NULL);
52 TEST(iinfo.fIcon == TRUE);
53 TEST(iinfo.yHotspot == 8);
54 TEST(iinfo.xHotspot == 8);
55
56 TEST(iinfo.hbmMask != mask);
57 TEST(iinfo.hbmColor != color);
58
59 DeleteObject(mask);
60 DeleteObject(color);
61
62 DestroyIcon(hIcon);
63
64 /* Test full param, with local icon */
65 hIcon = LoadImageA(GetModuleHandle(NULL),
66 MAKEINTRESOURCE(IDI_ICON),
67 IMAGE_ICON,
68 0,
69 0,
70 LR_DEFAULTSIZE);
71
72 TEST(hIcon != NULL);
73
74 RtlInitUnicodeString(&hInstStr, NULL);
75 RtlInitUnicodeString(&ResourceStr, NULL);
76
77 TEST(NtUserGetIconInfo(hIcon,
78 &iinfo,
79 &hInstStr,
80 &ResourceStr,
81 &bpp,
82 FALSE) == TRUE);
83
84 TESTX(hInstStr.Buffer == NULL, "hInstStr.buffer : %p\n", hInstStr.Buffer);
85 TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(IDI_ICON));
86 TEST(bpp == 32);
87
88 /* Last param doesn't seem to matter*/
89 TEST(NtUserGetIconInfo(hIcon,
90 &iinfo,
91 &hInstStr,
92 &ResourceStr,
93 &bpp,
94 TRUE) == TRUE);
95
96 TESTX(hInstStr.Buffer == NULL, "hInstStr.buffer : %p\n", hInstStr.Buffer);
97 TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(IDI_ICON));
98 TEST(bpp == 32);
99
100 DestroyIcon(hIcon);
101
102 return APISTATUS_NORMAL;
103 }