1 #include "ddrawtest.h"
2
3 HWND CreateBasicWindow (VOID);
4
Test_CreateDDraw(INT * passed,INT * failed)5 BOOL Test_CreateDDraw (INT* passed, INT* failed)
6 {
7 LPDIRECTDRAW7 DirectDraw;
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 }
40
Test_SetCooperativeLevel(INT * passed,INT * failed)41 BOOL Test_SetCooperativeLevel (INT* passed, INT* failed)
42 {
43 HWND hwnd;
44 LPDIRECTDRAW7 DirectDraw;
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
68 TEST ( DirectDraw->SetCooperativeLevel (NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) == DDERR_INVALIDPARAMS );
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 }
88
Test_GetFourCCCodes(INT * passed,INT * failed)89 BOOL Test_GetFourCCCodes (INT* passed, INT* failed)
90 {
91 LPDIRECTDRAW7 DirectDraw;
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
Test_GetDeviceIdentifier(INT * passed,INT * failed)115 BOOL Test_GetDeviceIdentifier (INT* passed, INT* failed)
116 {
117 LPDIRECTDRAW7 DirectDraw;
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 }
158