ReactOS  0.4.14-dev-342-gdc047f9
gdiobj.c File Reference
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
Include dependency graph for gdiobj.c:

Go to the source code of this file.

Classes

struct  hgdiobj_event
 

Functions

static void test_gdi_objects (void)
 
static DWORD WINAPI thread_proc (void *param)
 
static void test_thread_objects (void)
 
static void test_GetCurrentObject (void)
 
static void test_region (void)
 
static void test_handles_on_win64 (void)
 
 START_TEST (gdiobj)
 

Function Documentation

◆ START_TEST()

START_TEST ( gdiobj  )

Definition at line 365 of file gdiobj.c.

366 {
370  test_region();
372 }
static void test_GetCurrentObject(void)
Definition: gdiobj.c:197
static void test_region(void)
Definition: gdiobj.c:283
static void test_gdi_objects(void)
Definition: gdiobj.c:32
static void test_thread_objects(void)
Definition: gdiobj.c:144
static void test_handles_on_win64(void)
Definition: gdiobj.c:322

◆ test_gdi_objects()

static void test_gdi_objects ( void  )
static

Definition at line 32 of file gdiobj.c.

33 {
34  BYTE buff[256];
35  HDC hdc = GetDC(NULL);
36  HPEN hp;
37  int i;
38  BOOL ret;
39 
40  /* SelectObject() with a NULL DC returns 0 and sets ERROR_INVALID_HANDLE.
41  * Note: Under XP at least invalid ptrs can also be passed, not just NULL;
42  * Don't test that here in case it crashes earlier win versions.
43  */
44  SetLastError(0);
47  "SelectObject(NULL DC) expected 0, ERROR_INVALID_HANDLE, got %p, %u\n",
48  hp, GetLastError());
49 
50  /* With a valid DC and a NULL object, the call returns 0 but does not SetLastError() */
51  SetLastError(0);
52  hp = SelectObject(hdc, NULL);
53  ok(!hp && !GetLastError(),
54  "SelectObject(NULL obj) expected 0, NO_ERROR, got %p, %u\n",
55  hp, GetLastError());
56 
57  /* The DC is unaffected by the NULL SelectObject */
58  SetLastError(0);
60  ok(hp && !GetLastError(),
61  "SelectObject(post NULL) expected non-null, NO_ERROR, got %p, %u\n",
62  hp, GetLastError());
63 
64  /* GetCurrentObject does not SetLastError() on a null object */
65  SetLastError(0);
67  ok(!hp && !GetLastError(),
68  "GetCurrentObject(NULL DC) expected 0, NO_ERROR, got %p, %u\n",
69  hp, GetLastError());
70 
71  /* DeleteObject does not SetLastError() on a null object */
73  ok( !ret && !GetLastError(),
74  "DeleteObject(NULL obj), expected 0, NO_ERROR, got %d, %u\n",
75  ret, GetLastError());
76 
77  /* GetObject does not SetLastError() on a null object */
78  SetLastError(0);
79  i = GetObjectA(NULL, sizeof(buff), buff);
81  "GetObject(NULL obj), expected 0, NO_ERROR, got %d, %u\n",
82  i, GetLastError());
83 
84  /* GetObject expects ERROR_NOACCESS when passed an invalid buffer */
86  SetLastError(0);
87  i = GetObjectA(hp, (INT_PTR)buff, (LPVOID)sizeof(buff));
88  ok (!i && (GetLastError() == 0 || GetLastError() == ERROR_NOACCESS),
89  "GetObject(invalid buff), expected 0, ERROR_NOACCESS, got %d, %u\n",
90  i, GetLastError());
91 
92  /* GetObjectType does SetLastError() on a null object */
93  SetLastError(0);
94  i = GetObjectType(NULL);
96  "GetObjectType(NULL obj), expected 0, ERROR_INVALID_HANDLE, got %d, %u\n",
97  i, GetLastError());
98 
99  /* UnrealizeObject does not SetLastError() on a null object */
100  SetLastError(0);
102  ok (!i && !GetLastError(),
103  "UnrealizeObject(NULL obj), expected 0, NO_ERROR, got %d, %u\n",
104  i, GetLastError());
105 
106  ReleaseDC(NULL, hdc);
107 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
HGDIOBJ WINAPI GetStockObject(INT fnObject)
Definition: gdiobj.c:13
HDC WINAPI GetDC(_In_opt_ HWND)
int WINAPI GetObjectA(_In_ HGDIOBJ hGdiObj, _In_ int cbSize, _Out_ LPVOID lpBuffer)
Definition: gdiobj.c:162
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT_PTR
Definition: typedefs.h:62
#define OBJ_PEN
Definition: objidl.idl:1409
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ERROR_NOACCESS
Definition: winerror.h:578
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetObjectType(HGDIOBJ h)
Definition: gdiobj.c:43
BOOL WINAPI UnrealizeObject(_In_ HGDIOBJ)
BOOL WINAPI DeleteObject(HGDIOBJ hObject)
Definition: gdiobj.c:315
#define SetLastError(x)
Definition: compat.h:417
int ret
HDC hdc
Definition: main.c:9
unsigned char BYTE
Definition: mem.h:68
#define broken(x)
Definition: _sntprintf.h:21
#define BLACK_PEN
Definition: wingdi.h:902
#define ok(value,...)
Definition: atltest.h:57
static unsigned char buff[32768]
Definition: fatten.c:17
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439

