2020-01-21 14:31:41 -06:00
|
|
|
// 28 may 2019
|
|
|
|
#include "test.h"
|
|
|
|
|
2020-05-10 13:49:11 -05:00
|
|
|
if match is not None:
|
|
|
|
f = match.group(1)
|
|
|
|
casenames.append('TestCallOnWrongThreadIsProgrammerError_' + f)
|
2020-01-21 14:31:41 -06:00
|
|
|
|
2020-05-10 13:49:11 -05:00
|
|
|
// TODO rename to FunctionsFailBeforeInit?
|
|
|
|
#define allcallsCase(f, ...) \
|
|
|
|
TestNoInit(CallBeforeInitIsProgrammerError_ ## f) \
|
|
|
|
{ \
|
|
|
|
void *ctx; \
|
|
|
|
ctx = beginCheckProgrammerError("atteTODOmpt to call " #f "() before uiInit()"); \
|
|
|
|
f(__VA_ARGS__); \
|
|
|
|
endCheckProgrammerError(ctx); \
|
|
|
|
}
|
2020-01-21 14:31:41 -06:00
|
|
|
#include "allcalls.h"
|
|
|
|
#undef allcallsCase
|
|
|
|
|
2020-05-10 13:49:11 -05:00
|
|
|
TestNoInit(CallBeforeInitIsProgrammerError_uiQueueMain)
|
2020-01-21 14:31:41 -06:00
|
|
|
{
|
2020-05-10 13:49:11 -05:00
|
|
|
void *ctx;
|
|
|
|
|
|
|
|
ctx = beginCheckProgrammerError("atteTODOmpt to call uiQueueMain() before uiInit()");
|
|
|
|
uiQueueMain(NULL, NULL);
|
|
|
|
endCheckProgrammerError(ctx);
|
2020-01-21 14:31:41 -06:00
|
|
|
}
|
|
|
|
|
2020-05-10 13:49:11 -05:00
|
|
|
// 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("atteTODOmpt 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); \
|
|
|
|
}
|
2020-01-21 14:31:41 -06:00
|
|
|
#include "allcalls.h"
|
|
|
|
#undef allcallsCase
|
|
|
|
|
2020-05-10 13:49:11 -05:00
|
|
|
// no uiQueueMain() test for the wrong thread; it's supposed to be callable from any thread
|