From 612375a5019cfbffc6157481a445c9ac79699e5c Mon Sep 17 00:00:00 2001 From: Mohamad Al-Jaf Date: Wed, 25 Jan 2023 22:21:35 -0500 Subject: [PATCH] windows.applicationmodel: Add IPackageStatics stub interface. --- dlls/windows.applicationmodel/package.c | 30 +++++++++++++ dlls/windows.applicationmodel/private.h | 38 ++++++++++++++++ dlls/windows.applicationmodel/tests/application.c | 54 +++++++++++++++++++++++ dlls/windows.applicationmodel/tests/model.c | 6 +++ 4 files changed, 128 insertions(+) diff --git a/dlls/windows.applicationmodel/package.c b/dlls/windows.applicationmodel/package.c index 087d96b5ec8..d894897b504 100644 --- a/dlls/windows.applicationmodel/package.c +++ b/dlls/windows.applicationmodel/package.c @@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(model); struct package_statics { IActivationFactory IActivationFactory_iface; + IPackageStatics IPackageStatics_iface; LONG ref; }; @@ -49,6 +50,13 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; } + if (IsEqualGUID( iid, &IID_IPackageStatics )) + { + *out = &impl->IPackageStatics_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -107,9 +115,31 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, }; +DEFINE_IINSPECTABLE( package_statics, IPackageStatics, struct package_statics, IActivationFactory_iface ) + +static HRESULT WINAPI package_statics_get_Current( IPackageStatics *iface, IPackage **value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static const struct IPackageStaticsVtbl package_statics_vtbl = +{ + package_statics_QueryInterface, + package_statics_AddRef, + package_statics_Release, + /* IInspectable methods */ + package_statics_GetIids, + package_statics_GetRuntimeClassName, + package_statics_GetTrustLevel, + /* IPackageStatics methods */ + package_statics_get_Current, +}; + static struct package_statics package_statics = { {&factory_vtbl}, + {&package_statics_vtbl}, 1, }; diff --git a/dlls/windows.applicationmodel/private.h b/dlls/windows.applicationmodel/private.h index df4b3721a13..0ca3c8931bb 100644 --- a/dlls/windows.applicationmodel/private.h +++ b/dlls/windows.applicationmodel/private.h @@ -37,4 +37,42 @@ extern IActivationFactory *package_factory; +#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ + static inline impl_type *impl_from( iface_type *iface ) \ + { \ + return CONTAINING_RECORD( iface, impl_type, iface_mem ); \ + } \ + static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \ + } \ + static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_AddRef( (IInspectable *)(expr) ); \ + } \ + static ULONG WINAPI pfx##_Release( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_Release( (IInspectable *)(expr) ); \ + } \ + static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \ + } \ + static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \ + } \ + static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \ + } +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface ) + #endif diff --git a/dlls/windows.applicationmodel/tests/application.c b/dlls/windows.applicationmodel/tests/application.c index a3f0ceb07d9..9e4bd14b3e6 100644 --- a/dlls/windows.applicationmodel/tests/application.c +++ b/dlls/windows.applicationmodel/tests/application.c @@ -31,9 +31,61 @@ #include "roapi.h" +#define WIDL_using_Windows_Foundation +#define WIDL_using_Windows_Foundation_Collections +#include "windows.foundation.h" +#define WIDL_using_Windows_ApplicationModel +#include "windows.applicationmodel.h" + #define WINE_WINRT_TEST #include "winrt_test.h" +#define check_interface( obj, iid ) check_interface_( __LINE__, obj, iid ) +static void check_interface_( unsigned int line, void *obj, const IID *iid ) +{ + IUnknown *iface = obj; + IUnknown *unk; + HRESULT hr; + + hr = IUnknown_QueryInterface( iface, iid, (void **)&unk ); + ok_(__FILE__, line)( hr == S_OK, "got hr %#lx.\n", hr ); + if (SUCCEEDED(hr)) + IUnknown_Release( unk ); +} + +static void test_PackageStatics(void) +{ + static const WCHAR *package_statics_name = L"Windows.ApplicationModel.Package"; + IPackageStatics *package_statics; + IActivationFactory *factory; + HSTRING str; + HRESULT hr; + LONG ref; + + hr = WindowsCreateString( package_statics_name, wcslen( package_statics_name ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory ); + WindowsDeleteString( str ); + ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr ); + if (hr == REGDB_E_CLASSNOTREG) + { + win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( package_statics_name ) ); + return; + } + + check_interface( factory, &IID_IUnknown ); + check_interface( factory, &IID_IInspectable ); + + hr = IActivationFactory_QueryInterface( factory, &IID_IPackageStatics, (void **)&package_statics ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + ref = IPackageStatics_Release( package_statics ); + ok( ref == 2, "got ref %ld.\n", ref ); + ref = IActivationFactory_Release( factory ); + ok( ref == 1, "got ref %ld.\n", ref ); +} + int main( int argc, char const *argv[] ) { HRESULT hr; @@ -43,6 +95,8 @@ int main( int argc, char const *argv[] ) hr = RoInitialize( RO_INIT_MULTITHREADED ); ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr ); + test_PackageStatics(); + RoUninitialize(); winrt_test_exit(); diff --git a/dlls/windows.applicationmodel/tests/model.c b/dlls/windows.applicationmodel/tests/model.c index 2d0494dabda..44546194690 100644 --- a/dlls/windows.applicationmodel/tests/model.c +++ b/dlls/windows.applicationmodel/tests/model.c @@ -541,6 +541,7 @@ skip_tests: static void test_PackageStatics(void) { static const WCHAR *package_statics_name = L"Windows.ApplicationModel.Package"; + IPackageStatics *package_statics; IActivationFactory *factory; HSTRING str; HRESULT hr; @@ -561,6 +562,11 @@ static void test_PackageStatics(void) check_interface( factory, &IID_IUnknown ); check_interface( factory, &IID_IInspectable ); + hr = IActivationFactory_QueryInterface( factory, &IID_IPackageStatics, (void **)&package_statics ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + ref = IPackageStatics_Release( package_statics ); + ok( ref == 2, "got ref %ld.\n", ref ); ref = IActivationFactory_Release( factory ); ok( ref == 1, "got ref %ld.\n", ref ); } -- 2.11.4.GIT