- Release Ddraw Object Test_CreateDDraw

- First Surface Test of many to follow
- GetMonitorFrequency and whitespace changes by EmuandCo

svn path=/trunk/; revision=26758
This commit is contained in:
Maarten Bosma 2007-05-13 17:31:35 +00:00
parent 779a784f15
commit 35b29a1d0a
5 changed files with 61 additions and 18 deletions

View file

@ -5,7 +5,7 @@ PCHAR DDErrorString (HRESULT hResult)
{
switch (hResult)
{
case DD_OK: return "DD_OK";
case DD_OK: return "DD_OK";
case DDERR_ALREADYINITIALIZED: return "DDERR_ALREADYINITIALIZED";
case DDERR_CANNOTATTACHSURFACE: return "DDERR_CANNOTATTACHSURFACE";
case DDERR_CANNOTDETACHSURFACE: return "DDERR_CANNOTDETACHSURFACE";

View file

@ -15,7 +15,8 @@ TEST TestList[] =
{ "DirectDrawCreate(Ex)", Test_CreateDDraw },
{ "IDirectDraw::SetCooperativeLevel", Test_SetCooperativeLevel },
// { "IDirectDraw::EnumDisplayModes/SetDisplayMode", Test_DisplayModes }, // uncomment this test if you have enough time and patience
{ "IDirectDraw::CreateSurface", Test_CreateSurface }
{ "IDirectDraw::CreateSurface", Test_CreateSurface },
{ "IDirectDraw::GetMonitorFrequency", Test_GetMonitorFrequency },
};
/* The function that gives us the number of tests */

View file

@ -4,8 +4,8 @@ HWND CreateBasicWindow (VOID);
BOOL Test_CreateDDraw (INT* passed, INT* failed)
{
LPDIRECTDRAW7 DirectDraw;
IDirectDraw* DirectDraw2;
LPDIRECTDRAW7 DirectDraw = NULL;
IDirectDraw* DirectDraw2 = NULL;
/*** FIXME: Test first parameter using EnumDisplayDrivers ***/
@ -13,16 +13,19 @@ BOOL Test_CreateDDraw (INT* passed, INT* failed)
TEST (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw4, NULL) == DDERR_INVALIDPARAMS);
TEST (DirectDrawCreateEx(NULL, NULL, IID_IDirectDraw7, NULL) == DDERR_INVALIDPARAMS);
TEST (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) == DD_OK);
TEST (DirectDraw && DirectDraw->Release());
TEST (DirectDrawCreate(NULL ,&DirectDraw2, NULL) == DD_OK);
TEST (DirectDraw2 && DirectDraw2->Release());
return TRUE;
}
BOOL Test_SetCooperativeLevel (INT* passed, INT* failed)
{
HWND hwnd;
HWND hwnd;
LPDIRECTDRAW7 DirectDraw;
/* Preparations */
if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
{
@ -36,9 +39,10 @@ BOOL Test_SetCooperativeLevel (INT* passed, INT* failed)
DirectDraw->Release();
return FALSE;
}
/* The Test */
TEST ( DirectDraw->SetCooperativeLevel (NULL, DDSCL_FULLSCREEN) == DDERR_INVALIDPARAMS );
TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_FULLSCREEN) == DDERR_INVALIDPARAMS );
TEST ( DirectDraw->SetCooperativeLevel (NULL, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) == DDERR_INVALIDPARAMS );
TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_FULLSCREEN) == DDERR_INVALIDPARAMS);
TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL | DDSCL_ALLOWMODEX) == DDERR_INVALIDPARAMS );
@ -54,27 +58,27 @@ BOOL Test_SetCooperativeLevel (INT* passed, INT* failed)
return TRUE;
}
LONG WINAPI BasicWindowProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
LONG WINAPI BasicWindowProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
switch (message)
{
case WM_DESTROY:
{
PostQuitMessage (0);
PostQuitMessage (0);
return 0;
} break;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}
}
HWND CreateBasicWindow (VOID)
{
WNDCLASS wndclass = {0};
wndclass.lpfnWndProc = BasicWindowProc;
wndclass.hInstance = GetModuleHandle(NULL);
wndclass.lpszClassName = "DDrawTest";
RegisterClass(&wndclass);
wndclass.lpszClassName = "DDrawTest";
RegisterClass(&wndclass);
return CreateWindow("DDrawTest", "ReactOS DirectDraw Test", WS_POPUP, 0, 0, 10, 10, NULL, NULL, GetModuleHandle(NULL), NULL);
}

