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
25 #include "netlistmgr.h"
26 #include "wine/test.h"
28 static void test_INetworkListManager( void )
30 IConnectionPointContainer
*cpc
, *cpc2
;
31 INetworkListManager
*mgr
;
32 INetworkCostManager
*cost_mgr
;
33 NLM_CONNECTIVITY connectivity
;
34 VARIANT_BOOL connected
;
40 hr
= CoCreateInstance( &CLSID_NetworkListManager
, NULL
, CLSCTX_INPROC_SERVER
,
41 &IID_INetworkListManager
, (void **)&mgr
);
44 win_skip( "can't create instance of NetworkListManager\n" );
48 connectivity
= 0xdeadbeef;
49 hr
= INetworkListManager_GetConnectivity( mgr
, &connectivity
);
50 ok( hr
== S_OK
, "got %08x\n", hr
);
51 ok( connectivity
!= 0xdeadbeef, "unchanged value\n" );
52 trace( "GetConnectivity: %08x\n", connectivity
);
55 hr
= INetworkListManager_IsConnected( mgr
, &connected
);
56 ok( hr
== S_OK
, "got %08x\n", hr
);
57 ok( connected
== VARIANT_TRUE
|| connected
== VARIANT_FALSE
, "expected boolean value\n" );
60 hr
= INetworkListManager_IsConnectedToInternet( mgr
, &connected
);
61 ok( hr
== S_OK
, "got %08x\n", hr
);
62 ok( connected
== VARIANT_TRUE
|| connected
== VARIANT_FALSE
, "expected boolean value\n" );
64 /* INetworkCostManager is supported starting Win8 */
65 hr
= INetworkListManager_QueryInterface( mgr
, &IID_INetworkCostManager
, (void **)&cost_mgr
);
66 ok( hr
== S_OK
|| broken(hr
== E_NOINTERFACE
), "got %08x\n", hr
);
70 NLM_DATAPLAN_STATUS status
;
72 hr
= INetworkCostManager_GetCost( cost_mgr
, NULL
, NULL
);
73 ok( hr
== E_POINTER
, "got %08x\n", hr
);
76 hr
= INetworkCostManager_GetCost( cost_mgr
, &cost
, NULL
);
77 ok( hr
== S_OK
, "got %08x\n", hr
);
78 ok( cost
!= 0xdeadbeef, "cost not set\n" );
80 hr
= INetworkCostManager_GetDataPlanStatus( cost_mgr
, NULL
, NULL
);
81 ok( hr
== E_POINTER
, "got %08x\n", hr
);
83 hr
= INetworkCostManager_GetDataPlanStatus( cost_mgr
, &status
, NULL
);
84 ok( hr
== S_OK
, "got %08x\n", hr
);
86 INetworkCostManager_Release( cost_mgr
);
89 hr
= INetworkListManager_QueryInterface( mgr
, &IID_IConnectionPointContainer
, (void**)&cpc
);
90 ok( hr
== S_OK
, "got %08x\n", hr
);
92 ref1
= IConnectionPointContainer_AddRef( cpc
);
94 hr
= IConnectionPointContainer_FindConnectionPoint( cpc
, &IID_INetworkListManagerEvents
, &pt
);
95 ok( hr
== S_OK
, "got %08x\n", hr
);
97 ref2
= IConnectionPointContainer_AddRef( cpc
);
98 ok( ref2
== ref1
+ 2, "Expected refcount %d, got %d\n", ref1
+ 2, ref2
);
100 IConnectionPointContainer_Release( cpc
);
101 IConnectionPointContainer_Release( cpc
);
103 hr
= IConnectionPoint_GetConnectionPointContainer( pt
, &cpc2
);
104 ok( hr
== S_OK
, "got %08x\n", hr
);
105 ok( cpc2
== cpc
, "Expected cpc2 == %p, but got %p\n", cpc
, cpc2
);
106 IConnectionPointContainer_Release( cpc2
);
108 memset( &iid
, 0, sizeof(iid
) );
109 hr
= IConnectionPoint_GetConnectionInterface( pt
, &iid
);
110 ok( hr
== S_OK
, "got %08x\n", hr
);
111 ok( !memcmp( &iid
, &IID_INetworkListManagerEvents
, sizeof(iid
) ),
112 "Expected iid to be IID_INetworkListManagerEvents\n" );
113 IConnectionPoint_Release( pt
);
115 hr
= IConnectionPointContainer_FindConnectionPoint( cpc
, &IID_INetworkCostManagerEvents
, &pt
);
116 ok( hr
== S_OK
|| hr
== CO_E_FAILEDTOIMPERSONATE
, "got %08x\n", hr
);
117 if (hr
== S_OK
) IConnectionPoint_Release( pt
);
119 IConnectionPointContainer_Release( cpc
);
120 INetworkListManager_Release( mgr
);
125 CoInitialize( NULL
);
126 test_INetworkListManager();