ReactOS 0.4.15-dev-7934-g1dc8d80
create.cpp
Go to the documentation of this file.
1#include "ddrawtest.h"
2
4
5BOOL Test_CreateDDraw (INT* passed, INT* failed)
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);
15 TEST (DirectDrawCreateEx(NULL, NULL, IID_IDirectDraw7, NULL) == DDERR_INVALIDPARAMS);
16
18 TEST (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) == DD_OK);
19 if(DirectDraw)
20 {
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}
40
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);
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 );
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}
88
89BOOL Test_GetFourCCCodes (INT* passed, INT* failed)
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}
114
116{
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 NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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 GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
DWORD * LPDIRECTDRAW7
Definition: vmrender.idl:6
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
#define TEST(x)
Definition: precomp.h:20
HWND CreateBasicWindow(VOID)
BOOL Test_CreateDDraw(INT *passed, INT *failed)
Definition: create.cpp:5
BOOL Test_GetFourCCCodes(INT *passed, INT *failed)
Definition: create.cpp:89
BOOL Test_GetDeviceIdentifier(INT *passed, INT *failed)
Definition: create.cpp:115
BOOL Test_SetCooperativeLevel(INT *passed, INT *failed)
Definition: create.cpp:41
#define DWORD
Definition: nt_native.h:44
DWORD * PDWORD
Definition: pedump.c:68
#define DDSCL_NORMAL
Definition: ddraw.h:535
#define DDSCL_EXCLUSIVE
Definition: ddraw.h:536
#define DDGDI_GETHOSTIDENTIFIER
Definition: ddraw.h:202
#define DDERR_NOEXCLUSIVEMODE
Definition: ddraw.h:93
#define DD_OK
Definition: ddraw.h:186
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67
#define DDSCL_ALLOWMODEX
Definition: ddraw.h:537
#define DDSCL_FULLSCREEN
Definition: ddraw.h:532
#define memset(x, y, z)
Definition: compat.h:39
int32_t INT
Definition: typedefs.h:58
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662