1 2 #include "precomp.h" 3 4 // FIXME user32 5 6 void 7 Test_GetIconInfo(BOOL fIcon) 8 { 9 HICON hicon; 10 ICONINFO iconinfo, iconinfo2; 11 BITMAP bitmap; 12 13 iconinfo.fIcon = fIcon; 14 iconinfo.xHotspot = 0; 15 iconinfo.yHotspot = 0; 16 iconinfo.hbmMask = NULL; 17 iconinfo.hbmColor = NULL; 18 19 hicon = CreateIconIndirect(&iconinfo); 20 ok(hicon == 0, "should fail\n"); 21 22 iconinfo.hbmMask = CreateBitmap(8, 16, 1, 1, NULL); 23 hicon = CreateIconIndirect(&iconinfo); 24 ok(hicon != 0, "should not fail\n"); 25 26 ok(GetIconInfo(hicon, &iconinfo2), "\n"); 27 ok_int(iconinfo2.fIcon, iconinfo.fIcon); 28 if (fIcon) 29 { 30 ok(iconinfo2.xHotspot == 4, "%ld\n", iconinfo2.xHotspot); 31 ok(iconinfo2.yHotspot == 4, "%ld\n", iconinfo2.yHotspot); 32 } 33 else 34 { 35 ok(iconinfo2.xHotspot == 0, "%ld\n", iconinfo2.xHotspot); 36 ok(iconinfo2.yHotspot == 0, "%ld\n", iconinfo2.yHotspot); 37 } 38 ok(iconinfo2.hbmMask != NULL, "iconinfo2.hbmMask was NULL\n"); 39 ok(iconinfo2.hbmMask != iconinfo.hbmMask, "\n"); 40 ok(iconinfo2.hbmColor == NULL, "iconinfo2.hbmColor was not NULL\n"); 41 42 ok(GetIconInfo(hicon, &iconinfo2), "\n"); 43 ok(iconinfo2.fIcon == iconinfo.fIcon, "\n"); 44 if (fIcon) 45 { 46 ok(iconinfo2.xHotspot == 4, "%ld\n", iconinfo2.xHotspot); 47 ok(iconinfo2.yHotspot == 4, "%ld\n", iconinfo2.yHotspot); 48 } 49 else 50 { 51 ok(iconinfo2.xHotspot == 0, "%ld\n", iconinfo2.xHotspot); 52 ok(iconinfo2.yHotspot == 0, "%ld\n", iconinfo2.yHotspot); 53 } 54 ok(iconinfo2.hbmMask != NULL, "\n"); 55 ok(iconinfo2.hbmMask != iconinfo.hbmMask, "\n"); 56 ok(iconinfo2.hbmColor == NULL, "\n"); 57 58 iconinfo.hbmColor = CreateBitmap(2, 2, 1, 1, NULL); 59 hicon = CreateIconIndirect(&iconinfo); 60 ok(hicon != 0, "should not fail\n"); 61 62 ok(GetIconInfo(hicon, &iconinfo2), "\n"); 63 ok_int(iconinfo2.fIcon, iconinfo.fIcon); 64 if (fIcon) 65 { 66 ok(iconinfo2.xHotspot == 4, "%ld\n", iconinfo2.xHotspot); 67 ok(iconinfo2.yHotspot == 8, "%ld\n", iconinfo2.yHotspot); 68 } 69 else 70 { 71 ok(iconinfo2.xHotspot == 0, "%ld\n", iconinfo2.xHotspot); 72 ok(iconinfo2.yHotspot == 0, "%ld\n", iconinfo2.yHotspot); 73 } 74 ok(iconinfo2.hbmMask != NULL, "\n"); 75 ok(iconinfo2.hbmMask != iconinfo.hbmMask, "\n"); 76 ok(iconinfo2.hbmColor != NULL, "\n"); 77 ok(iconinfo2.hbmMask != iconinfo.hbmColor, "\n"); 78 79 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n"); 80 ok_int(bitmap.bmType, 0); 81 ok_int(bitmap.bmWidth, 8); 82 ok_int(bitmap.bmHeight, 16); 83 ok_int(bitmap.bmWidthBytes, 2); 84 ok_int(bitmap.bmPlanes, 1); 85 ok_int(bitmap.bmBitsPixel, 1); 86 ok(bitmap.bmBits == NULL, "\n"); 87 88 ok(GetObject(iconinfo2.hbmColor, sizeof(bitmap), &bitmap), "GetObject failed\n"); 89 ok_int(bitmap.bmType, 0); 90 ok_int(bitmap.bmWidth, 8); 91 ok_int(bitmap.bmHeight, 16); 92 ok_int(bitmap.bmWidthBytes, ((bitmap.bmWidth * bitmap.bmBitsPixel + 15) & ~15) / 8); 93 ok_int(bitmap.bmPlanes, 1); 94 ok(bitmap.bmBitsPixel == 1 || bitmap.bmBitsPixel == 2 || bitmap.bmBitsPixel == 4 || 95 bitmap.bmBitsPixel == 8 || bitmap.bmBitsPixel == 16 || bitmap.bmBitsPixel == 32, 96 "bmBitsPixel = %u\n", bitmap.bmBitsPixel); 97 ok(bitmap.bmBits == NULL, "\n"); 98 99 DeleteObject(iconinfo.hbmMask); 100 iconinfo.hbmMask = NULL; 101 hicon = CreateIconIndirect(&iconinfo); 102 ok(hicon == 0, "should fail\n"); 103 104 DeleteObject(iconinfo.hbmColor); 105 iconinfo.hbmColor = CreateCompatibleBitmap(GetDC(0), 16, 16); 106 hicon = CreateIconIndirect(&iconinfo); 107 ok(hicon == 0, "should fail\n"); 108 109 iconinfo.hbmMask = CreateCompatibleBitmap(GetDC(0), 8, 16); 110 hicon = CreateIconIndirect(&iconinfo); 111 ok(hicon != 0, "should not fail\n"); 112 113 ok(GetIconInfo(hicon, &iconinfo2), "\n"); 114 115 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n"); 116 ok_int(bitmap.bmType, 0); 117 ok_int(bitmap.bmWidth, 8); 118 ok_int(bitmap.bmHeight, 16); 119 ok_int(bitmap.bmWidthBytes, 2); 120 ok_int(bitmap.bmPlanes, 1); 121 ok_int(bitmap.bmBitsPixel, 1); 122 ok(bitmap.bmBits == NULL, "\n"); 123 124 ok(GetObject(iconinfo2.hbmColor, sizeof(bitmap), &bitmap), "GetObject failed\n"); 125 ok_int(bitmap.bmType, 0); 126 ok_int(bitmap.bmWidth, 8); 127 ok_int(bitmap.bmHeight, 16); 128 ok_int(bitmap.bmWidthBytes, ((bitmap.bmWidth * bitmap.bmBitsPixel + 15) & ~15) / 8); 129 ok_int(bitmap.bmPlanes, 1); 130 ok(bitmap.bmBitsPixel == 1 || bitmap.bmBitsPixel == 2 || bitmap.bmBitsPixel == 4 || 131 bitmap.bmBitsPixel == 8 || bitmap.bmBitsPixel == 16 || bitmap.bmBitsPixel == 32, 132 "bmBitsPixel = %u\n", bitmap.bmBitsPixel); 133 ok(bitmap.bmBits == NULL, "\n"); 134 } 135 136 137 START_TEST(CreateIconIndirect) 138 { 139 HCURSOR hcursor; 140 HICON hicon; 141 ICONINFO iconinfo2; 142 BITMAP bitmap; 143 DWORD data[] = {0, 0, 0, 0, 0, 0}; 144 145 Test_GetIconInfo(0); 146 Test_GetIconInfo(1); 147 148 hcursor = LoadCursor(NULL, IDC_APPSTARTING); 149 ok(hcursor != 0, "should not fail\n"); 150 ok(GetIconInfo(hcursor, &iconinfo2), "\n"); 151 ok(iconinfo2.fIcon == 0, "\n"); 152 ok(iconinfo2.hbmMask != NULL, "\n"); 153 154 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n"); 155 ok_int(bitmap.bmType, 0); 156 ok(bitmap.bmWidth > 4, "bmWidth = %lu\n", bitmap.bmWidth); 157 ok(bitmap.bmHeight > 4, "bmHeight = %lu\n", bitmap.bmHeight); 158 ok_int(bitmap.bmWidthBytes, ((bitmap.bmWidth * bitmap.bmBitsPixel + 15) & ~15) / 8); 159 ok_int(bitmap.bmPlanes, 1); 160 ok_int(bitmap.bmBitsPixel, 1); 161 ok(bitmap.bmBits == NULL, "\n"); 162 163 ok(iconinfo2.xHotspot < bitmap.bmWidth, "xHotspot = %lu, bmWidth = %lu\n", iconinfo2.xHotspot, bitmap.bmWidth); 164 ok(iconinfo2.yHotspot < bitmap.bmHeight, "yHotspot = %lu, bmHeight = %lu\n", iconinfo2.yHotspot, bitmap.bmHeight); 165 166 hcursor = CreateCursor(NULL, 1, 2, 4, 4, data, data); 167 ok(hcursor != 0, "should not fail\n"); 168 ok(GetIconInfo(hcursor, &iconinfo2), "\n"); 169 ok(iconinfo2.fIcon == 0, "\n"); 170 ok_int(iconinfo2.xHotspot, 1); 171 ok_int(iconinfo2.yHotspot, 2); 172 ok(iconinfo2.hbmMask != NULL, "\n"); 173 ok(iconinfo2.hbmColor == NULL, "\n"); 174 175 ok(GetObject(iconinfo2.hbmMask, sizeof(bitmap), &bitmap), "GetObject failed\n"); 176 ok_int(bitmap.bmType, 0); 177 ok_int(bitmap.bmWidth, 4); 178 ok_int(bitmap.bmHeight, 8); 179 ok_int(bitmap.bmWidthBytes, 2); 180 ok_int(bitmap.bmPlanes, 1); 181 ok_int(bitmap.bmBitsPixel, 1); 182 ok(bitmap.bmBits == NULL, "\n"); 183 184 185 hicon = CreateIcon(0, 4, 4, 1, 1, (PBYTE)data, (PBYTE)data); 186 ok(hicon != 0, "should not fail\n"); 187 188 ok(GetIconInfo(hicon, &iconinfo2), "\n"); 189 ok(iconinfo2.fIcon == 0 || iconinfo2.fIcon == 1, "fIcon = 0x%x\n", iconinfo2.fIcon); 190 ok_int(iconinfo2.xHotspot, 2); 191 ok_int(iconinfo2.yHotspot, 2); 192 ok(iconinfo2.hbmMask != NULL, "\n"); 193 ok(iconinfo2.hbmColor == NULL, "\n"); 194 195 } 196