ReactOS  0.4.15-dev-3303-g1ade494
create.cpp File Reference
#include "ddrawtest.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 Test_CreateDDraw (INT *passed, INT *failed)
 
BOOL Test_SetCooperativeLevel (INT *passed, INT *failed)
 
BOOL Test_GetFourCCCodes (INT *passed, INT *failed)
 
BOOL Test_GetDeviceIdentifier (INT *passed, INT *failed)
 

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 Test_CreateSurface(), and Test_SetCooperativeLevel().

◆ Test_CreateDDraw()

BOOL Test_CreateDDraw ( INT passed,
INT failed 
)

Definition at line 5 of file create.cpp.

6 {
8  IDirectDraw* DirectDraw2;
9 
10  /*** FIXME: Test first parameter using EnumDisplayDrivers ***/
11  DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL);
12 
13  TEST (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, (IUnknown*)0xdeadbeef) == CLASS_E_NOAGGREGATION);
14  TEST (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw4, NULL) == DDERR_INVALIDPARAMS);
15  TEST (DirectDrawCreateEx(NULL, NULL, IID_IDirectDraw7, NULL) == DDERR_INVALIDPARAMS);
16 
17  DirectDraw = NULL;
18  TEST (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) == DD_OK);
19  if(DirectDraw)
20  {
21  TEST (DirectDraw->Initialize(NULL) == DDERR_ALREADYINITIALIZED);
22  TEST (DirectDraw->Release() == 0);
23  }
24 
25  DirectDraw2 = NULL;
26  TEST (DirectDrawCreate(NULL ,&DirectDraw2, NULL) == DD_OK);
27  if(DirectDraw2)
28  {
29  TEST (DirectDraw2->QueryInterface(IID_IDirectDraw7, (PVOID*)&DirectDraw) == 0);
30  TEST (DirectDraw2->AddRef() == 2);
31  TEST (DirectDraw->AddRef() == 2);
32  TEST (DirectDraw->Release() == 1);
33  TEST (DirectDraw->Release() == 0);
34  TEST (DirectDraw2->Release() == 1);
35  TEST (DirectDraw2->Release() == 0);
36  }
37 
38  return TRUE;
39 }
#define TRUE
Definition: types.h:120
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
HRESULT WINAPI DirectDrawCreate(LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter)
Definition: main.c:86
#define DD_OK
Definition: ddraw.h:186
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67
#define TEST(x)
Definition: precomp.h:20
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
LPDIRECTDRAW7 DirectDraw
Definition: create.cpp:3
#define NULL
Definition: types.h:112
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ Test_GetDeviceIdentifier()

BOOL Test_GetDeviceIdentifier ( INT passed,
INT failed 
)

Definition at line 115 of file create.cpp.

116 {
118  DDDEVICEIDENTIFIER2 pDDDI;
119  //OLECHAR GuidStr[100];
120 
121  /* Preparations */
122  if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
123  {
124  printf("ERROR: Failed to set up ddraw\n");
125  return FALSE;
126  }
127 
128  TEST ( DirectDraw->GetDeviceIdentifier(NULL, 0) == DDERR_INVALIDPARAMS );
129  TEST ( DirectDraw->GetDeviceIdentifier(NULL, ~DDGDI_GETHOSTIDENTIFIER) == DDERR_INVALIDPARAMS );
130  TEST ( DirectDraw->GetDeviceIdentifier(NULL, DDGDI_GETHOSTIDENTIFIER) == DDERR_INVALIDPARAMS );
131 
132  memset(&pDDDI,0,sizeof(DDDEVICEIDENTIFIER2));
133  TEST ( DirectDraw->GetDeviceIdentifier(&pDDDI, 0) == DD_OK );
134 
135 /*
136  StringFromGUID2(pDDDI.guidDeviceIdentifier, GuidStr, 100);
137  printf("1. \n");
138  printf("szDriver : %s\n",pDDDI.szDriver);
139  printf("szDescription : %s\n",pDDDI.szDescription);
140  printf("liDriverVersion : 0x%08x . 0x%08x\n", pDDDI.liDriverVersion.HighPart, pDDDI.liDriverVersion.LowPart);
141  printf("dwVendorId : 0x%08x\n",pDDDI.dwVendorId);
142  printf("dwDeviceId : 0x%08x\n",pDDDI.dwDeviceId);
143  printf("dwSubSysId : 0x%08x\n",pDDDI.dwSubSysId);
144  printf("dwRevision : 0x%08x\n",pDDDI.dwRevision);
145  printf("guidDeviceIdentifier : %ls\n",GuidStr);
146  printf("dwWHQLLevel : 0x%08x\n",pDDDI.dwWHQLLevel);
147 */
148 
149  memset(&pDDDI,0,sizeof(DDDEVICEIDENTIFIER2));
150  TEST ( DirectDraw->GetDeviceIdentifier(&pDDDI, DDGDI_GETHOSTIDENTIFIER) == DD_OK );
151  memset(&pDDDI,0,sizeof(DDDEVICEIDENTIFIER2));
152  TEST ( DirectDraw->GetDeviceIdentifier(&pDDDI, ~DDGDI_GETHOSTIDENTIFIER) == DDERR_INVALIDPARAMS );
153 
154  DirectDraw->Release();
155 
156  return TRUE;
157 }
#define DDGDI_GETHOSTIDENTIFIER
Definition: ddraw.h:202
#define TRUE
Definition: types.h:120
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
#define DD_OK
Definition: ddraw.h:186
#define FALSE
Definition: types.h:117
#define TEST(x)
Definition: precomp.h:20
LPDIRECTDRAW7 DirectDraw
Definition: create.cpp:3
#define NULL
Definition: types.h:112
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
#define memset(x, y, z)
Definition: compat.h:39
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define printf
Definition: config.h:203

