From: Vibhav Pant vibhavp@gmail.com
--- .../tests/Makefile.in | 1 + .../tests/application.c | 106 ++++++++++++++++++ .../tests/application.spec | 1 + .../tests/appxmanifest.xml | 8 ++ 4 files changed, 116 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..2cb30c0bfe1 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,109 @@ static void test_PackageStatics(void) ok( ref == 1, "got ref %ld.\n", ref ); }
+ +static HRESULT WINAPI test_factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IActivationFactory ) || + IsEqualGUID( iid, &IID_IInspectable )) + { + IActivationFactory_AddRef(( *out = iface )); + return S_OK; + } + + *out = NULL; + return S_OK; +} + +static ULONG WINAPI test_factory_AddRef( IActivationFactory *iface ) +{ + return 2; +} + +static ULONG WINAPI test_factory_Release( IActivationFactory *iface ) +{ + return 1; +} + +static HRESULT WINAPI test_factory_GetIids( IActivationFactory *iface, ULONG *count, GUID **iids ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI test_factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *name ) +{ + static const WCHAR *nameW = L"Wine.Application.Class"; + return WindowsCreateString( nameW, wcslen( nameW ), name ); +} + +static HRESULT WINAPI test_factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *level ) +{ + return S_OK; +} + +static HRESULT WINAPI test_factory_ActivateInstance( IActivationFactory *iface, IInspectable **out ) +{ + return E_NOTIMPL; +} + +static const IActivationFactoryVtbl test_factory_vtbl = +{ + /* IUnknown */ + test_factory_QueryInterface, + test_factory_AddRef, + test_factory_Release, + /* IInspectable */ + test_factory_GetIids, + test_factory_GetRuntimeClassName, + test_factory_GetTrustLevel, + /* IActivationFactory */ + test_factory_ActivateInstance +}; + +static IActivationFactory test_factory = { &test_factory_vtbl }; + +HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **factory ) +{ + const WCHAR *buffer = WindowsGetStringRawBuffer( classid, NULL ); + + *factory = NULL; + + if (!wcscmp( buffer, L"Wine.Application.Class" )) + return IActivationFactory_QueryInterface( &test_factory, &IID_IActivationFactory, (void **)factory ); + + return CLASS_E_CLASSNOTAVAILABLE; +} + +static void test_registration( void ) +{ + static const WCHAR *name = L"Wine.Application.Class"; + IActivationFactory *factory; + const WCHAR *buf; + 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); + + hr = IActivationFactory_GetRuntimeClassName( factory, &str ); + ok(hr == S_OK, "got hr %#lx\n", hr ); + buf = WindowsGetStringRawBuffer( str, NULL ); + ok(buf && !wcscmp(buf, name), "got str %s\n", debugstr_hstring(str)); + WindowsDeleteString( str ); + + IActivationFactory_Release( factory ); +} + int main( int argc, char const *argv[] ) { HRESULT hr; @@ -189,6 +293,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..4e778c2ca8c --- /dev/null +++ b/dlls/windows.applicationmodel/tests/application.spec @@ -0,0 +1 @@ +@ stdcall -private DllGetActivationFactory(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>