[PATCH 4/4] d3drm/tests: Add tests to compare vtables for frame{1-3}, object and visual
Aaryaman Vasishta
jem456.vasishta at gmail.com
Wed Apr 1 11:15:21 CDT 2015
---
dlls/d3drm/tests/d3drm.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index 6029b1a..db50bfb 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -33,6 +33,30 @@
ok(count == rc_new, "Invalid refcount. Expected %d got %d\n", rc_new, count); \
}
+static const char* get_IID_string(const GUID* guid)
+{
+ if (IsEqualGUID(guid, &IID_IDirect3DRMFrame))
+ return "IID_IDirect3DRMFrame";
+ else if (IsEqualGUID(guid, &IID_IDirect3DRMFrame2))
+ return "IID_IDirect3DRMFrame2";
+ else if (IsEqualGUID(guid, &IID_IDirect3DRMFrame3))
+ return "IID_IDirect3DRMFrame3";
+ else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder))
+ return "IID_IDirect3DRMMeshBuilder";
+ else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder2))
+ return "IID_IDirect3DRMMeshBuilder2";
+ else if (IsEqualGUID(guid, &IID_IDirect3DRMMeshBuilder3))
+ return "IID_IDirect3DRMMeshBuilder3";
+ else if (IsEqualGUID(guid, &IID_IDirect3DRMObject))
+ return "IID_IDirect3DRMMeshObject";
+ else if (IsEqualGUID(guid, &IID_IDirect3DRMVisual))
+ return "IID_IDirect3DRMMeshVisual";
+ else if (IsEqualGUID(guid, &IID_IUnknown))
+ return "IID_IUnknown";
+
+ return "?";
+}
+
static int get_refcount(IUnknown *object)
{
IUnknown_AddRef( object );
@@ -1939,6 +1963,106 @@ static void test_frame_qi(void)
IDirect3DRM_Release(d3drm);
}
+struct vtable_test
+{
+ REFIID iid;
+ BOOL equal;
+ BOOL todo;
+};
+
+static void compare_vtables(const char *test_name, IUnknown *base_iface, REFIID base_iid, const struct vtable_test *tests, UINT entry_count)
+{
+ HRESULT hr;
+ IUnknown *iface;
+ UINT i;
+
+ for (i = 0; i < entry_count; ++i)
+ {
+ hr = IUnknown_QueryInterface(base_iface, tests[i].iid, (void **)&iface);
+ ok(hr == S_OK, "Got hr %#x for test \"%s\" %u.\n", hr, test_name, i);
+ if (tests[i].todo)
+ todo_wine ok((iface == base_iface) == tests[i].equal, "%s %s %s for test \"%s\".\n", get_IID_string(base_iid),
+ (iface==base_iface?"==":"!="), get_IID_string(tests[i].iid), test_name);
+ else
+ ok((iface == base_iface) == tests[i].equal, "%s %s %s for test \"%s\".\n", get_IID_string(base_iid),
+ (iface==base_iface?"==":"!="), get_IID_string(tests[i].iid), test_name);
+ IUnknown_Release(iface);
+ }
+}
+
+static void test_vtables(void)
+{
+ static const struct vtable_test frame1_vtable_tests[] =
+ {
+ { &IID_IDirect3DRMFrame3, FALSE, FALSE },
+ { &IID_IDirect3DRMFrame2, FALSE, TRUE },
+ { &IID_IDirect3DRMFrame, TRUE, FALSE },
+ { &IID_IDirect3DRMVisual, TRUE, FALSE },
+ { &IID_IDirect3DRMObject, TRUE, FALSE },
+ { &IID_IUnknown, FALSE, TRUE },
+ };
+ static const struct vtable_test frame2_vtable_tests[] =
+ {
+ { &IID_IDirect3DRMFrame3, FALSE, FALSE },
+ { &IID_IDirect3DRMFrame2, TRUE, FALSE },
+ { &IID_IDirect3DRMFrame, FALSE, TRUE },
+ { &IID_IDirect3DRMVisual, FALSE, TRUE },
+ { &IID_IDirect3DRMObject, FALSE, TRUE },
+ { &IID_IUnknown, FALSE, TRUE },
+ };
+ static const struct vtable_test frame3_vtable_tests[] =
+ {
+ { &IID_IDirect3DRMFrame3, TRUE, FALSE },
+ { &IID_IDirect3DRMFrame2, FALSE, FALSE },
+ { &IID_IDirect3DRMFrame, FALSE, FALSE },
+ { &IID_IDirect3DRMVisual, FALSE, FALSE },
+ { &IID_IDirect3DRMObject, FALSE, FALSE },
+ { &IID_IUnknown, FALSE, FALSE },
+ };
+ HRESULT hr;
+ IDirect3DRM *d3drm;
+ IDirect3DRM3 *d3drm3;
+ IDirect3DRMFrame3 *frame3;
+ IDirect3DRMFrame2 *frame2;
+ IDirect3DRMFrame *frame1;
+
+ hr = Direct3DRMCreate(&d3drm);
+ ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
+
+ if (FAILED(hr = IDirect3DRM_QueryInterface(d3drm, &IID_IDirect3DRM3, (void **)&d3drm3)))
+ {
+ win_skip("Cannot get IDirect3DRM3 interface (hr = %x), skipping tests\n", hr);
+ IDirect3DRM_Release(d3drm);
+ return;
+ }
+
+ hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &frame3);
+ ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
+
+ if (FAILED(hr = IDirect3DRMFrame3_QueryInterface(frame3, &IID_IDirect3DRMFrame2, (void **)&frame2)))
+ {
+ win_skip("Cannot get IDirect3DRMFrame2 interface (hr = %x), skipping tests\n", hr);
+ IDirect3DRM_Release(frame3);
+ return;
+ }
+ if (FAILED(hr = IDirect3DRMFrame3_QueryInterface(frame3, &IID_IDirect3DRMFrame, (void **)&frame1)))
+ {
+ win_skip("Cannot get IDirect3DRMFrame interface (hr = %x), skipping tests\n", hr);
+ IDirect3DRM_Release(frame3);
+ return;
+ }
+
+ compare_vtables("frame1_vtable_test", (IUnknown *)frame1, &IID_IDirect3DRMFrame, frame1_vtable_tests, sizeof(frame1_vtable_tests) / sizeof(*frame1_vtable_tests));
+ compare_vtables("frame2_vtable_test", (IUnknown *)frame2, &IID_IDirect3DRMFrame2, frame2_vtable_tests, sizeof(frame2_vtable_tests) / sizeof(*frame2_vtable_tests));
+ compare_vtables("frame3_vtable_test", (IUnknown *)frame3, &IID_IDirect3DRMFrame3, frame3_vtable_tests, sizeof(frame3_vtable_tests) / sizeof(*frame3_vtable_tests));
+
+ IDirect3DRMFrame3_Release(frame3);
+ IDirect3DRMFrame3_Release(frame2);
+ IDirect3DRMFrame3_Release(frame1);
+ IDirect3DRM3_Release(d3drm3);
+ IDirect3DRM_Release(d3drm);
+}
+
START_TEST(d3drm)
{
test_MeshBuilder();
@@ -1956,4 +2080,5 @@ START_TEST(d3drm)
test_frame_mesh_materials();
test_d3drm_qi();
test_frame_qi();
+ test_vtables();
}
--
1.9.3 (Apple Git-50)
More information about the wine-patches
mailing list