View file

@ -4,7 +4,7 @@ HWND CreateBasicWindow (VOID);
BOOL Test_CreateSurface (INT* passed, INT* failed)
{
LPDIRECTDRAW7 DirectDraw;
LPDIRECTDRAWSURFACE7 DirectDrawSurface;
LPDIRECTDRAWSURFACE7 DirectDrawSurface = NULL;
HWND hwnd;
/* Preparations */
@ -40,7 +40,17 @@ BOOL Test_CreateSurface (INT* passed, INT* failed)
Desc.dwSize = sizeof (DDSURFACEDESC2);
TEST ( DirectDraw->CreateSurface(&Desc, &DirectDrawSurface, NULL) == DDERR_INVALIDPARAMS );
Desc.dwFlags = DDSD_CAPS;
Desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
TEST ( DirectDraw->CreateSurface(&Desc, &DirectDrawSurface, NULL) == DD_OK );
TEST ( DirectDrawSurface && DirectDrawSurface->Release() == DD_OK );
DirectDrawSurface = NULL;
Desc.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
TEST ( DirectDraw->CreateSurface(&Desc, &DirectDrawSurface, NULL) == DD_OK );
TEST ( DirectDrawSurface && DirectDrawSurface->Release() == DD_OK );
DirectDraw->Release();
return TRUE;
}
}

View file

@ -22,7 +22,7 @@ BOOL Test_DisplayModes (INT* passed, INT* failed)
{
/*** FIXME: Also test with surface as parameter; try busy/locked surface as well ***/
LPDIRECTDRAW7 DirectDraw;
/* Preparations */
if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
{
@ -34,12 +34,12 @@ BOOL Test_DisplayModes (INT* passed, INT* failed)
/* The Test */
// First try with some generic display modes
// First try with some generic display modes
TEST ( DirectDraw->SetDisplayMode (1586, 895, 0, 0, 0) == DDERR_UNSUPPORTED );
TEST ( DirectDraw->SetDisplayMode (0, 0, 0, 0, 0x123) == DDERR_INVALIDPARAMS );
TEST ( DirectDraw->SetDisplayMode (0, 0, 0, 0, 0) == DD_OK );
TEST ( DirectDraw->SetDisplayMode (800, 600, 0, 0, 0) == DD_OK );
TEST ( DirectDraw->SetDisplayMode (800, 600, 0, 0, 0) == DD_OK );
TEST ( DirectDraw->SetDisplayMode (0, 0, 16, 0, 0) == DD_OK );
// does this change the display mode to DDSCL_EXCLUSIVE ?
@ -55,3 +55,31 @@ BOOL Test_DisplayModes (INT* passed, INT* failed)
return TRUE;
}
BOOL Test_GetMonitorFrequency (INT* passed, INT* failed)
{
HWND hwnd;
DWORD lpdwFrequency;
LPDIRECTDRAW7 DirectDraw;
/* Preparations */
if (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) != DD_OK)
{
printf("ERROR: Failed to set up ddraw\n");
return FALSE;
}
if(!( hwnd = CreateBasicWindow() ))
{
printf("ERROR: Failed to create window\n");
DirectDraw->Release();
return FALSE;
}
/* The Test */
TEST ( DirectDraw->GetMonitorFrequency (NULL) == DDERR_INVALIDPARAMS );
TEST ( DirectDraw->GetMonitorFrequency (&lpdwFrequency) == DD_OK );
TEST ( lpdwFrequency != 0 );
return TRUE;
}