Referenced by START_TEST().

◆ test_GetCurrentObject()

static void test_GetCurrentObject ( void  )
static

Definition at line 197 of file gdiobj.c.

198 {
199  DWORD type;
200  HPEN hpen;
201  HBRUSH hbrush;
202  HPALETTE hpal;
203  HFONT hfont;
204  HBITMAP hbmp;
205  HRGN hrgn;
206  HDC hdc;
207  HCOLORSPACE hcs;
208  HGDIOBJ hobj;
209  LOGBRUSH lb;
210  LOGCOLORSPACEA lcs;
211 
212  hdc = CreateCompatibleDC(0);
213  assert(hdc != 0);
214 
216  ok(type == OBJ_MEMDC, "GetObjectType returned %u\n", type);
217 
218  hpen = CreatePen(PS_SOLID, 10, RGB(10, 20, 30));
219  assert(hpen != 0);
221  hobj = GetCurrentObject(hdc, OBJ_PEN);
222  ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
224  ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);
225 
226  hbrush = CreateSolidBrush(RGB(10, 20, 30));
227  assert(hbrush != 0);
229  hobj = GetCurrentObject(hdc, OBJ_BRUSH);
230  ok(hobj == hbrush, "OBJ_BRUSH is wrong: %p\n", hobj);
231 
232  hpal = CreateHalftonePalette(hdc);
233  assert(hpal != 0);
234  SelectPalette(hdc, hpal, FALSE);
235  hobj = GetCurrentObject(hdc, OBJ_PAL);
236  ok(hobj == hpal, "OBJ_PAL is wrong: %p\n", hobj);
237 
238  hfont = CreateFontA(10, 5, 0, 0, FW_DONTCARE, 0, 0, 0, ANSI_CHARSET,
240  DEFAULT_PITCH, "MS Sans Serif");
241  assert(hfont != 0);
243  hobj = GetCurrentObject(hdc, OBJ_FONT);
244  ok(hobj == hfont, "OBJ_FONT is wrong: %p\n", hobj);
245 
246  hbmp = CreateBitmap(100, 100, 1, 1, NULL);
247  assert(hbmp != 0);
250  ok(hobj == hbmp, "OBJ_BITMAP is wrong: %p\n", hobj);
251 
252  assert(GetObjectA(hbrush, sizeof(lb), &lb) == sizeof(lb));
254  10, &lb, 0, NULL);
255  assert(hpen != 0);
257  hobj = GetCurrentObject(hdc, OBJ_PEN);
258  ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
260  ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);
261 
262  hcs = GetColorSpace(hdc);
263  if (hcs)
264  {
265  trace("current color space is not NULL\n");
266  ok(GetLogColorSpaceA(hcs, &lcs, sizeof(lcs)), "GetLogColorSpace failed\n");
267  hcs = CreateColorSpaceA(&lcs);
268  ok(hcs != 0, "CreateColorSpace failed\n");
269  SelectObject(hdc, hcs);
271  ok(hobj == hcs, "OBJ_COLORSPACE is wrong: %p\n", hobj);
272  }
273 
274  hrgn = CreateRectRgn(1, 1, 100, 100);
275  assert(hrgn != 0);
278  ok(!hobj, "OBJ_REGION is wrong: %p\n", hobj);
279 
280  DeleteDC(hdc);
281 }
#define PS_ENDCAP_SQUARE
Definition: wingdi.h:594
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
static HBRUSH hbrush
#define DEFAULT_QUALITY
Definition: wingdi.h:435
int WINAPI GetObjectA(_In_ HGDIOBJ hGdiObj, _In_ int cbSize, _Out_ LPVOID lpBuffer)
Definition: gdiobj.c:162
#define OBJ_MEMDC
Definition: objidl.idl:1418
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
#define PS_JOIN_BEVEL
Definition: wingdi.h:596
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HPEN hpen
#define PS_GEOMETRIC
Definition: wingdi.h:582
#define OBJ_PEN
Definition: objidl.idl:1409
#define PS_SOLID
Definition: wingdi.h:585
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
#define OBJ_COLORSPACE
Definition: wingdi.h:703
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
#define OBJ_REGION
Definition: objidl.idl:1416
static HFONT hfont
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HBITMAP hbmp
BOOL WINAPI GetLogColorSpaceA(_In_ HCOLORSPACE hColorSpace, _Out_writes_bytes_(nSize) LPLOGCOLORSPACEA lpBuffer, _In_ DWORD nSize)
#define trace
Definition: atltest.h:70
#define DEFAULT_PITCH
Definition: wingdi.h:442
DWORD WINAPI GetObjectType(HGDIOBJ h)
Definition: gdiobj.c:43
HCOLORSPACE WINAPI CreateColorSpaceA(_In_ LPLOGCOLORSPACEA pLogColorSpace)
#define RGB(r, g, b)
Definition: wingdi.h:2935
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
unsigned long DWORD
Definition: ntddk_ex.h:95
#define OBJ_PAL
Definition: objidl.idl:1413
#define OBJ_FONT
Definition: objidl.idl:1414
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
#define OBJ_EXTPEN
Definition: objidl.idl:1419
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
HCOLORSPACE WINAPI GetColorSpace(_In_ HDC)
#define FW_DONTCARE
Definition: wingdi.h:367
BOOL WINAPI DeleteDC(_In_ HDC)
#define OBJ_BRUSH
Definition: objidl.idl:1410
#define ok(value,...)
Definition: atltest.h:57
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HPEN WINAPI ExtCreatePen(_In_ DWORD iPenStyle, _In_ DWORD cWidth, _In_ const LOGBRUSH *plbrush, _In_ DWORD cStyle, _In_reads_opt_(cStyle) const DWORD *pstyle)
static HBITMAP
Definition: button.c:44
#define ANSI_CHARSET
Definition: wingdi.h:382
#define OBJ_BITMAP
Definition: objidl.idl:1415
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HPALETTE WINAPI CreateHalftonePalette(_In_opt_ HDC)

