[PATCH 1/4] d3drm/tests: Add test for IDirect3DRM*::CreateDeviceFromClipper.
Aaryaman Vasishta
jem456.vasishta at gmail.com
Wed Jun 10 06:10:24 CDT 2015
---
dlls/d3drm/tests/d3drm.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index 5dcfddc..b6a5f27 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -1947,6 +1947,130 @@ static void test_frame_qi(void)
IDirect3DRM_Release(d3drm1);
}
+static void test_create_device_from_clipper(void)
+{
+ DDSCAPS caps = { DDSCAPS_ZBUFFER };
+ IDirect3DRM *d3drm1;
+ IDirect3DRM2 *d3drm2;
+ IDirect3DRMDevice2 *device2;
+ IDirect3DDevice2 *d3ddevice2;
+ IDirectDrawClipper *clipper;
+ IDirectDrawSurface *surface, *ds;
+ IDirectDrawSurface7 *surface7;
+ IUnknown *unknown;
+ IDirectDraw *ddraw;
+ DDSURFACEDESC desc;
+ DWORD expected_caps, expected_flags;
+ HWND window;
+ GUID driver;
+ HRESULT hr;
+ ULONG ref;
+ RECT rc;
+
+ window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 500, 400, 0, 0, 0, 0);
+ GetClientRect(window, &rc);
+ hr = DirectDrawCreateClipper(0, &clipper, NULL);
+ ref = get_refcount((IUnknown *)clipper);
+ ok(hr == DD_OK, "Cannot get IDirectDrawClipper interface (hr = %x)\n", hr);
+ hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
+ ok(hr == DD_OK, "Cannot set HWnd to Clipper (hr = %x)\n", hr);
+
+ hr = Direct3DRMCreate(&d3drm1);
+ ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
+
+ hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
+ ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);
+ memcpy(&driver, &IID_IDirect3DRGBDevice, sizeof(GUID));
+ hr = IDirect3DRM2_CreateDeviceFromClipper(d3drm2, clipper, &driver, rc.right, rc.bottom, &device2);
+ ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice2 interface (hr = %x)\n", hr);
+
+ hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
+ ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x)\n", hr);
+
+ hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &surface);
+ ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x)\n", hr);
+ if (FAILED(hr))
+ goto cleanup;
+
+ desc.dwSize = sizeof(desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
+ ok(hr == DD_OK, "Cannot get surface desc structure (hr = %x)\n", hr);
+ if (FAILED(hr))
+ goto cleanup;
+
+ ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimentions = %d, %d, got %d, %d.\n",
+ rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
+ expected_caps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY;
+ todo_wine ok(desc.ddsCaps.dwCaps == expected_caps, "Expected %x for caps, got %x.\n", expected_caps, desc.ddsCaps.dwCaps);
+ expected_flags = DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
+ ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
+
+ hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &ds);
+ ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x)\n", hr);
+ if (FAILED(hr))
+ goto cleanup;
+
+ desc.dwSize = sizeof(desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
+ ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x)\n", hr);
+ if (FAILED(hr))
+ goto cleanup;
+
+ ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimentions = %d, %d, got %d, %d.\n",
+ rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
+ expected_caps = DDSCAPS_ZBUFFER | DDSCAPS_SYSTEMMEMORY;
+ todo_wine ok(desc.ddsCaps.dwCaps == expected_caps, "Expected %x for caps, got %x.\n", expected_caps, desc.ddsCaps.dwCaps);
+ expected_flags = DDSD_ZBUFFERBITDEPTH | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
+ ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
+
+ hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface7, (void**)&surface7);
+ ok(hr == DD_OK, "Cannot get IDirectDrawSurface7 Interface (hr = %x)\n", hr);
+
+ hr = IDirectDrawSurface7_GetDDInterface(surface7, (void**)&unknown);
+ ok(hr == DD_OK, "Cannot get ddraw Interface (hr = %x)\n", hr);
+
+ hr = IUnknown_QueryInterface(unknown, &IID_IDirectDraw, (void**)&ddraw);
+ ok(hr == DD_OK, "Cannot get IDirectDraw Interface (hr = %x)\n", hr);
+
+ hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
+ ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
+ ok(desc.ddpfPixelFormat.dwRGBBitCount == 32, "Expected 32 bpp, got %d", desc.ddpfPixelFormat.dwRGBBitCount);
+
+ hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 8);
+ ok(hr == DD_OK, "Cannot set display mode to 8bpp (hr = %x).\n", hr);
+
+ hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
+ ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
+ ok(desc.ddpfPixelFormat.dwRGBBitCount == 8, "Expected 16 bpp, got %d.\n", desc.ddpfPixelFormat.dwRGBBitCount);
+
+ hr = IDirectDraw_SetDisplayMode(ddraw, desc.dwWidth, desc.dwHeight, 16);
+ ok(hr == DD_OK, "Cannot set display mode to 16bpp (hr = %x).\n", hr);
+
+ hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
+ ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
+ ok(desc.ddpfPixelFormat.dwRGBBitCount == 16, "Expected 16 bpp, got %d.\n", desc.ddpfPixelFormat.dwRGBBitCount);
+
+ hr = IDirectDraw_SetDisplayMode(ddraw, 640, 480, 32);
+ ok(hr == DD_OK, "Cannot set display mode to 8bpp (hr = %x).\n", hr);
+
+ hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
+ ok(hr == DD_OK, "Cannot get IDirectDraw display mode (hr = %x)\n", hr);
+ ok((desc.dwWidth == 640) && (desc.dwHeight == 480), "Expected 640x480, got %dx%d\n", desc.dwWidth, desc.dwHeight);
+
+ IDirectDrawSurface7_Release(surface7);
+ IDirectDrawSurface_Release(ds);
+ IDirectDrawSurface_Release(surface);
+ IUnknown_Release(unknown);
+ IDirectDraw_Release(ddraw);
+ cleanup:
+ IDirectDrawClipper_Release(clipper);
+ IDirect3DRM_Release(d3drm1);
+ IDirect3DRM2_Release(d3drm2);
+ IDirect3DDevice2_Release(d3ddevice2);
+ IDirect3DRMDevice2_Release(device2);
+ DestroyWindow(window);
+}
+
START_TEST(d3drm)
{
test_MeshBuilder();
@@ -1964,4 +2088,5 @@ START_TEST(d3drm)
test_frame_mesh_materials();
test_d3drm_qi();
test_frame_qi();
+ test_create_device_from_clipper();
}
--
1.9.3 (Apple Git-50)
More information about the wine-patches
mailing list