2 * Copyright 2011 Louis Lenders
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
20 #define WIN32_LEAN_AND_MEAN
24 #include "wine/test.h"
26 static char *show_guid(const GUID *guid, char *buf)
29 "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
30 guid->Data1, guid->Data2, guid->Data3,
31 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
32 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
37 static IDirectPlay8Peer* peer = NULL;
39 static HRESULT WINAPI DirectPlayMessageHandler(PVOID context, DWORD message_id, PVOID buffer)
44 static void test_init_dp(void)
49 ok(hr == S_OK, "CoInitialize failed with %x\n", hr);
51 hr = CoCreateInstance(&CLSID_DirectPlay8Peer, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectPlay8Peer, (void **)&peer);
52 ok(hr == S_OK, "CoCreateInstance failed with 0x%x\n", hr);
54 hr = IDirectPlay8Peer_Initialize(peer, NULL, DirectPlayMessageHandler, 0);
55 ok(hr == S_OK, "IDirectPlay8Peer_Initialize failed with %x\n", hr);
58 static void test_enum_service_providers(void)
60 DPN_SERVICE_PROVIDER_INFO *serv_prov_info;
69 hr = IDirectPlay8Peer_EnumServiceProviders(peer, NULL, NULL, NULL, &size, &items, 0);
70 todo_wine ok(hr == DPNERR_BUFFERTOOSMALL, "IDirectPlay8Peer_EnumServiceProviders failed with %x\n", hr);
71 todo_wine ok(size != 0, "size is unexpectedly 0\n");
73 serv_prov_info = (DPN_SERVICE_PROVIDER_INFO*) HeapAlloc(GetProcessHeap(), 0, size);
75 hr = IDirectPlay8Peer_EnumServiceProviders(peer, NULL, NULL, serv_prov_info, &size, &items, 0);
76 todo_wine ok(hr == S_OK, "IDirectPlay8Peer_EnumServiceProviders failed with %x\n", hr);
77 todo_wine ok(items != 0, "Found unexpectedly no service providers\n");
79 trace("number of items found: %d\n", items);
83 trace("Found Service Provider: %s\n", wine_dbgstr_w(serv_prov_info->pwszName));
84 trace("Found guid: %s\n", show_guid(&serv_prov_info->guid, guid));
89 serv_prov_info -= items; /* set pointer back */
90 ok(HeapFree(GetProcessHeap(), 0, serv_prov_info), "Failed freeing server provider info\n");
95 hr = IDirectPlay8Peer_EnumServiceProviders(peer, &CLSID_DP8SP_TCPIP, NULL, NULL, &size, &items, 0);
96 todo_wine ok(hr == DPNERR_BUFFERTOOSMALL, "IDirectPlay8Peer_EnumServiceProviders failed with %x\n", hr);
97 todo_wine ok(size != 0, "size is unexpectedly 0\n");
99 serv_prov_info = (DPN_SERVICE_PROVIDER_INFO*) HeapAlloc(GetProcessHeap(), 0, size);
101 hr = IDirectPlay8Peer_EnumServiceProviders(peer, &CLSID_DP8SP_TCPIP, NULL, serv_prov_info, &size, &items, 0);
102 todo_wine ok(hr == S_OK, "IDirectPlay8Peer_EnumServiceProviders failed with %x\n", hr);
103 todo_wine ok(items != 0, "Found unexpectedly no adapter\n");
105 for (i=0;i<items;i++)
107 trace("Found adapter: %s\n", wine_dbgstr_w(serv_prov_info->pwszName));
108 trace("Found adapter guid: %s\n", show_guid(&serv_prov_info->guid, guid));
113 serv_prov_info -= items; /* set pointer back */
114 ok(HeapFree(GetProcessHeap(), 0, serv_prov_info), "Failed freeing server provider info\n");
117 static void test_cleanup_dp(void)
121 hr = IDirectPlay8Peer_Close(peer, 0);
122 ok(hr == S_OK, "IDirectPlay8Peer_Close failed with %x\n", hr);
124 hr = IDirectPlay8Peer_Release(peer);
125 ok(hr == S_OK, "IDirectPlay8Peer_Release failed with %x\n", hr);
133 test_enum_service_providers();