avifil32/tests: Add WAVFile COM tests.

This commit is contained in:
Michael Stefaniuc 2014-03-03 22:06:15 +01:00 committed by Alexandre Julliard
parent 8e9cacf099
commit b1c6d5b111
1 changed files with 63 additions and 0 deletions

View File

@ -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();
}