[PATCH 2/5] ddraw/tests: Test GetPrivateData size behavior.
Stefan Dösinger
stefan at codeweavers.com
Sun Mar 16 14:38:59 CDT 2014
---
dlls/ddraw/tests/ddraw4.c | 26 ++++++++++++++++++++++++++
dlls/ddraw/tests/ddraw7.c | 26 ++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index bb725e7..f01f812 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -6122,13 +6122,39 @@ static void test_private_data(void)
hr = IDirectDrawSurface4_SetPrivateData(surface, &IID_IDirect3D, ddraw,
sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+ size = 2 * sizeof(ptr);
hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3D, &ptr, &size);
ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr);
+ ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
refcount2 = get_refcount(ptr);
/* Object is NOT addref'ed by the getter. */
ok(ptr == (IUnknown *)ddraw, "Returned interface pointer is %p, expected %p.\n", ptr, ddraw);
ok(refcount2 == refcount + 1, "Got unexpected refcount %u.\n", refcount2);
+ ptr = (IUnknown *)0xdeadbeef;
+ size = 1;
+ hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3D, NULL, &size);
+ ok(hr == DDERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
+ ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+ size = 2 * sizeof(ptr);
+ hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3D, NULL, &size);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ ok(size == 2 * sizeof(ptr), "Got unexpected size %u.\n", size);
+ size = 1;
+ hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3D, &ptr, &size);
+ ok(hr == DDERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
+ ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+ ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
+ hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3DViewport, NULL, NULL);
+ ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+ size = 0xdeadbabe;
+ hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3DViewport, &ptr, &size);
+ ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+ ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
+ ok(size == 0xdeadbabe, "Got unexpected size %u.\n", size);
+ hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3D, NULL, NULL);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+
refcount3 = IDirectDrawSurface4_Release(surface);
ok(!refcount3, "Got unexpected refcount %u.\n", refcount3);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 15e89a1..1efde27 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -5977,13 +5977,39 @@ static void test_private_data(void)
hr = IDirectDrawSurface7_SetPrivateData(surface, &IID_IDirect3D, ddraw,
sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
+ size = 2 * sizeof(ptr);
hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3D, &ptr, &size);
ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr);
+ ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
refcount2 = get_refcount(ptr);
/* Object is NOT addref'ed by the getter. */
ok(ptr == (IUnknown *)ddraw, "Returned interface pointer is %p, expected %p.\n", ptr, ddraw);
ok(refcount2 == refcount + 1, "Got unexpected refcount %u.\n", refcount2);
+ ptr = (IUnknown *)0xdeadbeef;
+ size = 1;
+ hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3D, NULL, &size);
+ ok(hr == DDERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
+ ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+ size = 2 * sizeof(ptr);
+ hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3D, NULL, &size);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ ok(size == 2 * sizeof(ptr), "Got unexpected size %u.\n", size);
+ size = 1;
+ hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3D, &ptr, &size);
+ ok(hr == DDERR_MOREDATA, "Got unexpected hr %#x.\n", hr);
+ ok(size == sizeof(ddraw), "Got unexpected size %u.\n", size);
+ ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
+ hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3DViewport, NULL, NULL);
+ ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+ size = 0xdeadbabe;
+ hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3DViewport, &ptr, &size);
+ ok(hr == DDERR_NOTFOUND, "Got unexpected hr %#x.\n", hr);
+ ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
+ ok(size == 0xdeadbabe, "Got unexpected size %u.\n", size);
+ hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3D, NULL, NULL);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+
refcount3 = IDirectDrawSurface7_Release(surface);
ok(!refcount3, "Got unexpected refcount %u.\n", refcount3);
--
1.8.3.2
More information about the wine-patches
mailing list