And added (in a somewhat dirty for now way) the noinitwrongthread.c case for uiDarwinControlHandle().

This commit is contained in:
Pietro Gagliardi 2020-05-25 22:42:44 -04:00
parent de3598df80
commit d423688def
4 changed files with 49 additions and 0 deletions

5
test/allcalls_darwin.h Normal file
View File

@ -0,0 +1,5 @@
// 28 may 2019
// This file should NOT have include guards as it is intended to be included more than once; see noinitwrongthread_darwin.m for details.
allcallsCase(uiDarwinControlHandle, NULL)

View File

@ -17,8 +17,12 @@ if libui_OS == 'windows'
elif libui_OS == 'darwin'
libui_test_sources += files([
'controls_darwin.m',
'noinitwrongthread_darwin.m',
'window_darwin.m',
])
libui_allcalls_headers += files([
'allcalls_darwin.h',
])
elif libui_OS == 'haiku'
libui_test_sources += files([
'controls_haiku.c',

View File

@ -2,6 +2,8 @@
#include "test.h"
#include "thread.h"
// TODO split the macros in this file into its own file
// TODO rename to FunctionsFailBeforeInit?
#define allcallsCase(f, ...) \
TestNoInit(CallBeforeInitIsProgrammerError_ ## f) \

View File

@ -0,0 +1,38 @@
// 28 may 2019
#import "test_darwin.h"
#import "thread.h"
// TODO rename to FunctionsFailBeforeInit?
#define allcallsCase(f, ...) \
TestNoInit(CallBeforeInitIsProgrammerError_ ## f) \
{ \
void *ctx; \
ctx = beginCheckProgrammerError("attempt to call " #f "() before uiInit()"); \
f(__VA_ARGS__); \
endCheckProgrammerError(ctx); \
}
#include "allcalls_darwin.h"
#undef allcallsCase
// TODO rename to FunctionsFailOnWrongThread?
#define allcallsCase(f, ...) \
static void threadTest ## f(void *data) \
{ \
f(__VA_ARGS__); \
} \
Test(CallOnWrongThreadIsProgrammerError_ ## f) \
{ \
threadThread *thread; \
threadSysError err; \
void *ctx; \
ctx = beginCheckProgrammerError("attempt to call " #f "() on a thread other than the GUI thread"); \
err = threadNewThread(threadTest ## f, NULL, &thread); \
if (err != 0) \
TestFatalf("error creating thread: " threadSysErrorFmt, threadSysErrorFmtArg(err)); \
err = threadThreadWaitAndFree(thread); \
if (err != 0) \
TestFatalf("error waiting for thread to finish: " threadSysErrorFmt, threadSysErrorFmtArg(err)); \
endCheckProgrammerError(ctx); \
}
#include "allcalls_darwin.h"
#undef allcallsCase