Author: akhaldi
Date: Sat Jul 2 15:34:17 2016
New Revision: 71758
URL:
http://svn.reactos.org/svn/reactos?rev=71758&view=rev
Log:
[D3DRM_WINETEST] Sync with Wine Staging 1.9.11. CORE-11368
Modified:
trunk/rostests/winetests/d3drm/d3drm.c
Modified: trunk/rostests/winetests/d3drm/d3drm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/d3drm/d3drm.c?r…
==============================================================================
--- trunk/rostests/winetests/d3drm/d3drm.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/d3drm/d3drm.c [iso-8859-1] Sat Jul 2 15:34:17 2016
@@ -994,6 +994,8 @@
ok(hr == D3DRM_OK, "Cannot get parent frame (hr = %x)\n", hr);
ok(pFrameTmp == pFrameP1, "pFrameTmp = %p\n", pFrameTmp);
CHECK_REFCOUNT(pFrameP1, 2);
+ IDirect3DRMFrame_Release(pFrameTmp);
+ CHECK_REFCOUNT(pFrameP1, 1);
/* Add child to second parent */
hr = IDirect3DRM_CreateFrame(d3drm, NULL, &pFrameP2);
@@ -1037,6 +1039,8 @@
ok(pFrameTmp == pFrameP2, "pFrameTmp = %p\n", pFrameTmp);
CHECK_REFCOUNT(pFrameP2, 2);
CHECK_REFCOUNT(pFrameC, 2);
+ IDirect3DRMFrame_Release(pFrameTmp);
+ CHECK_REFCOUNT(pFrameP2, 1);
/* Add child again */
hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameC);
@@ -1088,7 +1092,7 @@
hr = IDirect3DRMFrame_AddChild(pFrameP2, pFrameP1);
ok(hr == D3DRM_OK, "Cannot add child frame (hr = %x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
frame_array = NULL;
hr = IDirect3DRMFrame_GetChildren(pFrameP2, &frame_array);
@@ -1111,11 +1115,11 @@
/* [Add/Delete]Visual with NULL pointer */
hr = IDirect3DRMFrame_AddVisual(pFrameP1, NULL);
ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr =
%x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
hr = IDirect3DRMFrame_DeleteVisual(pFrameP1, NULL);
ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr =
%x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
/* Create Visual */
hr = IDirect3DRM_CreateMeshBuilder(d3drm, &mesh_builder);
@@ -1125,7 +1129,7 @@
/* Add Visual to first parent */
hr = IDirect3DRMFrame_AddVisual(pFrameP1, visual1);
ok(hr == D3DRM_OK, "Cannot add visual (hr = %x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
CHECK_REFCOUNT(visual1, 2);
visual_array = NULL;
@@ -1145,17 +1149,17 @@
/* Delete Visual */
hr = IDirect3DRMFrame_DeleteVisual(pFrameP1, visual1);
ok(hr == D3DRM_OK, "Cannot delete visual (hr = %x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
IDirect3DRMMeshBuilder_Release(mesh_builder);
/* [Add/Delete]Light with NULL pointer */
hr = IDirect3DRMFrame_AddLight(pFrameP1, NULL);
ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr =
%x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
hr = IDirect3DRMFrame_DeleteLight(pFrameP1, NULL);
ok(hr == D3DRMERR_BADOBJECT, "Should have returned D3DRMERR_BADOBJECT (hr =
%x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
/* Create Light */
hr = IDirect3DRM_CreateLightRGB(d3drm, D3DRMLIGHT_SPOT, 0.1, 0.2, 0.3, &light1);
@@ -1164,7 +1168,7 @@
/* Add Light to first parent */
hr = IDirect3DRMFrame_AddLight(pFrameP1, light1);
ok(hr == D3DRM_OK, "Cannot add light (hr = %x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
CHECK_REFCOUNT(light1, 2);
light_array = NULL;
@@ -1184,7 +1188,7 @@
/* Delete Light */
hr = IDirect3DRMFrame_DeleteLight(pFrameP1, light1);
ok(hr == D3DRM_OK, "Cannot delete light (hr = %x)\n", hr);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameP1, 2);
IDirect3DRMLight_Release(light1);
/* Test SceneBackground on first parent */
@@ -1203,13 +1207,258 @@
/* Cleanup */
IDirect3DRMFrame_Release(pFrameP2);
- CHECK_REFCOUNT(pFrameC, 2);
- CHECK_REFCOUNT(pFrameP1, 3);
+ CHECK_REFCOUNT(pFrameC, 1);
+ CHECK_REFCOUNT(pFrameP1, 1);
IDirect3DRMFrame_Release(pFrameC);
IDirect3DRMFrame_Release(pFrameP1);
IDirect3DRM_Release(d3drm);
+}
+
+struct destroy_context
+{
+ IDirect3DRMObject *obj;
+ unsigned int test_idx;
+ int called;
+};
+
+struct callback_order
+{
+ void *callback;
+ void *context;
+} corder[3], d3drm_corder[3];
+
+static void CDECL destroy_callback(IDirect3DRMObject *obj, void *arg)
+{
+ struct destroy_context *ctxt = arg;
+ ok(ctxt->called == 1 || ctxt->called == 2, "got called counter %d\n",
ctxt->called);
+ ok(obj == ctxt->obj, "called with %p, expected %p\n", obj,
ctxt->obj);
+ d3drm_corder[ctxt->called].callback = &destroy_callback;
+ d3drm_corder[ctxt->called++].context = ctxt;
+}
+
+static void CDECL destroy_callback1(IDirect3DRMObject *obj, void *arg)
+{
+ struct destroy_context *ctxt = (struct destroy_context*)arg;
+ ok(ctxt->called == 0, "got called counter %d\n", ctxt->called);
+ ok(obj == ctxt->obj, "called with %p, expected %p\n", obj,
ctxt->obj);
+ d3drm_corder[ctxt->called].callback = &destroy_callback1;
+ d3drm_corder[ctxt->called++].context = ctxt;
+}
+
+static void test_destroy_callback(unsigned int test_idx, REFCLSID clsid, REFIID iid)
+{
+ struct destroy_context context;
+ IDirect3DRMObject *obj;
+ IUnknown *unknown;
+ IDirect3DRM *d3drm;
+ HRESULT hr;
+ int i;
+
+ hr = Direct3DRMCreate(&d3drm);
+ ok(SUCCEEDED(hr), "Test %u: Cannot get IDirect3DRM interface (hr = %x).\n",
test_idx, hr);
+
+ hr = IDirect3DRM_CreateObject(d3drm, clsid, NULL, iid, (void **)&unknown);
+ ok(hr == D3DRM_OK, "Test %u: Cannot get IDirect3DRMObject interface (hr =
%x).\n", test_idx, hr);
+ hr = IUnknown_QueryInterface(unknown, &IID_IDirect3DRMObject, (void**)&obj);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+ IUnknown_Release(unknown);
+
+ context.called = 0;
+ context.test_idx = test_idx;
+ context.obj = obj;
+
+ hr = IDirect3DRMObject_AddDestroyCallback(obj, NULL, &context);
+ ok(hr == D3DRMERR_BADVALUE, "Test %u: expected D3DRMERR_BADVALUE (hr =
%x).\n", test_idx, hr);
+
+ hr = IDirect3DRMObject_AddDestroyCallback(obj, destroy_callback, &context);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+ corder[2].callback = &destroy_callback;
+ corder[2].context = &context;
+
+ /* same callback added twice */
+ hr = IDirect3DRMObject_AddDestroyCallback(obj, destroy_callback, &context);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+ corder[1].callback = &destroy_callback;
+ corder[1].context = &context;
+
+ hr = IDirect3DRMObject_DeleteDestroyCallback(obj, destroy_callback1, NULL);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+
+ hr = IDirect3DRMObject_DeleteDestroyCallback(obj, destroy_callback1, &context);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+
+ /* add one more */
+ hr = IDirect3DRMObject_AddDestroyCallback(obj, destroy_callback1, &context);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+ corder[0].callback = &destroy_callback1;
+ corder[0].context = &context;
+
+ hr = IDirect3DRMObject_DeleteDestroyCallback(obj, NULL, NULL);
+ ok(hr == D3DRMERR_BADVALUE, "Test %u: expected D3DRM_BADVALUE (hr =
%x).\n", test_idx, hr);
+
+ context.called = 0;
+ IDirect3DRMObject_Release(obj);
+ ok(context.called == 3, "Test %u: got %d, expected 3.\n", test_idx,
context.called);
+ for (i = 0; i < context.called; i++)
+ {
+ ok(corder[i].callback == d3drm_corder[i].callback
+ && corder[i].context == d3drm_corder[i].context,
+ "Expected callback = %p, context = %p. Got callback = %p, context =
%p.\n", d3drm_corder[i].callback,
+ d3drm_corder[i].context, corder[i].callback, corder[i].context);
+ }
+
+ /* test this pattern - add cb1, add cb2, add cb1, delete cb1 */
+ hr = IDirect3DRM_CreateObject(d3drm, clsid, NULL, iid, (void **)&unknown);
+ ok(hr == D3DRM_OK, "Test %u: Cannot get IDirect3DRMObject interface (hr =
%x).\n", test_idx, hr);
+ hr = IUnknown_QueryInterface(unknown, &IID_IDirect3DRMObject, (void**)&obj);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+ IUnknown_Release(unknown);
+
+ hr = IDirect3DRMObject_AddDestroyCallback(obj, destroy_callback, &context);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+ corder[1].callback = &destroy_callback;
+ corder[1].context = &context;
+
+ hr = IDirect3DRMObject_AddDestroyCallback(obj, destroy_callback1, &context);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+ corder[0].callback = &destroy_callback1;
+ corder[0].context = &context;
+
+ hr = IDirect3DRMObject_AddDestroyCallback(obj, destroy_callback, &context);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+
+ hr = IDirect3DRMObject_DeleteDestroyCallback(obj, destroy_callback, &context);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+
+ context.called = 0;
+ hr = IDirect3DRMObject_QueryInterface(obj, &IID_IDirect3DRMObject,
(void**)&context.obj);
+ ok(hr == D3DRM_OK, "Test %u: expected D3DRM_OK (hr = %x).\n", test_idx,
hr);
+ IDirect3DRMObject_Release(context.obj);
+ IUnknown_Release(unknown);
+ ok(context.called == 2, "Test %u: got %d, expected 2.\n", test_idx,
context.called);
+ for (i = 0; i < context.called; i++)
+ {
+ ok(corder[i].callback == d3drm_corder[i].callback
+ && corder[i].context == d3drm_corder[i].context,
+ "Expected callback = %p, context = %p. Got callback = %p, context =
%p.\n", d3drm_corder[i].callback,
+ d3drm_corder[i].context, corder[i].callback, corder[i].context);
+ }
+}
+
+static void test_object(void)
+{
+ static const struct
+ {
+ REFCLSID clsid;
+ REFIID iid;
+ BOOL todo;
+ }
+ tests[] =
+ {
+ { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice, TRUE
},
+ { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice2, TRUE
},
+ { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMDevice3, TRUE
},
+ { &CLSID_CDirect3DRMDevice, &IID_IDirect3DRMWinDevice, TRUE
},
+ { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture, FALSE
},
+ { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture2, FALSE
},
+ { &CLSID_CDirect3DRMTexture, &IID_IDirect3DRMTexture3, FALSE
},
+ { &CLSID_CDirect3DRMViewport, &IID_IDirect3DRMViewport, TRUE
},
+ { &CLSID_CDirect3DRMViewport, &IID_IDirect3DRMViewport2, TRUE
},
+ };
+ IDirect3DRM *d3drm1;
+ IDirect3DRM2 *d3drm2;
+ IDirect3DRM3 *d3drm3;
+ IUnknown *unknown = (IUnknown *)0xdeadbeef;
+ HRESULT hr;
+ ULONG ref1, ref2, ref3, ref4;
+ int i;
+
+ hr = Direct3DRMCreate(&d3drm1);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface (hr = %#x).\n", hr);
+ ref1 = get_refcount((IUnknown *)d3drm1);
+ hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void
**)&d3drm2);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface (hr = %#x).\n", hr);
+ hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void
**)&d3drm3);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr);
+
+ hr = IDirect3DRM_CreateObject(d3drm1, &CLSID_DirectDraw, NULL,
&IID_IDirectDraw, (void **)&unknown);
+ ok(hr == CLASSFACTORY_E_FIRST, "Expected hr == CLASSFACTORY_E_FIRST, got
%#x.\n", hr);
+ ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
+
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ unknown = (IUnknown *)0xdeadbeef;
+ hr = IDirect3DRM_CreateObject(d3drm1, NULL, NULL, tests[i].iid, (void
**)&unknown);
+ ok(hr == D3DRMERR_BADVALUE, "Test %u: expected hr == D3DRMERR_BADVALUE, got
%#x.\n", i, hr);
+ ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
+ unknown = (IUnknown *)0xdeadbeef;
+ hr = IDirect3DRM_CreateObject(d3drm1, tests[i].clsid, NULL, NULL, (void
**)&unknown);
+ ok(hr == D3DRMERR_BADVALUE, "Test %u: expected hr == D3DRMERR_BADVALUE, got
%#x.\n", i, hr);
+ ok(!unknown, "Expected object returned == NULL, got %p.\n", unknown);
+ hr = IDirect3DRM_CreateObject(d3drm1, tests[i].clsid, NULL, NULL, NULL);
+ ok(hr == D3DRMERR_BADVALUE, "Test %u: expected hr == D3DRMERR_BADVALUE, got
%#x.\n", i, hr);
+
+ hr = IDirect3DRM_CreateObject(d3drm1, tests[i].clsid, NULL, tests[i].iid, (void
**)&unknown);
+ todo_wine_if(tests[i].todo)
+ ok(SUCCEEDED(hr), "Test %u: expected hr == D3DRM_OK, got %#x.\n", i,
hr);
+ if (SUCCEEDED(hr))
+ {
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 =
%u.\n", i, ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 =
%u.\n", i, ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 =
%u.\n", i, ref1, ref4);
+ IUnknown_Release(unknown);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 =
%u.\n", i, ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 =
%u.\n", i, ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 =
%u.\n", i, ref1, ref4);
+
+ /* test Add/Destroy callbacks */
+ test_destroy_callback(i, tests[i].clsid, tests[i].iid);
+
+ hr = IDirect3DRM2_CreateObject(d3drm2, tests[i].clsid, NULL, tests[i].iid,
(void **)&unknown);
+ ok(SUCCEEDED(hr), "Test %u: expected hr == D3DRM_OK, got %#x.\n",
i, hr);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 =
%u.\n", i, ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 =
%u.\n", i, ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 =
%u.\n", i, ref1, ref4);
+ IUnknown_Release(unknown);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 =
%u.\n", i, ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 =
%u.\n", i, ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 =
%u.\n", i, ref1, ref4);
+
+ hr = IDirect3DRM3_CreateObject(d3drm3, tests[i].clsid, NULL, tests[i].iid,
(void **)&unknown);
+ ok(SUCCEEDED(hr), "Test %u: expected hr == D3DRM_OK, got %#x.\n",
i, hr);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 =
%u.\n", i, ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 =
%u.\n", i, ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 =
%u.\n", i, ref1, ref4);
+ IUnknown_Release(unknown);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "Test %u: expected ref2 == ref1, got ref1 = %u, ref2 =
%u.\n", i, ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "Test %u: expected ref3 == ref1, got ref1 = %u, ref3 =
%u.\n", i, ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "Test %u: expected ref4 == ref1, got ref1 = %u, ref4 =
%u.\n", i, ref1, ref4);
+ }
+ }
+
+ IDirect3DRM_Release(d3drm1);
+ IDirect3DRM2_Release(d3drm2);
+ IDirect3DRM3_Release(d3drm3);
}
static void test_Viewport(void)
@@ -1220,10 +1469,12 @@
IDirect3DRMDevice *device;
IDirect3DRMFrame *frame;
IDirect3DRMViewport *viewport;
+ IDirect3DRMViewport2 *viewport2;
+ IDirect3DRMObject *obj, *obj2;
GUID driver;
HWND window;
RECT rc;
- DWORD size;
+ DWORD size, data;
CHAR cname[64] = {0};
window = CreateWindowA("static", "d3drm_test",
WS_OVERLAPPEDWINDOW, 0, 0, 300, 200, 0, 0, 0, 0);
@@ -1247,6 +1498,22 @@
hr = IDirect3DRM_CreateViewport(d3drm, device, frame, rc.left, rc.top, rc.right,
rc.bottom, &viewport);
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %x)\n",
hr);
+
+ hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMObject,
(void**)&obj);
+ ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
+ ok((IDirect3DRMObject*)viewport == obj, "got object pointer %p, expected
%p\n", obj, viewport);
+
+ hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMViewport2,
(void**)&viewport2);
+ ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
+
+ hr = IDirect3DRMViewport2_QueryInterface(viewport2, &IID_IDirect3DRMObject,
(void**)&obj2);
+ ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
+ ok(obj == obj2, "got object pointer %p, expected %p\n", obj2, obj);
+ ok((IUnknown*)viewport != (IUnknown*)viewport2, "got viewport1 %p, viewport2
%p\n", viewport, viewport2);
+
+ IDirect3DRMViewport2_Release(viewport2);
+ IDirect3DRMObject_Release(obj);
+ IDirect3DRMObject_Release(obj2);
hr = IDirect3DRMViewport_GetClassName(viewport, NULL, cname);
ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
@@ -1261,7 +1528,26 @@
ok(size == sizeof("Viewport"), "wrong size: %u\n", size);
ok(!strcmp(cname, "Viewport"), "Expected cname to be
\"Viewport\", but got \"%s\"\n", cname);
- IDirect3DRMViewport_Release(viewport);
+ /* AppData */
+ hr = IDirect3DRMViewport_SetAppData(viewport, 0);
+ ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
+
+ hr = IDirect3DRMViewport_SetAppData(viewport, 0);
+ ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
+
+ hr = IDirect3DRMViewport_SetAppData(viewport, 1);
+ ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
+
+ hr = IDirect3DRMViewport_SetAppData(viewport, 1);
+ ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
+
+ hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMViewport2,
(void**)&viewport2);
+ ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
+
+ data = IDirect3DRMViewport2_GetAppData(viewport2);
+ ok(data == 1, "got %x\n", data);
+ IDirect3DRMViewport2_Release(viewport2);
+
IDirect3DRMFrame_Release(frame);
IDirect3DRMDevice_Release(device);
IDirectDrawClipper_Release(pClipper);
@@ -1408,40 +1694,403 @@
static void test_Texture(void)
{
HRESULT hr;
- IDirect3DRM *d3drm;
- IDirect3DRMTexture *texture;
- D3DRMIMAGE initimg = {
+ IDirect3DRM *d3drm1;
+ IDirect3DRM2 *d3drm2;
+ IDirect3DRM3 *d3drm3;
+ IDirect3DRMTexture *texture1;
+ IDirect3DRMTexture2 *texture2;
+ IDirect3DRMTexture3 *texture3;
+
+ D3DRMIMAGE initimg =
+ {
2, 2, 1, 1, 32,
TRUE, 2 * sizeof(DWORD), NULL, NULL,
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 0, NULL
- };
+ },
+ testimg =
+ {
+ 0, 0, 0, 0, 0,
+ TRUE, 0, (void *)0xcafebabe, NULL,
+ 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL
+ },
+ *d3drm_img = NULL;
+
DWORD pixel[4] = { 20000, 30000, 10000, 0 };
DWORD size;
CHAR cname[64] = {0};
-
- hr = Direct3DRMCreate(&d3drm);
- ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
+ ULONG ref1, ref2, ref3, ref4;
+
+ hr = Direct3DRMCreate(&d3drm1);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
+ ref1 = get_refcount((IUnknown *)d3drm1);
+
+ hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void
**)&d3drm2);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRM2 interface (hr = %x).\n", hr);
+
+ hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void
**)&d3drm3);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);
+
+ /* Test NULL params */
+ texture1 = (IDirect3DRMTexture *)0xdeadbeef;
+ hr = IDirect3DRM_CreateTexture(d3drm1, NULL, &texture1);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ ok(!texture1, "Expected texture returned == NULL, got %p.\n", texture1);
+ hr = IDirect3DRM_CreateTexture(d3drm1, NULL, NULL);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+
+ texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
+ hr = IDirect3DRM2_CreateTexture(d3drm2, NULL, &texture2);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ ok(!texture2, "Expected texture returned == NULL, got %p.\n", texture2);
+ hr = IDirect3DRM2_CreateTexture(d3drm2, NULL, NULL);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+
+ texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
+ hr = IDirect3DRM3_CreateTexture(d3drm3, NULL, &texture3);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ ok(!texture3, "Expected texture returned == NULL, got %p.\n", texture3);
+ hr = IDirect3DRM3_CreateTexture(d3drm3, NULL, NULL);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+
+ /* Tests for validation of D3DRMIMAGE struct */
+ hr = IDirect3DRM_CreateTexture(d3drm1, &testimg, &texture1);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n",
hr);
+ hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg, &texture2);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n",
hr);
+ hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n",
hr);
+ IDirect3DRMTexture_Release(texture1);
+ IDirect3DRMTexture2_Release(texture2);
+ IDirect3DRMTexture3_Release(texture3);
+
+ testimg.rgb = 0;
+ testimg.palette = (void *)0xdeadbeef;
+ testimg.palette_size = 0x39;
+ hr = IDirect3DRM_CreateTexture(d3drm1, &testimg, &texture1);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n",
hr);
+ hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg, &texture2);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n",
hr);
+ hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg, &texture3);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n",
hr);
+ IDirect3DRMTexture_Release(texture1);
+ IDirect3DRMTexture2_Release(texture2);
+ IDirect3DRMTexture3_Release(texture3);
+
+ initimg.rgb = 0;
+ texture1 = (IDirect3DRMTexture *)0xdeadbeef;
+ hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ ok(!texture1, "Expected texture == NULL, got %p.\n", texture1);
+ texture2 = (IDirect3DRMTexture2 *)0xdeadbeef;
+ hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ ok(!texture2, "Expected texture == NULL, got %p.\n", texture2);
+ texture3 = (IDirect3DRMTexture3 *)0xdeadbeef;
+ hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ ok(!texture3, "Expected texture == NULL, got %p.\n", texture3);
+ initimg.rgb = 1;
+ initimg.red_mask = 0;
+ hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ initimg.red_mask = 0x000000ff;
+ initimg.green_mask = 0;
+ hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ initimg.green_mask = 0x0000ff00;
+ initimg.blue_mask = 0;
+ hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ initimg.blue_mask = 0x00ff0000;
+ initimg.buffer1 = NULL;
+ hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
+ hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
+ ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n",
hr);
initimg.buffer1 = &pixel;
- hr = IDirect3DRM_CreateTexture(d3drm, &initimg, &texture);
- ok(hr == D3DRM_OK, "Cannot get IDirect3DRMTexture interface (hr = %x)\n",
hr);
-
- hr = IDirect3DRMTexture_GetClassName(texture, NULL, cname);
+ hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface (hr = %#x)\n",
hr);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n",
ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n",
ref1, ref4);
+ hr = IDirect3DRM2_CreateTexture(d3drm2, &initimg, &texture2);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x)\n",
hr);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 > ref1 + 1, "expected ref2 > (ref1 + 1), got ref1 = %u , ref2 =
%u.\n", ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n",
ref1, ref4);
+ hr = IDirect3DRM3_CreateTexture(d3drm3, &initimg, &texture3);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x)\n",
hr);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 > ref1 + 2, "expected ref2 > (ref1 + 2), got ref1 = %u , ref2 =
%u.\n", ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n",
ref1, ref4);
+
+ /* Test all failures together */
+ hr = IDirect3DRMTexture_GetClassName(texture1, NULL, cname);
ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
- hr = IDirect3DRMTexture_GetClassName(texture, NULL, NULL);
+ hr = IDirect3DRMTexture_GetClassName(texture1, NULL, NULL);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ hr = IDirect3DRMTexture2_GetClassName(texture2, NULL, cname);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ hr = IDirect3DRMTexture2_GetClassName(texture2, NULL, NULL);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ hr = IDirect3DRMTexture3_GetClassName(texture3, NULL, cname);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ hr = IDirect3DRMTexture3_GetClassName(texture3, NULL, NULL);
ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
size = 1;
- hr = IDirect3DRMTexture_GetClassName(texture, &size, cname);
+ hr = IDirect3DRMTexture_GetClassName(texture1, &size, cname);
ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ hr = IDirect3DRMTexture2_GetClassName(texture2, &size, cname);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ hr = IDirect3DRMTexture3_GetClassName(texture3, &size, cname);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ size = sizeof("Texture") - 1;
+ strcpy(cname, "test");
+ hr = IDirect3DRMTexture_GetClassName(texture1, &size, cname);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ ok(size == sizeof("Texture") - 1, "wrong size: %u\n", size);
+ ok(!strcmp(cname, "test"), "Expected cname to be \"test\",
but got \"%s\"\n", cname);
+ hr = IDirect3DRMTexture2_GetClassName(texture2, &size, cname);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ ok(size == sizeof("Texture") - 1, "wrong size: %u\n", size);
+ ok(!strcmp(cname, "test"), "Expected cname to be \"test\",
but got \"%s\"\n", cname);
+ hr = IDirect3DRMTexture3_GetClassName(texture3, &size, cname);
+ ok(hr == E_INVALIDARG, "GetClassName failed with %x\n", hr);
+ ok(size == sizeof("Texture") - 1, "wrong size: %u\n", size);
+ ok(!strcmp(cname, "test"), "Expected cname to be \"test\",
but got \"%s\"\n", cname);
+
+ d3drm_img = IDirect3DRMTexture_GetImage(texture1);
+ ok(!!d3drm_img, "Failed to get image.\n");
+ ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n",
&initimg, d3drm_img);
+
size = sizeof(cname);
- hr = IDirect3DRMTexture_GetClassName(texture, &size, cname);
- ok(hr == D3DRM_OK, "Cannot get classname (hr = %x)\n", hr);
+ hr = IDirect3DRMTexture_GetClassName(texture1, &size, cname);
+ ok(SUCCEEDED(hr), "Cannot get classname (hr = %x)\n", hr);
ok(size == sizeof("Texture"), "wrong size: %u\n", size);
ok(!strcmp(cname, "Texture"), "Expected cname to be
\"Texture\", but got \"%s\"\n", cname);
-
- IDirect3DRMTexture_Release(texture);
-
- IDirect3DRM_Release(d3drm);
+ size = sizeof("Texture");
+ hr = IDirect3DRMTexture_GetClassName(texture1, &size, cname);
+ ok(SUCCEEDED(hr), "Cannot get classname (hr = %x)\n", hr);
+ ok(size == sizeof("Texture"), "wrong size: %u\n", size);
+ ok(!strcmp(cname, "Texture"), "Expected cname to be
\"Texture\", but got \"%s\"\n", cname);
+
+ IDirect3DRMTexture_Release(texture1);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 - 2 == ref1, "expected (ref2 - 2) == ref1, got ref1 = %u, ref2 =
%u.\n", ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n",
ref1, ref4);
+
+ d3drm_img = NULL;
+ d3drm_img = IDirect3DRMTexture2_GetImage(texture2);
+ ok(!!d3drm_img, "Failed to get image.\n");
+ ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n",
&initimg, d3drm_img);
+
+ size = sizeof(cname);
+ hr = IDirect3DRMTexture2_GetClassName(texture2, &size, cname);
+ ok(SUCCEEDED(hr), "Cannot get classname (hr = %x)\n", hr);
+ ok(size == sizeof("Texture"), "wrong size: %u\n", size);
+ ok(!strcmp(cname, "Texture"), "Expected cname to be
\"Texture\", but got \"%s\"\n", cname);
+ size = sizeof("Texture");
+ hr = IDirect3DRMTexture2_GetClassName(texture2, &size, cname);
+ ok(SUCCEEDED(hr), "Cannot get classname (hr = %x)\n", hr);
+ ok(size == sizeof("Texture"), "wrong size: %u\n", size);
+ ok(!strcmp(cname, "Texture"), "Expected cname to be
\"Texture\", but got \"%s\"\n", cname);
+
+ IDirect3DRMTexture2_Release(texture2);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 - 1 == ref1, "expected (ref2 - 1) == ref1, got ref1 = %u, ref2 =
%u.\n", ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n",
ref1, ref4);
+
+ d3drm_img = NULL;
+ d3drm_img = IDirect3DRMTexture3_GetImage(texture3);
+ ok(!!d3drm_img, "Failed to get image.\n");
+ ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n",
&initimg, d3drm_img);
+
+ size = sizeof(cname);
+ hr = IDirect3DRMTexture3_GetClassName(texture3, &size, cname);
+ ok(SUCCEEDED(hr), "Cannot get classname (hr = %x)\n", hr);
+ ok(size == sizeof("Texture"), "wrong size: %u\n", size);
+ ok(!strcmp(cname, "Texture"), "Expected cname to be
\"Texture\", but got \"%s\"\n", cname);
+ size = sizeof("Texture");
+ hr = IDirect3DRMTexture3_GetClassName(texture3, &size, cname);
+ ok(SUCCEEDED(hr), "Cannot get classname (hr = %x)\n", hr);
+ ok(size == sizeof("Texture"), "wrong size: %u\n", size);
+ ok(!strcmp(cname, "Texture"), "Expected cname to be
\"Texture\", but got \"%s\"\n", cname);
+
+ IDirect3DRMTexture3_Release(texture3);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n",
ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n",
ref1, ref4);
+
+ /* InitFromImage tests */
+ /* Tests for validation of D3DRMIMAGE struct */
+ testimg.rgb = 1;
+ testimg.palette = NULL;
+ testimg.palette_size = 0;
+ hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL,
&IID_IDirect3DRMTexture2,
+ (void **)&texture2);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n",
hr);
+ hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL,
&IID_IDirect3DRMTexture3,
+ (void **)&texture3);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n",
hr);
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &testimg);
+ ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture2 interface (hr =
%#x)\n", hr);
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &testimg);
+ ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture3 interface (hr =
%#x)\n", hr);
+ IDirect3DRMTexture2_Release(texture2);
+ IDirect3DRMTexture3_Release(texture3);
+
+ testimg.rgb = 0;
+ testimg.palette = (void *)0xdeadbeef;
+ testimg.palette_size = 0x39;
+ hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL,
&IID_IDirect3DRMTexture2,
+ (void **)&texture2);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n",
hr);
+ hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL,
&IID_IDirect3DRMTexture3,
+ (void **)&texture3);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n",
hr);
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &testimg);
+ ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture2 interface (hr =
%#x)\n", hr);
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &testimg);
+ ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture3 interface (hr =
%#x)\n", hr);
+ IDirect3DRMTexture2_Release(texture2);
+ IDirect3DRMTexture3_Release(texture3);
+
+ hr = IDirect3DRM2_CreateObject(d3drm2, &CLSID_CDirect3DRMTexture, NULL,
&IID_IDirect3DRMTexture2,
+ (void **)&texture2);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface (hr = %#x).\n",
hr);
+ ref2 = get_refcount((IUnknown *)texture2);
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, NULL);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ ref3 = get_refcount((IUnknown *)texture2);
+ ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n",
ref2, ref3);
+
+ hr = IDirect3DRM3_CreateObject(d3drm3, &CLSID_CDirect3DRMTexture, NULL,
&IID_IDirect3DRMTexture3,
+ (void **)&texture3);
+ ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface (hr = %#x).\n",
hr);
+ ref2 = get_refcount((IUnknown *)texture3);
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, NULL);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ ref3 = get_refcount((IUnknown *)texture3);
+ ok(ref3 == ref2, "expected ref3 == ref2, got ref2 = %u , ref3 = %u.\n",
ref2, ref3);
+
+ initimg.rgb = 0;
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ initimg.rgb = 1;
+ initimg.red_mask = 0;
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ initimg.red_mask = 0x000000ff;
+ initimg.green_mask = 0;
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ initimg.green_mask = 0x0000ff00;
+ initimg.blue_mask = 0;
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ initimg.blue_mask = 0x00ff0000;
+ initimg.buffer1 = NULL;
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ initimg.buffer1 = &pixel;
+
+ d3drm_img = NULL;
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
+ ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture2 from image (hr =
%#x).\n", hr);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n",
ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n",
ref1, ref4);
+
+ hr = IDirect3DRMTexture2_InitFromImage(texture2, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ /* Release leaked reference to d3drm1 */
+ IDirect3DRM_Release(d3drm1);
+
+ d3drm_img = IDirect3DRMTexture2_GetImage(texture2);
+ ok(!!d3drm_img, "Failed to get image.\n");
+ ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n",
&initimg, d3drm_img);
+ IDirect3DRMTexture2_Release(texture2);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n",
ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n",
ref1, ref4);
+
+ d3drm_img = NULL;
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
+ ok(SUCCEEDED(hr), "Cannot initialize IDirect3DRMTexture3 from image (hr =
%#x).\n", hr);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n",
ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u , ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u , ref4 = %u.\n",
ref1, ref4);
+
+ hr = IDirect3DRMTexture3_InitFromImage(texture3, &initimg);
+ ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got
%#x.\n", hr);
+ IDirect3DRM_Release(d3drm1);
+
+ d3drm_img = IDirect3DRMTexture3_GetImage(texture3);
+ ok(!!d3drm_img, "Failed to get image.\n");
+ ok(d3drm_img == &initimg, "Expected image returned == %p, got %p.\n",
&initimg, d3drm_img);
+ IDirect3DRMTexture3_Release(texture3);
+ ref2 = get_refcount((IUnknown *)d3drm1);
+ ok(ref2 == ref1, "expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n",
ref1, ref2);
+ ref3 = get_refcount((IUnknown *)d3drm2);
+ ok(ref3 == ref1, "expected ref3 == ref1, got ref1 = %u, ref3 = %u.\n",
ref1, ref3);
+ ref4 = get_refcount((IUnknown *)d3drm3);
+ ok(ref4 == ref1, "expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n",
ref1, ref4);
+
+ IDirect3DRM3_Release(d3drm3);
+ IDirect3DRM2_Release(d3drm2);
+ IDirect3DRM_Release(d3drm1);
}
static void test_Device(void)
@@ -4100,6 +4749,7 @@
test_Face();
test_Frame();
test_Device();
+ test_object();
test_Viewport();
test_Light();
test_Material2();