dplayx: Remove unneeded address-of operator from array name.
[wine] / dlls / dplayx / tests / dplayx.c
1 /* DirectPlay Conformance Tests
2  *
3  * Copyright 2007 - Alessandro Pignotti
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include "wine/test.h"
21 #define INITGUID
22 #include <dplay.h>
23
24 static BOOL validSP = FALSE; /*This global variable is needed until wine has a working service provider
25                                implementation*/
26
27 static BOOL CALLBACK EnumConnectionsCallback(LPCGUID lpguidSP, LPVOID lpConnection,
28     DWORD dwConnectionSize, LPCDPNAME lpName, DWORD dwFlags, LPVOID lpContext)
29 {
30     HRESULT hr;
31
32     if(IsEqualGUID(lpguidSP,&DPSPGUID_TCPIP))
33     {
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;
39     }
40     return TRUE;
41 }
42
43 static void test_session_guid(LPDIRECTPLAY4 pDP)
44 {
45     GUID appGuid;
46     GUID zeroGuid;
47     DPSESSIONDESC2 sessionDesc;
48     LPDPSESSIONDESC2 newSession;
49     DWORD sessionSize;
50     static char name[] = "DPlay conformance test";
51
52     CoCreateGuid( &appGuid );
53     IDirectPlayX_EnumConnections(pDP, &appGuid, EnumConnectionsCallback, pDP, 0);
54
55     if( !validSP )
56     {
57         skip("Tests will not work without a valid service provider, skipping.\n");
58         return;
59     }
60
61     memset(&sessionDesc, 0, sizeof( DPSESSIONDESC2 ));
62     memset(&zeroGuid, 0, 16);
63
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);
71
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*/
75
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);
81 }
82
83 START_TEST(dplayx)
84 {
85     LPDIRECTPLAY4 pDP;
86
87     CoInitialize( NULL );
88     CoCreateInstance(&CLSID_DirectPlay, NULL, CLSCTX_ALL, &IID_IDirectPlay4A, (VOID**)&pDP);
89
90     test_session_guid( pDP );
91
92     IDirectPlayX_Release( pDP );
93     CoUninitialize();
94 }