From 3fa5e74711a61563577bbca89ed04c4439b68581 Mon Sep 17 00:00:00 2001 From: Maarten Bosma Date: Wed, 16 May 2007 20:42:33 +0000 Subject: [PATCH] - Tests for Compact, TestCooperativeLevel, Initialize, GetDisplayMode, RestoreDisplayMode - Merge GetMonitorFrequency Test with other Display Mode Tests svn path=/trunk/; revision=26810 --- rostests/dxtest/ddraw/tests/CreateDDraw.cpp | 5 ++ rostests/dxtest/ddraw/tests/DisplayModes.cpp | 51 ++++++++------------ 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/rostests/dxtest/ddraw/tests/CreateDDraw.cpp b/rostests/dxtest/ddraw/tests/CreateDDraw.cpp index 5be9b98dc71..596a77267cc 100644 --- a/rostests/dxtest/ddraw/tests/CreateDDraw.cpp +++ b/rostests/dxtest/ddraw/tests/CreateDDraw.cpp @@ -18,6 +18,7 @@ BOOL Test_CreateDDraw (INT* passed, INT* failed) TEST (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, NULL) == DD_OK); if(DirectDraw) { + TEST (DirectDraw->Initialize(NULL) == DDERR_ALREADYINITIALIZED); TEST (DirectDraw->Release() == 0); } @@ -65,9 +66,13 @@ BOOL Test_SetCooperativeLevel (INT* passed, INT* failed) TEST ( DirectDraw->SetCooperativeLevel ((HWND)0xdeadbeef, DDSCL_NORMAL) == DDERR_INVALIDPARAMS); TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE) == DD_OK); + TEST ( DirectDraw->Compact() == DD_OK ); TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWMODEX) == DD_OK); TEST ( DirectDraw->SetCooperativeLevel (NULL, DDSCL_NORMAL) == DD_OK ); TEST ( DirectDraw->SetCooperativeLevel (hwnd, DDSCL_NORMAL) == DD_OK ); + TEST ( DirectDraw->Compact() == DDERR_NOEXCLUSIVEMODE ); + + TEST ( DirectDraw->TestCooperativeLevel() == DD_OK ); // I do not get what this API does it always seems to return DD_OK DirectDraw->Release(); diff --git a/rostests/dxtest/ddraw/tests/DisplayModes.cpp b/rostests/dxtest/ddraw/tests/DisplayModes.cpp index 544353c0f04..046cff223e5 100644 --- a/rostests/dxtest/ddraw/tests/DisplayModes.cpp +++ b/rostests/dxtest/ddraw/tests/DisplayModes.cpp @@ -12,12 +12,24 @@ HRESULT CALLBACK DummyEnumDisplayModes( LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT* Con HRESULT CALLBACK EnumDisplayModes( LPDDSURFACEDESC2 pDDSD, ENUMCONTEXT* Context ) { + DWORD lpdwFrequency = 0; INT* passed = Context->passed; INT* failed = Context->failed; static int setcout = 0; + + DDSURFACEDESC2 DisplayMode = {0}; + DisplayMode.dwSize = sizeof(DDSURFACEDESC2); + if(setcout < 5) { TEST ( Context->DirectDraw->SetDisplayMode (pDDSD->dwWidth, pDDSD->dwHeight, pDDSD->ddpfPixelFormat.dwRGBBitCount, pDDSD->dwRefreshRate, 0) == DD_OK); + TEST ( Context->DirectDraw->GetMonitorFrequency (&lpdwFrequency) == DD_OK && lpdwFrequency == pDDSD->dwRefreshRate); + TEST ( Context->DirectDraw->GetDisplayMode (&DisplayMode) == DD_OK + && pDDSD->dwWidth == DisplayMode.dwHeight + && pDDSD->dwWidth == DisplayMode.dwWidth + && pDDSD->dwRefreshRate == DisplayMode.dwRefreshRate + && pDDSD->ddpfPixelFormat.dwRGBBitCount == DisplayMode.ddpfPixelFormat.dwRGBBitCount); + } setcout++; return DDENUMRET_OK; @@ -39,52 +51,31 @@ 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 ); + // does this change the display mode to DDSCL_EXCLUSIVE ? TEST ( DirectDraw->SetDisplayMode (0, 0, 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 ? + TEST ( DirectDraw->GetMonitorFrequency (NULL) == DDERR_INVALIDPARAMS ); + TEST ( DirectDraw->GetDisplayMode (NULL) == DDERR_INVALIDPARAMS ); + DDSURFACEDESC2 DisplayMode = {0}; + TEST ( DirectDraw->GetDisplayMode (&DisplayMode) == DDERR_INVALIDPARAMS ); - // Now try getting vaild modes from driver + //* Now try getting vaild modes from drive */ TEST (DirectDraw->EnumDisplayModes(DDEDM_STANDARDVGAMODES, NULL, (PVOID)&Context, NULL) == DDERR_INVALIDPARAMS); TEST (DirectDraw->EnumDisplayModes(0, NULL, (PVOID)&Context, (LPDDENUMMODESCALLBACK2)DummyEnumDisplayModes) == DD_OK ); TEST (DirectDraw->EnumDisplayModes(DDEDM_REFRESHRATES, NULL, (PVOID)&Context, (LPDDENUMMODESCALLBACK2)DummyEnumDisplayModes) == DD_OK ); TEST (DirectDraw->EnumDisplayModes(DDEDM_STANDARDVGAMODES, NULL, (PVOID)&Context, (LPDDENUMMODESCALLBACK2)DummyEnumDisplayModes) == DD_OK ); TEST (DirectDraw->EnumDisplayModes(DDEDM_STANDARDVGAMODES|DDEDM_REFRESHRATES, NULL, (PVOID)&Context, (LPDDENUMMODESCALLBACK2)EnumDisplayModes) == DD_OK); + TEST (DirectDraw->RestoreDisplayMode() == DD_OK); + DirectDraw->Release(); - 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; }