Started writing the controls Darwin-specific code and all-platforms tests for real.

This commit is contained in:
Pietro Gagliardi 2019-06-10 23:09:35 -04:00
parent 89f64eb067
commit 6903bebe7d
6 changed files with 48 additions and 8 deletions

View File

@ -3,12 +3,18 @@
bool uiprivOSVtableValid(uiControlOSVtable *osVtable, const char *func) bool uiprivOSVtableValid(uiControlOSVtable *osVtable, const char *func)
{ {
// TODO if (vtable->Size != sizeof (uiControlOSVtable)) {
uiprivProgrammerErrorWrongStructSize(vtable->Size, "uiControlOSVtable", func);
return false;
}
return true; return true;
} }
uiControlOSVtable *uiprivCloneOSVtable(uiControlOSVtable *osVtable) uiControlOSVtable *uiprivCloneOSVtable(uiControlOSVtable *osVtable)
{ {
// TODO uiControlOSVtable *v2;
return NULL;
v2 = uiprivNew(uiControlOSVtable);
*v2 = *osVtable;
return v2;
} }

View File

@ -3,10 +3,6 @@
#if 0 #if 0
struct testOSVtable {
void (*TestMethod)(uiControl *c, void *implData);
};
struct testOSImplData { struct testOSImplData {
bool initCalled; bool initCalled;
bool *freeCalled; bool *freeCalled;
@ -28,7 +24,7 @@ static void testVtableTestMethod(uiControl *c, void *implData)
// do nothing // do nothing
} }
static void createTestVtables(uiControlVtable *vtable, struct testOSVtable *osVtable) static void createTestVtables(uiControlVtable *vtable, uiControlOSVtable **osVtable)
{ {
memset(&vtable, 0, sizeof (uiControlVtable)); memset(&vtable, 0, sizeof (uiControlVtable));
vtable.Size = sizeof (uiControlVtable); vtable.Size = sizeof (uiControlVtable);

14
test/controls_darwin.m Normal file
View File

@ -0,0 +1,14 @@
// 10 june 2019
#import "test_darwin.h"
uiControlOSVtable *allocOSVtableFull(testingT *t, const char *file, long line)
{
uiControlOSVtable *v;
v = (uiControlOSVtable *) malloc(sizeof (uiControlOSVtable));
if (v == NULL)
testingTFatalfFull(t, file, line, "memory exhausted allocating uiControlOSVtable");
memset(v, 0, sizeof (uiControlOSVtable));
v->Size = sizeof (uiControlOSVtable);
return v;
}

View File

@ -9,6 +9,20 @@ libui_test_sources = [
'noinitwrongthread.c', 'noinitwrongthread.c',
] ]
if libui_OS == 'windows'
libui_test_sources += [
'controls_windows.c',
]
else if libui_OS == 'darwin'
libui_test_sources += [
'controls_darwin.m',
]
else
libui_test_sources += [
'controls_unix.c',
]
endif
if libui_OS == 'windows' if libui_OS == 'windows'
libui_test_sources += [ libui_test_sources += [
windows.compile_resources('resources_' + libui_mode + '.rc', windows.compile_resources('resources_' + libui_mode + '.rc',

View File

@ -5,6 +5,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../ui.h" #include "../ui.h"
#ifdef libuiOSHeader
#include libuiOSHeader
#endif
#include "../common/testhooks.h" #include "../common/testhooks.h"
#include "lib/testing.h" #include "lib/testing.h"
#include "lib/thread.h" #include "lib/thread.h"
@ -34,3 +37,7 @@ extern testingSet *beforeTests;
extern void checkProgrammerErrorFull(testingT *t, const char *file, long line, const char *name, void (*f)(void *data), void *data, const char *msgWant, bool inThread); extern void checkProgrammerErrorFull(testingT *t, const char *file, long line, const char *name, void (*f)(void *data), void *data, const char *msgWant, bool inThread);
#define checkProgrammerError(t, name, f, data, msgWant) checkProgrammerErrorFull(t, __FILE__, __LINE__, name, f, data, msgWant, false) #define checkProgrammerError(t, name, f, data, msgWant) checkProgrammerErrorFull(t, __FILE__, __LINE__, name, f, data, msgWant, false)
#define checkProgrammerErrorInThread(t, name, f, data, msgWant) checkProgrammerErrorFull(t, __FILE__, __LINE__, name, f, data, msgWant, true) #define checkProgrammerErrorInThread(t, name, f, data, msgWant) checkProgrammerErrorFull(t, __FILE__, __LINE__, name, f, data, msgWant, true)
// controls.c
extern uiControlOSVtable *allocOSVtableFull(testingT *t, const char *file, long line);
#define allocOSVtable(t) allocOSVtableFull(t, __FILE__, __LINE__)

3
test/test_darwin.h Normal file
View File

@ -0,0 +1,3 @@
// 10 june 2019
#define libuiOSHeader "../ui_darwin.h"
#include "test.h"