Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 78 +++++++++++++++-----
dlls/ddraw/tests/ddraw2.c | 135 ++++++++++++++++++++++++----------
dlls/ddraw/tests/ddraw4.c | 149 ++++++++++++++++++++++++++------------
3 files changed, 256 insertions(+), 106 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 1f93a97329eb..7d8ccec7bbc6 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -1212,6 +1212,7 @@ static void test_viewport_object(void)
IDirect3D *d3d;
HRESULT hr;
ULONG ref;
+ D3DVIEWPORT vp;
IDirect3DViewport *viewport, *another_vp;
IDirect3DViewport2 *viewport2;
IDirect3DViewport3 *viewport3;
@@ -1219,6 +1220,11 @@ static void test_viewport_object(void)
IUnknown *unknown;
IDirect3DDevice *device;
HWND window;
+ union
+ {
+ D3DVIEWPORT vp1;
+ BYTE blob[1024];
+ } desc;
window = create_window();
ddraw = create_ddraw();
@@ -1234,14 +1240,28 @@ static void test_viewport_object(void)
hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D, (void **)&d3d);
ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) d3d);
- ok(ref == 2, "IDirect3D refcount is %d\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
hr = IDirect3D_CreateViewport(d3d, &viewport, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *)viewport);
- ok(ref == 1, "Initial IDirect3DViewport refcount is %u\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *)d3d);
- ok(ref == 2, "IDirect3D refcount is %u\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+
+ memset(&desc, 0, sizeof(desc));
+ hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1) + 1;
+ hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1) - 1;
+ hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1);
+ hr = IDirect3DViewport_GetViewport(viewport, &desc.vp1);
+ todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
+ ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
/* E_FAIL return values are returned by Winetestbot Windows NT machines. While not supporting
* newer interfaces is legitimate for old ddraw versions, E_FAIL violates Microsoft's rules
@@ -1259,9 +1279,9 @@ static void test_viewport_object(void)
if (viewport2)
{
ref = get_refcount((IUnknown *)viewport);
- ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *)viewport2);
- ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
IDirect3DViewport2_Release(viewport2);
viewport2 = NULL;
}
@@ -1272,47 +1292,65 @@ static void test_viewport_object(void)
if (viewport3)
{
ref = get_refcount((IUnknown *)viewport);
- ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *)viewport3);
- ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
IDirect3DViewport3_Release(viewport3);
}
hr = IDirect3DViewport_QueryInterface(viewport, &IID_IUnknown, (void **)&unknown);
ok(SUCCEEDED(hr), "Failed to QI IUnknown, hr %#x.\n", hr);
- if (unknown)
- {
- ref = get_refcount((IUnknown *)viewport);
- ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
- ref = get_refcount(unknown);
- ok(ref == 2, "IUnknown refcount is %u\n", ref);
- IUnknown_Release(unknown);
- }
+ ref = get_refcount((IUnknown *)viewport);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ ref = get_refcount(unknown);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ IUnknown_Release(unknown);
- /* AddViewport(NULL): Segfault */
hr = IDirect3DDevice_DeleteViewport(device, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirect3D_CreateViewport(d3d, &another_vp, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
+ /* AddViewport(NULL): Segfault */
hr = IDirect3DDevice_AddViewport(device, viewport);
ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport);
- ok(ref == 2, "IDirect3DViewport refcount is %d\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
hr = IDirect3DDevice_AddViewport(device, another_vp);
ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) another_vp);
- ok(ref == 2, "IDirect3DViewport refcount is %d\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+
+ memset(&vp, 0, sizeof(vp));
+ vp.dwX = 0;
+ vp.dwY = 0;
+ vp.dwWidth = 640;
+ vp.dwHeight = 480;
+ vp.dvMinZ = 0.0f;
+ vp.dvMaxZ = 1.0f;
+ vp.dvScaleX = vp.dwWidth / 2.0f;
+ vp.dvScaleY = vp.dwHeight / 2.0f;
+ vp.dvMaxX = 1.0f;
+ vp.dvMaxY = 1.0f;
+ hr = IDirect3DViewport_SetViewport(viewport, &vp);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+
+ vp.dwSize = sizeof(vp);
+ hr = IDirect3DViewport_SetViewport(viewport, &vp);
+ ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
hr = IDirect3DDevice_DeleteViewport(device, another_vp);
ok(SUCCEEDED(hr), "Failed to delete viewport from device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) another_vp);
- ok(ref == 1, "IDirect3DViewport refcount is %d\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
IDirect3DDevice_Release(device);
ref = get_refcount((IUnknown *) viewport);
- ok(ref == 1, "IDirect3DViewport refcount is %d\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+
+ hr = IDirect3DViewport_SetViewport(viewport, &vp);
+ ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
IDirect3DViewport_Release(another_vp);
IDirect3D_Release(d3d);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 95cdf8bd82d4..1ae7ffe3fae8 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -1380,6 +1380,8 @@ static void test_viewport_object(void)
IDirect3D2 *d3d;
HRESULT hr;
ULONG ref, old_d3d_ref;
+ D3DVIEWPORT vp;
+ D3DVIEWPORT2 vp2;
IDirect3DViewport *viewport;
IDirect3DViewport2 *viewport2, *another_vp, *test_vp;
IDirect3DViewport3 *viewport3;
@@ -1387,6 +1389,12 @@ static void test_viewport_object(void)
IUnknown *unknown;
IDirect3DDevice2 *device;
HWND window;
+ union
+ {
+ D3DVIEWPORT2 vp2;
+ D3DVIEWPORT vp1;
+ BYTE blob[1024];
+ } desc;
window = create_window();
ddraw = create_ddraw();
@@ -1412,52 +1420,64 @@ static void test_viewport_object(void)
hr = IDirect3D2_CreateViewport(d3d, &viewport2, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *)viewport2);
- ok(ref == 1, "Initial IDirect3DViewport2 refcount is %u\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *)d3d);
- ok(ref == old_d3d_ref, "IDirect3D2 refcount is %u\n", ref);
+ ok(ref == old_d3d_ref, "Got unexpected refcount %u.\n", ref);
+
+ memset(&desc, 0, sizeof(desc));
+ hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1) + 1;
+ hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1) - 1;
+ hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1);
+ hr = IDirect3DViewport2_GetViewport(viewport2, &desc.vp1);
+ todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
+ ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
+ hr = IDirect3DViewport2_GetViewport2(viewport2, &desc.vp2);
+ todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %u.\n", desc.vp2.dwSize);
+ desc.vp2.dwSize = sizeof(desc.vp2) + 1;
+ hr = IDirect3DViewport2_GetViewport2(viewport2, &desc.vp2);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
gamma = (IDirectDrawGammaControl *)0xdeadbeef;
hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IDirectDrawGammaControl, (void **)&gamma);
ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
- ok(gamma == NULL, "Interface not set to NULL by failed QI call: %p\n", gamma);
- if (SUCCEEDED(hr)) IDirectDrawGammaControl_Release(gamma);
+ ok(!gamma, "Interface not set to NULL by failed QI call: %p\n", gamma);
/* NULL iid: Segfaults */
hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IDirect3DViewport, (void **)&viewport);
ok(SUCCEEDED(hr), "Failed to QI IDirect3DViewport, hr %#x.\n", hr);
- if (viewport)
- {
- ref = get_refcount((IUnknown *)viewport);
- ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
- ref = get_refcount((IUnknown *)viewport2);
- ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
- IDirect3DViewport_Release(viewport);
- viewport = NULL;
- }
+ ref = get_refcount((IUnknown *)viewport);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ ref = get_refcount((IUnknown *)viewport2);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ IDirect3DViewport_Release(viewport);
+ viewport = NULL;
hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IDirect3DViewport3, (void **)&viewport3);
ok(SUCCEEDED(hr) || hr == E_NOINTERFACE, "Failed to QI IDirect3DViewport3, hr %#x.\n", hr);
if (viewport3)
{
ref = get_refcount((IUnknown *)viewport2);
- ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *)viewport3);
- ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
IDirect3DViewport3_Release(viewport3);
}
hr = IDirect3DViewport2_QueryInterface(viewport2, &IID_IUnknown, (void **)&unknown);
ok(SUCCEEDED(hr), "Failed to QI IUnknown, hr %#x.\n", hr);
- if (unknown)
- {
- ref = get_refcount((IUnknown *)viewport2);
- ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
- ref = get_refcount(unknown);
- ok(ref == 2, "IUnknown refcount is %u\n", ref);
- IUnknown_Release(unknown);
- }
+ ref = get_refcount((IUnknown *)viewport2);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ ref = get_refcount(unknown);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ IUnknown_Release(unknown);
- /* AddViewport(NULL): Segfault */
hr = IDirect3DDevice2_DeleteViewport(device, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_GetCurrentViewport(device, NULL);
@@ -1470,14 +1490,15 @@ static void test_viewport_object(void)
hr = IDirect3DDevice2_SetCurrentViewport(device, another_vp);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ /* AddViewport(NULL): Segfault */
hr = IDirect3DDevice2_AddViewport(device, viewport2);
ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport2);
- ok(ref == 2, "viewport2 refcount is %d\n", ref);
+ ok(ref == 2, "viewport2 refcount is %u.\n", ref);
hr = IDirect3DDevice2_AddViewport(device, another_vp);
ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) another_vp);
- ok(ref == 2, "another_vp refcount is %d\n", ref);
+ ok(ref == 2, "another_vp refcount is %u.\n", ref);
test_vp = (IDirect3DViewport2 *) 0xbaadc0de;
hr = IDirect3DDevice2_GetCurrentViewport(device, &test_vp);
@@ -1487,17 +1508,18 @@ static void test_viewport_object(void)
hr = IDirect3DDevice2_SetCurrentViewport(device, viewport2);
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport2);
- ok(ref == 3, "viewport2 refcount is %d\n", ref);
+ ok(ref == 3, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *) device);
- ok(ref == 1, "device refcount is %d\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
test_vp = NULL;
hr = IDirect3DDevice2_GetCurrentViewport(device, &test_vp);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(test_vp == viewport2, "Got unexpected viewport %p\n", test_vp);
ref = get_refcount((IUnknown *) viewport2);
- ok(ref == 4, "viewport2 refcount is %d\n", ref);
- if(test_vp) IDirect3DViewport2_Release(test_vp);
+ ok(ref == 4, "Got unexpected refcount %u.\n", ref);
+ if (test_vp)
+ IDirect3DViewport2_Release(test_vp);
/* GetCurrentViewport with a viewport set and NULL input param: Segfault */
@@ -1508,44 +1530,79 @@ static void test_viewport_object(void)
hr = IDirect3DDevice2_GetCurrentViewport(device, &test_vp);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(test_vp == viewport2, "Got unexpected viewport %p\n", test_vp);
- if(test_vp) IDirect3DViewport2_Release(test_vp);
+ if (test_vp)
+ IDirect3DViewport2_Release(test_vp);
/* SetCurrentViewport properly releases the old viewport's reference */
hr = IDirect3DDevice2_SetCurrentViewport(device, another_vp);
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport2);
- ok(ref == 2, "viewport2 refcount is %d\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *) another_vp);
- ok(ref == 3, "another_vp refcount is %d\n", ref);
+ ok(ref == 3, "Got unexpected refcount %u.\n", ref);
/* Deleting the viewport removes the reference added by AddViewport, but not
* the one added by SetCurrentViewport. */
hr = IDirect3DDevice2_DeleteViewport(device, another_vp);
ok(SUCCEEDED(hr), "Failed to delete viewport from device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) another_vp);
- todo_wine ok(ref == 2, "IDirect3DViewport2 refcount is %d\n", ref);
+ todo_wine ok(ref == 2, "Got unexpected refcount %u.\n", ref);
/* GetCurrentViewport fails though */
test_vp = NULL;
hr = IDirect3DDevice2_GetCurrentViewport(device, &test_vp);
ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#x.\n", hr);
- ok(test_vp == NULL, "Got unexpected viewport %p\n", test_vp);
- if(test_vp) IDirect3DViewport2_Release(test_vp);
+ ok(!test_vp, "Got unexpected viewport %p\n", test_vp);
/* Setting a different viewport does not free the leaked reference. How
* do I get rid of it? Leak the viewport for now. */
hr = IDirect3DDevice2_SetCurrentViewport(device, viewport2);
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport2);
- ok(ref == 3, "viewport2 refcount is %d\n", ref);
+ ok(ref == 3, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *) another_vp);
- todo_wine ok(ref == 2, "another_vp refcount is %d\n", ref);
+ todo_wine ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+
+ memset(&vp, 0, sizeof(vp));
+ memset(&vp, 0, sizeof(vp2));
+ vp.dwX = vp2.dwX = 0;
+ vp.dwY = vp2.dwY = 0;
+ vp.dwWidth = vp2.dwWidth = 640;
+ vp.dwHeight = vp2.dwHeight = 480;
+ vp.dvMinZ = vp2.dvMinZ = 0.0f;
+ vp.dvMaxZ = vp2.dvMaxZ = 1.0f;
+ vp.dvScaleX = vp.dwWidth / 2.0f;
+ vp.dvScaleY = vp.dwHeight / 2.0f;
+ vp.dvMaxX = 1.0f;
+ vp.dvMaxY = 1.0f;
+ vp2.dvClipX = -1.0f;
+ vp2.dvClipY = 1.0f;
+ vp2.dvClipWidth = 2.0f;
+ vp2.dvClipHeight = 2.0f;
+ hr = IDirect3DViewport2_SetViewport(viewport2, &vp);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DViewport2_SetViewport2(viewport2, &vp2);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+
+ vp.dwSize = sizeof(vp);
+ hr = IDirect3DViewport2_SetViewport(viewport2, &vp);
+ ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+ vp2.dwSize = sizeof(vp2);
+ hr = IDirect3DViewport2_SetViewport2(viewport2, &vp2);
+ ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
/* Destroying the device removes the viewport, but does not free the reference
* added by SetCurrentViewport. */
IDirect3DDevice2_Release(device);
ref = get_refcount((IUnknown *) viewport2);
- todo_wine ok(ref == 2, "viewport2 refcount is %d\n", ref);
+ todo_wine ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+
+ vp.dwSize = sizeof(vp);
+ hr = IDirect3DViewport2_SetViewport(viewport2, &vp);
+ ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+ vp2.dwSize = sizeof(vp2);
+ hr = IDirect3DViewport2_SetViewport2(viewport2, &vp2);
+ ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
IDirect3DViewport2_Release(another_vp);
IDirect3DViewport2_Release(viewport2);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index a62aaf0f30ec..28d724062fd8 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -1544,6 +1544,8 @@ static void test_viewport_object(void)
IDirect3D3 *d3d;
HRESULT hr, old_d3d_ref;
ULONG ref;
+ D3DVIEWPORT vp;
+ D3DVIEWPORT2 vp2;
IDirect3DViewport *viewport;
IDirect3DViewport2 *viewport2;
IDirect3DViewport3 *viewport3, *another_vp, *test_vp;
@@ -1551,6 +1553,12 @@ static void test_viewport_object(void)
IUnknown *unknown;
HWND window;
IDirect3DDevice3 *device;
+ union
+ {
+ D3DVIEWPORT2 vp2;
+ D3DVIEWPORT vp1;
+ BYTE blob[1024];
+ } desc;
window = create_window();
if (!(device = create_device(window, DDSCL_NORMAL)))
@@ -1568,52 +1576,61 @@ static void test_viewport_object(void)
hr = IDirect3D3_CreateViewport(d3d, &viewport3, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *)viewport3);
- ok(ref == 1, "Initial IDirect3DViewport3 refcount is %u\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *)d3d);
- ok(ref == old_d3d_ref, "IDirect3D3 refcount is %u\n", ref);
+ ok(ref == old_d3d_ref, "Got unexpected refcount %u.\n", ref);
+
+ memset(&desc, 0, sizeof(desc));
+ hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1) + 1;
+ hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1) - 1;
+ hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ desc.vp1.dwSize = sizeof(desc.vp1);
+ hr = IDirect3DViewport3_GetViewport(viewport3, &desc.vp1);
+ todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
+ ok(desc.vp1.dwSize == sizeof(desc.vp1), "Got unexpected dwSize %u.\n", desc.vp1.dwSize);
+ hr = IDirect3DViewport3_GetViewport2(viewport3, &desc.vp2);
+ todo_wine ok(hr == D3DERR_VIEWPORTDATANOTSET, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(desc.vp2.dwSize == sizeof(desc.vp2), "Got unexpected dwSize %u.\n", desc.vp2.dwSize);
+ desc.vp2.dwSize = sizeof(desc.vp2) + 1;
+ hr = IDirect3DViewport3_GetViewport2(viewport3, &desc.vp2);
+ todo_wine ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
gamma = (IDirectDrawGammaControl *)0xdeadbeef;
hr = IDirect3DViewport2_QueryInterface(viewport3, &IID_IDirectDrawGammaControl, (void **)&gamma);
ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr);
- ok(gamma == NULL, "Interface not set to NULL by failed QI call: %p\n", gamma);
- if (SUCCEEDED(hr)) IDirectDrawGammaControl_Release(gamma);
+ ok(!gamma, "Interface not set to NULL by failed QI call: %p\n", gamma);
/* NULL iid: Segfaults */
hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IDirect3DViewport, (void **)&viewport);
ok(SUCCEEDED(hr), "Failed to QI IDirect3DViewport, hr %#x.\n", hr);
- if (viewport)
- {
- ref = get_refcount((IUnknown *)viewport);
- ok(ref == 2, "IDirect3DViewport refcount is %u\n", ref);
- ref = get_refcount((IUnknown *)viewport3);
- ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
- IDirect3DViewport_Release(viewport);
- viewport = NULL;
- }
+ ref = get_refcount((IUnknown *)viewport);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ ref = get_refcount((IUnknown *)viewport3);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ IDirect3DViewport_Release(viewport);
+ viewport = NULL;
hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IDirect3DViewport3, (void **)&viewport2);
ok(SUCCEEDED(hr), "Failed to QI IDirect3DViewport3, hr %#x.\n", hr);
- if (viewport2)
- {
- ref = get_refcount((IUnknown *)viewport2);
- ok(ref == 2, "IDirect3DViewport2 refcount is %u\n", ref);
- ref = get_refcount((IUnknown *)viewport3);
- ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
- IDirect3DViewport3_Release(viewport2);
- }
+ ref = get_refcount((IUnknown *)viewport2);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ ref = get_refcount((IUnknown *)viewport3);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ IDirect3DViewport3_Release(viewport2);
hr = IDirect3DViewport3_QueryInterface(viewport3, &IID_IUnknown, (void **)&unknown);
ok(SUCCEEDED(hr), "Failed to QI IUnknown, hr %#x.\n", hr);
- if (unknown)
- {
- ref = get_refcount((IUnknown *)viewport3);
- ok(ref == 2, "IDirect3DViewport3 refcount is %u\n", ref);
- ref = get_refcount(unknown);
- ok(ref == 2, "IUnknown refcount is %u\n", ref);
- IUnknown_Release(unknown);
- }
+ ref = get_refcount((IUnknown *)viewport3);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ ref = get_refcount(unknown);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
+ IUnknown_Release(unknown);
- /* AddViewport(NULL): Segfault */
hr = IDirect3DDevice3_DeleteViewport(device, NULL);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_GetCurrentViewport(device, NULL);
@@ -1626,14 +1643,15 @@ static void test_viewport_object(void)
hr = IDirect3DDevice3_SetCurrentViewport(device, another_vp);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ /* AddViewport(NULL): Segfault */
hr = IDirect3DDevice3_AddViewport(device, viewport3);
ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport3);
- ok(ref == 2, "viewport3 refcount is %d\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
hr = IDirect3DDevice3_AddViewport(device, another_vp);
ok(SUCCEEDED(hr), "Failed to add viewport to device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) another_vp);
- ok(ref == 2, "another_vp refcount is %d\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
test_vp = (IDirect3DViewport3 *) 0xbaadc0de;
hr = IDirect3DDevice3_GetCurrentViewport(device, &test_vp);
@@ -1643,17 +1661,18 @@ static void test_viewport_object(void)
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport3);
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport3);
- ok(ref == 3, "viewport3 refcount is %d\n", ref);
+ ok(ref == 3, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *) device);
- ok(ref == 1, "device refcount is %d\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
test_vp = NULL;
hr = IDirect3DDevice3_GetCurrentViewport(device, &test_vp);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(test_vp == viewport3, "Got unexpected viewport %p\n", test_vp);
ref = get_refcount((IUnknown *) viewport3);
- ok(ref == 4, "viewport3 refcount is %d\n", ref);
- if(test_vp) IDirect3DViewport3_Release(test_vp);
+ ok(ref == 4, "Got unexpected refcount %u.\n", ref);
+ if (test_vp)
+ IDirect3DViewport3_Release(test_vp);
/* GetCurrentViewport with a viewport set and NULL input param: Segfault */
@@ -1664,47 +1683,83 @@ static void test_viewport_object(void)
hr = IDirect3DDevice3_GetCurrentViewport(device, &test_vp);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(test_vp == viewport3, "Got unexpected viewport %p\n", test_vp);
- if(test_vp) IDirect3DViewport3_Release(test_vp);
+ if (test_vp)
+ IDirect3DViewport3_Release(test_vp);
/* SetCurrentViewport properly releases the old viewport's reference */
hr = IDirect3DDevice3_SetCurrentViewport(device, another_vp);
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport3);
- ok(ref == 2, "viewport3 refcount is %d\n", ref);
+ ok(ref == 2, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *) another_vp);
- ok(ref == 3, "another_vp refcount is %d\n", ref);
+ ok(ref == 3, "Got unexpected refcount %u.\n", ref);
/* Unlike device2::DeleteViewport, device3::DeleteViewport releases the
* reference held by SetCurrentViewport */
hr = IDirect3DDevice3_DeleteViewport(device, another_vp);
ok(SUCCEEDED(hr), "Failed to delete viewport from device, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) another_vp);
- ok(ref == 1, "another_vp refcount is %d\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
/* GetCurrentViewport still fails */
test_vp = NULL;
hr = IDirect3DDevice3_GetCurrentViewport(device, &test_vp);
ok(hr == D3DERR_NOCURRENTVIEWPORT, "Got unexpected hr %#x.\n", hr);
- ok(test_vp == NULL, "Got unexpected viewport %p\n", test_vp);
- if(test_vp) IDirect3DViewport3_Release(test_vp);
+ ok(!test_vp, "Got unexpected viewport %p\n", test_vp);
/* Setting a different viewport doesn't have any surprises now */
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport3);
ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
ref = get_refcount((IUnknown *) viewport3);
- ok(ref == 3, "viewport3 refcount is %d\n", ref);
+ ok(ref == 3, "Got unexpected refcount %u.\n", ref);
ref = get_refcount((IUnknown *) another_vp);
- ok(ref == 1, "another_vp refcount is %d\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+
+ memset(&vp, 0, sizeof(vp));
+ memset(&vp, 0, sizeof(vp2));
+ vp.dwSize = vp2.dwSize = 0;
+ vp.dwX = vp2.dwX = 0;
+ vp.dwY = vp2.dwY = 0;
+ vp.dwWidth = vp2.dwWidth = 640;
+ vp.dwHeight = vp2.dwHeight = 480;
+ vp.dvMinZ = vp2.dvMinZ = 0.0f;
+ vp.dvMaxZ = vp2.dvMaxZ = 1.0f;
+ vp.dvScaleX = vp.dwWidth / 2.0f;
+ vp.dvScaleY = vp.dwHeight / 2.0f;
+ vp.dvMaxX = 1.0f;
+ vp.dvMaxY = 1.0f;
+ vp2.dvClipX = -1.0f;
+ vp2.dvClipY = 1.0f;
+ vp2.dvClipWidth = 2.0f;
+ vp2.dvClipHeight = 2.0f;
+ hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DViewport3_SetViewport2(viewport3, &vp2);
+ ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+
+ vp.dwSize = sizeof(vp);
+ hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
+ ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
+ vp2.dwSize = sizeof(vp2);
+ hr = IDirect3DViewport3_SetViewport2(viewport3, &vp2);
+ ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x.\n", hr);
/* Destroying the device removes the viewport and releases the reference */
IDirect3DDevice3_Release(device);
ref = get_refcount((IUnknown *) viewport3);
- ok(ref == 1, "viewport3 refcount is %d\n", ref);
+ ok(ref == 1, "Got unexpected refcount %u.\n", ref);
+
+ vp.dwSize = sizeof(vp);
+ hr = IDirect3DViewport3_SetViewport(viewport3, &vp);
+ ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
+ vp2.dwSize = sizeof(vp2);
+ hr = IDirect3DViewport3_SetViewport2(viewport3, &vp2);
+ ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
ref = IDirect3DViewport3_Release(another_vp);
- ok(ref == 0, "Got unexpected ref %d\n", ref);
+ ok(!ref, "Got unexpected refcount %u.\n", ref);
ref = IDirect3DViewport3_Release(viewport3);
- ok(ref == 0, "Got unexpected ref %d\n", ref);
+ ok(!ref, "Got unexpected refcount %u.\n", ref);
IDirect3D3_Release(d3d);
DestroyWindow(window);
IDirectDraw4_Release(ddraw);
--
2.18.1