1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for NtGdiGetStockObject 5 * PROGRAMMERS: 6 */ 7 8 #include "../win32nt.h" 9 10 START_TEST(NtGdiGetStockObject) 11 { 12 HANDLE handle = NULL; 13 BITMAP bitmap; 14 15 /* BRUSH testing */ 16 handle = (HANDLE) NtGdiGetStockObject(WHITE_BRUSH); 17 RTEST(handle != 0); 18 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_BRUSH); 19 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 20 21 handle = (HANDLE) NtGdiGetStockObject(LTGRAY_BRUSH); 22 RTEST(handle != 0); 23 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_BRUSH); 24 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 25 26 handle = (HANDLE) NtGdiGetStockObject(GRAY_BRUSH); 27 RTEST(handle != 0); 28 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_BRUSH); 29 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 30 31 handle = (HANDLE) NtGdiGetStockObject(DKGRAY_BRUSH); 32 RTEST(handle != 0); 33 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_BRUSH); 34 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 35 36 handle = (HANDLE) NtGdiGetStockObject(BLACK_BRUSH); 37 RTEST(handle != 0); 38 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_BRUSH); 39 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 40 41 handle = (HANDLE) NtGdiGetStockObject(NULL_BRUSH); 42 RTEST(handle != 0); 43 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_BRUSH); 44 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 45 46 /* PEN testing */ 47 handle = (HANDLE) NtGdiGetStockObject(WHITE_PEN); 48 RTEST(handle != 0); 49 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_PEN); 50 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) != 0); 51 52 handle = (HANDLE) NtGdiGetStockObject(BLACK_PEN); 53 RTEST(handle != 0); 54 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_PEN); 55 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) != 0); 56 57 handle = (HANDLE) NtGdiGetStockObject(NULL_PEN); 58 RTEST(handle != 0); 59 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_PEN); 60 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 61 62 /* Not inuse ? */ 63 RTEST(NtGdiGetStockObject(9) == 0); 64 65 /* FONT testing */ 66 handle = (HANDLE) NtGdiGetStockObject(OEM_FIXED_FONT); 67 RTEST(handle != 0); 68 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_FONT); 69 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) != 0); 70 71 handle = (HANDLE) NtGdiGetStockObject(ANSI_FIXED_FONT); 72 RTEST(handle != 0); 73 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_FONT); 74 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 75 76 handle = (HANDLE) NtGdiGetStockObject(ANSI_VAR_FONT); 77 RTEST(handle != 0); 78 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_FONT); 79 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 80 81 handle = (HANDLE) NtGdiGetStockObject(SYSTEM_FONT); 82 RTEST(handle != 0); 83 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_FONT); 84 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 85 86 handle = (HANDLE) NtGdiGetStockObject(DEVICE_DEFAULT_FONT); 87 RTEST(handle != 0); 88 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_FONT); 89 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 90 91 handle = (HANDLE) NtGdiGetStockObject(SYSTEM_FIXED_FONT); 92 RTEST(handle != 0); 93 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_FONT); 94 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 95 96 handle = (HANDLE) NtGdiGetStockObject(DEFAULT_GUI_FONT); 97 RTEST(handle != 0); 98 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_FONT); 99 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 100 101 /* PALETTE testing */ 102 handle = (HANDLE) NtGdiGetStockObject(DEFAULT_PALETTE); 103 RTEST(handle != 0); 104 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_PALETTE); 105 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 106 107 /* DC testing */ 108 handle = (HANDLE) NtGdiGetStockObject(DC_BRUSH); 109 RTEST(handle != 0); 110 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_BRUSH); 111 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 112 113 handle = (HANDLE) NtGdiGetStockObject(DC_PEN); 114 RTEST(handle != 0); 115 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_PEN); 116 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 117 118 119 /* ? testing */ 120 handle = (HANDLE) NtGdiGetStockObject(20); 121 RTEST(handle != 0); 122 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_COLORSPACE); 123 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 124 125 /* value 21 is getting back 1x1 1Bpp Bitmap */ 126 handle = (HANDLE) NtGdiGetStockObject(21); 127 RTEST(handle != 0); 128 RTEST(GDI_HANDLE_GET_TYPE(handle) == GDI_OBJECT_TYPE_BITMAP); 129 RTEST(GDI_HANDLE_IS_STOCKOBJ(handle) == TRUE); 130 131 RTEST(GetObject(handle, sizeof(BITMAP), &bitmap) == sizeof(BITMAP)); 132 RTEST(bitmap.bmType == 0); 133 RTEST(bitmap.bmWidth == 1); 134 RTEST(bitmap.bmHeight == 1); 135 RTEST(bitmap.bmWidthBytes == 2); 136 RTEST(bitmap.bmPlanes == 1); 137 RTEST(bitmap.bmBitsPixel == 1); 138 RTEST(bitmap.bmBits == 0); 139 140 141 RTEST(NtGdiGetStockObject(22) == 0); 142 RTEST(NtGdiGetStockObject(23) == 0); 143 144 } 145