gdi32: Reimplement Ellipse in paths to avoid calling imprecise arc helper functions.
[wine.git] / dlls / netprofm / tests / list.c
blobeb8477c6e153848fd28bd62f3e35aac0219c6560
1 /*
2 * Copyright 2014 Hans Leidekker 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 <stdio.h>
20 #include "windows.h"
21 #define COBJMACROS
22 #include "initguid.h"
23 #include "objbase.h"
24 #include "ocidl.h"
25 #include "netlistmgr.h"
26 #include "wine/test.h"
28 static void test_INetwork( INetwork *network )
30 NLM_NETWORK_CATEGORY category;
31 NLM_CONNECTIVITY connectivity;
32 NLM_DOMAIN_TYPE domain_type;
33 VARIANT_BOOL connected;
34 GUID id;
35 BSTR str;
36 HRESULT hr;
38 str = NULL;
39 hr = INetwork_GetName( network, &str );
40 todo_wine ok( hr == S_OK, "got %08x\n", hr );
41 todo_wine ok( str != NULL, "str not set\n" );
42 if (str) trace( "name %s\n", wine_dbgstr_w(str) );
43 SysFreeString( str );
45 str = NULL;
46 hr = INetwork_GetDescription( network, &str );
47 todo_wine ok( hr == S_OK, "got %08x\n", hr );
48 todo_wine ok( str != NULL, "str not set\n" );
49 if (str) trace( "description %s\n", wine_dbgstr_w(str) );
50 SysFreeString( str );
52 memset( &id, 0, sizeof(id) );
53 hr = INetwork_GetNetworkId( network, &id );
54 ok( hr == S_OK, "got %08x\n", hr );
55 trace("network id %s\n", wine_dbgstr_guid(&id));
57 domain_type = 0xdeadbeef;
58 hr = INetwork_GetDomainType( network, &domain_type );
59 ok( hr == S_OK, "got %08x\n", hr );
60 ok( domain_type != 0xdeadbeef, "domain_type not set\n" );
61 trace( "domain type %08x\n", domain_type );
63 category = 0xdeadbeef;
64 hr = INetwork_GetCategory( network, &category );
65 ok( hr == S_OK, "got %08x\n", hr );
66 ok( category != 0xdeadbeef, "category not set\n" );
67 trace( "category %08x\n", category );
69 connectivity = 0xdeadbeef;
70 hr = INetwork_GetConnectivity( network, &connectivity );
71 ok( hr == S_OK, "got %08x\n", hr );
72 ok( connectivity != 0xdeadbeef, "connectivity not set\n" );
73 trace( "connectivity %08x\n", connectivity );
75 connected = 0xdead;
76 hr = INetwork_get_IsConnected( network, &connected );
77 ok( hr == S_OK, "got %08x\n", hr );
78 trace("connected %d\n", connected);
80 connected = 0xdead;
81 hr = INetwork_get_IsConnectedToInternet( network, &connected );
82 ok( hr == S_OK, "got %08x\n", hr );
83 trace("connected to internet %d\n", connected);
86 static void test_INetworkConnection( INetworkConnection *conn )
88 INetwork *network;
89 INetworkConnectionCost *conn_cost;
90 NLM_CONNECTIVITY connectivity;
91 NLM_DOMAIN_TYPE domain_type;
92 VARIANT_BOOL connected;
93 GUID id;
94 HRESULT hr;
96 memset( &id, 0, sizeof(id) );
97 hr = INetworkConnection_GetAdapterId( conn, &id );
98 ok( hr == S_OK, "got %08x\n", hr );
99 trace("adapter id %s\n", wine_dbgstr_guid(&id));
101 memset( &id, 0, sizeof(id) );
102 hr = INetworkConnection_GetConnectionId( conn, &id );
103 ok( hr == S_OK, "got %08x\n", hr );
104 trace("connection id %s\n", wine_dbgstr_guid(&id));
106 connectivity = 0xdeadbeef;
107 hr = INetworkConnection_GetConnectivity( conn, &connectivity );
108 ok( hr == S_OK, "got %08x\n", hr );
109 ok( connectivity != 0xdeadbeef, "connectivity not set\n" );
110 trace( "connectivity %08x\n", connectivity );
112 domain_type = 0xdeadbeef;
113 hr = INetworkConnection_GetDomainType( conn, &domain_type );
114 ok( hr == S_OK, "got %08x\n", hr );
115 ok( domain_type != 0xdeadbeef, "domain_type not set\n" );
116 trace( "domain type %08x\n", domain_type );
118 connected = 0xdead;
119 hr = INetworkConnection_get_IsConnected( conn, &connected );
120 ok( hr == S_OK, "got %08x\n", hr );
121 trace("connected %d\n", connected);
123 connected = 0xdead;
124 hr = INetworkConnection_get_IsConnectedToInternet( conn, &connected );
125 ok( hr == S_OK, "got %08x\n", hr );
126 trace("connected to internet %d\n", connected);
128 network = NULL;
129 hr = INetworkConnection_GetNetwork( conn, &network );
130 ok( hr == S_OK, "got %08x\n", hr );
131 if (network)
133 test_INetwork( network );
134 INetwork_Release( network );
137 conn_cost = NULL;
138 hr = INetworkConnection_QueryInterface( conn, &IID_INetworkConnectionCost, (void **)&conn_cost );
139 ok( hr == S_OK || broken(hr == E_NOINTERFACE), "got %08x\n", hr );
140 if (conn_cost)
142 DWORD cost;
143 NLM_DATAPLAN_STATUS status;
145 cost = 0xdeadbeef;
146 hr = INetworkConnectionCost_GetCost( conn_cost, &cost );
147 ok( hr == S_OK, "got %08x\n", hr );
148 ok( cost != 0xdeadbeef, "cost not set\n" );
149 trace("cost %08x\n", cost);
151 memset( &status, 0,sizeof(status) );
152 hr = INetworkConnectionCost_GetDataPlanStatus( conn_cost, &status );
153 ok( hr == S_OK, "got %08x\n", hr );
154 trace("InterfaceGuid %s\n", wine_dbgstr_guid(&status.InterfaceGuid));
156 INetworkConnectionCost_Release( conn_cost );
160 static void test_INetworkListManager( void )
162 IConnectionPointContainer *cpc, *cpc2;
163 INetworkListManager *mgr;
164 INetworkCostManager *cost_mgr;
165 NLM_CONNECTIVITY connectivity;
166 VARIANT_BOOL connected;
167 IConnectionPoint *pt;
168 IEnumNetworks *network_iter;
169 INetwork *network;
170 IEnumNetworkConnections *conn_iter;
171 INetworkConnection *conn;
172 HRESULT hr;
173 ULONG ref1, ref2;
174 IID iid;
176 hr = CoCreateInstance( &CLSID_NetworkListManager, NULL, CLSCTX_INPROC_SERVER,
177 &IID_INetworkListManager, (void **)&mgr );
178 if (hr != S_OK)
180 win_skip( "can't create instance of NetworkListManager\n" );
181 return;
184 connectivity = 0xdeadbeef;
185 hr = INetworkListManager_GetConnectivity( mgr, &connectivity );
186 ok( hr == S_OK, "got %08x\n", hr );
187 ok( connectivity != 0xdeadbeef, "unchanged value\n" );
188 trace( "GetConnectivity: %08x\n", connectivity );
190 connected = 0xdead;
191 hr = INetworkListManager_IsConnected( mgr, &connected );
192 ok( hr == S_OK, "got %08x\n", hr );
193 ok( connected == VARIANT_TRUE || connected == VARIANT_FALSE, "expected boolean value\n" );
195 connected = 0xdead;
196 hr = INetworkListManager_IsConnectedToInternet( mgr, &connected );
197 ok( hr == S_OK, "got %08x\n", hr );
198 ok( connected == VARIANT_TRUE || connected == VARIANT_FALSE, "expected boolean value\n" );
200 /* INetworkCostManager is supported starting Win8 */
201 cost_mgr = NULL;
202 hr = INetworkListManager_QueryInterface( mgr, &IID_INetworkCostManager, (void **)&cost_mgr );
203 ok( hr == S_OK || broken(hr == E_NOINTERFACE), "got %08x\n", hr );
204 if (cost_mgr)
206 DWORD cost;
207 NLM_DATAPLAN_STATUS status;
209 hr = INetworkCostManager_GetCost( cost_mgr, NULL, NULL );
210 ok( hr == E_POINTER, "got %08x\n", hr );
212 cost = 0xdeadbeef;
213 hr = INetworkCostManager_GetCost( cost_mgr, &cost, NULL );
214 ok( hr == S_OK, "got %08x\n", hr );
215 ok( cost != 0xdeadbeef, "cost not set\n" );
217 hr = INetworkCostManager_GetDataPlanStatus( cost_mgr, NULL, NULL );
218 ok( hr == E_POINTER, "got %08x\n", hr );
220 hr = INetworkCostManager_GetDataPlanStatus( cost_mgr, &status, NULL );
221 ok( hr == S_OK, "got %08x\n", hr );
223 INetworkCostManager_Release( cost_mgr );
226 hr = INetworkListManager_QueryInterface( mgr, &IID_IConnectionPointContainer, (void**)&cpc );
227 ok( hr == S_OK, "got %08x\n", hr );
229 ref1 = IConnectionPointContainer_AddRef( cpc );
231 hr = IConnectionPointContainer_FindConnectionPoint( cpc, &IID_INetworkListManagerEvents, &pt );
232 ok( hr == S_OK, "got %08x\n", hr );
234 ref2 = IConnectionPointContainer_AddRef( cpc );
235 ok( ref2 == ref1 + 2, "Expected refcount %d, got %d\n", ref1 + 2, ref2 );
237 IConnectionPointContainer_Release( cpc );
238 IConnectionPointContainer_Release( cpc );
240 hr = IConnectionPoint_GetConnectionPointContainer( pt, &cpc2 );
241 ok( hr == S_OK, "got %08x\n", hr );
242 ok( cpc2 == cpc, "Expected cpc2 == %p, but got %p\n", cpc, cpc2 );
243 IConnectionPointContainer_Release( cpc2 );
245 memset( &iid, 0, sizeof(iid) );
246 hr = IConnectionPoint_GetConnectionInterface( pt, &iid );
247 ok( hr == S_OK, "got %08x\n", hr );
248 ok( !memcmp( &iid, &IID_INetworkListManagerEvents, sizeof(iid) ),
249 "Expected iid to be IID_INetworkListManagerEvents\n" );
250 IConnectionPoint_Release( pt );
252 hr = IConnectionPointContainer_FindConnectionPoint( cpc, &IID_INetworkCostManagerEvents, &pt );
253 ok( hr == S_OK || hr == CO_E_FAILEDTOIMPERSONATE, "got %08x\n", hr );
254 if (hr == S_OK) IConnectionPoint_Release( pt );
256 hr = IConnectionPointContainer_FindConnectionPoint( cpc, &IID_INetworkConnectionEvents, &pt );
257 ok( hr == S_OK || hr == CO_E_FAILEDTOIMPERSONATE, "got %08x\n", hr );
258 if (hr == S_OK) IConnectionPoint_Release( pt );
259 IConnectionPointContainer_Release( cpc );
261 network_iter = NULL;
262 hr = INetworkListManager_GetNetworks( mgr, NLM_ENUM_NETWORK_ALL, &network_iter );
263 ok( hr == S_OK, "got %08x\n", hr );
264 if (network_iter)
266 while ((hr = IEnumNetworks_Next( network_iter, 1, &network, NULL )) == S_OK)
268 test_INetwork( network );
269 INetwork_Release( network );
271 IEnumNetworks_Release( network_iter );
274 conn_iter = NULL;
275 hr = INetworkListManager_GetNetworkConnections( mgr, &conn_iter );
276 ok( hr == S_OK, "got %08x\n", hr );
277 if (conn_iter)
279 while ((hr = IEnumNetworkConnections_Next( conn_iter, 1, &conn, NULL )) == S_OK)
281 test_INetworkConnection( conn );
282 INetworkConnection_Release( conn );
284 IEnumNetworkConnections_Release( conn_iter );
286 INetworkListManager_Release( mgr );
289 START_TEST( list )
291 CoInitialize( NULL );
292 test_INetworkListManager();
293 CoUninitialize();