summaryrefslogtreecommitdiffstatsci
path: root/tests/common/test.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/test.h')
-rw-r--r--tests/common/test.h115
1 files changed, 57 insertions, 58 deletions
diff --git a/tests/common/test.h b/tests/common/test.h
index f916c45..91b6393 100644
--- a/tests/common/test.h
+++ b/tests/common/test.h
@@ -1,7 +1,10 @@
#include "vkengine.h"
-#include "stdio.h"
-#include "stdlib.h"
-#include "time.h"
+#include <stdio.h>
+#include <stdlib.h>
+#define _USE_MATH_DEFINES
+#include <math.h>
+#include <time.h>
+
#include "vkvg.h"
#include "vkh_device.h"
@@ -18,64 +21,59 @@
# define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
-#ifdef _WIN32 // MSC_VER
- #define WIN32_LEAN_AND_MEAN
- #define NOMINMAX
- #include <Windows.h> // Windows.h -> WinDef.h defines min() max()
-
- /*
- typedef uint16_t WORD ;
- typedef uint32_t DWORD;
-
- typedef struct _FILETIME {
- DWORD dwLowDateTime;
- DWORD dwHighDateTime;
- } FILETIME;
-
- typedef struct _SYSTEMTIME {
- WORD wYear;
- WORD wMonth;
- WORD wDayOfWeek;
- WORD wDay;
- WORD wHour;
- WORD wMinute;
- WORD wSecond;
- WORD wMilliseconds;
- } SYSTEMTIME, *PSYSTEMTIME;
- */
+#define PERFORM_TEST(testName, argc, argv) perform_test(testName, #testName, argc, argv);
+#if defined(_WIN32) || defined(_WIN64)
+ #define WIN32_LEAN_AND_MEAN
+ #define NOMINMAX
+ #include <Windows.h> // Windows.h -> WinDef.h defines min() max()
- // *sigh* Microsoft has this in winsock2.h because they are too lazy to put it in the standard location ... !?!?
- typedef struct timeval {
- long tv_sec;
- long tv_usec;
- } timeval;
+ /*
+ typedef uint16_t WORD ;
+ typedef uint32_t DWORD;
- // *sigh* no gettimeofday on Win32/Win64
- int gettimeofday(struct timeval * tp, struct timezone * tzp)
- {
- // FILETIME Jan 1 1970 00:00:00
- // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
- static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
+ typedef struct _FILETIME {
+ DWORD dwLowDateTime;
+ DWORD dwHighDateTime;
+ } FILETIME;
- SYSTEMTIME nSystemTime;
- FILETIME nFileTime;
- uint64_t nTime;
+ typedef struct _SYSTEMTIME {
+ WORD wYear;
+ WORD wMonth;
+ WORD wDayOfWeek;
+ WORD wDay;
+ WORD wHour;
+ WORD wMinute;
+ WORD wSecond;
+ WORD wMilliseconds;
+ } SYSTEMTIME, *PSYSTEMTIME;
+ */
- GetSystemTime( &nSystemTime );
- SystemTimeToFileTime( &nSystemTime, &nFileTime );
- nTime = ((uint64_t)nFileTime.dwLowDateTime ) ;
- nTime += ((uint64_t)nFileTime.dwHighDateTime) << 32;
+ // *sigh* Microsoft has this in winsock2.h because they are too lazy to put it in the standard location ... !?!?
+ typedef struct timeval {
+ long tv_sec;
+ long tv_usec;
+ } timeval;
- tp->tv_sec = (long) ((nTime - EPOCH) / 10000000L);
- tp->tv_usec = (long) (nSystemTime.wMilliseconds * 1000);
- return 0;
- }
+ // *sigh* no gettimeofday on Win32/Win64
+ int gettimeofday(struct timeval * tp, void * tzp);
#else
- #include <sys/time.h>
-#endif // _WIN32
+ #include <sys/time.h>
+#endif
+
+typedef enum _shape_t {
+ SHAPE_LINE,
+ SHAPE_RECTANGLE,
+ SHAPE_ROUNDED_RECTANGLE,
+ SHAPE_CIRCLE,
+ SHAPE_TRIANGLE,
+ SHAPE_STAR,
+ SHAPE_RANDOM,
+} shape_t;
-extern uint test_size;
-extern int iterations;
+extern uint32_t test_size;
+extern uint32_t iterations;
+extern uint32_t test_width;
+extern uint32_t test_height;
extern float panX;
extern float panY;
@@ -88,10 +86,11 @@ extern VkvgDevice device;
extern VkvgSurface surf;
//run test in one step
-void perform_test (void(*testfunc)(void),uint width, uint height);
-void randomize_color (VkvgContext ctx);
+void perform_test (void(*testfunc)(), const char* testName, int argc, char *argv[]);
+
+void randomize_color (VkvgContext ctx);
+void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact);
//run test in 3 step: init, run, clear.
-void init_test (uint width, uint height);
-void run_test_func (void(*testfunc)(void),uint width, uint height);
+void init_test (uint32_t width, uint32_t height);
void clear_test ();