twinapi.appcore: Stub Windows.System.Profile.AnalyticsInfo runtimeclass.
[wine.git] / dlls / twinapi.appcore / tests / twinapi.c
blob358cd6719a87e7249b00493adbeeed1e3e0aca0f
1 /*
2 * Copyright 2023 RĂ©mi Bernon for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include <stddef.h>
22 #include "windef.h"
23 #include "winbase.h"
25 #define COBJMACROS
26 #include "initguid.h"
27 #include "winstring.h"
28 #include "roapi.h"
30 #define WIDL_using_Windows_Foundation
31 #define WIDL_using_Windows_Foundation_Collections
32 #include "windows.foundation.h"
33 #define WIDL_using_Windows_Security_ExchangeActiveSyncProvisioning
34 #include "windows.security.exchangeactivesyncprovisioning.h"
35 #define WIDL_using_Windows_System_Profile
36 #include "windows.system.profile.h"
37 #define WIDL_using_Windows_System_UserProfile
38 #include "windows.system.userprofile.h"
40 #include "wine/test.h"
42 #define check_interface( a, b, c ) check_interface_( __LINE__, a, b, c )
43 static void check_interface_( unsigned int line, void *iface_ptr, REFIID iid, BOOL supported )
45 IUnknown *iface = iface_ptr;
46 HRESULT hr, expected;
47 IUnknown *unk;
49 expected = supported ? S_OK : E_NOINTERFACE;
50 hr = IUnknown_QueryInterface( iface, iid, (void **)&unk );
51 ok_ (__FILE__, line)( hr == expected, "got hr %#lx, expected %#lx.\n", hr, expected );
52 if (SUCCEEDED(hr)) IUnknown_Release( unk );
55 static void test_EasClientDeviceInformation(void)
57 static const WCHAR *class_name = RuntimeClass_Windows_Security_ExchangeActiveSyncProvisioning_EasClientDeviceInformation;
58 IEasClientDeviceInformation *client_device_information;
59 IActivationFactory *factory;
60 HSTRING str;
61 HRESULT hr;
62 LONG ref;
64 hr = WindowsCreateString( class_name, wcslen( class_name ), &str );
65 ok( hr == S_OK, "got hr %#lx.\n", hr );
67 hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory );
68 WindowsDeleteString( str );
69 ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr );
70 if (hr == REGDB_E_CLASSNOTREG)
72 win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) );
73 return;
76 check_interface( factory, &IID_IUnknown, TRUE );
77 check_interface( factory, &IID_IInspectable, TRUE );
78 check_interface( factory, &IID_IAgileObject, FALSE );
80 hr = IActivationFactory_ActivateInstance( factory, (IInspectable **)&client_device_information );
81 ok( hr == S_OK, "got hr %#lx.\n", hr );
83 check_interface( client_device_information, &IID_IUnknown, TRUE );
84 check_interface( client_device_information, &IID_IInspectable, TRUE );
85 check_interface( client_device_information, &IID_IAgileObject, FALSE );
87 hr = IEasClientDeviceInformation_get_OperatingSystem( client_device_information, &str );
88 ok( hr == S_OK, "got hr %#lx\n", hr );
89 WindowsDeleteString( str );
91 hr = IEasClientDeviceInformation_get_FriendlyName( client_device_information, &str );
92 ok( hr == S_OK, "got hr %#lx\n", hr );
93 WindowsDeleteString( str );
95 hr = IEasClientDeviceInformation_get_SystemManufacturer( client_device_information, &str );
96 ok( hr == S_OK, "got hr %#lx\n", hr );
97 WindowsDeleteString( str );
99 hr = IEasClientDeviceInformation_get_SystemProductName( client_device_information, &str );
100 ok( hr == S_OK, "got hr %#lx\n", hr );
101 WindowsDeleteString( str );
103 hr = IEasClientDeviceInformation_get_SystemSku( client_device_information, &str );
104 ok( hr == S_OK, "got hr %#lx\n", hr );
105 WindowsDeleteString( str );
107 ref = IEasClientDeviceInformation_Release( client_device_information );
108 ok( ref == 0, "got ref %ld.\n", ref );
110 ref = IActivationFactory_Release( factory );
111 ok( ref == 1, "got ref %ld.\n", ref );
114 static void test_AnalyticsVersionInfo(void)
116 static const WCHAR *class_name = RuntimeClass_Windows_System_Profile_AnalyticsInfo;
117 IAnalyticsInfoStatics *analytics_info_statics;
118 IAnalyticsVersionInfo *analytics_version_info;
119 IActivationFactory *factory;
120 HSTRING str;
121 HRESULT hr;
122 LONG ref;
124 hr = WindowsCreateString( class_name, wcslen( class_name ), &str );
125 ok( hr == S_OK, "got hr %#lx.\n", hr );
127 hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory );
128 WindowsDeleteString( str );
129 ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr );
130 if (hr == REGDB_E_CLASSNOTREG)
132 win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) );
133 return;
136 check_interface( factory, &IID_IUnknown, TRUE );
137 check_interface( factory, &IID_IInspectable, TRUE );
138 check_interface( factory, &IID_IAgileObject, TRUE );
140 hr = IActivationFactory_QueryInterface( factory, &IID_IAnalyticsInfoStatics, (void **)&analytics_info_statics );
141 ok( hr == S_OK, "got hr %#lx.\n", hr );
143 hr = IAnalyticsInfoStatics_get_VersionInfo( analytics_info_statics, &analytics_version_info );
144 ok( hr == S_OK, "got hr %#lx.\n", hr );
146 check_interface( analytics_version_info, &IID_IUnknown, TRUE );
147 check_interface( analytics_version_info, &IID_IInspectable, TRUE );
148 check_interface( analytics_version_info, &IID_IAgileObject, TRUE );
150 ref = IAnalyticsVersionInfo_Release( analytics_version_info );
151 ok( ref == 0, "got ref %ld.\n", ref );
153 ref = IAnalyticsInfoStatics_Release( analytics_info_statics );
154 ok( ref == 2, "got ref %ld.\n", ref );
155 ref = IActivationFactory_Release( factory );
156 ok( ref == 1, "got ref %ld.\n", ref );
159 START_TEST(twinapi)
161 HRESULT hr;
163 hr = RoInitialize( RO_INIT_MULTITHREADED );
164 ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr );
166 test_EasClientDeviceInformation();
167 test_AnalyticsVersionInfo();
169 RoUninitialize();