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
);
71 hr
= INetworkCostManager_GetCost( cost_mgr
, NULL
, NULL
);
72 ok( hr
== E_POINTER
, "got %08x\n", hr
);
75 hr
= INetworkCostManager_GetCost( cost_mgr
, &cost
, NULL
);
76 ok( hr
== S_OK
, "got %08x\n", hr
);
77 ok( cost
!= 0xdeadbeef, "cost not set\n" );
79 INetworkCostManager_Release( cost_mgr
);
82 hr
= INetworkListManager_QueryInterface( mgr
, &IID_IConnectionPointContainer
, (void**)&cpc
);
83 ok( hr
== S_OK
, "got %08x\n", hr
);
85 ref1
= IConnectionPointContainer_AddRef( cpc
);
87 hr
= IConnectionPointContainer_FindConnectionPoint( cpc
, &IID_INetworkListManagerEvents
, &pt
);
88 ok( hr
== S_OK
, "got %08x\n", hr
);
90 ref2
= IConnectionPointContainer_AddRef( cpc
);
91 ok( ref2
== ref1
+ 2, "Expected refcount %d, got %d\n", ref1
+ 2, ref2
);
93 IConnectionPointContainer_Release( cpc
);
94 IConnectionPointContainer_Release( cpc
);
96 hr
= IConnectionPoint_GetConnectionPointContainer( pt
, &cpc2
);
97 ok( hr
== S_OK
, "got %08x\n", hr
);
98 ok( cpc2
== cpc
, "Expected cpc2 == %p, but got %p\n", cpc
, cpc2
);
99 IConnectionPointContainer_Release( cpc2
);
101 memset( &iid
, 0, sizeof(iid
) );
102 hr
= IConnectionPoint_GetConnectionInterface( pt
, &iid
);
103 ok( hr
== S_OK
, "got %08x\n", hr
);
104 ok( !memcmp( &iid
, &IID_INetworkListManagerEvents
, sizeof(iid
) ),
105 "Expected iid to be IID_INetworkListManagerEvents\n" );
106 IConnectionPoint_Release( pt
);
108 hr
= IConnectionPointContainer_FindConnectionPoint( cpc
, &IID_INetworkCostManagerEvents
, &pt
);
109 ok( hr
== S_OK
|| hr
== CO_E_FAILEDTOIMPERSONATE
, "got %08x\n", hr
);
110 if (hr
== S_OK
) IConnectionPoint_Release( pt
);
112 IConnectionPointContainer_Release( cpc
);
113 INetworkListManager_Release( mgr
);
118 CoInitialize( NULL
);
119 test_INetworkListManager();