From d3857726a0c0e323dbb259a8ff928b68b3a0d6e6 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 2 Sep 2015 10:44:59 +0200 Subject: [PATCH] netprofm/tests: Add tests. --- dlls/netprofm/tests/Makefile.in | 2 +- dlls/netprofm/tests/list.c | 166 +++++++++++++++++++++++++++++++- 2 files changed, 165 insertions(+), 3 deletions(-) diff --git a/dlls/netprofm/tests/Makefile.in b/dlls/netprofm/tests/Makefile.in index 45b880952a2..3b5be5c5453 100644 --- a/dlls/netprofm/tests/Makefile.in +++ b/dlls/netprofm/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = netprofm.dll -IMPORTS = ole32 +IMPORTS = oleaut32 ole32 C_SRCS = \ list.c diff --git a/dlls/netprofm/tests/list.c b/dlls/netprofm/tests/list.c index 1e1ba82db1e..eb8477c6e15 100644 --- a/dlls/netprofm/tests/list.c +++ b/dlls/netprofm/tests/list.c @@ -25,6 +25,138 @@ #include "netlistmgr.h" #include "wine/test.h" +static void test_INetwork( INetwork *network ) +{ + NLM_NETWORK_CATEGORY category; + NLM_CONNECTIVITY connectivity; + NLM_DOMAIN_TYPE domain_type; + VARIANT_BOOL connected; + GUID id; + BSTR str; + HRESULT hr; + + str = NULL; + hr = INetwork_GetName( network, &str ); + todo_wine ok( hr == S_OK, "got %08x\n", hr ); + todo_wine ok( str != NULL, "str not set\n" ); + if (str) trace( "name %s\n", wine_dbgstr_w(str) ); + SysFreeString( str ); + + str = NULL; + hr = INetwork_GetDescription( network, &str ); + todo_wine ok( hr == S_OK, "got %08x\n", hr ); + todo_wine ok( str != NULL, "str not set\n" ); + if (str) trace( "description %s\n", wine_dbgstr_w(str) ); + SysFreeString( str ); + + memset( &id, 0, sizeof(id) ); + hr = INetwork_GetNetworkId( network, &id ); + ok( hr == S_OK, "got %08x\n", hr ); + trace("network id %s\n", wine_dbgstr_guid(&id)); + + domain_type = 0xdeadbeef; + hr = INetwork_GetDomainType( network, &domain_type ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( domain_type != 0xdeadbeef, "domain_type not set\n" ); + trace( "domain type %08x\n", domain_type ); + + category = 0xdeadbeef; + hr = INetwork_GetCategory( network, &category ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( category != 0xdeadbeef, "category not set\n" ); + trace( "category %08x\n", category ); + + connectivity = 0xdeadbeef; + hr = INetwork_GetConnectivity( network, &connectivity ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( connectivity != 0xdeadbeef, "connectivity not set\n" ); + trace( "connectivity %08x\n", connectivity ); + + connected = 0xdead; + hr = INetwork_get_IsConnected( network, &connected ); + ok( hr == S_OK, "got %08x\n", hr ); + trace("connected %d\n", connected); + + connected = 0xdead; + hr = INetwork_get_IsConnectedToInternet( network, &connected ); + ok( hr == S_OK, "got %08x\n", hr ); + trace("connected to internet %d\n", connected); +} + +static void test_INetworkConnection( INetworkConnection *conn ) +{ + INetwork *network; + INetworkConnectionCost *conn_cost; + NLM_CONNECTIVITY connectivity; + NLM_DOMAIN_TYPE domain_type; + VARIANT_BOOL connected; + GUID id; + HRESULT hr; + + memset( &id, 0, sizeof(id) ); + hr = INetworkConnection_GetAdapterId( conn, &id ); + ok( hr == S_OK, "got %08x\n", hr ); + trace("adapter id %s\n", wine_dbgstr_guid(&id)); + + memset( &id, 0, sizeof(id) ); + hr = INetworkConnection_GetConnectionId( conn, &id ); + ok( hr == S_OK, "got %08x\n", hr ); + trace("connection id %s\n", wine_dbgstr_guid(&id)); + + connectivity = 0xdeadbeef; + hr = INetworkConnection_GetConnectivity( conn, &connectivity ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( connectivity != 0xdeadbeef, "connectivity not set\n" ); + trace( "connectivity %08x\n", connectivity ); + + domain_type = 0xdeadbeef; + hr = INetworkConnection_GetDomainType( conn, &domain_type ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( domain_type != 0xdeadbeef, "domain_type not set\n" ); + trace( "domain type %08x\n", domain_type ); + + connected = 0xdead; + hr = INetworkConnection_get_IsConnected( conn, &connected ); + ok( hr == S_OK, "got %08x\n", hr ); + trace("connected %d\n", connected); + + connected = 0xdead; + hr = INetworkConnection_get_IsConnectedToInternet( conn, &connected ); + ok( hr == S_OK, "got %08x\n", hr ); + trace("connected to internet %d\n", connected); + + network = NULL; + hr = INetworkConnection_GetNetwork( conn, &network ); + ok( hr == S_OK, "got %08x\n", hr ); + if (network) + { + test_INetwork( network ); + INetwork_Release( network ); + } + + conn_cost = NULL; + hr = INetworkConnection_QueryInterface( conn, &IID_INetworkConnectionCost, (void **)&conn_cost ); + ok( hr == S_OK || broken(hr == E_NOINTERFACE), "got %08x\n", hr ); + if (conn_cost) + { + DWORD cost; + NLM_DATAPLAN_STATUS status; + + cost = 0xdeadbeef; + hr = INetworkConnectionCost_GetCost( conn_cost, &cost ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( cost != 0xdeadbeef, "cost not set\n" ); + trace("cost %08x\n", cost); + + memset( &status, 0,sizeof(status) ); + hr = INetworkConnectionCost_GetDataPlanStatus( conn_cost, &status ); + ok( hr == S_OK, "got %08x\n", hr ); + trace("InterfaceGuid %s\n", wine_dbgstr_guid(&status.InterfaceGuid)); + + INetworkConnectionCost_Release( conn_cost ); + } +} + static void test_INetworkListManager( void ) { IConnectionPointContainer *cpc, *cpc2; @@ -33,6 +165,10 @@ static void test_INetworkListManager( void ) NLM_CONNECTIVITY connectivity; VARIANT_BOOL connected; IConnectionPoint *pt; + IEnumNetworks *network_iter; + INetwork *network; + IEnumNetworkConnections *conn_iter; + INetworkConnection *conn; HRESULT hr; ULONG ref1, ref2; IID iid; @@ -62,9 +198,10 @@ static void test_INetworkListManager( void ) ok( connected == VARIANT_TRUE || connected == VARIANT_FALSE, "expected boolean value\n" ); /* INetworkCostManager is supported starting Win8 */ + cost_mgr = NULL; hr = INetworkListManager_QueryInterface( mgr, &IID_INetworkCostManager, (void **)&cost_mgr ); ok( hr == S_OK || broken(hr == E_NOINTERFACE), "got %08x\n", hr ); - if (hr == S_OK) + if (cost_mgr) { DWORD cost; NLM_DATAPLAN_STATUS status; @@ -119,8 +256,33 @@ static void test_INetworkListManager( void ) hr = IConnectionPointContainer_FindConnectionPoint( cpc, &IID_INetworkConnectionEvents, &pt ); ok( hr == S_OK || hr == CO_E_FAILEDTOIMPERSONATE, "got %08x\n", hr ); if (hr == S_OK) IConnectionPoint_Release( pt ); - IConnectionPointContainer_Release( cpc ); + + network_iter = NULL; + hr = INetworkListManager_GetNetworks( mgr, NLM_ENUM_NETWORK_ALL, &network_iter ); + ok( hr == S_OK, "got %08x\n", hr ); + if (network_iter) + { + while ((hr = IEnumNetworks_Next( network_iter, 1, &network, NULL )) == S_OK) + { + test_INetwork( network ); + INetwork_Release( network ); + } + IEnumNetworks_Release( network_iter ); + } + + conn_iter = NULL; + hr = INetworkListManager_GetNetworkConnections( mgr, &conn_iter ); + ok( hr == S_OK, "got %08x\n", hr ); + if (conn_iter) + { + while ((hr = IEnumNetworkConnections_Next( conn_iter, 1, &conn, NULL )) == S_OK) + { + test_INetworkConnection( conn ); + INetworkConnection_Release( conn ); + } + IEnumNetworkConnections_Release( conn_iter ); + } INetworkListManager_Release( mgr ); }