diff --git a/dlls/windows.perception.stub/Makefile.in b/dlls/windows.perception.stub/Makefile.in index c19496cdd66..dd4274e2055 100644 --- a/dlls/windows.perception.stub/Makefile.in +++ b/dlls/windows.perception.stub/Makefile.in @@ -2,6 +2,7 @@ MODULE = windows.perception.stub.dll IMPORTS = combase C_SRCS = \ + holographicspace.c \ main.c \ observer.c diff --git a/dlls/windows.perception.stub/classes.idl b/dlls/windows.perception.stub/classes.idl index 7d0412fa9b2..cf5d6c1ee34 100644 --- a/dlls/windows.perception.stub/classes.idl +++ b/dlls/windows.perception.stub/classes.idl @@ -21,3 +21,4 @@ #pragma makedep register #include "windows.perception.spatial.surfaces.idl" +#include "windows.graphics.holographic.idl" diff --git a/dlls/windows.perception.stub/holographicspace.c b/dlls/windows.perception.stub/holographicspace.c new file mode 100644 index 00000000000..36a315bd26a --- /dev/null +++ b/dlls/windows.perception.stub/holographicspace.c @@ -0,0 +1,168 @@ +/* WinRT Windows.Perception.Stub HolographicSpace Implementation + * + * Copyright (C) 2023 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(perception); + +struct holographicspace +{ + IActivationFactory IActivationFactory_iface; + IHolographicSpaceStatics2 IHolographicSpaceStatics2_iface; + LONG ref; +}; + +static inline struct holographicspace *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct holographicspace, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct holographicspace *impl = impl_from_IActivationFactory( iface ); + + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IActivationFactory )) + { + *out = &impl->IActivationFactory_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + + if (IsEqualGUID( iid, &IID_IHolographicSpaceStatics2 )) + { + *out = &impl->IHolographicSpaceStatics2_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +{ + struct holographicspace *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI factory_Release( IActivationFactory *iface ) +{ + struct holographicspace *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +{ + FIXME( "iface %p, instance %p stub!\n", iface, instance ); + return E_NOTIMPL; +} + +static const struct IActivationFactoryVtbl factory_vtbl = +{ + factory_QueryInterface, + factory_AddRef, + factory_Release, + /* IInspectable methods */ + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, + /* IActivationFactory methods */ + factory_ActivateInstance, +}; + +DEFINE_IINSPECTABLE( holographicspace_statics2, IHolographicSpaceStatics2, struct holographicspace, IActivationFactory_iface ) + +static HRESULT WINAPI holographicspace_statics2_get_IsSupported( IHolographicSpaceStatics2 *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI holographicspace_statics2_get_IsAvailable( IHolographicSpaceStatics2 *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI holographicspace_statics2_add_IsAvailableChanged( IHolographicSpaceStatics2 *iface, IEventHandler_IInspectable *handler, + EventRegistrationToken *token ) +{ + FIXME( "iface %p, handler %p, token %p stub!\n", iface, handler, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI holographicspace_statics2_remove_IsAvailableChanged( IHolographicSpaceStatics2 *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static const struct IHolographicSpaceStatics2Vtbl holographicspace_statics2_vtbl = +{ + holographicspace_statics2_QueryInterface, + holographicspace_statics2_AddRef, + holographicspace_statics2_Release, + /* IInspectable methods */ + holographicspace_statics2_GetIids, + holographicspace_statics2_GetRuntimeClassName, + holographicspace_statics2_GetTrustLevel, + /* IHolographicSpaceStatics2 methods */ + holographicspace_statics2_get_IsSupported, + holographicspace_statics2_get_IsAvailable, + holographicspace_statics2_add_IsAvailableChanged, + holographicspace_statics2_remove_IsAvailableChanged, +}; + +static struct holographicspace holographicspace_statics = +{ + {&factory_vtbl}, + {&holographicspace_statics2_vtbl}, + 1, +}; + +IActivationFactory *holographicspace_factory = &holographicspace_statics.IActivationFactory_iface; diff --git a/dlls/windows.perception.stub/main.c b/dlls/windows.perception.stub/main.c index 094b1b60654..4403c9cfb3f 100644 --- a/dlls/windows.perception.stub/main.c +++ b/dlls/windows.perception.stub/main.c @@ -49,6 +49,8 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **fa if (!wcscmp( buffer, RuntimeClass_Windows_Perception_Spatial_Surfaces_SpatialSurfaceObserver )) IActivationFactory_QueryInterface( observer_factory, &IID_IActivationFactory, (void **)factory ); + if (!wcscmp( buffer, RuntimeClass_Windows_Graphics_Holographic_HolographicSpace )) + IActivationFactory_QueryInterface( holographicspace_factory, &IID_IActivationFactory, (void **)factory ); if (*factory) return S_OK; return CLASS_E_CLASSNOTAVAILABLE; diff --git a/dlls/windows.perception.stub/private.h b/dlls/windows.perception.stub/private.h index a32f8221380..a6ae62916e1 100644 --- a/dlls/windows.perception.stub/private.h +++ b/dlls/windows.perception.stub/private.h @@ -34,8 +34,11 @@ #include "windows.foundation.h" #define WIDL_using_Windows_Perception_Spatial_Surfaces #include "windows.perception.spatial.surfaces.h" +#define WIDL_using_Windows_Graphics_Holographic +#include "windows.graphics.holographic.h" extern IActivationFactory *observer_factory; +extern IActivationFactory *holographicspace_factory; #define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ static inline impl_type *impl_from( iface_type *iface ) \ diff --git a/dlls/windows.perception.stub/tests/perception.c b/dlls/windows.perception.stub/tests/perception.c index c83986f4b6c..9cc7c40debb 100644 --- a/dlls/windows.perception.stub/tests/perception.c +++ b/dlls/windows.perception.stub/tests/perception.c @@ -30,6 +30,8 @@ #include "windows.foundation.h" #define WIDL_using_Windows_Perception_Spatial_Surfaces #include "windows.perception.spatial.surfaces.h" +#define WIDL_using_Windows_Graphics_Holographic +#include "windows.graphics.holographic.h" #include "wine/test.h" @@ -73,20 +75,63 @@ static void test_ObserverStatics(void) check_interface( factory, &IID_ISpatialSurfaceObserverStatics ); hr = IActivationFactory_QueryInterface( factory, &IID_ISpatialSurfaceObserverStatics2, (void **)&observer_statics2 ); - if (hr == E_NOINTERFACE /* win1607 */) - win_skip("ISpatialSurfaceObserverStatics2 is not supported\n"); - else + if (hr == E_NOINTERFACE) /* win1607 */ { - ok( hr == S_OK, "got hr %#lx.\n", hr ); - - value = TRUE; - hr = ISpatialSurfaceObserverStatics2_IsSupported( observer_statics2, &value ); - ok( hr == S_OK, "got hr %#lx.\n", hr ); - ok( !value, "got %d.\n", value ); - - ref = ISpatialSurfaceObserverStatics2_Release( observer_statics2 ); - ok( ref == 2, "got ref %ld.\n", ref ); + win_skip( "ISpatialSurfaceObserverStatics2 is not supported, skipping tests.\n" ); + goto done; } + + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + value = TRUE; + hr = ISpatialSurfaceObserverStatics2_IsSupported( observer_statics2, &value ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + ok( !value, "got %d.\n", value ); + + ref = ISpatialSurfaceObserverStatics2_Release( observer_statics2 ); + ok( ref == 2, "got ref %ld.\n", ref ); +done: + ref = IActivationFactory_Release( factory ); + ok( ref == 1, "got ref %ld.\n", ref ); +} + +static void test_HolographicSpaceStatics(void) +{ + static const WCHAR *holographicspace_statics_name = L"Windows.Graphics.Holographic.HolographicSpace"; + IHolographicSpaceStatics2 *holographicspace_statics2; + IActivationFactory *factory; + HSTRING str; + HRESULT hr; + LONG ref; + + hr = WindowsCreateString( holographicspace_statics_name, wcslen( holographicspace_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( holographicspace_statics_name ) ); + return; + } + + check_interface( factory, &IID_IUnknown ); + check_interface( factory, &IID_IInspectable ); + check_interface( factory, &IID_IAgileObject ); + + hr = IActivationFactory_QueryInterface( factory, &IID_IHolographicSpaceStatics2, (void **)&holographicspace_statics2 ); + if (hr == E_NOINTERFACE) /* win1607 */ + { + win_skip( "IHolographicSpaceStatics2 is not supported, skipping tests.\n" ); + goto done; + } + + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + ref = IHolographicSpaceStatics2_Release( holographicspace_statics2 ); + ok( ref == 2, "got ref %ld.\n", ref ); +done: ref = IActivationFactory_Release( factory ); ok( ref == 1, "got ref %ld.\n", ref ); } @@ -99,6 +144,7 @@ START_TEST(perception) ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr ); test_ObserverStatics(); + test_HolographicSpaceStatics(); RoUninitialize(); }