From: Vibhav Pant vibhavp@gmail.com
--- .../tests/Makefile.in | 1 + .../tests/application.c | 126 ++++++++++++++++++ .../tests/application.spec | 3 + .../tests/appxmanifest.xml | 8 ++ 4 files changed, 138 insertions(+) create mode 100644 dlls/windows.applicationmodel/tests/application.spec
diff --git a/dlls/windows.applicationmodel/tests/Makefile.in b/dlls/windows.applicationmodel/tests/Makefile.in index 3987f627736..1319b25581e 100644 --- a/dlls/windows.applicationmodel/tests/Makefile.in +++ b/dlls/windows.applicationmodel/tests/Makefile.in @@ -5,5 +5,6 @@ application_EXTRADLLFLAGS = -mconsole
SOURCES = \ application.c \ + application.spec \ model.c \ resource.rc diff --git a/dlls/windows.applicationmodel/tests/application.c b/dlls/windows.applicationmodel/tests/application.c index ee357ecb264..7b8408507de 100644 --- a/dlls/windows.applicationmodel/tests/application.c +++ b/dlls/windows.applicationmodel/tests/application.c @@ -32,6 +32,7 @@
#include "roapi.h"
+#include "inspectable.h" #define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Foundation_Collections #include "windows.foundation.h" @@ -177,6 +178,129 @@ static void test_PackageStatics(void) ok( ref == 1, "got ref %ld.\n", ref ); }
+struct test_factory +{ + IActivationFactory IActivationFactory_iface; + LONG ref; +}; + +static inline struct test_factory *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD(iface, struct test_factory, IActivationFactory_iface); +} + +static HRESULT WINAPI test_inspectable_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct test_factory *impl = impl_from_IActivationFactory( iface ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IActivationFactory ) || + IsEqualGUID( iid, &IID_IInspectable )) + { + IActivationFactory_AddRef(( *out = &impl->IActivationFactory_iface )); + return S_OK; + } + + *out = NULL; + return S_OK; +} + +static ULONG WINAPI test_inspectable_AddRef( IActivationFactory *iface ) +{ + struct test_factory *impl = impl_from_IActivationFactory( iface ); + + return InterlockedIncrement( &impl->ref ); +} + +static ULONG WINAPI test_inspectable_Release( IActivationFactory *iface ) +{ + struct test_factory *impl = impl_from_IActivationFactory( iface ); + return InterlockedDecrement( &impl->ref ); +} + +static HRESULT WINAPI test_inspectable_GetRuntimeClassName( IActivationFactory *iface, HSTRING *name ) +{ + static const WCHAR *nameW = L"Wine.Application.Class"; + return WindowsCreateString( nameW, wcslen( nameW ), name ); +} +static HRESULT WINAPI test_inspectable_GetIids( IActivationFactory *iface, ULONG *count, GUID **iids ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI test_inspectable_GetTrustLevel( IActivationFactory *iface, TrustLevel *level ) +{ + return S_OK; +} + +static HRESULT WINAPI test_inspectable_ActivateInstance( IActivationFactory *iface, IInspectable **out ) +{ + return E_NOTIMPL; +} + +static const IActivationFactoryVtbl test_factory_vtbl = +{ + /* IUnknown */ + test_inspectable_QueryInterface, + test_inspectable_AddRef, + test_inspectable_Release, + /* IInspectable */ + test_inspectable_GetIids, + test_inspectable_GetRuntimeClassName, + test_inspectable_GetTrustLevel, + /* IActivationFactory */ + test_inspectable_ActivateInstance +}; + +struct test_factory test_factory_impl = { { &test_factory_vtbl }, 1 }; + +HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **factory ) +{ + const WCHAR *buffer = WindowsGetStringRawBuffer( classid, NULL ); + + *factory = NULL; + + trace("(%s, %p)\n", debugstr_hstring(classid), factory); + + if (!wcscmp( buffer, L"Wine.Application.Class" )) + return IActivationFactory_QueryInterface( &test_factory_impl.IActivationFactory_iface, &IID_IActivationFactory, (void **)factory ); + + return CLASS_E_CLASSNOTAVAILABLE; +} + +HRESULT WINAPI DllCanUnloadNow(void) +{ + return S_OK; +} + +HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out) +{ + return CLASS_E_CLASSNOTAVAILABLE; +} + +static void test_registration( void ) +{ + static const WCHAR *name = L"Wine.Application.Class"; + IActivationFactory *factory; + HSTRING str; + HRESULT hr; + + hr = WindowsCreateString( name, wcslen( name ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory ); + WindowsDeleteString( str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + check_interface(factory, &IID_IUnknown); + check_interface(factory, &IID_IInspectable); + check_interface(factory, &IID_IActivationFactory); + check_interface(factory, &IID_IAgileObject); + + IActivationFactory_Release( factory ); +} + int main( int argc, char const *argv[] ) { HRESULT hr; @@ -189,6 +313,8 @@ int main( int argc, char const *argv[] ) test_ApplicationDataStatics(); test_PackageStatics();
+ test_registration(); + RoUninitialize();
winrt_test_exit(); diff --git a/dlls/windows.applicationmodel/tests/application.spec b/dlls/windows.applicationmodel/tests/application.spec new file mode 100644 index 00000000000..20a8bfa98ea --- /dev/null +++ b/dlls/windows.applicationmodel/tests/application.spec @@ -0,0 +1,3 @@ +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetActivationFactory(ptr ptr) +@ stdcall -private DllGetClassObject(ptr ptr ptr) diff --git a/dlls/windows.applicationmodel/tests/appxmanifest.xml b/dlls/windows.applicationmodel/tests/appxmanifest.xml index 33cf6ae6c1c..19e75a6a544 100644 --- a/dlls/windows.applicationmodel/tests/appxmanifest.xml +++ b/dlls/windows.applicationmodel/tests/appxmanifest.xml @@ -23,4 +23,12 @@ <uap:VisualElements BackgroundColor="transparent" DisplayName="WineTest" Square150x150Logo="logo.png" Square44x44Logo="logo.png" Description="WineTest" /> </Application> </Applications> + <Extensions> + <Extension Category="windows.activatableClass.inProcessServer"> + <InProcessServer> + <Path>application.exe</Path> + <ActivatableClass ActivatableClassId="Wine.Application.Class" ThreadingModel="both"></ActivatableClass> + </InProcessServer> + </Extension> + </Extensions> </Package>