Commit 1d9ff5c4 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw/tests: Test GetPrivateData size behavior.

parent 7d793715
...@@ -6122,13 +6122,39 @@ static void test_private_data(void) ...@@ -6122,13 +6122,39 @@ static void test_private_data(void)
hr = IDirectDrawSurface4_SetPrivateData(surface, &IID_IDirect3D, ddraw, hr = IDirectDrawSurface4_SetPrivateData(surface, &IID_IDirect3D, ddraw,
sizeof(ddraw), DDSPD_IUNKNOWNPOINTER); sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
size = 2 * sizeof(ptr);
hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3D, &ptr, &size); hr = IDirectDrawSurface4_GetPrivateData(surface, &IID_IDirect3D, &ptr, &size);
ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr); 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); refcount2 = get_refcount(ptr);
/* Object is NOT addref'ed by the getter. */ /* Object is NOT addref'ed by the getter. */
ok(ptr == (IUnknown *)ddraw, "Returned interface pointer is %p, expected %p.\n", ptr, ddraw); ok(ptr == (IUnknown *)ddraw, "Returned interface pointer is %p, expected %p.\n", ptr, ddraw);
ok(refcount2 == refcount + 1, "Got unexpected refcount %u.\n", refcount2); 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); refcount3 = IDirectDrawSurface4_Release(surface);
ok(!refcount3, "Got unexpected refcount %u.\n", refcount3); ok(!refcount3, "Got unexpected refcount %u.\n", refcount3);
......
...@@ -5977,13 +5977,39 @@ static void test_private_data(void) ...@@ -5977,13 +5977,39 @@ static void test_private_data(void)
hr = IDirectDrawSurface7_SetPrivateData(surface, &IID_IDirect3D, ddraw, hr = IDirectDrawSurface7_SetPrivateData(surface, &IID_IDirect3D, ddraw,
sizeof(ddraw), DDSPD_IUNKNOWNPOINTER); sizeof(ddraw), DDSPD_IUNKNOWNPOINTER);
ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to set private data, hr %#x.\n", hr);
size = 2 * sizeof(ptr);
hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3D, &ptr, &size); hr = IDirectDrawSurface7_GetPrivateData(surface, &IID_IDirect3D, &ptr, &size);
ok(SUCCEEDED(hr), "Failed to get private data, hr %#x.\n", hr); 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); refcount2 = get_refcount(ptr);
/* Object is NOT addref'ed by the getter. */ /* Object is NOT addref'ed by the getter. */
ok(ptr == (IUnknown *)ddraw, "Returned interface pointer is %p, expected %p.\n", ptr, ddraw); ok(ptr == (IUnknown *)ddraw, "Returned interface pointer is %p, expected %p.\n", ptr, ddraw);
ok(refcount2 == refcount + 1, "Got unexpected refcount %u.\n", refcount2); 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); refcount3 = IDirectDrawSurface7_Release(surface);
ok(!refcount3, "Got unexpected refcount %u.\n", refcount3); ok(!refcount3, "Got unexpected refcount %u.\n", refcount3);
......
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