Referenced by START_TEST().

◆ test_handles_on_win64()

static void test_handles_on_win64 ( void  )
static

Definition at line 322 of file gdiobj.c.

323 {
324  int i;
325  BOOL ret;
326  DWORD type;
327  HRGN hrgn, hrgn_test;
328 
329  static const struct
330  {
331  ULONG high;
332  ULONG low;
333  BOOL ret;
334  } cases[] =
335  {
336  { 0x00000000, 0x00000000, TRUE },
337  { 0x00000000, 0x0000ffe0, FALSE }, /* just over MAX_LARGE_HANDLES */
338  { 0x00000000, 0x0000ffb0, FALSE }, /* just under MAX_LARGE_HANDLES */
339  { 0xffffffff, 0xffff0000, FALSE },
340  { 0xffffffff, 0x00000000, TRUE },
341  { 0xdeadbeef, 0x00000000, TRUE },
342  { 0xcccccccc, 0xcccccccc, FALSE }
343  };
344 
345  if (sizeof(void*) != 8)
346  return;
347 
348  for (i = 0; i < sizeof(cases)/sizeof(cases[0]); i++)
349  {
350  hrgn = CreateRectRgn(10, 10, 20, 20);
351  hrgn_test = (HRGN)(ULONG_PTR)((ULONG_PTR)hrgn | ((ULONGLONG)cases[i].high << 32) | cases[i].low);
352  type = GetObjectType( hrgn_test );
353  if (cases[i].ret)
354  ok( type == OBJ_REGION, "wrong type %u\n", type );
355  else
356  ok( type == 0, "wrong type %u\n", type );
357  ret = DeleteObject(hrgn_test);
358  ok( cases[i].ret == ret, "DeleteObject should return %s (%p)\n",
359  cases[i].ret ? "TRUE" : "FALSE", hrgn_test);
360  /* actually free it if above is expected to fail */
361  if (!ret) DeleteObject(hrgn);
362  }
363 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define OBJ_REGION
Definition: objidl.idl:1416
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
DWORD WINAPI GetObjectType(HGDIOBJ h)
Definition: gdiobj.c:43
uint64_t ULONGLONG
Definition: typedefs.h:65
BOOL WINAPI DeleteObject(HGDIOBJ hObject)
Definition: gdiobj.c:315
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static HRGN hrgn
Definition: win.c:55
#define ok(value,...)
Definition: atltest.h:57
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101

Referenced by START_TEST().

◆ test_region()

static void test_region ( void  )
static

Definition at line 283 of file gdiobj.c.

284 {
285  HRGN hrgn = CreateRectRgn(10, 10, 20, 20);
286  RECT rc = { 5, 5, 15, 15 };
287  BOOL ret = RectInRegion( hrgn, &rc);
288  ok( ret, "RectInRegion should return TRUE\n");
289  /* swap left and right */
290  SetRect( &rc, 15, 5, 5, 15 );
291  ret = RectInRegion( hrgn, &rc);
292  ok( ret, "RectInRegion should return TRUE\n");
293  /* swap top and bottom */
294  SetRect( &rc, 5, 15, 15, 5 );
295  ret = RectInRegion( hrgn, &rc);
296  ok( ret, "RectInRegion should return TRUE\n");
297  /* swap both */
298  SetRect( &rc, 15, 15, 5, 5 );
299  ret = RectInRegion( hrgn, &rc);
300  ok( ret, "RectInRegion should return TRUE\n");
302  /* swap left and right in the region */
303  hrgn = CreateRectRgn(20, 10, 10, 20);
304  SetRect( &rc, 5, 5, 15, 15 );
305  ret = RectInRegion( hrgn, &rc);
306  ok( ret, "RectInRegion should return TRUE\n");
307  /* swap left and right */
308  SetRect( &rc, 15, 5, 5, 15 );
309  ret = RectInRegion( hrgn, &rc);
310  ok( ret, "RectInRegion should return TRUE\n");
311  /* swap top and bottom */
312  SetRect( &rc, 5, 15, 15, 5 );
313  ret = RectInRegion( hrgn, &rc);
314  ok( ret, "RectInRegion should return TRUE\n");
315  /* swap both */
316  SetRect( &rc, 15, 15, 5, 5 );
317  ret = RectInRegion( hrgn, &rc);
318  ok( ret, "RectInRegion should return TRUE\n");
320 }
unsigned int BOOL
Definition: ntddk_ex.h:94
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI DeleteObject(HGDIOBJ hObject)
Definition: gdiobj.c:315
int ret
static HRGN hrgn
Definition: win.c:55
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI RectInRegion(_In_ HRGN, _In_ LPCRECT)

Referenced by START_TEST().

◆ test_thread_objects()

static void test_thread_objects ( void  )
static

Definition at line 144 of file gdiobj.c.

145 {
146  LOGPEN lp;
147  DWORD tid, type;
148  HANDLE hthread;
150  INT ret;
151  DWORD status;
152  BOOL bRet;
153 
155  ok(hgdiobj_event.stop_event != NULL, "CreateEvent error %u\n", GetLastError());
157  ok(hgdiobj_event.ready_event != NULL, "CreateEvent error %u\n", GetLastError());
158 
159  hthread = CreateThread(NULL, 0, thread_proc, &hgdiobj_event, 0, &tid);
160  ok(hthread != NULL, "CreateThread error %u\n", GetLastError());
161 
163  ok(status == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", GetLastError());
164 
165  ret = GetObjectA(hgdiobj_event.hgdiobj1, sizeof(lp), &lp);
166  ok(ret == sizeof(lp), "GetObject error %u\n", GetLastError());
167  ok(lp.lopnStyle == PS_DASHDOTDOT, "wrong pen style %d\n", lp.lopnStyle);
168  ok(lp.lopnWidth.x == 17, "wrong pen width.y %d\n", lp.lopnWidth.x);
169  ok(lp.lopnWidth.y == 0, "wrong pen width.y %d\n", lp.lopnWidth.y);
170  ok(lp.lopnColor == RGB(1, 2, 3), "wrong pen width.y %08x\n", lp.lopnColor);
171 
173  ok(ret == DT_RASDISPLAY, "GetDeviceCaps(TECHNOLOGY) should return DT_RASDISPLAY not %d\n", ret);
174 
176  ok(bRet, "DeleteObject error %u\n", GetLastError());
177  bRet = DeleteDC(hgdiobj_event.hdc);
178  ok(bRet, "DeleteDC error %u\n", GetLastError());
179 
181  ok(type == OBJ_REGION, "GetObjectType returned %u\n", type);
182 
184  status = WaitForSingleObject(hthread, INFINITE);
185  ok(status == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", GetLastError());
186  CloseHandle(hthread);
187 
189  ok(type == OBJ_REGION, "GetObjectType returned %u\n", type);
191  ok(bRet, "DeleteObject error %u\n", GetLastError());
192 
195 }
#define CloseHandle
Definition: compat.h:406
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int WINAPI GetObjectA(_In_ HGDIOBJ hGdiObj, _In_ int cbSize, _Out_ LPVOID lpBuffer)
Definition: gdiobj.c:162
static DWORD WINAPI thread_proc(void *param)
Definition: gdiobj.c:118
POINT lopnWidth
Definition: wingdi.h:1841
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HGDIOBJ hgdiobj2
Definition: gdiobj.c:113
#define DT_RASDISPLAY
Definition: wingdi.h:707
int32_t INT
Definition: typedefs.h:56
#define TECHNOLOGY
Definition: wingdi.h:705
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
UINT lopnStyle
Definition: wingdi.h:1840
COLORREF lopnColor
Definition: wingdi.h:1842
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
#define OBJ_REGION
Definition: objidl.idl:1416
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
#define WAIT_OBJECT_0
Definition: winbase.h:387
DWORD WINAPI GetObjectType(HGDIOBJ h)
Definition: gdiobj.c:43
#define RGB(r, g, b)
Definition: wingdi.h:2935
BOOL WINAPI DeleteObject(HGDIOBJ hObject)
Definition: gdiobj.c:315
unsigned long DWORD
Definition: ntddk_ex.h:95
HGDIOBJ hgdiobj1
Definition: gdiobj.c:112
int ret
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI DeleteDC(_In_ HDC)
HANDLE stop_event
Definition: gdiobj.c:114
#define ok(value,...)
Definition: atltest.h:57
#define PS_DASHDOTDOT
Definition: wingdi.h:589
HANDLE ready_event
Definition: gdiobj.c:115
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
static TfClientId tid
Definition: ps.c:97

Referenced by START_TEST().

◆ thread_proc()

static DWORD WINAPI thread_proc ( void param)
static

Definition at line 118 of file gdiobj.c.

119 {
120  LOGPEN lp;
121  DWORD status;
123 
124  hgdiobj_event->hdc = CreateDCA("display", NULL, NULL, NULL);
125  ok(hgdiobj_event->hdc != NULL, "CreateDC error %u\n", GetLastError());
126 
128  ok(hgdiobj_event->hgdiobj1 != 0, "Failed to create pen\n");
129 
130  hgdiobj_event->hgdiobj2 = CreateRectRgn(0, 1, 12, 17);
131  ok(hgdiobj_event->hgdiobj2 != 0, "Failed to create pen\n");
132 
135  ok(status == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", GetLastError());
136 
137  ok(!GetObjectA(hgdiobj_event->hgdiobj1, sizeof(lp), &lp), "GetObject should fail\n");
138 
139  ok(!GetDeviceCaps(hgdiobj_event->hdc, TECHNOLOGY), "GetDeviceCaps(TECHNOLOGY) should fail\n");
140 
141  return 0;
142 }
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
int WINAPI GetObjectA(_In_ HGDIOBJ hGdiObj, _In_ int cbSize, _Out_ LPVOID lpBuffer)
Definition: gdiobj.c:162
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HGDIOBJ hgdiobj2
Definition: gdiobj.c:113
#define TECHNOLOGY
Definition: wingdi.h:705
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define WAIT_OBJECT_0
Definition: winbase.h:387
GLfloat param
Definition: glext.h:5796
#define RGB(r, g, b)
Definition: wingdi.h:2935
unsigned long DWORD
Definition: ntddk_ex.h:95
HGDIOBJ hgdiobj1
Definition: gdiobj.c:112
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HANDLE stop_event
Definition: gdiobj.c:114
#define ok(value,...)
Definition: atltest.h:57
#define PS_DASHDOTDOT
Definition: wingdi.h:589
HANDLE ready_event
Definition: gdiobj.c:115
#define INFINITE
Definition: serial.h:102
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by test_thread_objects().