ReactOS  0.4.15-dev-3324-gda4e15f
create.cpp File Reference
#include "caps_tests.h"
Include dependency graph for create.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

HWND CreateBasicWindow (VOID)
 
BOOL TestCaps (const char *dummy, DWORD Caps, HRESULT test1, HRESULT test2)
 
BOOL Test_CreateSurface (INT *passed, INT *failed)
 

Variables

LPDIRECTDRAW7 DirectDraw
 

Function Documentation

◆ CreateBasicWindow()

HWND CreateBasicWindow ( VOID  )

Definition at line 17 of file helper.cpp.

18 {
19  WNDCLASS wndclass = {0};
20  wndclass.lpfnWndProc = BasicWindowProc;
21  wndclass.hInstance = GetModuleHandle(NULL);
22  wndclass.lpszClassName = "DDrawTest";
23  RegisterClass(&wndclass);
24 
25  return CreateWindow("DDrawTest", "ReactOS DirectDraw Test", WS_POPUP, 0, 0, 10, 10, NULL, NULL, GetModuleHandle(NULL), NULL);
26 }
#define CreateWindow
Definition: winuser.h:5730
LRESULT WINAPI BasicWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: helper.cpp:3
LPCSTR lpszClassName
Definition: winuser.h:3148
#define GetModuleHandle
Definition: winbase.h:3683
HINSTANCE hInstance
Definition: winuser.h:3143
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112
WNDPROC lpfnWndProc
Definition: winuser.h:3140
#define RegisterClass
Definition: winuser.h:5812

Referenced by CreateSurface().

◆ Test_CreateSurface()

BOOL Test_CreateSurface ( INT passed,
INT failed 
)

Definition at line 26 of file create.cpp.

27 {
28  LPDIRECTDRAWSURFACE7 Surface = NULL;
29  HWND hwnd;
30 
31  /* Preparations */
32  if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
33  {
34  printf("ERROR: Failed to set up ddraw\n");
35  return FALSE;
36  }
37 
38  TEST ( DirectDraw->CreateSurface(NULL, NULL, NULL) == DDERR_NOCOOPERATIVELEVELSET);
39 
40  if(!( hwnd = CreateBasicWindow() ))
41  {
42  printf("ERROR: Failed to create window\n");
43  DirectDraw->Release();
44  return FALSE;
45  }
46 
47  if (DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL) != DD_OK)
48  {
49  printf("ERROR: Could not set cooperative level\n");
50  DirectDraw->Release();
51  return 0;
52  }
53 
54  /* The Test */
55  DDSURFACEDESC2 Desc = { 0 };
56  Desc.dwSize = sizeof (DDSURFACEDESC2);
57  Desc.dwHeight = 200;
58  Desc.dwWidth = 200;
59 
60  TEST ( DirectDraw->CreateSurface(&Desc, &Surface, (IUnknown*)0xdeadbeef) == CLASS_E_NOAGGREGATION );
61  TEST ( DirectDraw->CreateSurface(NULL, &Surface, NULL) == DDERR_INVALIDPARAMS );
62  TEST ( DirectDraw->CreateSurface(&Desc, NULL, NULL) == DDERR_INVALIDPARAMS );
63  TEST ( DirectDraw->CreateSurface(&Desc, &Surface, NULL) == DDERR_INVALIDPARAMS );
64 
65  // Test (nearly) all possible cap combinations
66  #include "caps_tests.h"
67 
68  DirectDraw->Release();
69 
70  return TRUE;
71 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HWND CreateBasicWindow(VOID)
Definition: helper.cpp:17
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
#define DDERR_NOCOOPERATIVELEVELSET
Definition: ddraw.h:89
DWORD dwWidth
Definition: ddraw.h:1155
#define DD_OK
Definition: ddraw.h:186
#define FALSE
Definition: types.h:117
#define TEST(x)
Definition: precomp.h:20
DWORD dwSize
Definition: ddraw.h:1152
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
DWORD dwHeight
Definition: ddraw.h:1154
#define NULL
Definition: types.h:112
struct _DDSURFACEDESC2 DDSURFACEDESC2
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7
#define printf
Definition: config.h:203

◆ TestCaps()

BOOL TestCaps ( const char dummy,
DWORD  Caps,
HRESULT  test1,
HRESULT  test2 
)

Definition at line 5 of file create.cpp.

6 {
7  LPDIRECTDRAWSURFACE7 Surface = NULL;
8  DDSURFACEDESC2 Desc = { 0 };
9  Desc.dwHeight = 200;
10  Desc.dwWidth = 200;
11  Desc.dwSize = sizeof (DDSURFACEDESC2);
12  Desc.ddsCaps.dwCaps = Caps;
13 
14  Desc.dwFlags = DDSD_CAPS;
15  BOOL ret = DirectDraw->CreateSurface(&Desc, &Surface, NULL) == test1;
16 
18  ret = ret && DirectDraw->CreateSurface(&Desc, &Surface, NULL) == test2;
19 
20  if ( Surface )
21  Surface->Release();
22 
23  return ret;
24 }
DWORD dwFlags
Definition: ddraw.h:1153
DWORD dwWidth
Definition: ddraw.h:1155
#define DDSD_CAPS
Definition: ddraw.h:208
unsigned int BOOL
Definition: ntddk_ex.h:94
DDSCAPS2 ddsCaps
Definition: ddraw.h:1188
DWORD dwCaps
Definition: ddraw.h:732
#define DDSD_HEIGHT
Definition: ddraw.h:209
void test1()
Definition: ehthrow.cxx:277
nsrefcnt Release()
int ret
DWORD dwSize
Definition: ddraw.h:1152
DWORD dwHeight
Definition: ddraw.h:1154
#define DDSD_WIDTH
Definition: ddraw.h:210
void test2()
Definition: ehthrow.cxx:284
#define NULL
Definition: types.h:112
struct _DDSURFACEDESC2 DDSURFACEDESC2
DWORD * LPDIRECTDRAWSURFACE7
Definition: vmrender.idl:7

Variable Documentation

◆ DirectDraw