ReactOS  0.4.12-dev-918-g6c6e7b8
private_data.cpp
Go to the documentation of this file.
2 
3 BOOL Test_PrivateData (INT* passed, INT* failed)
4 {
5  LPDIRECTDRAWSURFACE7 Surface;
6  DWORD size, dummy = 0xBAADF00D;
7  GUID guid = { 0 };
8  GUID guid2 = { 0x1 };
9 
10  if(!CreateSurface(&Surface))
11  return FALSE;
12 
13  // General test
14  TEST(Surface->SetPrivateData(guid, NULL, 0, 0) == DDERR_INVALIDPARAMS);
15  TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, 0, 0) == DDERR_INVALIDPARAMS);
16  TEST(Surface->SetPrivateData(guid, (LPVOID)0xdeadbeef, sizeof(DWORD), 0) == DDERR_INVALIDPARAMS);
17  TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, sizeof(DWORD), 0) == DD_OK);
18 
19  TEST(Surface->GetPrivateData(guid, NULL, 0) == DDERR_INVALIDPARAMS);
20  TEST(Surface->GetPrivateData(guid, &dummy, 0) == DDERR_INVALIDPARAMS);
21  size = 0;
22  TEST(Surface->GetPrivateData(guid, &dummy, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
23  size = 2;
24  TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
25  TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_INVALIDPARAMS);
26  TEST(Surface->GetPrivateData(guid, &dummy, &size) == DD_OK && dummy == 0xBAADF00D);
27  TEST(Surface->GetPrivateData(guid2, NULL, 0) == DDERR_NOTFOUND);
28 
29  TEST(Surface->FreePrivateData(guid) == DD_OK);
30  TEST(Surface->FreePrivateData(guid) == DDERR_NOTFOUND);
31 
32  // Test for DDSPD_VOLATILE flag
33  TEST(Surface->SetPrivateData(guid, (LPVOID)&dummy, sizeof(DWORD), DDSPD_VOLATILE) == DD_OK);
34  size = 0;
35  TEST(Surface->GetPrivateData(guid, NULL, &size) == DDERR_MOREDATA && size == sizeof(DWORD));
36  TEST(Surface->GetPrivateData(guid, &dummy, &size) == DD_OK && dummy == 0xBAADF00D);
37 
38  DDBLTFX bltfx;
39  bltfx.dwSize = sizeof(DDBLTFX);
40  bltfx.dwFillColor = RGB(0, 0, 0);
41  if(Surface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx) != DD_OK)
42  printf("ERROR: Failed to draw to surface !");
43  TEST(Surface->GetPrivateData(guid, &dummy, &size) == DDERR_EXPIRED);
44 
45  // TODO: Test for DDSPD_IUNKNOWNPOINTER (see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_5qyf.asp)
46 
47  Surface->Release();
48  return TRUE;
49 }
#define TRUE
Definition: types.h:120
BOOL Test_PrivateData(INT *passed, INT *failed)
Definition: private_data.cpp:3
DWORD dwSize
Definition: ddraw.h:1272
#define DDERR_MOREDATA
Definition: ddraw.h:176
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:56
#define DD_OK
Definition: ddraw.h:186
static GUID guid2
Definition: devinst.c:42
const GUID * guid
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DDSPD_VOLATILE
Definition: ddraw.h:465
smooth NULL
Definition: ftsmooth.c:416
#define DDBLT_COLORFILL
Definition: ddraw.h:555
#define DDBLT_WAIT
Definition: ddraw.h:569
#define DDERR_NOTFOUND
Definition: ddraw.h:97
GLsizeiptr size
Definition: glext.h:5919
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
#define TEST(x)
Definition: precomp.h:20
struct _DDBLTFX DDBLTFX
#define RGB(r, g, b)
Definition: wingdi.h:2918
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL CreateSurface(LPDIRECTDRAWSURFACE7 *pSurface)
Definition: helper.cpp:28
#define DDERR_EXPIRED
Definition: ddraw.h:177
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
#define printf
Definition: config.h:203