ReactOS 0.4.16-dev-306-g647d351
display_modes.cpp
Go to the documentation of this file.
1typedef struct
2{
7
8BOOL Test_GetMonitorFrequency (INT* passed, INT* failed);
9
11{
12 return DDENUMRET_OK;
13}
14
16{
17 static int setcout = 0;
18 if(setcout >= 5)
19 return DDENUMRET_OK;
20
21 DWORD lpdwFrequency = 0;
22 INT* passed = Context->passed;
23 INT* failed = Context->failed;
25 DisplayMode.dwSize = sizeof(DDSURFACEDESC2);
26
29 TEST ( Context->DirectDraw->SetDisplayMode (pDDSD->dwWidth, pDDSD->dwHeight, pDDSD->ddpfPixelFormat.dwRGBBitCount, pDDSD->dwRefreshRate, 0) == DD_OK);
30 TEST ( Context->DirectDraw->GetMonitorFrequency (&lpdwFrequency) == DD_OK && lpdwFrequency == pDDSD->dwRefreshRate);
31 TEST ( Context->DirectDraw->GetDisplayMode (&DisplayMode) == DD_OK
32 && pDDSD->dwHeight == DisplayMode.dwHeight
33 && pDDSD->dwWidth == DisplayMode.dwWidth
34 && pDDSD->dwRefreshRate == DisplayMode.dwRefreshRate
35 && pDDSD->ddpfPixelFormat.dwRGBBitCount == DisplayMode.ddpfPixelFormat.dwRGBBitCount
37
38 setcout++;
39 return DDENUMRET_OK;
40}
41
42BOOL Test_DisplayModes (INT* passed, INT* failed)
43{
44 /*** FIXME: Also test with surface as parameter; try busy/locked surface as well ***/
46
47 /* Preparations */
48 if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
49 {
50 printf("ERROR: Failed to set up ddraw\n");
51 return FALSE;
52 }
53
54 ENUMCONTEXT Context = {passed, failed, DirectDraw};
55
56 /* The Test */
57
58 Test_GetMonitorFrequency(passed, failed);
59
60 /* First try with some generic display modes */
61 TEST ( DirectDraw->SetDisplayMode (1586, 895, 0, 0, 0) == DDERR_UNSUPPORTED );
62 TEST ( DirectDraw->SetDisplayMode (0, 0, 0, 0, 0x123) == DDERR_INVALIDPARAMS );
63
64 // does this change the display mode to DDSCL_EXCLUSIVE ?
65 TEST ( DirectDraw->SetDisplayMode (0, 0, 0, 0, 0) == DD_OK );
66 TEST ( DirectDraw->SetDisplayMode (800, 600, 0, 0, 0) == DD_OK );
67 TEST ( DirectDraw->SetDisplayMode (0, 0, 16, 0, 0) == DD_OK );
68
69 TEST ( DirectDraw->GetDisplayMode (NULL) == DDERR_INVALIDPARAMS );
71 TEST ( DirectDraw->GetDisplayMode (&DisplayMode) == DDERR_INVALIDPARAMS );
72
73 //* Now try getting vaild modes from drive */
79
80 TEST (DirectDraw->RestoreDisplayMode() == DD_OK);
81
82 DirectDraw->Release();
83
84 return TRUE;
85}
86
88{
91
92 /* Preparations */
93 if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
94 {
95 printf("ERROR: Failed to set up ddraw\n");
96 return FALSE;
97 }
99
100 /* Here we go */
101 DWORD lpFreq;
102 DWORD temp;
103 HRESULT retVal;
104 TEST (DirectDraw->GetMonitorFrequency((PDWORD)0xdeadbeef) == DDERR_INVALIDPARAMS);
105 TEST (DirectDraw->GetMonitorFrequency(NULL) == DDERR_INVALIDPARAMS);
106
107 // result depends on our graphices card
108 retVal = DirectDraw->GetMonitorFrequency((PDWORD)&lpFreq);
109 TEST ( retVal == DD_OK || retVal == DDERR_UNSUPPORTED);
110
111 /* Test by hacking interal structures */
112
113 // should return DDERR_UNSUPPORTED
114 This->lpLcl->lpGbl->dwMonitorFrequency = 0;
115 TEST (DirectDraw->GetMonitorFrequency(&temp) == DDERR_UNSUPPORTED);
116
117 // should return DD_OK
118 This->lpLcl->lpGbl->dwMonitorFrequency = 85;
119 TEST (DirectDraw->GetMonitorFrequency(&temp) == DD_OK);
120
121 /* Restore */
122 This->lpLcl->lpGbl->dwMonitorFrequency = lpFreq;
123
124 DirectDraw->Release();
125
126 return TRUE;
127}
struct _DDRAWI_DIRECTDRAW_INT * LPDDRAWI_DIRECTDRAW_INT
Definition: ddrawi.h:124
BOOL Test_GetMonitorFrequency(INT *passed, INT *failed)
HRESULT CALLBACK EnumDisplayModes(LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT *Context)
HRESULT CALLBACK DummyEnumDisplayModes(LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT *Context)
BOOL Test_DisplayModes(INT *passed, INT *failed)
#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
#define CALLBACK
Definition: compat.h:35
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
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:117
DWORD * PDWORD
Definition: pedump.c:68
static calc_node_t temp
Definition: rpn_ieee.c:38
#define DDSD_WIDTH
Definition: ddraw.h:210
#define DDSD_PIXELFORMAT
Definition: ddraw.h:216
HRESULT(WINAPI * LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID)
Definition: ddraw.h:1259
#define DDSD_PITCH
Definition: ddraw.h:211
#define DDEDM_REFRESHRATES
Definition: ddraw.h:529
#define DDSD_REFRESHRATE
Definition: ddraw.h:222
#define DDEDM_STANDARDVGAMODES
Definition: ddraw.h:530
#define DDENUMRET_OK
Definition: ddraw.h:189
struct _DDSURFACEDESC2 DDSURFACEDESC2
#define DDSD_HEIGHT
Definition: ddraw.h:209
#define DDPF_RGB
Definition: ddraw.h:507
#define DD_OK
Definition: ddraw.h:186
#define DDPF_PALETTEINDEXED8
Definition: ddraw.h:506
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
LPDIRECTDRAW7 DirectDraw
DWORD dwRGBBitCount
Definition: ddraw.h:1075
DWORD dwFlags
Definition: ddraw.h:1071
DWORD dwWidth
Definition: ddraw.h:1155
DWORD dwHeight
Definition: ddraw.h:1154
DWORD dwRefreshRate
Definition: ddraw.h:1169
DDPIXELFORMAT ddpfPixelFormat
Definition: ddraw.h:1185
DWORD dwFlags
Definition: ddraw.h:1153
int32_t INT
Definition: typedefs.h:58