Commit e6069c25 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d2d1: Test device context type in BindDC().

parent ffbe1e62
......@@ -689,11 +689,13 @@ static HRESULT STDMETHODCALLTYPE d2d_dc_render_target_BindDC(ID2D1DCRenderTarget
ID2D1DeviceContext *context;
D2D1_SIZE_U bitmap_size;
ID2D1Bitmap *bitmap;
DWORD obj_type;
HRESULT hr;
TRACE("iface %p, hdc %p, rect %s.\n", iface, hdc, wine_dbgstr_rect(rect));
if (!hdc)
obj_type = GetObjectType(hdc);
if (obj_type != OBJ_DC && obj_type != OBJ_ENHMETADC && obj_type != OBJ_MEMDC)
return E_INVALIDARG;
/* Switch dxgi target to new surface. */
......
......@@ -5825,15 +5825,18 @@ static void test_dc_target(BOOL d3d11)
ID2D1Factory *factory;
FLOAT dpi_x, dpi_y;
D2D1_COLOR_F color;
HENHMETAFILE hemf;
D2D1_SIZE_U sizeu;
D2D1_SIZE_F size;
D2D1_TAG t1, t2;
unsigned int i;
HDC hdc, hdc2;
HMETAFILE hmf;
D2D_RECT_F r;
COLORREF clr;
HRESULT hr;
RECT rect;
HWND hwnd;
if (!init_test_context(&ctx, d3d11))
return;
......@@ -5997,7 +6000,7 @@ static void test_dc_target(BOOL d3d11)
/* Invalid DC. */
hr = ID2D1DCRenderTarget_BindDC(rt, (HDC)0xdeadbeef, &rect);
todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
ID2D1DCRenderTarget_BeginDraw(rt);
......@@ -6008,7 +6011,7 @@ static void test_dc_target(BOOL d3d11)
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
clr = GetPixel(hdc2, 0, 0);
todo_wine ok(clr == RGB(255, 0, 0), "Got unexpected colour 0x%08lx.\n", clr);
ok(clr == RGB(255, 0, 0), "Got unexpected colour 0x%08lx.\n", clr);
hr = ID2D1DCRenderTarget_BindDC(rt, NULL, &rect);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
......@@ -6022,10 +6025,46 @@ static void test_dc_target(BOOL d3d11)
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
clr = GetPixel(hdc2, 0, 0);
todo_wine ok(clr == RGB(0, 0, 255), "Got unexpected colour 0x%08lx.\n", clr);
ok(clr == RGB(0, 0, 255), "Got unexpected colour 0x%08lx.\n", clr);
DeleteDC(hdc);
DeleteDC(hdc2);
/* Metafile context. */
hdc = CreateMetaFileA(NULL);
ok(!!hdc, "Failed to create a device context.\n");
hr = ID2D1DCRenderTarget_BindDC(rt, hdc, &rect);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
hmf = CloseMetaFile(hdc);
ok(!!hmf, "Failed to close a metafile, error %ld.\n", GetLastError());
DeleteMetaFile(hmf);
/* Enhanced metafile context. */
hdc = CreateEnhMetaFileA(NULL, NULL, NULL, NULL);
ok(!!hdc, "Failed to create a device context.\n");
hr = ID2D1DCRenderTarget_BindDC(rt, hdc, &rect);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hemf = CloseEnhMetaFile(hdc);
ok(!!hemf, "Failed to close a metafile, error %ld.\n", GetLastError());
DeleteEnhMetaFile(hemf);
/* Window context. */
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 100, 100, 0, 0, 0, NULL);
ok(!!hwnd, "Failed to create a test window.\n");
hdc = GetDC(hwnd);
ok(!!hdc, "Failed to get a context.\n");
hr = ID2D1DCRenderTarget_BindDC(rt, hdc, &rect);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
ID2D1DCRenderTarget_Release(rt);
ID2D1Factory_Release(factory);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment