diff --git a/rostests/dxtest/ddraw/ddraw.rbuild b/rostests/dxtest/ddraw/ddraw.rbuild new file mode 100644 index 00000000000..5829f25c05e --- /dev/null +++ b/rostests/dxtest/ddraw/ddraw.rbuild @@ -0,0 +1,12 @@ + + . + + 0x0501 + kernel32 + user32 + gdi32 + ddraw + dxguid + ddraw_test.c + testlist.cpp + diff --git a/rostests/dxtest/ddraw/ddraw_test.c b/rostests/dxtest/ddraw/ddraw_test.c new file mode 100644 index 00000000000..608a4ac8fa1 --- /dev/null +++ b/rostests/dxtest/ddraw/ddraw_test.c @@ -0,0 +1,51 @@ +#include +#include + +#include "ddrawtest.h" + +INT NumTests(void); + +int main(int argc, char *argv[]) +{ + INT Num = NumTests(); + INT i, j; + INT passed, failed, opassed, ofailed; + + opassed = 0; + ofailed = 0; + printf("DirectDraw tests\n"); + if (argc > 1) + { + for (i = 1; i < argc; i++) + { + for (j = 0; j < NumTests(); j++) + { + if (stricmp(argv[i], TestList[j].Test) == 0) + { + passed = 0; + failed = 0; + TestList[j].Proc(&passed, &failed); + opassed += passed; + ofailed += failed; + printf(" tests: %d, passed: %d, failed: %d\n\n", passed+failed, passed, failed); + } + } + } + } + else + { + for (i = 0; i < Num; i++) + { + passed = 0; + failed = 0; + printf("Test: %s\n", TestList[i].Test); + TestList[i].Proc(&passed, &failed); + opassed += passed; + ofailed += failed; + printf(" tests: %d, passed: %d, failed: %d\n\n", passed+failed, passed, failed); + } + } + printf("\nOverall tests: %d, passed: %d, failed: %d\n", opassed+ofailed, opassed, ofailed); + + return ofailed; +} diff --git a/rostests/dxtest/ddraw/ddrawtest.h b/rostests/dxtest/ddraw/ddrawtest.h new file mode 100644 index 00000000000..6e2464aee49 --- /dev/null +++ b/rostests/dxtest/ddraw/ddrawtest.h @@ -0,0 +1,34 @@ +#ifndef _DDRAWTEST_H +#define _DDRAWTEST_H + +#define WINVER 0x501 + +#include +#include +#include + +#define TEST(x) \ + if (x)\ + {\ + (*passed)++;\ + } else {\ + (*failed)++;\ + printf("Test failed in %s:%d (%s)\n", __FILE__, __LINE__, #x);\ + }; + + +/* The type definitions */ +typedef BOOL (*TESTPROC)(INT*, INT*); + +typedef struct tagTEST +{ + CHAR* Test; + TESTPROC Proc; +} TEST, *PTEST; + + +extern TEST TestList[]; + +#endif /* _DDRAWTEST_H */ + +/* EOF */ diff --git a/rostests/dxtest/ddraw/testlist.cpp b/rostests/dxtest/ddraw/testlist.cpp new file mode 100644 index 00000000000..9e4e0557b32 --- /dev/null +++ b/rostests/dxtest/ddraw/testlist.cpp @@ -0,0 +1,23 @@ +#ifndef _DDRAWTESTLIST_H +#define _DDRAWTESTLIST_H + +#include "ddrawtest.h" + +/* include the tests */ +#include "tests/CreateDDraw.cpp" + +/* The List of tests */ +TEST TestList[] = +{ + { "CreateDDraw", Test_CreateDDraw } +}; + +/* The function that gives us the number of tests */ +extern "C" INT NumTests(void) +{ + return sizeof(TestList) / sizeof(TEST); +} + +#endif /* _DDRAWTESTLIST_H */ + +/* EOF */ diff --git a/rostests/dxtest/ddraw/tests/CreateDDraw.cpp b/rostests/dxtest/ddraw/tests/CreateDDraw.cpp new file mode 100644 index 00000000000..f310675e1cf --- /dev/null +++ b/rostests/dxtest/ddraw/tests/CreateDDraw.cpp @@ -0,0 +1,19 @@ +#include "ddrawtest.h" + +PCHAR DDErrorString (HRESULT hResult); + +BOOL Test_CreateDDraw (INT* passed, INT* failed) +{ + LPDIRECTDRAW7 DirectDraw; + IDirectDraw* DirectDraw2; + + // FIXME: Test first parameter + + TEST (DirectDrawCreateEx(NULL, (VOID**)&DirectDraw, IID_IDirectDraw7, (IUnknown*)0xdeadbeef) == CLASS_E_NOAGGREGATION); + 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 (DirectDrawCreate(NULL ,&DirectDraw2, NULL) == DD_OK); + + return TRUE; +}