Add a test for GetCurrentObject, make it pass under Wine.
This commit is contained in:
parent
372a281c24
commit
62d3ab9bd0
|
@ -1106,11 +1106,15 @@ HGDIOBJ WINAPI GetCurrentObject(HDC hdc,UINT type)
|
|||
if (dc)
|
||||
{
|
||||
switch (type) {
|
||||
case OBJ_EXTPEN: /* fall through */
|
||||
case OBJ_PEN: ret = dc->hPen; break;
|
||||
case OBJ_BRUSH: ret = dc->hBrush; break;
|
||||
case OBJ_PAL: ret = dc->hPalette; break;
|
||||
case OBJ_FONT: ret = dc->hFont; break;
|
||||
case OBJ_BITMAP: ret = dc->hBitmap; break;
|
||||
|
||||
/* tests show that OBJ_REGION is explicitly ignored */
|
||||
case OBJ_REGION: break;
|
||||
default:
|
||||
/* the SDK only mentions those above */
|
||||
FIXME("(%p,%d): unknown type.\n",hdc,type);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -328,7 +329,8 @@ static void test_text_extents(void)
|
|||
struct hgdiobj_event
|
||||
{
|
||||
HDC hdc;
|
||||
HGDIOBJ hgdiobj;
|
||||
HGDIOBJ hgdiobj1;
|
||||
HGDIOBJ hgdiobj2;
|
||||
HANDLE stop_event;
|
||||
HANDLE ready_event;
|
||||
};
|
||||
|
@ -341,14 +343,17 @@ static DWORD WINAPI thread_proc(void *param)
|
|||
hgdiobj_event->hdc = CreateDC("display", NULL, NULL, NULL);
|
||||
ok(hgdiobj_event->hdc != NULL, "CreateDC error %ld\n", GetLastError());
|
||||
|
||||
hgdiobj_event->hgdiobj = CreatePen(PS_DASHDOTDOT, 17, RGB(1, 2, 3));
|
||||
ok(hgdiobj_event->hgdiobj != 0, "Failed to create pen\n");
|
||||
hgdiobj_event->hgdiobj1 = CreatePen(PS_DASHDOTDOT, 17, RGB(1, 2, 3));
|
||||
ok(hgdiobj_event->hgdiobj1 != 0, "Failed to create pen\n");
|
||||
|
||||
hgdiobj_event->hgdiobj2 = CreateRectRgn(0, 1, 12, 17);
|
||||
ok(hgdiobj_event->hgdiobj2 != 0, "Failed to create pen\n");
|
||||
|
||||
SetEvent(hgdiobj_event->ready_event);
|
||||
ok(WaitForSingleObject(hgdiobj_event->stop_event, INFINITE) == WAIT_OBJECT_0,
|
||||
"WaitForSingleObject error %ld\n", GetLastError());
|
||||
|
||||
ok(!GetObject(hgdiobj_event->hgdiobj, sizeof(lp), &lp), "GetObject should fail\n");
|
||||
ok(!GetObject(hgdiobj_event->hgdiobj1, sizeof(lp), &lp), "GetObject should fail\n");
|
||||
|
||||
ok(!GetDeviceCaps(hgdiobj_event->hdc, TECHNOLOGY), "GetDeviceCaps(TECHNOLOGY) should fail\n");
|
||||
|
||||
|
@ -358,7 +363,7 @@ static DWORD WINAPI thread_proc(void *param)
|
|||
static void test_thread_objects(void)
|
||||
{
|
||||
LOGPEN lp;
|
||||
DWORD tid;
|
||||
DWORD tid, type;
|
||||
HANDLE hthread;
|
||||
struct hgdiobj_event hgdiobj_event;
|
||||
INT ret;
|
||||
|
@ -374,7 +379,7 @@ static void test_thread_objects(void)
|
|||
ok(WaitForSingleObject(hgdiobj_event.ready_event, INFINITE) == WAIT_OBJECT_0,
|
||||
"WaitForSingleObject error %ld\n", GetLastError());
|
||||
|
||||
ok(GetObject(hgdiobj_event.hgdiobj, sizeof(lp), &lp) == sizeof(lp),
|
||||
ok(GetObject(hgdiobj_event.hgdiobj1, sizeof(lp), &lp) == sizeof(lp),
|
||||
"GetObject error %ld\n", GetLastError());
|
||||
ok(lp.lopnStyle == PS_DASHDOTDOT, "wrong pen style %d\n", lp.lopnStyle);
|
||||
ok(lp.lopnWidth.x == 17, "wrong pen width.y %ld\n", lp.lopnWidth.x);
|
||||
|
@ -384,18 +389,111 @@ static void test_thread_objects(void)
|
|||
ret = GetDeviceCaps(hgdiobj_event.hdc, TECHNOLOGY);
|
||||
ok(ret == DT_RASDISPLAY, "GetDeviceCaps(TECHNOLOGY) should return DT_RASDISPLAY not %d\n", ret);
|
||||
|
||||
ok(DeleteObject(hgdiobj_event.hgdiobj), "DeleteObject error %ld\n", GetLastError());
|
||||
ok(DeleteObject(hgdiobj_event.hgdiobj1), "DeleteObject error %ld\n", GetLastError());
|
||||
ok(DeleteDC(hgdiobj_event.hdc), "DeleteDC error %ld\n", GetLastError());
|
||||
|
||||
type = GetObjectType(hgdiobj_event.hgdiobj2);
|
||||
ok(type == OBJ_REGION, "GetObjectType returned %lu\n", type);
|
||||
|
||||
SetEvent(hgdiobj_event.stop_event);
|
||||
ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0,
|
||||
"WaitForSingleObject error %ld\n", GetLastError());
|
||||
CloseHandle(hthread);
|
||||
|
||||
type = GetObjectType(hgdiobj_event.hgdiobj2);
|
||||
ok(type == OBJ_REGION, "GetObjectType returned %lu\n", type);
|
||||
ok(DeleteObject(hgdiobj_event.hgdiobj2), "DeleteObject error %ld\n", GetLastError());
|
||||
|
||||
CloseHandle(hgdiobj_event.stop_event);
|
||||
CloseHandle(hgdiobj_event.ready_event);
|
||||
}
|
||||
|
||||
static void test_GetCurrentObject(void)
|
||||
{
|
||||
DWORD type;
|
||||
HPEN hpen;
|
||||
HBRUSH hbrush;
|
||||
HPALETTE hpal;
|
||||
HFONT hfont;
|
||||
HBITMAP hbmp;
|
||||
HRGN hrgn;
|
||||
HDC hdc;
|
||||
HCOLORSPACE hcs;
|
||||
HGDIOBJ hobj;
|
||||
LOGBRUSH lb;
|
||||
LOGCOLORSPACEA lcs;
|
||||
|
||||
hdc = CreateCompatibleDC(0);
|
||||
assert(hdc != 0);
|
||||
|
||||
type = GetObjectType(hdc);
|
||||
ok(type == OBJ_MEMDC, "GetObjectType returned %lu\n", type);
|
||||
|
||||
hpen = CreatePen(PS_SOLID, 10, RGB(10, 20, 30));
|
||||
assert(hpen != 0);
|
||||
SelectObject(hdc, hpen);
|
||||
hobj = GetCurrentObject(hdc, OBJ_PEN);
|
||||
ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
|
||||
hobj = GetCurrentObject(hdc, OBJ_EXTPEN);
|
||||
ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);
|
||||
|
||||
hbrush = CreateSolidBrush(RGB(10, 20, 30));
|
||||
assert(hbrush != 0);
|
||||
SelectObject(hdc, hbrush);
|
||||
hobj = GetCurrentObject(hdc, OBJ_BRUSH);
|
||||
ok(hobj == hbrush, "OBJ_BRUSH is wrong: %p\n", hobj);
|
||||
|
||||
hpal = CreateHalftonePalette(hdc);
|
||||
assert(hpal != 0);
|
||||
SelectPalette(hdc, hpal, FALSE);
|
||||
hobj = GetCurrentObject(hdc, OBJ_PAL);
|
||||
ok(hobj == hpal, "OBJ_PAL is wrong: %p\n", hobj);
|
||||
|
||||
hfont = CreateFontA(10, 5, 0, 0, FW_DONTCARE, 0, 0, 0, ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH, "MS Sans Serif");
|
||||
assert(hfont != 0);
|
||||
SelectObject(hdc, hfont);
|
||||
hobj = GetCurrentObject(hdc, OBJ_FONT);
|
||||
ok(hobj == hfont, "OBJ_FONT is wrong: %p\n", hobj);
|
||||
|
||||
hbmp = CreateBitmap(100, 100, 1, 1, NULL);
|
||||
assert(hbmp != 0);
|
||||
SelectObject(hdc, hbmp);
|
||||
hobj = GetCurrentObject(hdc, OBJ_BITMAP);
|
||||
ok(hobj == hbmp, "OBJ_BITMAP is wrong: %p\n", hobj);
|
||||
|
||||
assert(GetObject(hbrush, sizeof(lb), &lb) == sizeof(lb));
|
||||
hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE | PS_JOIN_BEVEL,
|
||||
10, &lb, 0, NULL);
|
||||
assert(hpen != 0);
|
||||
SelectObject(hdc, hpen);
|
||||
hobj = GetCurrentObject(hdc, OBJ_PEN);
|
||||
ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
|
||||
hobj = GetCurrentObject(hdc, OBJ_EXTPEN);
|
||||
ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);
|
||||
|
||||
hcs = GetColorSpace(hdc);
|
||||
if (hcs)
|
||||
{
|
||||
trace("current color space is not NULL\n");
|
||||
ok(GetLogColorSpaceA(hcs, &lcs, sizeof(lcs)), "GetLogColorSpace failed\n");
|
||||
hcs = CreateColorSpaceA(&lcs);
|
||||
ok(hcs != 0, "CreateColorSpace failed\n");
|
||||
SelectObject(hdc, hcs);
|
||||
hobj = GetCurrentObject(hdc, OBJ_COLORSPACE);
|
||||
ok(hobj == hcs, "OBJ_COLORSPACE is wrong: %p\n", hobj);
|
||||
}
|
||||
|
||||
hrgn = CreateRectRgn(1, 1, 100, 100);
|
||||
assert(hrgn != 0);
|
||||
SelectObject(hdc, hrgn);
|
||||
hobj = GetCurrentObject(hdc, OBJ_REGION);
|
||||
ok(!hobj, "OBJ_REGION is wrong: %p\n", hobj);
|
||||
|
||||
DeleteDC(hdc);
|
||||
}
|
||||
|
||||
START_TEST(gdiobj)
|
||||
{
|
||||
test_logfont();
|
||||
|
@ -404,4 +502,5 @@ START_TEST(gdiobj)
|
|||
test_GdiGetCharDimensions();
|
||||
test_text_extents();
|
||||
test_thread_objects();
|
||||
test_GetCurrentObject();
|
||||
}
|
||||
|
|
|
@ -3385,6 +3385,7 @@ BOOL WINAPI GetCharWidthFloatW(HDC,UINT,UINT,PFLOAT);
|
|||
INT WINAPI GetClipBox(HDC,LPRECT);
|
||||
INT WINAPI GetClipRgn(HDC,HRGN);
|
||||
BOOL WINAPI GetColorAdjustment(HDC, LPCOLORADJUSTMENT);
|
||||
HCOLORSPACE WINAPI GetColorSpace(HDC);
|
||||
HGDIOBJ WINAPI GetCurrentObject(HDC,UINT);
|
||||
BOOL WINAPI GetCurrentPositionEx(HDC,LPPOINT);
|
||||
INT WINAPI GetDeviceCaps(HDC,INT);
|
||||
|
|
Loading…
Reference in New Issue