◆ Test_GetFourCCCodes()

BOOL Test_GetFourCCCodes ( INT passed,
INT failed 
)

Definition at line 89 of file create.cpp.

90 {
92 
93  /* Preparations */
94  if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
95  {
96  printf("ERROR: Failed to set up ddraw\n");
97  return FALSE;
98  }
99 
100  /* Here we go */
101  DWORD dwNumCodes, *lpCodes;
102  TEST (DirectDraw->GetFourCCCodes(NULL, (PDWORD)0xdeadbeef) == DDERR_INVALIDPARAMS);
103 
104  TEST (DirectDraw->GetFourCCCodes(&dwNumCodes, NULL) == DD_OK && dwNumCodes);
105  lpCodes = (PDWORD)HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD)*dwNumCodes);
106  *lpCodes = 0;
107  TEST ( DirectDraw->GetFourCCCodes(NULL, lpCodes) == DDERR_INVALIDPARAMS );
108  TEST (DirectDraw->GetFourCCCodes(&dwNumCodes, lpCodes) == DD_OK && *lpCodes );
109 
110  DirectDraw->Release();
111 
112  return TRUE;
113 }
#define TRUE
Definition: types.h:120
HRESULT WINAPI DirectDrawCreateEx(LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
Definition: main.c:139
#define DWORD
Definition: nt_native.h:44
#define DD_OK
Definition: ddraw.h:186
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define TEST(x)
Definition: precomp.h:20
unsigned long DWORD
Definition: ntddk_ex.h:95
LPDIRECTDRAW7 DirectDraw
Definition: create.cpp:3
#define NULL
Definition: types.h:112
DWORD * PDWORD
Definition: pedump.c:68
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define printf
Definition: config.h:203

◆ Test_SetCooperativeLevel()

BOOL Test_SetCooperativeLevel ( INT passed,
INT failed 
)

Definition at line 41 of file create.cpp.

42 {
43  HWND hwnd;
45 
46  /* Preparations */
47  if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
48  {
49  printf("ERROR: Failed to set up ddraw\n");
50  return FALSE;
51  }
52 
53  if(!( hwnd = CreateBasicWindow() ))
54  {
55  printf("ERROR: Failed to create window\n");
56  DirectDraw->Release();
57  return FALSE;
58  }
59 
60  /* The Test */
61  TEST ( DirectDraw->SetCooperativeLevel (NULL, DDSCL_FULLSCREEN) == DDERR_INVALIDPARAMS );
62  TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_FULLSCREEN) == DDERR_INVALIDPARAMS );
63 
64  TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL) == DD_OK );
65  TEST ( DirectDraw->Compact() == DDERR_NOEXCLUSIVEMODE );
66 
67 
69  TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_FULLSCREEN) == DDERR_INVALIDPARAMS);
70  TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL | DDSCL_ALLOWMODEX) == DDERR_INVALIDPARAMS );
71  TEST ( DirectDraw->SetCooperativeLevel ((HWND)0xdeadbeef, DDSCL_NORMAL) == DDERR_INVALIDPARAMS);
72 
73  TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) == DD_OK);
74  TEST ( DirectDraw->Compact() == DD_OK );
75  TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWMODEX) == DD_OK);
76  TEST ( DirectDraw->Compact() == DD_OK );
77  TEST ( DirectDraw->SetCooperativeLevel (NULL, DDSCL_NORMAL) == DD_OK );
78  TEST ( DirectDraw->Compact() == DDERR_NOEXCLUSIVEMODE );
79  TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL) == DD_OK );
80  TEST ( DirectDraw->Compact() == DDERR_NOEXCLUSIVEMODE );
81 
82  TEST ( DirectDraw->TestCooperativeLevel() == DD_OK ); // I do not get what this API does it always seems to return DD_OK
83 
84  DirectDraw->Release();
85 
86  return TRUE;
87 }
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 DDSCL_EXCLUSIVE
Definition: ddraw.h:536
#define DDSCL_ALLOWMODEX
Definition: ddraw.h:537
#define DD_OK
Definition: ddraw.h:186
#define FALSE
Definition: types.h:117
#define TEST(x)
Definition: precomp.h:20
#define DDERR_NOEXCLUSIVEMODE
Definition: ddraw.h:93
LPDIRECTDRAW7 DirectDraw
Definition: create.cpp:3
#define DDSCL_FULLSCREEN
Definition: ddraw.h:532
#define NULL
Definition: types.h:112
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:4
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define printf
Definition: config.h:203