Author: akhaldi Date: Fri May 31 16:38:50 2013 New Revision: 59126 URL: http://svn.reactos.org/svn/reactos?rev=59126&view=rev Log: [AVIFIL32_WINETEST] * Sync with Wine 1.5.26.
Modified: trunk/rostests/winetests/avifil32/CMakeLists.txt trunk/rostests/winetests/avifil32/api.c trunk/rostests/winetests/avifil32/testlist.c Modified: trunk/rostests/winetests/avifil32/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/avifil32/CMakeLists.txt?rev=59126&r1=59125&r2=59126&view=diff ============================================================================== --- trunk/rostests/winetests/avifil32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/avifil32/CMakeLists.txt [iso-8859-1] Fri May 31 16:38:50 2013 @@ -1,7 +1,7 @@ -add_definitions(-D_DLL -D__USE_CRTIMP) +add_definitions(-D__ROS_LONG64__) add_executable(avifil32_winetest api.c testlist.c) target_link_libraries(avifil32_winetest wine) set_module_type(avifil32_winetest win32cui) -add_importlibs(avifil32_winetest avifil32 msvcrt kernel32) +add_importlibs(avifil32_winetest avifil32 ole32 msvcrt kernel32) add_cd_file(TARGET avifil32_winetest DESTINATION reactos/bin FOR all) Modified: trunk/rostests/winetests/avifil32/api.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/avifil32/api.c?rev=59126&r1=59125&r2=59126&view=diff ============================================================================== --- trunk/rostests/winetests/avifil32/api.c [iso-8859-1] (original) +++ trunk/rostests/winetests/avifil32/api.c [iso-8859-1] Fri May 31 16:38:50 2013 @@ -19,14 +19,17 @@ * */ -#include <stdarg.h> - -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "wingdi.h" -#include "vfw.h" -#include "wine/test.h" +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define COBJMACROS +#define CONST_VTABLE + +#include <wine/test.h> +#include <initguid.h> +#include <wingdi.h> +#include <vfw.h> /* ########################### */ @@ -541,7 +544,114 @@ ok(DeleteFile(filename) !=0, "Deleting file %s failed\n", filename); } -/* ########################### */ +/* Outer IUnknown for COM aggregation tests */ +struct unk_impl { + IUnknown IUnknown_iface; + LONG ref; + IUnknown *inner_unk; +}; + +static inline struct unk_impl *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, struct unk_impl, IUnknown_iface); +} + +static HRESULT WINAPI unk_QueryInterface(IUnknown *iface, REFIID riid, void **ppv) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + LONG ref = This->ref; + HRESULT hr; + + if (IsEqualGUID(riid, &IID_IUnknown)) + { + *ppv = iface; + IUnknown_AddRef(iface); + return S_OK; + } + + hr = IUnknown_QueryInterface(This->inner_unk, riid, ppv); + if (hr == S_OK) + { + trace("Working around COM aggregation ref counting bug\n"); + ok(ref == This->ref, "Outer ref count expected %d got %d\n", ref, This->ref); + IUnknown_AddRef((IUnknown*)*ppv); + ref = IUnknown_Release(This->inner_unk); + ok(ref == 1, "Inner ref count expected 1 got %d\n", ref); + } + + return hr; +} + +static ULONG WINAPI unk_AddRef(IUnknown *iface) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI unk_Release(IUnknown *iface) +{ + struct unk_impl *This = impl_from_IUnknown(iface); + + return InterlockedDecrement(&This->ref); +} + +static const IUnknownVtbl unk_vtbl = +{ + unk_QueryInterface, + unk_AddRef, + unk_Release +}; + +static void test_COM(void) +{ + struct unk_impl unk_obj = {{&unk_vtbl}, 19, NULL}; + IAVIFile *avif = NULL; + IPersistFile *pf; + IUnknown *unk; + LONG refcount; + HRESULT hr; + + /* COM aggregation */ + hr = CoCreateInstance(&CLSID_AVIFile, &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, "AVIFile just pretends to support COM aggregation\n"); + refcount = IAVIFile_Release(avif); + ok(refcount == unk_obj.ref, "AVIFile 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, "AVIFile 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_AVIFile, NULL, CLSCTX_INPROC_SERVER, &IID_IAVIStream, + (void**)&avif); + ok(hr == E_NOINTERFACE, "AVIFile create failed: %08x, expected E_NOINTERFACE\n", hr); + + /* Same refcount */ + hr = CoCreateInstance(&CLSID_AVIFile, NULL, CLSCTX_INPROC_SERVER, &IID_IAVIFile, (void**)&avif); + ok(hr == S_OK, "AVIFile 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_IUnknown, (void**)&unk); + ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); + refcount = IUnknown_AddRef(unk); + ok(refcount == 4, "refcount == %u, expected 4\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 == 6, "refcount == %u, expected 6\n", refcount); + + while (IAVIFile_Release(avif)); +} START_TEST(api) { @@ -553,6 +663,7 @@ test_amh_corruption(); test_ash1_corruption(); test_ash1_corruption2(); + test_COM(); AVIFileExit(); } Modified: trunk/rostests/winetests/avifil32/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/avifil32/testlist.c?rev=59126&r1=59125&r2=59126&view=diff ============================================================================== --- trunk/rostests/winetests/avifil32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/winetests/avifil32/testlist.c [iso-8859-1] Fri May 31 16:38:50 2013 @@ -1,10 +1,7 @@ /* Automatically generated file; DO NOT EDIT!! */ -#define WIN32_LEAN_AND_MEAN -#include <windows.h> - #define STANDALONE -#include "wine/test.h" +#include <wine/test.h> extern void func_api(void);