advpack: Fix buffer sizes for possibly quoted strings.
[wine.git] / dlls / dplayx / tests / dplayx.c
blob4af7f5c58106e3be18e3cc8d16e6e11c64a7c352
1 /* DirectPlay Conformance Tests
3 * Copyright 2007 - Alessandro Pignotti
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/test.h"
21 #define INITGUID
22 #include <dplay.h>
24 static BOOL validSP = FALSE; /*This global variable is needed until wine has a working service provider
25 implementation*/
27 static BOOL CALLBACK EnumConnectionsCallback(LPCGUID lpguidSP, LPVOID lpConnection,
28 DWORD dwConnectionSize, LPCDPNAME lpName, DWORD dwFlags, LPVOID lpContext)
30 HRESULT hr;
32 if(IsEqualGUID(lpguidSP,&DPSPGUID_TCPIP))
34 /*I'm forcing the TCP/IP Service provider*/
35 hr = IDirectPlayX_InitializeConnection((LPDIRECTPLAY4) lpContext, lpConnection, 0);
36 if( SUCCEEDED( hr ))
37 validSP = TRUE;
38 return FALSE;
40 return TRUE;
43 static void test_session_guid(LPDIRECTPLAY4 pDP)
45 GUID appGuid;
46 GUID zeroGuid;
47 DPSESSIONDESC2 sessionDesc;
48 LPDPSESSIONDESC2 newSession;
49 DWORD sessionSize;
50 static char name[] = "DPlay conformance test";
52 CoCreateGuid( &appGuid );
53 IDirectPlayX_EnumConnections(pDP, &appGuid, EnumConnectionsCallback, pDP, 0);
55 if( !validSP )
57 skip("Tests will not work without a valid service provider, skipping.\n");
58 return;
61 memset(&sessionDesc, 0, sizeof( DPSESSIONDESC2 ));
62 memset(&zeroGuid, 0, 16);
64 sessionDesc.dwSize = sizeof( DPSESSIONDESC2 );
65 memcpy(&sessionDesc.guidApplication, &appGuid, 16);
66 sessionDesc.dwFlags = DPSESSION_CLIENTSERVER;
67 U1(sessionDesc).lpszSessionNameA = name;
68 sessionDesc.dwMaxPlayers = 10;
69 sessionDesc.dwCurrentPlayers = 0;
70 IDirectPlayX_Open(pDP, &sessionDesc, DPOPEN_CREATE);
72 /* I read the sessiondesc from directplay in a fresh memory location,
73 because directplay does not touch the original struct, but saves
74 internally a version with the session guid set*/
76 IDirectPlayX_GetSessionDesc(pDP, NULL, &sessionSize);
77 newSession = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sessionSize);
78 IDirectPlayX_GetSessionDesc(pDP, newSession, &sessionSize);
79 todo_wine ok( !IsEqualGUID(&newSession->guidInstance, &zeroGuid), "Session guid not initialized\n");
80 HeapFree(GetProcessHeap(), 0, newSession);
83 START_TEST(dplayx)
85 LPDIRECTPLAY4 pDP;
87 CoInitialize( NULL );
88 CoCreateInstance(&CLSID_DirectPlay, NULL, CLSCTX_ALL, &IID_IDirectPlay4A, (VOID**)&pDP);
90 test_session_guid( pDP );
92 IDirectPlayX_Release( pDP );
93 CoUninitialize();