Michael Stefaniuc : avifil32/tests: Add WAVFile COM tests.

Alexandre Julliard julliard at winehq.org
Tue Mar 4 14:08:50 CST 2014


Module: wine
Branch: master
Commit: b1c6d5b111f879650b4840e05b1464ed304e7676
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b1c6d5b111f879650b4840e05b1464ed304e7676

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Mon Mar  3 22:06:15 2014 +0100

avifil32/tests: Add WAVFile COM tests.

---

 dlls/avifil32/tests/api.c |   63 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/dlls/avifil32/tests/api.c b/dlls/avifil32/tests/api.c
index c2a2d24..552a356 100644
--- a/dlls/avifil32/tests/api.c
+++ b/dlls/avifil32/tests/api.c
@@ -29,6 +29,7 @@
 
 /* ########################### */
 
+DEFINE_AVIGUID(CLSID_WAVFile,   0x00020003, 0, 0);
 static const CHAR winetest0[] = "winetest0";
 static const CHAR winetest1[] = "winetest1";
 static const CHAR testfilename[]  = "wine_avifil32_test.avi";
@@ -648,6 +649,67 @@ static void test_COM(void)
     while (IAVIFile_Release(avif));
 }
 
+static void test_COM_wavfile(void)
+{
+    struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL};
+    IAVIFile *avif = NULL;
+    IPersistFile *pf;
+    IAVIStream *avis;
+    IUnknown *unk;
+    ULONG refcount;
+    HRESULT hr;
+
+    /* COM aggregation */
+    hr = CoCreateInstance(&CLSID_WAVFile, &unk_obj.IUnknown_iface, CLSCTX_INPROC_SERVER,
+            &IID_IUnknown, (void**)&unk_obj.inner_unk);
+    ok(hr == S_OK, "COM aggregation failed: %08x, expected S_OK\n", hr);
+    hr = IUnknown_QueryInterface(&unk_obj.IUnknown_iface, &IID_IAVIFile, (void**)&avif);
+    ok(hr == S_OK, "QueryInterface for IID_IAVIFile failed: %08x\n", hr);
+    refcount = IAVIFile_AddRef(avif);
+    ok(refcount == unk_obj.ref, "WAVFile just pretends to support COM aggregation\n");
+    refcount = IAVIFile_Release(avif);
+    ok(refcount == unk_obj.ref, "WAVFile just pretends to support COM aggregation\n");
+    hr = IAVIFile_QueryInterface(avif, &IID_IPersistFile, (void**)&pf);
+    ok(hr == S_OK, "QueryInterface for IID_IPersistFile failed: %08x\n", hr);
+    refcount = IPersistFile_Release(pf);
+    ok(refcount == unk_obj.ref, "WAVFile just pretends to support COM aggregation\n");
+    refcount = IAVIFile_Release(avif);
+    ok(refcount == 19, "Outer ref count should be back at 19 but is %d\n", refcount);
+    refcount = IUnknown_Release(unk_obj.inner_unk);
+    ok(refcount == 0, "Inner ref count should be 0 but is %u\n", refcount);
+
+    /* Invalid RIID */
+    hr = CoCreateInstance(&CLSID_WAVFile, NULL, CLSCTX_INPROC_SERVER, &IID_IAVIStreaming,
+            (void**)&avif);
+    ok(hr == E_NOINTERFACE, "WAVFile create failed: %08x, expected E_NOINTERFACE\n", hr);
+
+    /* Same refcount for all WAVFile interfaces */
+    hr = CoCreateInstance(&CLSID_WAVFile, NULL, CLSCTX_INPROC_SERVER, &IID_IAVIFile, (void**)&avif);
+    ok(hr == S_OK, "WAVFile create failed: %08x, expected S_OK\n", hr);
+    refcount = IAVIFile_AddRef(avif);
+    ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+
+    hr = IAVIFile_QueryInterface(avif, &IID_IPersistFile, (void**)&pf);
+    ok(hr == S_OK, "QueryInterface for IID_IPersistFile failed: %08x\n", hr);
+    refcount = IPersistFile_AddRef(pf);
+    ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+    refcount = IPersistFile_Release(pf);
+
+    hr = IAVIFile_QueryInterface(avif, &IID_IAVIStream, (void**)&avis);
+    ok(hr == S_OK, "QueryInterface for IID_IAVIStream failed: %08x\n", hr);
+    refcount = IAVIStream_AddRef(avis);
+    ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
+    refcount = IAVIStream_Release(avis);
+
+    hr = IAVIFile_QueryInterface(avif, &IID_IUnknown, (void**)&unk);
+    ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+    refcount = IUnknown_AddRef(unk);
+    ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
+    refcount = IUnknown_Release(unk);
+
+    while (IAVIFile_Release(avif));
+}
+
 START_TEST(api)
 {
 
@@ -659,6 +721,7 @@ START_TEST(api)
     test_ash1_corruption();
     test_ash1_corruption2();
     test_COM();
+    test_COM_wavfile();
     AVIFileExit();
 
 }




More information about the wine-cvs mailing list