Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct destroy_context
- {
- IDirect3DRMObject *obj;
- unsigned int test_idx;
- int called;
- };
- struct callback_order
- {
- int id;
- void *callback;
- void *context;
- } corder[10], d3drm_corder[10];
- 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].id = ctxt->called;
- 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].id = ctxt->called;
- 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].id = 2;
- 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].id = 1;
- 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].id = 0;
- 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
- && corder[i].id == d3drm_corder[i].id, "Call order not matching.\n");
- }
- /* ... */
Add Comment
Please, Sign In to add comment