ReactOS 0.4.16-dev-197-g92996da
private_data.cpp
Go to the documentation of this file.
2
3BOOL Test_PrivateData (INT* passed, INT* failed)
4{
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 NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RGB(r, g, b)
Definition: precomp.h:71
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
GLsizeiptr size
Definition: glext.h:5919
const GUID * guid
#define TEST(x)
Definition: precomp.h:20
static GUID guid2
Definition: devinst.c:42
BOOL CreateSurface(LPDIRECTDRAWSURFACE7 *pSurface)
Definition: helper.cpp:28
BOOL Test_PrivateData(INT *passed, INT *failed)
Definition: private_data.cpp:3
#define DDBLT_COLORFILL
Definition: ddraw.h:555
#define DDSPD_VOLATILE
Definition: ddraw.h:465
struct _DDBLTFX DDBLTFX
#define DDERR_NOTFOUND
Definition: ddraw.h:97
#define DDERR_MOREDATA
Definition: ddraw.h:176
#define DD_OK
Definition: ddraw.h:186
#define DDBLT_WAIT
Definition: ddraw.h:569
#define DDERR_EXPIRED
Definition: ddraw.h:177
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
DWORD dwSize
Definition: ddraw.h:1272
DWORD dwFillColor
Definition: ddraw.h:1310
int32_t INT
Definition: typedefs.h:58
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481