ReactOS  0.4.12-dev-685-gf36cbf7
misc.cpp
Go to the documentation of this file.
2 
3 BOOL Test_Misc (INT* passed, INT* failed)
4 {
5  LPDIRECTDRAWSURFACE7 Surface;
6  if(!CreateSurface(&Surface))
7  return FALSE;
8 
9  TEST (Surface->Initialize(NULL, NULL) == DDERR_ALREADYINITIALIZED);
10 
11  // GetCaps
12  DDSCAPS2 Caps;
13  TEST (Surface->GetCaps((DDSCAPS2*)0xdeadbeef) == DDERR_INVALIDPARAMS);
14  TEST (Surface->GetCaps(&Caps) == DD_OK && Caps.dwCaps == 0x10004040
15  && Caps.dwCaps2 == 0 && Caps.dwCaps3 == 0 && Caps.dwCaps4 == 0); // FIXME: Replace 0x10004040
16 
17  // GetDC / ReleaseDC
18  HDC hdc;
19  TEST (Surface->GetDC((HDC*)0xdeadbeef) == DDERR_INVALIDPARAMS);
20  TEST (Surface->ReleaseDC((HDC)0xdeadbeef) == DDERR_NODC);
21  TEST (Surface->ReleaseDC(GetDC(NULL)) == DDERR_NODC);
22 
23  TEST (Surface->GetDC(&hdc) == DD_OK);
24  TEST (MoveToEx(hdc, 0, 0, NULL) == TRUE); // validate hdc
25  TEST (Surface->Blt(NULL, NULL, NULL, 0, NULL) == DDERR_SURFACEBUSY); // check lock
26  TEST (Surface->ReleaseDC(hdc) == DD_OK);
27 
28  // ChangeUniquenessValue / GetUniquenessValue
29  DWORD Value;
30  // FIXME: find out other apis which increases the uniqueness value
31  TEST (Surface->GetUniquenessValue(&Value) == DD_OK && Value == 2);
32  TEST (Surface->Blt(NULL, NULL, NULL, 0, NULL) == DDERR_INVALIDPARAMS); // Even this increases the uniqueness value
33  TEST (Surface->GetUniquenessValue(&Value) == DD_OK && Value == 3);
34  TEST (Surface->ChangeUniquenessValue() == DD_OK);
35  TEST (Surface->GetUniquenessValue(&Value) == DD_OK && Value == 4);
36 
37  // GetPixelFormat
39  // FIXME: Produce DDERR_INVALIDSURFACETYPE
40  TEST (Surface->GetPixelFormat((LPDDPIXELFORMAT)0xdeadbeef) == DDERR_INVALIDPARAMS);
41  TEST (Surface->GetPixelFormat(&PixelFormat));
42  PixelFormat.dwSize = sizeof(DDPIXELFORMAT);
43  TEST (Surface->GetPixelFormat(&PixelFormat) == DD_OK && PixelFormat.dwFlags == 0x40); // FIXME: Find out what 0x40 is
44 
45  // GetSurfaceDesc / SetSurfaceDesc
46  DDSURFACEDESC2 Desc = {0};
47  // FIXME: Produce DDERR_INVALIDSURFACETYPE
48  TEST (Surface->GetSurfaceDesc((LPDDSURFACEDESC2)0xdeadbeef) == DDERR_INVALIDPARAMS);
49  TEST (Surface->GetSurfaceDesc(&Desc));
50  Desc.dwSize = sizeof(DDSURFACEDESC2);
51  TEST (Surface->GetSurfaceDesc(&Desc) == DD_OK && Desc.dwFlags == 0x100f); // FIXME: Find out what 0x100f is
52  TEST (memcmp ((PVOID)&Desc.ddpfPixelFormat, (PVOID)&PixelFormat, sizeof(DDPIXELFORMAT)) == 0);
53  // FIXME: Test SetSurfaceDesc
54 
55  // GetDDInterface
56  IUnknown* iface;
57  TEST(Surface->GetDDInterface((LPVOID*)0xdeadbeef) == DDERR_INVALIDPARAMS);
58  TEST(Surface->GetDDInterface((LPVOID*)&iface) == DD_OK && iface);
59  TEST(iface->Release() == 1); // FIXME: Test the interface further
60 
61  Surface->Release();
62 
63  return TRUE;
64 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
#define HDC
Definition: msvc.h:22
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL Test_Misc(INT *passed, INT *failed)
Definition: misc.cpp:3
int32_t INT
Definition: typedefs.h:56
struct _DDPIXELFORMAT DDPIXELFORMAT
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define DD_OK
Definition: ddraw.h:186
#define DDERR_NODC
Definition: ddraw.h:160
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67
unsigned int BOOL
Definition: ntddk_ex.h:94
_In_ DD_SURFACE_LOCAL * pSurface
Definition: winddi.h:3481
#define TEST(x)
Definition: precomp.h:20
nsrefcnt Release()
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DDERR_SURFACEBUSY
Definition: ddraw.h:119
INT PixelFormat
struct _DDSURFACEDESC2 DDSURFACEDESC2
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
BOOL CreateSurface(LPDIRECTDRAWSURFACE7 *pSurface)
Definition: helper.cpp:28